[wp-hackers] Adding Additional Attributes in Script Tag for 3rd party JS

Andrew Bartel andrew.bartel at gmail.com
Mon Aug 26 22:11:11 UTC 2013


Hi All,

I asked this question on WPSE:
http://wordpress.stackexchange.com/questions/110929/adding-additional-attributes-in-script-tag-for-3rd-party-js
(and
added a bounty if anyone's interested at taking a crack).

I encountered this trying to add the dropbox dropin chooser app to a plugin
I'm writing.  Their directions are to include  <script type=
"text/javascript" src="https://www.dropbox.com/static/api/1/dropins.js" id=
"dropboxjs" data-app-key="MY_APP_KEY"></script>' in the page.

I'm curious as to what the best practice is to pass additional attributes
to script tags so that the final output includes the attributes in the tag
itself.  Including them with wp_localize_script() didn't seem to get them
registered by dropbox.

What's the best way to get those included when using the
wp_enqueue_script() function?  Or is there an alternate function?  Properly
hooked of course.

Thanks much,

Andrew


More information about the wp-hackers mailing list