Version Description
- SSL support for poll and survey shortcodes
- Security update of survey shortcode
- Resize the "Add Poll" popup.
- Validate the rating_id before updating it on the ratings settings page.
Download this release
Release Info
Developer | donncha |
Plugin | Crowdsignal Dashboard – Polls, Surveys & more |
Version | 2.0.26 |
Comparing to | |
See all releases |
Code changes from version 2.0.25 to 2.0.26
- ajax.php +4 -1
- js/polldaddy-shortcode.js +43 -0
- js/polldaddy.js +1 -20
- polldaddy-client.php +7 -5
- polldaddy-org.php +121 -56
- polldaddy.php +32 -19
- popups.php +4 -0
- rating.php +5 -1
- readme.txt +9 -1
ajax.php
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
add_action( 'wp_ajax_myajax-submit', 'myajax_submit' );
|
4 |
|
5 |
class Polldaddy_Ajax {
|
@@ -120,4 +123,4 @@ function polldaddy_ajax_init() {
|
|
120 |
}
|
121 |
|
122 |
add_action( 'init', 'polldaddy_ajax_init' );
|
123 |
-
?>
|
1 |
<?php
|
2 |
|
3 |
+
if ( function_exists( 'get_option' ) == false )
|
4 |
+
die( "Cheatin' eh?" );
|
5 |
+
|
6 |
add_action( 'wp_ajax_myajax-submit', 'myajax_submit' );
|
7 |
|
8 |
class Polldaddy_Ajax {
|
123 |
}
|
124 |
|
125 |
add_action( 'init', 'polldaddy_ajax_init' );
|
126 |
+
?>
|
js/polldaddy-shortcode.js
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($) {
|
2 |
+
|
3 |
+
window.polldaddyshortcode = {
|
4 |
+
|
5 |
+
render: function() {
|
6 |
+
var ratings = $( 'div.pd-rating[data-settings]' );
|
7 |
+
var polls = $( 'div.PDS_Poll[data-settings]' );
|
8 |
+
|
9 |
+
if ( polls ){
|
10 |
+
$.each( polls, function() {
|
11 |
+
var poll = $( this ).data( 'settings' );
|
12 |
+
|
13 |
+
if ( poll ) {
|
14 |
+
var wp_pd_js = document.createElement('script');
|
15 |
+
wp_pd_js.type = 'text/javascript';
|
16 |
+
wp_pd_js.src = poll['url'];
|
17 |
+
wp_pd_js.charset = 'utf-8';
|
18 |
+
wp_pd_js.async = true;
|
19 |
+
document.getElementsByTagName('head')[0].appendChild(wp_pd_js);
|
20 |
+
}
|
21 |
+
});
|
22 |
+
};
|
23 |
+
|
24 |
+
if ( ratings ){
|
25 |
+
var script = '';
|
26 |
+
|
27 |
+
$.each( ratings, function() {
|
28 |
+
var rating = $( this ).data( 'settings' );
|
29 |
+
|
30 |
+
if ( rating ) {
|
31 |
+
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'] + " );}}";
|
32 |
+
}
|
33 |
+
});
|
34 |
+
|
35 |
+
if ( script.length > 0 )
|
36 |
+
$( '#polldaddyRatings' ).after( "<script type='text/javascript' charset='utf-8' id='polldaddyDynamicRatings'>" + script + "</script>" );
|
37 |
+
};
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
$('body').on( 'post-load pd-script-load', function() { window.polldaddyshortcode.render() } );
|
42 |
+
$('body').trigger( 'pd-script-load' );
|
43 |
+
})(jQuery);
|
js/polldaddy.js
CHANGED
@@ -1,20 +1 @@
|
|
1 |
-
jQuery(function(
|
2 |
-
Plugin=function(args){var opts=$.extend({delete_rating:'Are you sure you want to delete the rating for "%s"?',delete_poll:'Are you sure you want to delete "%s"?',delete_answer:'Are you sure you want to delete this answer?',new_answer:'Enter an answer here',delete_answer_title:'delete this answer',reorder_answer_title:'click and drag to reorder',add_image_title:'Add an Image',add_audio_title:'Add Audio',add_video_title:'Add Video',standard_styles:'Standard Styles',custom_styles:'Custom Styles',base_url:''},args);$('.hide-if-js').hide();$('.empty-if-js').empty();$('.hide-if-no-js').removeClass('hide-if-no-js');$('.polldaddy-shortcode-row pre').click(function(){var refNode=$(this)[0];if($.browser.msie){var range=document.body.createTextRange();range.moveToElementText(refNode);range.select();}else if($.browser.mozilla||$.browser.opera){var selection=window.getSelection();var range=document.createRange();range.selectNodeContents(refNode);selection.removeAllRanges();selection.addRange(range);}else if($.browser.safari){var selection=window.getSelection();selection.setBaseAndExtent(refNode,0,refNode,1);}});$('input#shortcode-field').click(function(){$(this).select();});$('a.delete-rating').click(function(){return confirm(opts.delete_rating.replace("%s",$(this).parents('td').find('strong').text()));});$('a.delete-poll').click(function(){return confirm(opts.delete_poll.replace("%s",$(this).parents('td').find('strong').text()));});$('span.view a.thickbox').attr('href',function(){return $(this).attr('href')+'&iframe&TB_iframe=true';});var delAnswerPrep=function(context){$('a.delete-answer',context||null).click(function(){if(confirm(opts.delete_answer)){$(this).parents('li').remove();$('#choices option:last-child').remove();}
|
3 |
-
return false;});};delAnswerPrep();$('#answers').sortable({axis:'y',containment:'parent',handle:'.handle',tolerance:'pointer'});function is_ssl(){return"https:"==document.location.protocol?true:false}
|
4 |
-
function add_answer(aa,src){return false;}
|
5 |
-
var busy=false;$('#add-answer-holder').show().find('button').click(function(){if(!busy){busy=true;var aa=(1+get_number_answers()).toString();var src=$(this).closest('p').attr('class');$('form[name=add-answer] input[name=aa]').val(aa);$('form[name=add-answer] input[name=src]').val(src);$('form[name=add-answer] input[name=action]').val('polls_add_answer');$('form[name=add-answer]').ajaxSubmit(function(response){delAnswerPrep($('#answers').append(response).find('li:last'));$('#choices').append('<option value="'+(aa-1)+'">'+(aa-1)+'</option>');busy=false;init();});}
|
6 |
-
return false;});var win=window.dialogArguments||opener||parent||top;$('.polldaddy-send-to-editor').click(function(){var pollID=$(this).parents('div.row-actions').find('.polldaddy-poll-id').val();if(!pollID)pollID=$('.polldaddy-poll-id:first').val();if(pollID){pollID=parseInt(pollID);if(pollID>0){win.send_to_editor('[polldaddy poll='+pollID.toString()+']');}}});$('.polldaddy-show-shortcode').toggle(function(ev){ev.preventDefault();$(this).parents('tr:first').next('tr').fadeIn();$(this).parents('tr:first').next('tr').show();$(this).closest('tr').css('display','none');return false;},function(){$(this).parents('tr:first').next('tr').fadeOut();$(this).parents('tr:first').next('tr').hide();return false;});$('.pd-embed-done').click(function(ev){ev.preventDefault();$(this).closest('tr').hide();$(this).closest('tr').prev('tr').show();});$('.pd-tabs a').click(function(){if(!jQuery(this).closest('li').hasClass('selected')){jQuery('.pd-tabs li').removeClass('selected');jQuery(this).closest('li').addClass('selected');jQuery('.pd-tab-panel').removeClass('show');jQuery('.pd-tab-panel#'+$(this).closest('li').attr('id')+'-panel').addClass('show');}});var hiddenStyleID=$(':input[name=styleID]');var customStyle=$(':input[name=customSelect]');var customStyleVal=parseInt(customStyle.val());if(customStyleVal>0){hiddenStyleID.val(customStyleVal.toString());$('#pd-custom-styles a').click();}
|
7 |
-
$("#multipleChoice").click(function(){if($("#multipleChoice").is(":checked")){$("#numberChoices").show("fast");}else{$("#numberChoices").hide("fast");}});$('.block-repeat').click(function(){var repeat=jQuery(this).val();if(repeat=='off'){$('#cookieip_expiration_label').hide();$('#cookieip_expiration').hide();}else{$('#cookieip_expiration_label').show();$('#cookieip_expiration').show();}});var uploading=false;function init(){$('a.delete-media').unbind('click').click(function(){var container=$(this).parents('td.answer-media-icons');container.find('li.image-added').removeClass('image-added').html('');container.find(':hidden').val('');})
|
8 |
-
$('td.answer-media-icons li.image-added').unbind('mouseover').mouseover(function(){$(this).find('img').addClass('hidden');$(this).find('a.delete-media img').removeClass('hidden');$(this).find('a.delete-media').removeClass('hidden');}).unbind('mouseout').mouseout(function(){$(this).find('a.delete-media').addClass('hidden');$(this).find('img').removeClass('hidden');});$('.image').unbind('click').click(function(){var media_id=$(this).attr('id').replace('add_poll_image','');tb_show('Add an Image','media-upload.php?type=image&&polls_media=1TB_iframe=1');win.send_to_editor=function(html){var $h=$('<div/>').html(html);img=$h.find('img');attach_id=0;url=img.attr('src')
|
9 |
-
if(is_ssl())url=url.replace('http://','https://');match=img.attr('class').match(/wp-image-(\d+)/);if($.isArray(match)&&match[1]!==undefined)
|
10 |
-
attach_id=match[1];tb_remove();send_media(url,media_id,attach_id);}
|
11 |
-
return false;});$('.video').unbind('click').click(function(){var media_id=$(this).attr('id').replace('add_poll_video','');tb_show('Add Video','media-upload.php?type=video&tab=type_url&polls_media=1&TB_iframe=1');win.send_to_editor=function(shortcode){tb_remove();add_media(media_id,shortcode,'<img height="16" width="16" src="'+opts.base_url+'img/icon-report-ip-analysis.png" alt="Video Embed">');}
|
12 |
-
return false;});$('.audio').unbind('click').click(function(){var media_id=$(this).attr('id').replace('add_poll_audio','');tb_show('Add Audio','media-upload.php?type=audio&polls_media=1&TB_iframe=1');win.send_to_editor=function(html){var $h=$('<div/>').html(html);img=$h.find('img');attach_id=0;url=img.attr('src');if(is_ssl())url=url.replace('http://','https://');match=img.attr('class').match(/wp-image-(\d+)/);if($.isArray(match)&&match[1]!==undefined)
|
13 |
-
attach_id=match[1];tb_remove();send_media(url,media_id,attach_id);}
|
14 |
-
return false;});}
|
15 |
-
function send_media(url,media_id,attach_id){if(uploading==true)
|
16 |
-
return false;uploading=true;$('input[name="media\['+media_id+'\]"]').parents('td').find('.media-preview').addClass('st_image_loader');$('form[name=send-media] input[name=media-id]').val(media_id);$('form[name=send-media] input[name=attach-id]').val(attach_id);$('form[name=send-media] input[name=url]').val(url);$('form[name=send-media] input[name=action]').val('polls_upload_image');$('form[name=send-media]').ajaxSubmit(function(response){uploading=false;response=response.replace(/<div.*/,'');if(response.substr(0,4)=='true'){var parts=response.split('||');add_media(parts[4],parts[1],parts[2]);}
|
17 |
-
else
|
18 |
-
add_media(media_id,'','');});return false;}
|
19 |
-
function add_media(media_id,upload_id,img){if(parseInt(upload_id)>0)$('input[name="mediaType\['+media_id+'\]"]').val(1);else $('input[name="mediaType\['+media_id+'\]"]').val(2);if(is_ssl())img.replace('http://','https://');var link=$('div.hidden-links').find('div.delete-media-link').html();img+=link;var img_container=$('input[name="media\['+media_id+'\]"]').parents('td.answer-media-icons').find('li.media-preview');img_container.removeClass('st_image_loader');img_container.html(img);img_container.addClass('image-added');$('input[name="media\['+media_id+'\]"]').val(upload_id);init();};function get_number_answers(){var num_answers=parseInt($('.answer').size());$('input.answer-text').each(function(){var item=this;if($(item).val()==opts.new_answer||$(item).hasClass('idle'))num_answers--;});return num_answers;}
|
20 |
-
init();var api={add_media:add_media};return api;}});
|
1 |
+
jQuery(function(e){if(typeof window.$=="undefined"){window.$=jQuery}Plugin=function(t){function i(){return"https:"==document.location.protocol?true:false}function s(e,t){return false}function o(){var e=jQuery("body",window.parent.document).width();var t=jQuery("body",window.parent.document).height();var n=typeof document.body.style.maxHeight==="undefined";jQuery("#TB_window, #TB_iframeContent",window.parent.document).css("width","855px");jQuery("#TB_window",window.parent.document).css({left:(e-768)/2+"px",top:48+window.parent.scrollY+"px",position:"absolute",marginLeft:"0"});if(!n){jQuery("#TB_window, #TB_iframeContent",window.parent.document).css("height",t-73+"px")}}function p(){o();jQuery(window).resize(function(){setTimeout(o,50)});e("a.delete-media").unbind("click").click(function(){var t=e(this).parents("td.answer-media-icons");t.find("li.image-added").removeClass("image-added").html("");t.find(":hidden").val("")});e("td.answer-media-icons li.image-added").unbind("mouseover").mouseover(function(){e(this).find("img").addClass("hidden");e(this).find("a.delete-media img").removeClass("hidden");e(this).find("a.delete-media").removeClass("hidden")}).unbind("mouseout").mouseout(function(){e(this).find("a.delete-media").addClass("hidden");e(this).find("img").removeClass("hidden")});e(".image").unbind("click").click(function(){var t=e(this).attr("id").replace("add_poll_image","");tb_show("Add an Image","media-upload.php?type=image&polls_media=1TB_iframe=1");a.send_to_editor=function(n){var r=e("<div/>").html(n);img=r.find("img");attach_id=0;url=img.attr("src");if(i())url=url.replace("http://","https://");match=img.attr("class").match(/wp-image-(\d+)/);if(e.isArray(match)&&match[1]!==undefined)attach_id=match[1];tb_remove();d(url,t,attach_id)};return false});e(".video").unbind("click").click(function(){var t=e(this).attr("id").replace("add_poll_video","");tb_show("Add Video","media-upload.php?type=video&tab=type_url&polls_media=1&TB_iframe=1");a.send_to_editor=function(e){tb_remove();v(t,e,'<img height="16" width="16" src="'+n.base_url+'img/icon-report-ip-analysis.png" alt="Video Embed">')};return false});e(".audio").unbind("click").click(function(){var t=e(this).attr("id").replace("add_poll_audio","");tb_show("Add Audio","media-upload.php?type=audio&polls_media=1&TB_iframe=1");a.send_to_editor=function(n){var r=e("<div/>").html(n);img=r.find("img");attach_id=0;url=img.attr("src");if(i())url=url.replace("http://","https://");match=img.attr("class").match(/wp-image-(\d+)/);if(e.isArray(match)&&match[1]!==undefined)attach_id=match[1];tb_remove();d(url,t,attach_id)};return false})}function d(t,n,r){if(h==true)return false;h=true;e('input[name="media['+n+']"]').parents("td").find(".media-preview").addClass("st_image_loader");e("form[name=send-media] input[name=media-id]").val(n);e("form[name=send-media] input[name=attach-id]").val(r);e("form[name=send-media] input[name=url]").val(t);e("form[name=send-media] input[name=action]").val("polls_upload_image");e("form[name=send-media]").ajaxSubmit(function(e){h=false;e=e.replace(/<div.*/,"");if(e.substr(0,4)=="true"){var t=e.split("||");v(t[4],t[1],t[2])}else v(n,"","")});return false}function v(t,n,r){if(parseInt(n)>0)e('input[name="mediaType['+t+']"]').val(1);else e('input[name="mediaType['+t+']"]').val(2);if(i())r.replace("http://","https://");var s=e("div.hidden-links").find("div.delete-media-link").html();r+=s;var o=e('input[name="media['+t+']"]').parents("td.answer-media-icons").find("li.media-preview");o.removeClass("st_image_loader");o.html(r);o.addClass("image-added");e('input[name="media['+t+']"]').val(n);p()}function m(){var t=parseInt(e(".answer").size());e("input.answer-text").each(function(){var r=this;if(e(r).val()==n.new_answer||e(r).hasClass("idle"))t--});return t}var n=e.extend({delete_rating:'Are you sure you want to delete the rating for "%s"?',delete_poll:'Are you sure you want to delete "%s"?',delete_answer:"Are you sure you want to delete this answer?",new_answer:"Enter an answer here",delete_answer_title:"delete this answer",reorder_answer_title:"click and drag to reorder",add_image_title:"Add an Image",add_audio_title:"Add Audio",add_video_title:"Add Video",standard_styles:"Standard Styles",custom_styles:"Custom Styles",base_url:""},t);e(".hide-if-js").hide();e(".empty-if-js").empty();e(".hide-if-no-js").removeClass("hide-if-no-js");e(".polldaddy-shortcode-row pre").click(function(){var t=e(this)[0];if(e.browser.msie){var n=document.body.createTextRange();n.moveToElementText(t);n.select()}else if(e.browser.mozilla||e.browser.opera){var r=window.getSelection();var n=document.createRange();n.selectNodeContents(t);r.removeAllRanges();r.addRange(n)}else if(e.browser.safari){var r=window.getSelection();r.setBaseAndExtent(t,0,t,1)}});e("input#shortcode-field").click(function(){e(this).select()});e("a.delete-rating").click(function(){return confirm(n.delete_rating.replace("%s",e(this).parents("td").find("strong").text()))});e("a.delete-poll").click(function(){return confirm(n.delete_poll.replace("%s",e(this).parents("td").find("strong").text()))});e("span.view a.thickbox").attr("href",function(){return e(this).attr("href")+"&iframe&TB_iframe=true"});var r=function(t){e("a.delete-answer",t||null).click(function(){if(confirm(n.delete_answer)){e(this).parents("li").remove();e("#choices option:last-child").remove()}return false})};r();e("#answers").sortable({axis:"y",containment:"parent",handle:".handle",tolerance:"pointer"});var u=false;e("#add-answer-holder").show().find("button").click(function(){if(!u){u=true;var t=(1+m()).toString();var n=e(this).closest("p").attr("class");e("form[name=add-answer] input[name=aa]").val(t);e("form[name=add-answer] input[name=src]").val(n);e("form[name=add-answer] input[name=action]").val("polls_add_answer");e("form[name=add-answer]").ajaxSubmit(function(n){r(e("#answers").append(n).find("li:last"));e("#choices").append('<option value="'+(t-1)+'">'+(t-1)+"</option>");u=false;p()})}return false});var a=window.dialogArguments||opener||parent||top;e(".polldaddy-send-to-editor").click(function(){var t=e(this).parents("div.row-actions").find(".polldaddy-poll-id").val();if(!t)t=e(".polldaddy-poll-id:first").val();if(t){t=parseInt(t);if(t>0){a.send_to_editor("[polldaddy poll="+t.toString()+"]")}}});e(".polldaddy-show-shortcode").toggle(function(t){t.preventDefault();e(this).parents("tr:first").next("tr").fadeIn();e(this).parents("tr:first").next("tr").show();e(this).closest("tr").css("display","none");return false},function(){e(this).parents("tr:first").next("tr").fadeOut();e(this).parents("tr:first").next("tr").hide();return false});e(".pd-embed-done").click(function(t){t.preventDefault();e(this).closest("tr").hide();e(this).closest("tr").prev("tr").show()});e(".pd-tabs a").click(function(){if(!jQuery(this).closest("li").hasClass("selected")){jQuery(".pd-tabs li").removeClass("selected");jQuery(this).closest("li").addClass("selected");jQuery(".pd-tab-panel").removeClass("show");jQuery(".pd-tab-panel#"+e(this).closest("li").attr("id")+"-panel").addClass("show")}});var f=e(":input[name=styleID]");var l=e(":input[name=customSelect]");var c=parseInt(l.val());if(c>0){f.val(c.toString());e("#pd-custom-styles a").click()}e("#multipleChoice").click(function(){if(e("#multipleChoice").is(":checked")){e("#numberChoices").show("fast")}else{e("#numberChoices").hide("fast")}});e(".block-repeat").click(function(){var t=jQuery(this).val();if(t=="off"){e("#cookieip_expiration_label").hide();e("#cookieip_expiration").hide()}else{e("#cookieip_expiration_label").show();e("#cookieip_expiration").show()}});var h=false;p();var g={add_media:v};return g}})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
polldaddy-client.php
CHANGED
@@ -35,7 +35,7 @@ class api_client {
|
|
35 |
'body' => $this->request_xml
|
36 |
) );
|
37 |
if ( !$response || is_wp_error( $response ) ) {
|
38 |
-
$errors[-1] = "Can't connect";
|
39 |
return false;
|
40 |
}
|
41 |
$this->response_xml = wp_remote_retrieve_body( $response );
|
@@ -43,7 +43,7 @@ class api_client {
|
|
43 |
$parsed = parse_url( $this->polldaddy_url );
|
44 |
|
45 |
if ( !isset( $parsed['host'] ) && !isset( $parsed['scheme'] ) ) {
|
46 |
-
$errors[-1] = 'Invalid API URL';
|
47 |
return false;
|
48 |
}
|
49 |
|
@@ -56,7 +56,7 @@ class api_client {
|
|
56 |
);
|
57 |
|
58 |
if ( !$fp ) {
|
59 |
-
$errors[-1] = "Can't connect";
|
60 |
return false;
|
61 |
}
|
62 |
|
@@ -81,7 +81,7 @@ class api_client {
|
|
81 |
|
82 |
|
83 |
if ( !$response ) {
|
84 |
-
$errors[-2] = 'No Data';
|
85 |
}
|
86 |
|
87 |
list($headers, $this->response_xml) = explode( "\r\n\r\n", $response, 2 );
|
@@ -98,6 +98,7 @@ class api_client {
|
|
98 |
foreach ( $this->response->errors->error as $error )
|
99 |
$this->errors[$error->_id] = $error->___content;
|
100 |
}
|
|
|
101 |
}
|
102 |
|
103 |
function response_part( $pos ) {
|
@@ -795,7 +796,8 @@ function sync_rating( ){
|
|
795 |
|
796 |
$pos = $this->add_request( 'getrating', new Polldaddy_Rating( null , compact( 'id' ) ) );
|
797 |
|
798 |
-
$this->send_request()
|
|
|
799 |
|
800 |
$demand = $this->response_part( $pos );
|
801 |
|
35 |
'body' => $this->request_xml
|
36 |
) );
|
37 |
if ( !$response || is_wp_error( $response ) ) {
|
38 |
+
$this->errors[-1] = "Can't connect";
|
39 |
return false;
|
40 |
}
|
41 |
$this->response_xml = wp_remote_retrieve_body( $response );
|
43 |
$parsed = parse_url( $this->polldaddy_url );
|
44 |
|
45 |
if ( !isset( $parsed['host'] ) && !isset( $parsed['scheme'] ) ) {
|
46 |
+
$this->errors[-1] = 'Invalid API URL';
|
47 |
return false;
|
48 |
}
|
49 |
|
56 |
);
|
57 |
|
58 |
if ( !$fp ) {
|
59 |
+
$this->errors[-1] = "Can't connect";
|
60 |
return false;
|
61 |
}
|
62 |
|
81 |
|
82 |
|
83 |
if ( !$response ) {
|
84 |
+
$this->errors[-2] = 'No Data';
|
85 |
}
|
86 |
|
87 |
list($headers, $this->response_xml) = explode( "\r\n\r\n", $response, 2 );
|
98 |
foreach ( $this->response->errors->error as $error )
|
99 |
$this->errors[$error->_id] = $error->___content;
|
100 |
}
|
101 |
+
return true;
|
102 |
}
|
103 |
|
104 |
function response_part( $pos ) {
|
796 |
|
797 |
$pos = $this->add_request( 'getrating', new Polldaddy_Rating( null , compact( 'id' ) ) );
|
798 |
|
799 |
+
if ( false == $this->send_request() )
|
800 |
+
return false;
|
801 |
|
802 |
$demand = $this->response_part( $pos );
|
803 |
|
polldaddy-org.php
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
require_once dirname( __FILE__ ) . '/polldaddy-client.php';
|
4 |
|
5 |
$GLOBALS[ 'wp_log_plugins' ][] = 'polldaddy';
|
@@ -491,6 +494,46 @@ class PolldaddyShortcode {
|
|
491 |
add_action( 'infinite_scroll_render', array( $this, 'polldaddy_shortcode_infinite' ), 11 );
|
492 |
}
|
493 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
/**
|
495 |
* Shortcode for polldadddy
|
496 |
* [polldaddy poll|survey|rating="123456"]
|
@@ -523,7 +566,7 @@ class PolldaddyShortcode {
|
|
523 |
'visit' => 'single',
|
524 |
'domain' => '',
|
525 |
'id' => ''
|
526 |
-
), $atts ) );
|
527 |
|
528 |
if ( ! is_array( $atts ) ) {
|
529 |
return '<!-- Polldaddy shortcode passed invalid attributes -->';
|
@@ -548,11 +591,7 @@ class PolldaddyShortcode {
|
|
548 |
self::$add_script = $infinite_scroll;
|
549 |
|
550 |
if ( intval( $rating ) > 0 && !$no_script ) { //rating embed
|
551 |
-
|
552 |
-
$rating_js_file = "https://polldaddy.com/js/rating/rating.js";
|
553 |
-
else
|
554 |
-
$rating_js_file = "http://i0.poll.fm/js/rating/rating.js";
|
555 |
-
|
556 |
if ( empty( $unique_id ) )
|
557 |
$unique_id = is_page() ? 'wp-page-'.$post->ID : 'wp-post-'.$post->ID;
|
558 |
|
@@ -566,7 +605,7 @@ class PolldaddyShortcode {
|
|
566 |
$permalink = get_permalink( $post->ID );
|
567 |
|
568 |
$rating = intval( $rating );
|
569 |
-
$unique_id = preg_replace( '/[
|
570 |
$item_id = wp_strip_all_tags( $item_id );
|
571 |
$item_id = preg_replace( '/[^_a-z0-9]/i', '', $item_id );
|
572 |
|
@@ -579,7 +618,11 @@ class PolldaddyShortcode {
|
|
579 |
) );
|
580 |
|
581 |
$item_id = esc_js( $item_id );
|
582 |
-
|
|
|
|
|
|
|
|
|
583 |
if ( $inline ) {
|
584 |
return <<<SCRIPT
|
585 |
<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
|
@@ -613,7 +656,7 @@ CONTAINER;
|
|
613 |
|
614 |
$poll = intval( $poll );
|
615 |
$poll_url = sprintf( 'http://polldaddy.com/poll/%d', $poll );
|
616 |
-
$poll_js = sprintf( '%s.polldaddy.com/p/%d.js',
|
617 |
$poll_link = sprintf( '<a href="%s">Take Our Poll</a>', $poll_url );
|
618 |
|
619 |
if ( $no_script ) {
|
@@ -624,21 +667,15 @@ CONTAINER;
|
|
624 |
if( !in_array( $visit, array( 'single', 'multiple' ) ) )
|
625 |
$visit = 'single';
|
626 |
|
627 |
-
$settings =
|
628 |
'type' => 'slider',
|
629 |
'embed' => 'poll',
|
630 |
'delay' => intval( $delay ),
|
631 |
'visit' => $visit,
|
632 |
'id' => intval( $poll )
|
633 |
-
)
|
634 |
-
|
635 |
-
return
|
636 |
-
<script type="text/javascript" charset="UTF-8" src="http://i0.poll.fm/survey.js"></script>
|
637 |
-
<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!--
|
638 |
-
polldaddy.add( {$settings} );
|
639 |
-
//--><!]]></script>
|
640 |
-
<noscript>{$poll_link}</noscript>
|
641 |
-
SCRIPT;
|
642 |
} else {
|
643 |
$cb = ( $cb == 1 ? '?cb='.mktime() : false );
|
644 |
$margins = '';
|
@@ -653,6 +690,10 @@ SCRIPT;
|
|
653 |
$margins = 'margin: 0px 0px 0px 10px';
|
654 |
}
|
655 |
|
|
|
|
|
|
|
|
|
656 |
if ( $cb === false && !$inline ) {
|
657 |
if ( self::$scripts === false )
|
658 |
self::$scripts = array();
|
@@ -664,13 +705,34 @@ SCRIPT;
|
|
664 |
add_action( 'wp_footer', array( $this, 'generate_scripts' ) );
|
665 |
|
666 |
$data = esc_attr( json_encode( $data ) );
|
667 |
-
|
668 |
-
|
|
|
|
|
669 |
<a name="pd_a_{$poll}"></a>
|
670 |
<div class="PDS_Poll" id="PDI_container{$poll}" data-settings="{$data}" style="display:inline-block;{$float}{$margins}"></div>
|
671 |
<div id="PD_superContainer"></div>
|
672 |
<noscript>{$poll_link}</noscript>
|
673 |
CONTAINER;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
} else {
|
675 |
if ( $inline )
|
676 |
$cb = '';
|
@@ -690,11 +752,14 @@ CONTAINER;
|
|
690 |
if ( in_array( $type, array( 'iframe', 'button', 'banner', 'slider' ) ) ) {
|
691 |
|
692 |
if ( empty( $title ) ) {
|
693 |
-
$title = 'Take Our Survey';
|
694 |
if( !empty( $link_text ) )
|
695 |
$title = $link_text;
|
696 |
}
|
697 |
-
|
|
|
|
|
|
|
698 |
$survey = preg_replace( '/[^a-f0-9]/i', '', $survey );
|
699 |
$survey_url = esc_url( "http://polldaddy.com/s/{$survey}" );
|
700 |
$survey_link = sprintf( '<a href="%s">%s</a>', $survey_url, esc_html( $title ) );
|
@@ -702,7 +767,7 @@ CONTAINER;
|
|
702 |
if ( $no_script || $inline || $infinite_scroll )
|
703 |
return $survey_link;
|
704 |
|
705 |
-
if ( $type == 'iframe' ) {
|
706 |
if ( $height != 'auto' ) {
|
707 |
if ( isset( $content_width ) && is_numeric( $width ) && $width > $content_width )
|
708 |
$width = $content_width;
|
@@ -718,10 +783,13 @@ CONTAINER;
|
|
718 |
$height = (int) $height;
|
719 |
|
720 |
return <<<CONTAINER
|
721 |
-
<iframe src="{$survey_url}?iframe=1" frameborder="0" width="{$width}" height="{$height}" scrolling="auto" allowtransparency="true" marginheight="0" marginwidth="0">{$survey_link}</iframe>
|
722 |
CONTAINER;
|
723 |
} elseif ( !empty( $domain ) && !empty( $id ) ) {
|
724 |
-
|
|
|
|
|
|
|
725 |
$auto_src = esc_url( "http://{$domain}.polldaddy.com/s/{$id}" );
|
726 |
$auto_src = parse_url( $auto_src );
|
727 |
|
@@ -734,12 +802,12 @@ CONTAINER;
|
|
734 |
$domain = $auto_src['host'].'/s/';
|
735 |
$id = str_ireplace( '/s/', '', $auto_src['path'] );
|
736 |
|
737 |
-
$settings =
|
738 |
'type' => $type,
|
739 |
'auto' => true,
|
740 |
'domain' => $domain,
|
741 |
'id' => $id
|
742 |
-
)
|
743 |
}
|
744 |
} else {
|
745 |
$text_color = preg_replace( '/[^a-f0-9]/i', '', $text_color );
|
@@ -755,7 +823,7 @@ CONTAINER;
|
|
755 |
$body = wp_strip_all_tags( $body );
|
756 |
$button = wp_strip_all_tags( $button );
|
757 |
|
758 |
-
$settings =
|
759 |
'title' => $title,
|
760 |
'type' => $type,
|
761 |
'body' => $body,
|
@@ -765,15 +833,13 @@ CONTAINER;
|
|
765 |
'align' => $align,
|
766 |
'style' => $style,
|
767 |
'id' => $survey
|
768 |
-
) )
|
769 |
}
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
<noscript>{$survey_link}</noscript>
|
776 |
-
CONTAINER;
|
777 |
}
|
778 |
} else {
|
779 |
return '<!-- no polldaddy output -->';
|
@@ -784,11 +850,12 @@ CONTAINER;
|
|
784 |
$script = '';
|
785 |
|
786 |
if ( is_array( self::$scripts ) ) {
|
|
|
|
|
|
|
|
|
|
|
787 |
if ( isset( self::$scripts['rating'] ) ) {
|
788 |
-
if ( is_ssl() )
|
789 |
-
$rating_js_file = "https://polldaddy.com/js/rating/rating.js";
|
790 |
-
else
|
791 |
-
$rating_js_file = "http://i0.poll.fm/js/rating/rating.js";
|
792 |
$script = "<script type='text/javascript' charset='UTF-8' id='polldaddyRatings'><!--//--><![CDATA[//><!--\n";
|
793 |
foreach( self::$scripts['rating'] as $rating ) {
|
794 |
$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']} );}}";
|
@@ -825,25 +892,24 @@ CONTAINER;
|
|
825 |
function polldaddy_shortcode_infinite() {
|
826 |
// only try to load if a shortcode has been called and theme supports infinite scroll
|
827 |
if( self::$add_script ) {
|
828 |
-
$script_url =
|
829 |
|
830 |
// if the script hasn't been loaded, load it
|
831 |
// if the script loads successfully, fire an 'pd-script-load' event
|
832 |
echo <<<SCRIPT
|
833 |
<script type='text/javascript'>
|
834 |
//<![CDATA[
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
}
|
847 |
//]]>
|
848 |
</script>
|
849 |
SCRIPT;
|
@@ -858,13 +924,12 @@ new PolldaddyShortcode();
|
|
858 |
if ( !function_exists( 'polldaddy_link' ) ) {
|
859 |
// http://polldaddy.com/poll/1562975/?view=results&msg=voted
|
860 |
function polldaddy_link( $content ) {
|
861 |
-
return preg_replace( '!(?:\n|\A)http://polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n<script type='text/javascript'
|
862 |
}
|
863 |
|
864 |
// higher priority because we need it before auto-link and autop get to it
|
865 |
add_filter( 'the_content', 'polldaddy_link', 1 );
|
866 |
add_filter( 'the_content_rss', 'polldaddy_link', 1 );
|
867 |
-
add_filter( 'comment_text', 'polldaddy_link', 1 );
|
868 |
}
|
869 |
|
870 |
}
|
1 |
<?php
|
2 |
|
3 |
+
if ( function_exists( 'get_option' ) == false )
|
4 |
+
die( "Cheatin' eh?" );
|
5 |
+
|
6 |
require_once dirname( __FILE__ ) . '/polldaddy-client.php';
|
7 |
|
8 |
$GLOBALS[ 'wp_log_plugins' ][] = 'polldaddy';
|
494 |
add_action( 'infinite_scroll_render', array( $this, 'polldaddy_shortcode_infinite' ), 11 );
|
495 |
}
|
496 |
|
497 |
+
private function get_async_code( array $settings, $survey_link ) {
|
498 |
+
$embed_src = 'http://i0.poll.fm/survey.js';
|
499 |
+
$embed_src_ssl = 'https://polldaddy.com/survey.js';
|
500 |
+
|
501 |
+
$include = <<<CONTAINER
|
502 |
+
( function( d, c, j ) {
|
503 |
+
if ( !d.getElementById( j ) ) {
|
504 |
+
var pd = d.createElement( c ), s;
|
505 |
+
pd.id = j;
|
506 |
+
pd.src = ( 'https:' == d.location.protocol ) ? '{$embed_src_ssl}' : '{$embed_src}';
|
507 |
+
s = d.getElementsByTagName( c )[0];
|
508 |
+
s.parentNode.insertBefore( pd, s );
|
509 |
+
}
|
510 |
+
}( document, 'script', 'pd-embed' ) );
|
511 |
+
CONTAINER;
|
512 |
+
|
513 |
+
// Compress it a bit
|
514 |
+
$include = $this->compress_it( $include );
|
515 |
+
|
516 |
+
$placeholder = '<div class="pd-embed" data-settings="'.esc_attr( json_encode( $settings ) ).'"></div>';
|
517 |
+
if ( $type === 'button' )
|
518 |
+
$placeholder = '<a class="pd-embed" href="'.esc_attr( $survey_link ).'" data-settings="'.esc_attr( json_encode( $settings ) ).'">'.esc_html( $settings['title'] ).'</a>';
|
519 |
+
|
520 |
+
$js_include = $placeholder."\n";
|
521 |
+
$js_include .= '<script type="text/javascript"><!--//--><![CDATA[//><!--'."\n";
|
522 |
+
$js_include .= $include."\n";
|
523 |
+
$js_include .= "//--><!]]></script>\n";
|
524 |
+
|
525 |
+
if ( $type !== 'button' )
|
526 |
+
$js_include .= '<noscript>'.$survey_link."</noscript>\n";
|
527 |
+
|
528 |
+
return $js_include;
|
529 |
+
}
|
530 |
+
|
531 |
+
private function compress_it( $js ) {
|
532 |
+
$js = str_replace( array( "\n", "\t", "\r" ), '', $js );
|
533 |
+
$js = preg_replace( '/\s*([,:\?\{;\-=\(\)])\s*/', '$1', $js );
|
534 |
+
return $js;
|
535 |
+
}
|
536 |
+
|
537 |
/**
|
538 |
* Shortcode for polldadddy
|
539 |
* [polldaddy poll|survey|rating="123456"]
|
566 |
'visit' => 'single',
|
567 |
'domain' => '',
|
568 |
'id' => ''
|
569 |
+
), $atts, 'polldaddy' ) );
|
570 |
|
571 |
if ( ! is_array( $atts ) ) {
|
572 |
return '<!-- Polldaddy shortcode passed invalid attributes -->';
|
591 |
self::$add_script = $infinite_scroll;
|
592 |
|
593 |
if ( intval( $rating ) > 0 && !$no_script ) { //rating embed
|
594 |
+
|
|
|
|
|
|
|
|
|
595 |
if ( empty( $unique_id ) )
|
596 |
$unique_id = is_page() ? 'wp-page-'.$post->ID : 'wp-post-'.$post->ID;
|
597 |
|
605 |
$permalink = get_permalink( $post->ID );
|
606 |
|
607 |
$rating = intval( $rating );
|
608 |
+
$unique_id = preg_replace( '/[^\-_a-z0-9]/i', '', wp_strip_all_tags( $unique_id ) );
|
609 |
$item_id = wp_strip_all_tags( $item_id );
|
610 |
$item_id = preg_replace( '/[^_a-z0-9]/i', '', $item_id );
|
611 |
|
618 |
) );
|
619 |
|
620 |
$item_id = esc_js( $item_id );
|
621 |
+
if ( is_ssl() )
|
622 |
+
$rating_js_file = "https://polldaddy.com/js/rating/rating.js";
|
623 |
+
else
|
624 |
+
$rating_js_file = "http://i0.poll.fm/js/rating/rating.js";
|
625 |
+
|
626 |
if ( $inline ) {
|
627 |
return <<<SCRIPT
|
628 |
<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
|
656 |
|
657 |
$poll = intval( $poll );
|
658 |
$poll_url = sprintf( 'http://polldaddy.com/poll/%d', $poll );
|
659 |
+
$poll_js = sprintf( '%s.polldaddy.com/p/%d.js', '//static', $poll );
|
660 |
$poll_link = sprintf( '<a href="%s">Take Our Poll</a>', $poll_url );
|
661 |
|
662 |
if ( $no_script ) {
|
667 |
if( !in_array( $visit, array( 'single', 'multiple' ) ) )
|
668 |
$visit = 'single';
|
669 |
|
670 |
+
$settings = array(
|
671 |
'type' => 'slider',
|
672 |
'embed' => 'poll',
|
673 |
'delay' => intval( $delay ),
|
674 |
'visit' => $visit,
|
675 |
'id' => intval( $poll )
|
676 |
+
);
|
677 |
+
|
678 |
+
return $this->get_async_code( $settings, $poll_link );
|
|
|
|
|
|
|
|
|
|
|
|
|
679 |
} else {
|
680 |
$cb = ( $cb == 1 ? '?cb='.mktime() : false );
|
681 |
$margins = '';
|
690 |
$margins = 'margin: 0px 0px 0px 10px';
|
691 |
}
|
692 |
|
693 |
+
// Force the normal style embed on single posts/pages otherwise it's not rendered on infinite scroll themed blogs ('infinite_scroll_render' isn't fired)
|
694 |
+
if ( is_singular() )
|
695 |
+
$inline = true;
|
696 |
+
|
697 |
if ( $cb === false && !$inline ) {
|
698 |
if ( self::$scripts === false )
|
699 |
self::$scripts = array();
|
705 |
add_action( 'wp_footer', array( $this, 'generate_scripts' ) );
|
706 |
|
707 |
$data = esc_attr( json_encode( $data ) );
|
708 |
+
|
709 |
+
$script_url = esc_url_raw( plugins_url( 'js/polldaddy-shortcode.js', __FILE__ ) );
|
710 |
+
|
711 |
+
$str = <<<CONTAINER
|
712 |
<a name="pd_a_{$poll}"></a>
|
713 |
<div class="PDS_Poll" id="PDI_container{$poll}" data-settings="{$data}" style="display:inline-block;{$float}{$margins}"></div>
|
714 |
<div id="PD_superContainer"></div>
|
715 |
<noscript>{$poll_link}</noscript>
|
716 |
CONTAINER;
|
717 |
+
|
718 |
+
$loader = <<<SCRIPT
|
719 |
+
( function( d, c, j ) {
|
720 |
+
if ( !d.getElementById( j ) ) {
|
721 |
+
var pd = d.createElement( c ), s;
|
722 |
+
pd.id = j;
|
723 |
+
pd.src = '{$script_url}';
|
724 |
+
s = d.getElementsByTagName( c )[0];
|
725 |
+
s.parentNode.insertBefore( pd, s );
|
726 |
+
}
|
727 |
+
else if ( typeof jQuery !== 'undefined' )
|
728 |
+
jQuery( d.body ).trigger( 'pd-script-load' );
|
729 |
+
}( document, 'script', 'pd-polldaddy-loader' ) );
|
730 |
+
SCRIPT;
|
731 |
+
|
732 |
+
$loader = $this->compress_it( $loader );
|
733 |
+
$loader = "<script type='text/javascript'>\n".$loader."\n</script>";
|
734 |
+
|
735 |
+
return $str.$loader;
|
736 |
} else {
|
737 |
if ( $inline )
|
738 |
$cb = '';
|
752 |
if ( in_array( $type, array( 'iframe', 'button', 'banner', 'slider' ) ) ) {
|
753 |
|
754 |
if ( empty( $title ) ) {
|
755 |
+
$title = __( 'Take Our Survey!', 'polldaddy' );
|
756 |
if( !empty( $link_text ) )
|
757 |
$title = $link_text;
|
758 |
}
|
759 |
+
|
760 |
+
if ( $type == 'banner' || $type == 'slider' )
|
761 |
+
$inline = false;
|
762 |
+
|
763 |
$survey = preg_replace( '/[^a-f0-9]/i', '', $survey );
|
764 |
$survey_url = esc_url( "http://polldaddy.com/s/{$survey}" );
|
765 |
$survey_link = sprintf( '<a href="%s">%s</a>', $survey_url, esc_html( $title ) );
|
767 |
if ( $no_script || $inline || $infinite_scroll )
|
768 |
return $survey_link;
|
769 |
|
770 |
+
if ( $type == 'iframe' ) {
|
771 |
if ( $height != 'auto' ) {
|
772 |
if ( isset( $content_width ) && is_numeric( $width ) && $width > $content_width )
|
773 |
$width = $content_width;
|
783 |
$height = (int) $height;
|
784 |
|
785 |
return <<<CONTAINER
|
786 |
+
<iframe src="{$survey_url}?iframe=1" frameborder="0" width="{$width}" height="{$height}" scrolling="auto" allowtransparency="true" marginheight="0" marginwidth="0">{$survey_link}</iframe>
|
787 |
CONTAINER;
|
788 |
} elseif ( !empty( $domain ) && !empty( $id ) ) {
|
789 |
+
|
790 |
+
$domain = preg_replace( '/[^a-z0-9\-]/i', '', $domain );
|
791 |
+
$id = preg_replace( '/[\/\?&\{\}]/', '', $id );
|
792 |
+
|
793 |
$auto_src = esc_url( "http://{$domain}.polldaddy.com/s/{$id}" );
|
794 |
$auto_src = parse_url( $auto_src );
|
795 |
|
802 |
$domain = $auto_src['host'].'/s/';
|
803 |
$id = str_ireplace( '/s/', '', $auto_src['path'] );
|
804 |
|
805 |
+
$settings = array(
|
806 |
'type' => $type,
|
807 |
'auto' => true,
|
808 |
'domain' => $domain,
|
809 |
'id' => $id
|
810 |
+
);
|
811 |
}
|
812 |
} else {
|
813 |
$text_color = preg_replace( '/[^a-f0-9]/i', '', $text_color );
|
823 |
$body = wp_strip_all_tags( $body );
|
824 |
$button = wp_strip_all_tags( $button );
|
825 |
|
826 |
+
$settings = array_filter( array(
|
827 |
'title' => $title,
|
828 |
'type' => $type,
|
829 |
'body' => $body,
|
833 |
'align' => $align,
|
834 |
'style' => $style,
|
835 |
'id' => $survey
|
836 |
+
) );
|
837 |
}
|
838 |
+
|
839 |
+
if ( empty( $settings ) )
|
840 |
+
return '<!-- no polldaddy output -->';
|
841 |
+
|
842 |
+
return $this->get_async_code( $settings, $survey_link );
|
|
|
|
|
843 |
}
|
844 |
} else {
|
845 |
return '<!-- no polldaddy output -->';
|
850 |
$script = '';
|
851 |
|
852 |
if ( is_array( self::$scripts ) ) {
|
853 |
+
if ( is_ssl() )
|
854 |
+
$rating_js_file = "https://polldaddy.com/js/rating/rating.js";
|
855 |
+
else
|
856 |
+
$rating_js_file = "http://i0.poll.fm/js/rating/rating.js";
|
857 |
+
|
858 |
if ( isset( self::$scripts['rating'] ) ) {
|
|
|
|
|
|
|
|
|
859 |
$script = "<script type='text/javascript' charset='UTF-8' id='polldaddyRatings'><!--//--><![CDATA[//><!--\n";
|
860 |
foreach( self::$scripts['rating'] as $rating ) {
|
861 |
$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']} );}}";
|
892 |
function polldaddy_shortcode_infinite() {
|
893 |
// only try to load if a shortcode has been called and theme supports infinite scroll
|
894 |
if( self::$add_script ) {
|
895 |
+
$script_url = esc_url_raw( plugins_url( 'js/polldaddy-shortcode.js', __FILE__ ) );
|
896 |
|
897 |
// if the script hasn't been loaded, load it
|
898 |
// if the script loads successfully, fire an 'pd-script-load' event
|
899 |
echo <<<SCRIPT
|
900 |
<script type='text/javascript'>
|
901 |
//<![CDATA[
|
902 |
+
( function( d, c, j ) {
|
903 |
+
if ( !d.getElementById( j ) ) {
|
904 |
+
var pd = d.createElement( c ), s;
|
905 |
+
pd.id = j;
|
906 |
+
pd.src = '{$script_url}';
|
907 |
+
s = d.getElementsByTagName( c )[0];
|
908 |
+
s.parentNode.insertBefore( pd, s );
|
909 |
+
}
|
910 |
+
else if ( typeof jQuery !== 'undefined' )
|
911 |
+
jQuery( d.body ).trigger( 'pd-script-load' );
|
912 |
+
}( document, 'script', 'pd-polldaddy-loader' ) );
|
|
|
913 |
//]]>
|
914 |
</script>
|
915 |
SCRIPT;
|
924 |
if ( !function_exists( 'polldaddy_link' ) ) {
|
925 |
// http://polldaddy.com/poll/1562975/?view=results&msg=voted
|
926 |
function polldaddy_link( $content ) {
|
927 |
+
return preg_replace( '!(?:\n|\A)http://polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n<script type='text/javascript' charset='utf-8' src='//static.polldaddy.com/p/$1.js'></script><noscript> <a href='http://polldaddy.com/poll/$1/'>View Poll</a></noscript>\n", $content );
|
928 |
}
|
929 |
|
930 |
// higher priority because we need it before auto-link and autop get to it
|
931 |
add_filter( 'the_content', 'polldaddy_link', 1 );
|
932 |
add_filter( 'the_content_rss', 'polldaddy_link', 1 );
|
|
|
933 |
}
|
934 |
|
935 |
}
|
polldaddy.php
CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://wordpress.org/extend/plugins/polldaddy/
|
|
6 |
Description: Create and manage Polldaddy polls and ratings in WordPress
|
7 |
Author: Automattic, Inc.
|
8 |
Author URL: http://polldaddy.com/
|
9 |
-
Version: 2.0.
|
10 |
*/
|
11 |
|
12 |
// You can hardcode your Polldaddy PartnerGUID (API Key) here
|
@@ -3688,6 +3688,7 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
3688 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
|
3689 |
$polldaddy->reset();
|
3690 |
|
|
|
3691 |
$rating_errors = array();
|
3692 |
if ( empty( $rating_id ) ) {
|
3693 |
$pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
|
@@ -3722,10 +3723,19 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
3722 |
$pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
|
3723 |
$rating_errors[] = $polldaddy->errors;
|
3724 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3725 |
}
|
3726 |
}
|
3727 |
|
3728 |
-
if ( empty( $pd_rating ) ) { //something's up!
|
3729 |
$this->contact_support_message( __( 'There was an error creating your rating widget' ), $rating_errors );
|
3730 |
$error = true;
|
3731 |
} else {
|
@@ -4510,23 +4520,26 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
4510 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
|
4511 |
$polldaddy->reset();
|
4512 |
$rating = $polldaddy->update_rating( $rating_id, $settings_text, $rating_type );
|
4513 |
-
}
|
4514 |
-
|
4515 |
-
|
4516 |
-
|
4517 |
-
|
4518 |
-
|
4519 |
-
update_option( 'pd-rating-pages', $new_rating_id );
|
4520 |
-
|
4521 |
-
|
4522 |
-
|
4523 |
-
|
4524 |
-
update_option( 'pd-rating-comments', $new_rating_id );
|
4525 |
-
|
4526 |
-
|
4527 |
-
|
4528 |
-
|
4529 |
-
update_option( 'pd-rating-posts', $new_rating_id );
|
|
|
|
|
|
|
4530 |
}
|
4531 |
}
|
4532 |
|
6 |
Description: Create and manage Polldaddy polls and ratings in WordPress
|
7 |
Author: Automattic, Inc.
|
8 |
Author URL: http://polldaddy.com/
|
9 |
+
Version: 2.0.26
|
10 |
*/
|
11 |
|
12 |
// You can hardcode your Polldaddy PartnerGUID (API Key) here
|
3688 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
|
3689 |
$polldaddy->reset();
|
3690 |
|
3691 |
+
$error = false;
|
3692 |
$rating_errors = array();
|
3693 |
if ( empty( $rating_id ) ) {
|
3694 |
$pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
|
3723 |
$pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
|
3724 |
$rating_errors[] = $polldaddy->errors;
|
3725 |
}
|
3726 |
+
} elseif ( isset( $polldaddy->errors[ -1 ] ) && $polldaddy->errors[ -1 ] == "Can't connect" ) {
|
3727 |
+
$this->contact_support_message( __( 'Could not connect to the Polldaddy API' ), $rating_errors );
|
3728 |
+
$error = true;
|
3729 |
+
} elseif ( isset( $polldaddy->errors[ -1 ] ) && $polldaddy->errors[ -1 ] == "Invalid API URL" ) {
|
3730 |
+
$this->contact_support_message( __( 'The API URL is incorrect' ), $rating_errors );
|
3731 |
+
$error = true;
|
3732 |
+
} elseif ( isset( $polldaddy->errors[ -2 ] ) && $polldaddy->errors[ -2 ] == "No Data" ) {
|
3733 |
+
$this->contact_support_message( __( 'Your API request did not return any data' ), $rating_errors );
|
3734 |
+
$error = true;
|
3735 |
}
|
3736 |
}
|
3737 |
|
3738 |
+
if ( $error == false && empty( $pd_rating ) ) { //something's up!
|
3739 |
$this->contact_support_message( __( 'There was an error creating your rating widget' ), $rating_errors );
|
3740 |
$error = true;
|
3741 |
} else {
|
4520 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
|
4521 |
$polldaddy->reset();
|
4522 |
$rating = $polldaddy->update_rating( $rating_id, $settings_text, $rating_type );
|
4523 |
+
} elseif ( $this->is_admin && $new_rating_id > 0 ) {
|
4524 |
+
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
|
4525 |
+
$pd_rating = $polldaddy->get_rating( $new_rating_id );
|
4526 |
+
if ( false !== $pd_rating ) {
|
4527 |
+
switch ( $type ) {
|
4528 |
+
case 'pages':
|
4529 |
+
update_option( 'pd-rating-pages-id', $new_rating_id );
|
4530 |
+
if ( (int) get_option( 'pd-rating-pages' ) > 0 )
|
4531 |
+
update_option( 'pd-rating-pages', $new_rating_id );
|
4532 |
+
break;
|
4533 |
+
case 'comments':
|
4534 |
+
update_option( 'pd-rating-comments-id', $new_rating_id );
|
4535 |
+
if ( (int) get_option( 'pd-rating-comments' ) > 0 )
|
4536 |
+
update_option( 'pd-rating-comments', $new_rating_id );
|
4537 |
+
break;
|
4538 |
+
case 'posts':
|
4539 |
+
update_option( 'pd-rating-posts-id', $new_rating_id );
|
4540 |
+
if ( (int) get_option( 'pd-rating-posts' ) > 0 )
|
4541 |
+
update_option( 'pd-rating-posts', $new_rating_id );
|
4542 |
+
}
|
4543 |
}
|
4544 |
}
|
4545 |
|
popups.php
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
function pd_video_shortcodes_help($video_form) {
|
3 |
return '
|
4 |
<table class="describe"><tbody>
|
1 |
<?php
|
2 |
+
|
3 |
+
if ( function_exists( 'add_action' ) == false )
|
4 |
+
die( "Cheatin' eh?" );
|
5 |
+
|
6 |
function pd_video_shortcodes_help($video_form) {
|
7 |
return '
|
8 |
<table class="describe"><tbody>
|
rating.php
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
function polldaddy_show_rating_comments( $content ) {
|
3 |
if ( !is_feed() && !defined( 'DOING_AJAX' ) ) {
|
4 |
global $comment;
|
@@ -149,4 +153,4 @@ if ( (int) get_option( 'pd-rating-pages' ) > 0 || (int) get_option( 'pd-rating-p
|
|
149 |
}
|
150 |
|
151 |
add_filter( 'comment_text', 'polldaddy_show_rating_comments', 50 );
|
152 |
-
?>
|
1 |
<?php
|
2 |
+
|
3 |
+
if ( function_exists( 'get_option' ) == false )
|
4 |
+
die( "Cheatin' eh?" );
|
5 |
+
|
6 |
function polldaddy_show_rating_comments( $content ) {
|
7 |
if ( !is_feed() && !defined( 'DOING_AJAX' ) ) {
|
8 |
global $comment;
|
153 |
}
|
154 |
|
155 |
add_filter( 'comment_text', 'polldaddy_show_rating_comments', 50 );
|
156 |
+
?>
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: eoigal, alternatekev, mdawaffe, donncha, johnny5
|
|
3 |
Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 3.9.1
|
6 |
-
Stable tag: 2.0.
|
7 |
|
8 |
Create and manage Polldaddy polls and ratings from within WordPress.
|
9 |
|
@@ -112,6 +112,14 @@ Your theme is getting the post content, without necessarily showing it. If the p
|
|
112 |
|
113 |
|
114 |
== Upgrade Notice ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
= 2.0.25 =
|
116 |
* Fixed XSS in shortcode and added reset/restore settings form
|
117 |
|
3 |
Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 3.9.1
|
6 |
+
Stable tag: 2.0.26
|
7 |
|
8 |
Create and manage Polldaddy polls and ratings from within WordPress.
|
9 |
|
112 |
|
113 |
|
114 |
== Upgrade Notice ==
|
115 |
+
SSL support for poll shortcode, security update of survey shortcode, resize the "Add Poll" popup.
|
116 |
+
|
117 |
+
= 2.0.26 =
|
118 |
+
* SSL support for poll and survey shortcodes
|
119 |
+
* Security update of survey shortcode
|
120 |
+
* Resize the "Add Poll" popup.
|
121 |
+
* Validate the rating_id before updating it on the ratings settings page.
|
122 |
+
|
123 |
= 2.0.25 =
|
124 |
* Fixed XSS in shortcode and added reset/restore settings form
|
125 |
|