diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2020-01-06 14:32:30 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2020-01-06 14:32:30 -0500 |
commit | 10ef81bf85ad0a4bad0d204838e14c99ca2526f7 (patch) | |
tree | b4bb36a326d41de12d1a6181d2a2baf34696ac24 /plugins/jetpack/_inc/polldaddy-shortcode.js | |
parent | Updating script for Update (diff) | |
download | blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.gz blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.bz2 blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.zip |
Update jetpack 8.0
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/_inc/polldaddy-shortcode.js')
-rw-r--r-- | plugins/jetpack/_inc/polldaddy-shortcode.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/plugins/jetpack/_inc/polldaddy-shortcode.js b/plugins/jetpack/_inc/polldaddy-shortcode.js new file mode 100644 index 00000000..55c28fdf --- /dev/null +++ b/plugins/jetpack/_inc/polldaddy-shortcode.js @@ -0,0 +1,74 @@ +( function( $ ) { + window.polldaddyshortcode = { + render: function() { + var ratings = $( 'div.pd-rating[data-settings]' ); + var polls = $( 'div.PDS_Poll[data-settings]' ); + + if ( polls ) { + $.each( polls, function() { + var poll = $( this ).data( 'settings' ); + + if ( poll ) { + var poll_url = document.createElement( 'a' ); + poll_url.href = poll[ 'url' ]; + if ( + poll_url.hostname != 'secure.polldaddy.com' && + poll_url.hostname != 'static.polldaddy.com' + ) { + return false; + } + var pathname = poll_url.pathname; + if ( ! /\/?p\/\d+\.js/.test( pathname ) ) { + return false; + } + var wp_pd_js = document.createElement( 'script' ); + wp_pd_js.type = 'text/javascript'; + wp_pd_js.src = poll[ 'url' ]; + wp_pd_js.charset = 'utf-8'; + wp_pd_js.async = true; + document.getElementsByTagName( 'head' )[ 0 ].appendChild( wp_pd_js ); + } + } ); + } + + if ( ratings ) { + var script = ''; + + $.each( ratings, function() { + var rating = $( this ).data( 'settings' ); + + if ( rating ) { + script += + 'PDRTJS_settings_' + + rating[ 'id' ] + + rating[ 'item_id' ] + + '=' + + rating[ 'settings' ] + + "; if ( typeof PDRTJS_RATING !== 'undefined' ){ if ( typeof PDRTJS_" + + rating[ 'id' ] + + rating[ 'item_id' ] + + "=='undefined' ){PDRTJS_" + + rating[ 'id' ] + + rating[ 'item_id' ] + + '= new PDRTJS_RATING( PDRTJS_settings_' + + rating[ 'id' ] + + rating[ 'item_id' ] + + ' );}}'; + } + } ); + + if ( script.length > 0 ) + $( '#polldaddyRatings' ).after( + "<script type='text/javascript' charset='utf-8' id='polldaddyDynamicRatings'>" + + script + + '</script>' + ); + } + }, + }; + + $( 'body' ).on( 'post-load pd-script-load', function() { + window.polldaddyshortcode.render(); + } ); + $( 'body' ).trigger( 'pd-script-load' ); +} )( jQuery ); |