Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * This function by Adam Scheinberg, Twitter @sethadam1
- * dynamically inserts javascript into posts or pages
- * @usage [jsembed id="scriptid" src="http://example.com"]
- */
- function jsembed_shortcode($atts) {
- extract(shortcode_atts(array(
- 'id' => "script".dechex(rand(1000000,9999999)), //random ID if there isn't one
- 'src' => ''
- ), $atts));
- if(''==$src) { return; } else { return '<script id="'.$id.'" src="'.$src.'">'; }
- }
- add_shortcode('jsembed', 'jsembed_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement