• Resolved EMar

    (@sounds)


    Hi,

    Is there something wrong in wordpress that’s causing text widgets to strip out code?

    I have a piece of code in the text widget that displays now playing song info,
    It still works in any widget I haven’t updated recently, however if I update
    the code in the text widget or any other editor widget like SiteOrigin, then it won’t
    display the info in the widget when viewing it on the site.

    So I installed the Classic text Widget which does fix the problem.
    But I don’t think I should have to install another widget to fix the problem.

    What’s causing these other text widgets to strip the code?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Moderator James Huff

    (@macmanx)

    Use the Custom HTML widget instead of the Text widget for code like that.

    Thread Starter EMar

    (@sounds)

    I did try that Custom HTML widget, again just now, but there’s a few warnings,

    Example:

    “websiteUrl” is defined but never used.
    “showPlayer” is defined but never used.
    “shoutcastUrl” is defined but never used.
    “autostartPlayer” is defined but never used.
    “displayPlayer” is defined but never used.

    <script>
    //settings
    var websiteUrl = ‘https://www.h.ie/shoutcastinfo-ambient/&#8217;;//website url
    var showPlayer = ‘0’;//show player status
    var shoutcastUrl = ‘198.56.145.147:8655’;//shoutcast stream server url
    var autostartPlayer = false;//autostart player status
    var displayPlayer = ‘top’;//player area
    </script>
    <script type=”text/javascript” src=”https://www.t.ie/shoutcastinfo-ambient/js/main.js”></script&gt;
    <!–end shoutcast javascripts–>

    Hi sounds,

    Those are valid warning messages and they’re occurring as the custom HTML editor isn’t able to see the full scope of the script. They’re safe to ignore.

    Thread Starter EMar

    (@sounds)

    That Custom HTML widget doesn’t want to work for me.
    It’s asking me to add a few double quotes, but I can’t save it.

    I do not think it likes the mixing single and double quotes – also it is for HTML, not adding Javascript to the site. Javascript should be added via file https://codex.www.ads-software.com/Using_Javascript

    Thread Starter EMar

    (@sounds)

    I’m using the Classic text Widget for now, it’s too much.
    Why are all these text editors stripping out the code in the first place?

    Code can cause exploits – it is for security.

    And cause that is not where scripts go…

    Thread Starter EMar

    (@sounds)

    I see, but it can get a bit annoying, didn’t work in siteorigin editor either.
    The classic text widget works but I don’t want a plugin for every single fix.

    What do you mean a plugin? Javascript is not to be entered that way – it is not best practice. Use conditional functions to enqueue scripts on the pages that need them, or create custom template pages.

    Thread Starter EMar

    (@sounds)

    I mean I used classic text widget to display some javascript in the sidebar.
    Demo

    I need to find a better way to do this, I’m using a new widget for every page.
    But that’s another story.

    Is it a different script for every widget on every page?

    Thread Starter EMar

    (@sounds)

    Well it’s the same script but reused on different pages, I create radio pages.
    I have to enter different stream info in each widget for each shoutcast stream.
    It gets a bit heavy when you have multiple radio pages, now playing widget for each page.

    You can hardcode the script into a custom template page and use that template on pages that need the script. You can then modify the script a bit to look for a data-attribute for the stream url. Add the stream url to the link’s data-stream-url=”stream url”

    Thread Starter EMar

    (@sounds)

    That is kind of what I did, I got the script off code canyon link
    It has a horizontal and vertical php file which I embeded in a widget.
    One widget for each radio page, new shoutcast stream info in each widget,
    I can’t think of a better way to display the info without using separate widgets.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Text edit widgets stripping out code..’ is closed to new replies.