PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 8.2
Jetpack – WP Security, Backup, Speed, & Growth v8.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / _inc / polldaddy-shortcode.js
polldaddy-shortcode.js
75 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function( $ ) {
2 window.polldaddyshortcode = {
3 render: function() {
4 var ratings = $( 'div.pd-rating[data-settings]' );
5 var polls = $( 'div.PDS_Poll[data-settings]' );
6
7 if ( polls ) {
8 $.each( polls, function() {
9 var poll = $( this ).data( 'settings' );
10
11 if ( poll ) {
12 var poll_url = document.createElement( 'a' );
13 poll_url.href = poll[ 'url' ];
14 if (
15 poll_url.hostname != 'secure.polldaddy.com' &&
16 poll_url.hostname != 'static.polldaddy.com'
17 ) {
18 return false;
19 }
20 var pathname = poll_url.pathname;
21 if ( ! /\/?p\/\d+\.js/.test( pathname ) ) {
22 return false;
23 }
24 var wp_pd_js = document.createElement( 'script' );
25 wp_pd_js.type = 'text/javascript';
26 wp_pd_js.src = poll[ 'url' ];
27 wp_pd_js.charset = 'utf-8';
28 wp_pd_js.async = true;
29 document.getElementsByTagName( 'head' )[ 0 ].appendChild( wp_pd_js );
30 }
31 } );
32 }
33
34 if ( ratings ) {
35 var script = '';
36
37 $.each( ratings, function() {
38 var rating = $( this ).data( 'settings' );
39
40 if ( rating ) {
41 script +=
42 'PDRTJS_settings_' +
43 rating[ 'id' ] +
44 rating[ 'item_id' ] +
45 '=' +
46 rating[ 'settings' ] +
47 "; if ( typeof PDRTJS_RATING !== 'undefined' ){ if ( typeof PDRTJS_" +
48 rating[ 'id' ] +
49 rating[ 'item_id' ] +
50 "=='undefined' ){PDRTJS_" +
51 rating[ 'id' ] +
52 rating[ 'item_id' ] +
53 '= new PDRTJS_RATING( PDRTJS_settings_' +
54 rating[ 'id' ] +
55 rating[ 'item_id' ] +
56 ' );}}';
57 }
58 } );
59
60 if ( script.length > 0 )
61 $( '#polldaddyRatings' ).after(
62 "<script type='text/javascript' charset='utf-8' id='polldaddyDynamicRatings'>" +
63 script +
64 '</script>'
65 );
66 }
67 },
68 };
69
70 $( 'body' ).on( 'post-load pd-script-load', function() {
71 window.polldaddyshortcode.render();
72 } );
73 $( 'body' ).trigger( 'pd-script-load' );
74 } )( jQuery );
75