I have developed a JavaScript widget which works fine when I embed it in any of my html pages. The code is something like this
<script type="text/javascript" charset="utf-8">
var asset_host = 'http://domain.com';
var url = unescape("%3Cscript src='" + asset_host + "/javascripts/widget.js' type='text/javascript'%3E%3C/script%3E");
document.write(url);
</script>
<script type="text/javascript" charset="utf-8">
var widget_options = {};
widget_options.iframe_base_url = asset_host + '/widget/questions/10';
var feedback_widget = new ShowWidget.widget(widget_options);
</script>
However when I embed this code in wordpress then “style” tag is being stripped off ( probably for security reasons).
How should I go about generating the widget code for wordpress so that users have least amount of inconvenience.
WordPress.com does not allow you to post javascript.
From WordPress.com Support:
I assume you talk about widget in general sense and not WordPress Widget.
In what form would you like to offer your widget to WordPress users?
functions.php
;Also
wp_enqueue_script()
is mandatory reading for working with JS in WP.It all depends on how you want to handle it, your PHP skills and skills of your target WP users (the less savvy they are the more stuff you will have to take care of).