Script Code in Text Widget Does NOT Show

I have a self hosted WordPress 3.7 and using the Twenty Thirteen theme. I have placed a text widget on the sidebar and put a simple code from Amazon inside it:

<SCRIPT charset="utf-8" type="text/javascript" src="http://ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&MarketPlace=US&ID=V20070822%2FUS%2Fguardiaintern-20%2F8002%2Feb678005-711d-488e-bdc6-f6dd775e0ed8"> </SCRIPT> 
<NOSCRIPT><A HREF="http://ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&MarketPlace=US&ID=V20070822%2FUS%2Fguardiaintern-20%2F8002%2Feb678005-711d-488e-bdc6-f6dd775e0ed8&Operation=NoScript">Amazon.com Widgets</A></NOSCRIPT>

However, when you load the site, it doesn’t show up. I was under the impression that any arbitrary text or html would also include <SCRIPT> code as well and yet it seems to not be the case. Does anyone knows what’s wrong or how to fix this?

Read More

Additional UPDATE: It turns out that the code above shows up in Firefox and IE with a slight delay but it does render. However, it will NOT render on Chrome at all, no matter what. Any idea why it seems/appears on the surface at least to be browser specific? What would cause that difference in behavior?

DEBUGGING RESULTS: It is found that indeed it IS a WordPress BUG that is causing the code to break. Using @toscho recommended plugin Magic Widgets has resolved the issue making the code display without issue. I will be in touch with the WP developers Ryan and Andrew to figure out what is causing the issue and resolve the bug in the next release to avoid future issues of the same nature.

Related posts

1 comment

  1. [SUMMARY]

    Although in theory, using the core provided Text Widget should allow you to put any arbitrary HTML code into action, I recently encountered the issue above where the code was wrapped by WordPress in such a way that affected the ability to render properly on Chrome. The code still showed up fine on Firefox and Internet Explorer but the problem affected Chrome sufficiently that it would not display correctly (would show up blank/no output rendering).

    [SOLUTION]

    After looking at the core code and evaluating the “final” code that WordPress is pushing out, I realized that it has to do with the way it affects the element’s generated by code from being accessed by the Chrome mechanism for rendering. Removing those added wrappings that caused the issue from the final code resulted in displaying correctly. This process was further automated and verified repeatedly by using a plugin suggested by @toscho called Magic Widgets that provides you with an Unfiltered Text Widget that processes the code pasted in them in their pure form and without and processing or wrapping done by WordPress.

    [CONCLUSION]

    My conclusion and recommendation to everyone is that until such time as I can get the WordPress developers to provide a better Text Widget that doesn’t interact with the code in anyway, you should use the above mentioned Plugin for putting any raw codes, particularly <SCRIPT> codes or anything that pulls JavaScript code from the system (like the above example in my question) so that you avoid any interference with the way it is processed and rendered by WordPress – short of editing the pages manually and putting your code directly in the files you will be displaying.

Comments are closed.