WordPress.org

Forums

[Plugin: Text Widget] javascript tags get stripped from text widget on save (3 posts)

  1. faddah
    Member
    Posted 2 years ago #

    hi,

    WPMU install of wordpress 3.5.1 on a self-hosted site, child theme of standard “sight” theme from wpshower.com.

    i'm trying to add a piece of javascript in the standard text widget for the sidebar that comes with all wordpress installs. we are using a child derivative of the “sight” theme.

    when i put the code in the text widget, it strips out the <script> tags — i'm wondering why? this is a self-hosted wordpress 3.5.1, i should be allowed, as admin, to put my own javascript in.

    so if i put in something like this —

    <script language="javascript" text="text/javascript">
    ...
    [ some javascript code here ]
    ...
    </script>

    when i hit the 'save' button, the <script> get stripped out, so the code is just left there and shows as a block of text in the widget and is never run, of course. i'm wondering why this is happening with my install (3.5.1, WPMU, child of “sight” theme).

    this seems similar to posts put here on the forums previously, in previous wordpress versions —

    http://wordpress.org/support/topic/how-can-i-add-a-chunk-of-javascript-to-the-text-widget

    in that one, they say, in version 2.9.1, he should be able to add javascript to the standard text widget. has this functionality been taken out in 3.5.1?

    http://wordpress.org/support/topic/javascript-in-text-widget-not-working

    that is a situation similar to mine, where one admin has the script tags stripped out of the text widget on 'save,' but another admin can have the script tags in the text widget save just fine.

    so what is going on here?

    i've searched, but is there something in the wordpress.org codex that states explicitly you can't put javascript in the wordpress text widget?

    please advise. thank you in advance.

    best,

    — faddah wolf
    portland, oregon

  2. rcanpolat
    Member
    Posted 2 years ago #

    Take a look at this post i made and resolved a few days ago. I know its not completely relevant to your issue but i was having character stripping issues with the press this reloaded plugin.

    LINK

    If i were you i would look at my post and check the line of code i removed from the plugin and compare that to the widget code of your existing site, see if there is any similar code in there that is stripping characters.

    Its often a security practice to stop the use these characters as without that someone might find a way to bypass auth to a specific section of the admin interface (in your case the widget section), edit your widget code and implant some malicious code or redirecting code for their own profit. I imagine thats why WordPress stopped the functionality of that in widgets.

    Hope it helps a bit

  3. faddah
    Member
    Posted 2 years ago #

    thanks. that's a nice hack, but not really a solution to my problem. if they update core 3.5.x or the text widget itself, all that work gets wiped and/or i have to re-do it again (provided that code you hacked is available).

    i just want to know if it's wordpress codex “canon” that you can't put <script> tags in the text widget in the sidebar or not. if not, what can be done to fix that, short of hacking the code for the text widget.

    i do appreciate your answer, but i need to know why this is happening. thank you, though. still unresolved.

    best,

    — faddah wolf
    portland, oregon

Topic Closed

This topic has been closed to new replies.

About this Topic