Version Description
- Added a [crowdsignal] shortcode that mimics [polldaddy] which is now deprecated.
- Updated the plugin to work with updated Crowdsignal URLs for polls & surveys
- Updated the API client to use
api.crowdsignal.com/v1
Download this release
Release Info
Developer | ice9js |
Plugin | Crowdsignal Dashboard – Polls, Surveys & more |
Version | 2.1.0 |
Comparing to | |
See all releases |
Code changes from version 2.0.37 to 2.1.0
- css/polldaddy-rtl.css +4 -0
- css/polldaddy.css +10 -0
- css/style-editor.css +1 -0
- polldaddy-client.php +9 -15
- polldaddy-org.php +26 -499
- polldaddy-shortcode.php +463 -0
- polldaddy-xml.php +72 -48
- polldaddy.php +65 -36
- readme.txt +25 -16
css/polldaddy-rtl.css
CHANGED
@@ -23,19 +23,23 @@ ul#answer-options li label{
|
|
23 |
padding-right: 5px;
|
24 |
}
|
25 |
|
|
|
26 |
ul.pd-tabs li{
|
27 |
float: right;
|
28 |
}
|
29 |
|
|
|
30 |
ul.pd-tabs li.selected{
|
31 |
margin-right: 0;
|
32 |
margin-left: 5px;
|
33 |
}
|
34 |
|
|
|
35 |
.pd-embed-col{
|
36 |
float: right;
|
37 |
}
|
38 |
|
|
|
39 |
.pd-label{
|
40 |
float:right;
|
41 |
}
|
23 |
padding-right: 5px;
|
24 |
}
|
25 |
|
26 |
+
ul.cs-tabs li,
|
27 |
ul.pd-tabs li{
|
28 |
float: right;
|
29 |
}
|
30 |
|
31 |
+
ul.cs-tabs li.selected,
|
32 |
ul.pd-tabs li.selected{
|
33 |
margin-right: 0;
|
34 |
margin-left: 5px;
|
35 |
}
|
36 |
|
37 |
+
.cs-embed-col,
|
38 |
.pd-embed-col{
|
39 |
float: right;
|
40 |
}
|
41 |
|
42 |
+
.cs-label,
|
43 |
.pd-label{
|
44 |
float:right;
|
45 |
}
|
css/polldaddy.css
CHANGED
@@ -44,6 +44,7 @@ h2 a.button{
|
|
44 |
display: block;
|
45 |
}
|
46 |
|
|
|
47 |
.pd-box-header{
|
48 |
padding-bottom: 10px;
|
49 |
margin-bottom: 10px;
|
@@ -126,17 +127,20 @@ ul#answer-options li:last-of-type{
|
|
126 |
margin-bottom: 15px;
|
127 |
}
|
128 |
|
|
|
129 |
ul.pd-tabs{
|
130 |
list-style: none;
|
131 |
overflow: hidden;
|
132 |
margin-bottom: 0px;
|
133 |
}
|
134 |
|
|
|
135 |
ul.pd-tabs li{
|
136 |
float: left;
|
137 |
padding: 5px;
|
138 |
}
|
139 |
|
|
|
140 |
ul.pd-tabs li.selected{
|
141 |
background: #f1f1f1;
|
142 |
border: 1px #dfdfdf solid;
|
@@ -145,14 +149,17 @@ ul.pd-tabs li.selected{
|
|
145 |
margin-right: 5px;
|
146 |
}
|
147 |
|
|
|
148 |
ul.pd-tabs li a{
|
149 |
text-decoration: none;
|
150 |
}
|
151 |
|
|
|
152 |
ul.pd-tabs li.selected a{
|
153 |
color: #000;
|
154 |
}
|
155 |
|
|
|
156 |
.pd-tab-panel{
|
157 |
height: 300px;
|
158 |
border: 1px #dfdfdf solid;
|
@@ -160,6 +167,7 @@ ul.pd-tabs li.selected a{
|
|
160 |
display: none;
|
161 |
}
|
162 |
|
|
|
163 |
.pd-tab-panel.show{
|
164 |
display: block;
|
165 |
}
|
@@ -179,6 +187,7 @@ input#shortcode-field{
|
|
179 |
width: 165px;
|
180 |
}
|
181 |
|
|
|
182 |
.pd-embed-col{
|
183 |
width: 33%;
|
184 |
float: left;
|
@@ -189,6 +198,7 @@ input#shortcode-field{
|
|
189 |
background:#F8F7F3;
|
190 |
}
|
191 |
|
|
|
192 |
.pd-label{
|
193 |
display: block;
|
194 |
float:left;
|
44 |
display: block;
|
45 |
}
|
46 |
|
47 |
+
.cs-box-header,
|
48 |
.pd-box-header{
|
49 |
padding-bottom: 10px;
|
50 |
margin-bottom: 10px;
|
127 |
margin-bottom: 15px;
|
128 |
}
|
129 |
|
130 |
+
ul.cs-tabs,
|
131 |
ul.pd-tabs{
|
132 |
list-style: none;
|
133 |
overflow: hidden;
|
134 |
margin-bottom: 0px;
|
135 |
}
|
136 |
|
137 |
+
ul.cs-tabs li,
|
138 |
ul.pd-tabs li{
|
139 |
float: left;
|
140 |
padding: 5px;
|
141 |
}
|
142 |
|
143 |
+
ul.cs-tabs li.selected,
|
144 |
ul.pd-tabs li.selected{
|
145 |
background: #f1f1f1;
|
146 |
border: 1px #dfdfdf solid;
|
149 |
margin-right: 5px;
|
150 |
}
|
151 |
|
152 |
+
ul.cs-tabs li a,
|
153 |
ul.pd-tabs li a{
|
154 |
text-decoration: none;
|
155 |
}
|
156 |
|
157 |
+
ul.cs-tabs li.selected a,
|
158 |
ul.pd-tabs li.selected a{
|
159 |
color: #000;
|
160 |
}
|
161 |
|
162 |
+
.cs-tab-panel,
|
163 |
.pd-tab-panel{
|
164 |
height: 300px;
|
165 |
border: 1px #dfdfdf solid;
|
167 |
display: none;
|
168 |
}
|
169 |
|
170 |
+
.cs-tab-panel.show,
|
171 |
.pd-tab-panel.show{
|
172 |
display: block;
|
173 |
}
|
187 |
width: 165px;
|
188 |
}
|
189 |
|
190 |
+
.cs-embed-col,
|
191 |
.pd-embed-col{
|
192 |
width: 33%;
|
193 |
float: left;
|
198 |
background:#F8F7F3;
|
199 |
}
|
200 |
|
201 |
+
.cs-label,
|
202 |
.pd-label{
|
203 |
display: block;
|
204 |
float:left;
|
css/style-editor.css
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
.CSSE_main{width:374px;border-collapse:collapse;padding:0px;margin:0px 6px;} .CSSE_main_l{width:79px;border:0px;padding:11px 0px 0px 0px;text-align:right;} .CSSE_main_l a{line-height:2;text-decoration:none;font-size:11px;text-align:right;padding-right:5px;} .CSSE_main_r{width:295px;height:280px;padding:0px;margin:0px;border-color:#DFDFDF;border-style:solid;border-width:1px;padding:0.5em 0.9em;} .CSSE_main_l .off{height:23px;width:79px;margin:0px 0px 3px 0px;} .CSSE_main_l .on{-moz-border-radius-bottomleft:3px;-moz-border-radius-bottomright:0;-moz-border-radius-topleft:3px;-moz-border-radius-topright:0;border-style:solid none solid solid;border-color:#DFDFDF;border-width:1px 0 1px 1px;margin-right:-1px;background-color:#F1F1F1;font-color:#333333;font-weight:bold;text-decoration:none;text-shadow:0 1px 0 #FFFFFF;border-style:solid none solid solid;} .CSSE_main_l .Aoff,.CSSE_main_l .Aon{list-style-image:none;list-style-position:outside;list-style-type:none;margin:8px 5px 5px 0px;padding:0;white-space:nowrap;}.CSSE_main_l .Aon{color:#333333;-moz-background-clip:border;-moz-background-inline-policy:continuous;-moz-background-origin:padding;background:transparent none repeat scroll 0 0;border:medium none;} .CSSE_sub{width:295px;border-collapse:collapse;border:0;} .CSSE_sub .top{height:11px;} .CSSE_sub .btm{height:11px;} .CSSE_edit{border-collapse:collapse;width:100%;margin:0px 0px 0px 25px;min-height:160px;} .CSSE_edit TD{font-size:11px;color:#666;height:36px;} .pds-clear{clear:both;display:block;} .pds-answer-group{display:block;padding:5px 0px;} .pds-answer-input{display:block;float:left;width:25px;} .pds-answer{position:relative;cursor:pointer;display:block;float:left;} .pds-answer-other{display:block;} .pds-answer-group{display:block;} .pds-link{display:block;float:left;}
|
2 |
|
3 |
|
|
|
4 |
.pd-editor-label{
|
5 |
width: 200px !important;
|
6 |
padding:10px;
|
1 |
.CSSE_main{width:374px;border-collapse:collapse;padding:0px;margin:0px 6px;} .CSSE_main_l{width:79px;border:0px;padding:11px 0px 0px 0px;text-align:right;} .CSSE_main_l a{line-height:2;text-decoration:none;font-size:11px;text-align:right;padding-right:5px;} .CSSE_main_r{width:295px;height:280px;padding:0px;margin:0px;border-color:#DFDFDF;border-style:solid;border-width:1px;padding:0.5em 0.9em;} .CSSE_main_l .off{height:23px;width:79px;margin:0px 0px 3px 0px;} .CSSE_main_l .on{-moz-border-radius-bottomleft:3px;-moz-border-radius-bottomright:0;-moz-border-radius-topleft:3px;-moz-border-radius-topright:0;border-style:solid none solid solid;border-color:#DFDFDF;border-width:1px 0 1px 1px;margin-right:-1px;background-color:#F1F1F1;font-color:#333333;font-weight:bold;text-decoration:none;text-shadow:0 1px 0 #FFFFFF;border-style:solid none solid solid;} .CSSE_main_l .Aoff,.CSSE_main_l .Aon{list-style-image:none;list-style-position:outside;list-style-type:none;margin:8px 5px 5px 0px;padding:0;white-space:nowrap;}.CSSE_main_l .Aon{color:#333333;-moz-background-clip:border;-moz-background-inline-policy:continuous;-moz-background-origin:padding;background:transparent none repeat scroll 0 0;border:medium none;} .CSSE_sub{width:295px;border-collapse:collapse;border:0;} .CSSE_sub .top{height:11px;} .CSSE_sub .btm{height:11px;} .CSSE_edit{border-collapse:collapse;width:100%;margin:0px 0px 0px 25px;min-height:160px;} .CSSE_edit TD{font-size:11px;color:#666;height:36px;} .pds-clear{clear:both;display:block;} .pds-answer-group{display:block;padding:5px 0px;} .pds-answer-input{display:block;float:left;width:25px;} .pds-answer{position:relative;cursor:pointer;display:block;float:left;} .pds-answer-other{display:block;} .pds-answer-group{display:block;} .pds-link{display:block;float:left;}
|
2 |
|
3 |
|
4 |
+
.cs-editor-label,
|
5 |
.pd-editor-label{
|
6 |
width: 200px !important;
|
7 |
padding:10px;
|
polldaddy-client.php
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
require_once dirname( __FILE__ ) . '/polldaddy-xml.php';
|
4 |
|
5 |
class api_client {
|
6 |
-
var $polldaddy_url = 'https://api.polldaddy.com/';
|
7 |
var $partnerGUID;
|
8 |
var $userCode;
|
9 |
var $admin = 0;
|
@@ -24,32 +23,26 @@ class api_client {
|
|
24 |
function send_request( $timeout = 3 ) {
|
25 |
$this->request_xml = "<?xml version='1.0' encoding='utf-8' ?>\n";
|
26 |
$this->request_xml .= $this->request->xml( 'all' );
|
27 |
-
|
28 |
$this->requests[] = $this->request_xml;
|
29 |
|
30 |
if ( function_exists( 'wp_remote_post' ) ) {
|
31 |
-
$response = wp_remote_post(
|
32 |
'headers' => array( 'Content-Type' => 'text/xml; charset=utf-8', 'Content-Length' => strlen( $this->request_xml ) ),
|
33 |
'user-agent' => 'Polldaddy PHP Client/0.1',
|
34 |
'timeout' => $timeout,
|
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 );
|
42 |
} else {
|
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 |
-
|
50 |
$fp = fsockopen(
|
51 |
-
|
52 |
-
|
53 |
$err_num,
|
54 |
$err_str,
|
55 |
$timeout
|
@@ -66,8 +59,8 @@ class api_client {
|
|
66 |
if ( !isset( $parsed['path']) || !$path = $parsed['path'] . ( isset($parsed['query']) ? '?' . $parsed['query'] : '' ) )
|
67 |
$path = '/';
|
68 |
|
69 |
-
$request =
|
70 |
-
$request .=
|
71 |
$request .= "User-agent: Polldaddy PHP Client/0.1\r\n";
|
72 |
$request .= "Content-Type: text/xml; charset=utf-8\r\n";
|
73 |
$request .= 'Content-Length: ' . strlen( $this->request_xml ) . "\r\n";
|
@@ -184,8 +177,9 @@ class api_client {
|
|
184 |
'partnerUserID' => $partnerUserID
|
185 |
) );
|
186 |
$this->send_request();
|
187 |
-
if ( isset( $this->response->userCode ) )
|
188 |
return $this->response->userCode;
|
|
|
189 |
return false;
|
190 |
}
|
191 |
|
3 |
require_once dirname( __FILE__ ) . '/polldaddy-xml.php';
|
4 |
|
5 |
class api_client {
|
|
|
6 |
var $partnerGUID;
|
7 |
var $userCode;
|
8 |
var $admin = 0;
|
23 |
function send_request( $timeout = 3 ) {
|
24 |
$this->request_xml = "<?xml version='1.0' encoding='utf-8' ?>\n";
|
25 |
$this->request_xml .= $this->request->xml( 'all' );
|
26 |
+
|
27 |
$this->requests[] = $this->request_xml;
|
28 |
|
29 |
if ( function_exists( 'wp_remote_post' ) ) {
|
30 |
+
$response = wp_remote_post( polldaddy_api_url( '/' ), array(
|
31 |
'headers' => array( 'Content-Type' => 'text/xml; charset=utf-8', 'Content-Length' => strlen( $this->request_xml ) ),
|
32 |
'user-agent' => 'Polldaddy PHP Client/0.1',
|
33 |
'timeout' => $timeout,
|
34 |
'body' => $this->request_xml
|
35 |
) );
|
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 );
|
42 |
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
$fp = fsockopen(
|
44 |
+
polldaddy_api_url( '/', POLLDADDY_API_VERSION, 'tls' ),
|
45 |
+
443,
|
46 |
$err_num,
|
47 |
$err_str,
|
48 |
$timeout
|
59 |
if ( !isset( $parsed['path']) || !$path = $parsed['path'] . ( isset($parsed['query']) ? '?' . $parsed['query'] : '' ) )
|
60 |
$path = '/';
|
61 |
|
62 |
+
$request = 'POST ' . polldaddy_api_path( $path ) . " HTTP/1.0\r\n";
|
63 |
+
$request .= 'Host: ' . POLLDADDY_API_HOST . "\r\n";
|
64 |
$request .= "User-agent: Polldaddy PHP Client/0.1\r\n";
|
65 |
$request .= "Content-Type: text/xml; charset=utf-8\r\n";
|
66 |
$request .= 'Content-Length: ' . strlen( $this->request_xml ) . "\r\n";
|
177 |
'partnerUserID' => $partnerUserID
|
178 |
) );
|
179 |
$this->send_request();
|
180 |
+
if ( isset( $this->response->userCode ) ) {
|
181 |
return $this->response->userCode;
|
182 |
+
}
|
183 |
return false;
|
184 |
}
|
185 |
|
polldaddy-org.php
CHANGED
@@ -35,7 +35,7 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
35 |
$this->rating_user_code = get_option( 'pd-rating-usercode' );
|
36 |
|
37 |
if ( empty( $this->rating_user_code ) ) {
|
38 |
-
$this->log( 'set_api_user_code: retrieve usercode from
|
39 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
|
40 |
$polldaddy->reset();
|
41 |
|
@@ -152,7 +152,7 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
152 |
$polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
|
153 |
$polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
|
154 |
|
155 |
-
$this->log( 'api_key_page_load: get
|
156 |
|
157 |
if ( !$polldaddy_email )
|
158 |
$this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
|
@@ -181,7 +181,7 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
181 |
);
|
182 |
|
183 |
if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
|
184 |
-
$polldaddy_api_key = wp_remote_post( '
|
185 |
'body' => $details
|
186 |
) );
|
187 |
if ( is_wp_error( $polldaddy_api_key ) ) {
|
@@ -190,23 +190,23 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
190 |
}
|
191 |
$response_code = wp_remote_retrieve_response_code( $polldaddy_api_key );
|
192 |
if ( 200 != $response_code ) {
|
193 |
-
$this->log( 'management_page_load: could not connect to
|
194 |
-
$this->errors->add( 'http_code', __( 'Could not connect to
|
195 |
return false;
|
196 |
}
|
197 |
$polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
|
198 |
} else {
|
199 |
$fp = fsockopen(
|
200 |
-
'
|
201 |
-
|
202 |
$err_num,
|
203 |
$err_str,
|
204 |
-
|
205 |
);
|
206 |
|
207 |
if ( !$fp ) {
|
208 |
-
$this->log( 'management_page_load: could not connect to
|
209 |
-
$this->errors->add( 'connect', __( "Can't connect to
|
210 |
return false;
|
211 |
}
|
212 |
|
@@ -217,8 +217,8 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
217 |
|
218 |
$request_body = http_build_query( $details, null, '&' );
|
219 |
|
220 |
-
$request =
|
221 |
-
$request .=
|
222 |
$request .= "User-agent: WordPress/$wp_version\r\n";
|
223 |
$request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
|
224 |
$request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
|
@@ -235,11 +235,11 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
235 |
if ( isset( $polldaddy_api_key ) && strlen( $polldaddy_api_key ) > 0 ) {
|
236 |
update_option( 'polldaddy_api_key', $polldaddy_api_key );
|
237 |
} else {
|
238 |
-
$this->log( 'management_page_load: login to
|
239 |
-
$this->errors->add( 'polldaddy_api_key', __( 'Login to
|
240 |
if ( 1 !== $this->use_ssl ) {
|
241 |
$this->errors->add( 'polldaddy_api_key', __( 'If your email address and password are correct, your host may not support secure logins.', 'polldaddy' ) );
|
242 |
-
$this->errors->add( 'polldaddy_api_key', __( 'In that case, you may be able to log in to
|
243 |
$this->use_ssl = 0;
|
244 |
}
|
245 |
update_option( 'polldaddy_use_ssl', $this->use_ssl );
|
@@ -250,7 +250,7 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
250 |
$polldaddy->reset();
|
251 |
if ( !$polldaddy->get_usercode( $this->id ) ) {
|
252 |
$this->parse_errors( $polldaddy );
|
253 |
-
$this->log( 'management_page_load: get usercode from
|
254 |
$this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
|
255 |
return false;
|
256 |
}
|
@@ -265,16 +265,16 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
265 |
|
266 |
<div class="wrap">
|
267 |
|
268 |
-
<h2><?php _e( '
|
269 |
|
270 |
-
<p><?php printf( __( 'Before you can use the
|
271 |
|
272 |
<form action="" method="post">
|
273 |
<table class="form-table">
|
274 |
<tbody>
|
275 |
<tr class="form-field form-required">
|
276 |
<th valign="top" scope="row">
|
277 |
-
<label for="polldaddy-email"><?php _e( '
|
278 |
</th>
|
279 |
<td>
|
280 |
<input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php if ( isset( $_POST['polldaddy_email'] ) ) echo esc_attr( $_POST['polldaddy_email'] ); ?>" />
|
@@ -282,7 +282,7 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
282 |
</tr>
|
283 |
<tr class="form-field form-required">
|
284 |
<th valign="top" scope="row">
|
285 |
-
<label for="polldaddy-password"><?php _e( '
|
286 |
</th>
|
287 |
<td>
|
288 |
<input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
|
@@ -299,7 +299,7 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
299 |
</th>
|
300 |
<td>
|
301 |
<input type="checkbox" name="polldaddy_use_ssl" id="polldaddy-use-ssl" value="1" <?php echo $checked ?> style="width: auto"/>
|
302 |
-
<label for="polldaddy-use-ssl"><?php _e( 'This ensures a secure login to your
|
303 |
<input type="hidden" name="polldaddy_use_ssl_checkbox" value="1" />
|
304 |
</td>
|
305 |
</tr>
|
@@ -341,19 +341,19 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
341 |
<td>
|
342 |
<input type="checkbox" name="polldaddy-load-poll-inline" id="polldaddy-load-poll-inline" value="1" <?php echo $inline ?> style="width: auto" />
|
343 |
<span class="description">
|
344 |
-
<label for="polldaddy-load-poll-inline"><?php _e( 'This will load the
|
345 |
</span>
|
346 |
</td>
|
347 |
</tr><tr class="form-field form-required">
|
348 |
<th valign="top" scope="row">
|
349 |
<label for="polldaddy-multiple-accounts">
|
350 |
-
<?php _e( 'Multiple
|
351 |
</label>
|
352 |
</th>
|
353 |
<td>
|
354 |
<input type="checkbox" name="polldaddy-multiple-accounts" id="polldaddy-multiple-accounts" value="1" <?php echo $checked ?> style="width: auto" />
|
355 |
<span class="description">
|
356 |
-
<label for="polldaddy-multiple-accounts"><?php _e( 'This setting will allow each blog user to import a
|
357 |
</span>
|
358 |
</td>
|
359 |
</tr>
|
@@ -366,7 +366,7 @@ class WPORG_Polldaddy extends WP_Polldaddy {
|
|
366 |
<td>
|
367 |
<input type="checkbox" name="polldaddy-sync-account" id="polldaddy-sync-account" value="1" style="width: auto" />
|
368 |
<span class="description">
|
369 |
-
<label for="polldaddy-sync-account"><?php _e( 'This will synchronize your ratings
|
370 |
</span>
|
371 |
</td>
|
372 |
</tr>
|
@@ -470,479 +470,6 @@ function polldaddy_loader() {
|
|
470 |
add_action( 'admin_menu', array( &$polldaddy_object, 'admin_menu' ) );
|
471 |
}
|
472 |
|
473 |
-
|
474 |
-
if ( !function_exists( 'polldaddy_shortcode_handler' ) ) {
|
475 |
-
function polldaddy_shortcode_handler() {}
|
476 |
-
}
|
477 |
-
|
478 |
-
if ( !class_exists( 'PolldaddyShortcode' ) ) {
|
479 |
-
/**
|
480 |
-
* Class wrapper for polldaddy shortcodes
|
481 |
-
*/
|
482 |
-
class PolldaddyShortcode {
|
483 |
-
|
484 |
-
static $add_script = false;
|
485 |
-
static $scripts = false;
|
486 |
-
|
487 |
-
/**
|
488 |
-
* Add all the actions & resgister the shortcode
|
489 |
-
*/
|
490 |
-
function __construct() {
|
491 |
-
if ( defined( 'GLOBAL_TAGS' ) == false )
|
492 |
-
add_shortcode( 'polldaddy', array( $this, 'polldaddy_shortcode' ) );
|
493 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'check_infinite' ) );
|
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"]
|
540 |
-
*
|
541 |
-
* */
|
542 |
-
function polldaddy_shortcode( $atts ) {
|
543 |
-
global $post;
|
544 |
-
global $content_width;
|
545 |
-
|
546 |
-
extract( shortcode_atts( array(
|
547 |
-
'survey' => null,
|
548 |
-
'link_text' => 'Take Our Survey',
|
549 |
-
'poll' => 'empty',
|
550 |
-
'rating' => 'empty',
|
551 |
-
'unique_id' => null,
|
552 |
-
'item_id' => null,
|
553 |
-
'title' => null,
|
554 |
-
'permalink' => null,
|
555 |
-
'cb' => 0,
|
556 |
-
'type' => 'button',
|
557 |
-
'body' => '',
|
558 |
-
'button' => '',
|
559 |
-
'text_color' => '000000',
|
560 |
-
'back_color' => 'FFFFFF',
|
561 |
-
'align' => '',
|
562 |
-
'style' => '',
|
563 |
-
'width' => $content_width,
|
564 |
-
'height' => floor( $content_width * 3 / 4 ),
|
565 |
-
'delay' => 100,
|
566 |
-
'visit' => 'single',
|
567 |
-
'domain' => '',
|
568 |
-
'id' => ''
|
569 |
-
), $atts, 'polldaddy' ) );
|
570 |
-
|
571 |
-
if ( ! is_array( $atts ) ) {
|
572 |
-
return '<!-- Polldaddy shortcode passed invalid attributes -->';
|
573 |
-
}
|
574 |
-
|
575 |
-
$inline = !in_the_loop();
|
576 |
-
$no_script = false;
|
577 |
-
$infinite_scroll = false;
|
578 |
-
|
579 |
-
if ( is_home() && current_theme_supports( 'infinite-scroll' ) )
|
580 |
-
$infinite_scroll = true;
|
581 |
-
|
582 |
-
if ( defined( 'PADPRESS_LOADED' ) )
|
583 |
-
$inline = true;
|
584 |
-
|
585 |
-
if ( function_exists( 'get_option' ) && get_option( 'polldaddy_load_poll_inline' ) )
|
586 |
-
$inline = true;
|
587 |
-
|
588 |
-
if ( is_feed() || ( defined( 'DOING_AJAX' ) && !$infinite_scroll ) )
|
589 |
-
$no_script = false;
|
590 |
-
|
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 |
-
|
598 |
-
if ( empty( $item_id ) )
|
599 |
-
$item_id = is_page() ? '_page_'.$post->ID : '_post_'.$post->ID;
|
600 |
-
|
601 |
-
if ( empty( $title ) )
|
602 |
-
$title = apply_filters( 'the_title', $post->post_title );
|
603 |
-
|
604 |
-
if ( empty( $permalink ) )
|
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 |
-
|
612 |
-
$settings = json_encode( array(
|
613 |
-
'id' => $rating,
|
614 |
-
'unique_id' => $unique_id,
|
615 |
-
'title' => rawurlencode( trim( $title ) ),
|
616 |
-
'permalink' => esc_url( $permalink ),
|
617 |
-
'item_id' => $item_id
|
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>
|
629 |
-
<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!--
|
630 |
-
PDRTJS_settings_{$rating}{$item_id}={$settings};
|
631 |
-
//--><!]]></script>
|
632 |
-
<script type="text/javascript" charset="UTF-8" src="{$rating_js_file}"></script>
|
633 |
-
SCRIPT;
|
634 |
-
} else {
|
635 |
-
if ( self::$scripts === false )
|
636 |
-
self::$scripts = array();
|
637 |
-
|
638 |
-
$data = array( 'id' => $rating, 'item_id' => $item_id, 'settings' => $settings );
|
639 |
-
|
640 |
-
self::$scripts['rating'][] = $data;
|
641 |
-
|
642 |
-
add_action( 'wp_footer', array( $this, 'generate_scripts' ) );
|
643 |
-
|
644 |
-
$data = esc_attr( json_encode( $data ) );
|
645 |
-
|
646 |
-
if ( $infinite_scroll )
|
647 |
-
return <<<CONTAINER
|
648 |
-
<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}" data-settings="{$data}"></div>
|
649 |
-
CONTAINER;
|
650 |
-
else
|
651 |
-
return <<<CONTAINER
|
652 |
-
<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
|
653 |
-
CONTAINER;
|
654 |
-
}
|
655 |
-
} elseif ( intval( $poll ) > 0 ) { //poll embed
|
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 ) {
|
663 |
-
return $poll_link;
|
664 |
-
} else {
|
665 |
-
if ( $type == 'slider' && !$inline ) {
|
666 |
-
|
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='. time() : false );
|
681 |
-
$margins = '';
|
682 |
-
$float = '';
|
683 |
-
|
684 |
-
if ( in_array( $align, array( 'right', 'left' ) ) ) {
|
685 |
-
$float = sprintf( 'float: %s;', $align );
|
686 |
-
|
687 |
-
if ( $align == 'left')
|
688 |
-
$margins = 'margin: 0px 10px 0px 0px;';
|
689 |
-
elseif ( $align == 'right' )
|
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();
|
700 |
-
|
701 |
-
$data = array( 'url' => $poll_js );
|
702 |
-
|
703 |
-
self::$scripts['poll'][] = $data;
|
704 |
-
|
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 = '';
|
739 |
-
|
740 |
-
return <<<CONTAINER
|
741 |
-
<a name="pd_a_{$poll}"></a>
|
742 |
-
<div class="PDS_Poll" id="PDI_container{$poll}" style="display:inline-block;{$float}{$margins}"></div>
|
743 |
-
<div id="PD_superContainer"></div>
|
744 |
-
<script type="text/javascript" charset="UTF-8" src="{$poll_js}{$cb}"></script>
|
745 |
-
<noscript>{$poll_link}</noscript>
|
746 |
-
CONTAINER;
|
747 |
-
}
|
748 |
-
}
|
749 |
-
}
|
750 |
-
} elseif ( !empty( $survey ) ) { //survey embed
|
751 |
-
|
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 ) );
|
766 |
-
|
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;
|
774 |
-
|
775 |
-
if ( !$width )
|
776 |
-
$width = '100%';
|
777 |
-
else
|
778 |
-
$width = (int) $width;
|
779 |
-
|
780 |
-
if ( !$height )
|
781 |
-
$height = '600';
|
782 |
-
else
|
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 |
-
|
796 |
-
if ( !is_array( $auto_src ) || count( $auto_src ) == 0 )
|
797 |
-
return '<!-- no polldaddy output -->';
|
798 |
-
|
799 |
-
if ( !isset( $auto_src['host'] ) || !isset( $auto_src['path'] ) )
|
800 |
-
return '<!-- no polldaddy output -->';
|
801 |
-
|
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 );
|
814 |
-
$back_color = preg_replace( '/[^a-f0-9]/i', '', $back_color );
|
815 |
-
|
816 |
-
if ( !in_array( $align, array( 'right', 'left', 'top-left', 'top-right', 'middle-left', 'middle-right', 'bottom-left', 'bottom-right' ) ) )
|
817 |
-
$align = '';
|
818 |
-
|
819 |
-
if ( !in_array( $style, array( 'inline', 'side', 'corner', 'rounded', 'square' ) ) )
|
820 |
-
$style = '';
|
821 |
-
|
822 |
-
$title = wp_strip_all_tags( $title );
|
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,
|
830 |
-
'button' => $button,
|
831 |
-
'text_color' => $text_color,
|
832 |
-
'back_color' => $back_color,
|
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 -->';
|
846 |
-
}
|
847 |
-
}
|
848 |
-
|
849 |
-
function generate_scripts() {
|
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']} );}}";
|
862 |
-
}
|
863 |
-
$script .= "\n//--><!]]></script><script type='text/javascript' charset='UTF-8' src='{$rating_js_file}'></script>";
|
864 |
-
|
865 |
-
}
|
866 |
-
|
867 |
-
if ( isset( self::$scripts['poll'] ) ) {
|
868 |
-
foreach( self::$scripts['poll'] as $poll ) {
|
869 |
-
$script .= "<script type='text/javascript' charset='UTF-8' src='{$poll['url']}'></script>";
|
870 |
-
}
|
871 |
-
}
|
872 |
-
}
|
873 |
-
|
874 |
-
self::$scripts = false;
|
875 |
-
echo $script;
|
876 |
-
}
|
877 |
-
|
878 |
-
/**
|
879 |
-
* If the theme uses infinite scroll, include jquery at the start
|
880 |
-
*/
|
881 |
-
function check_infinite() {
|
882 |
-
if ( current_theme_supports( 'infinite-scroll' ) && class_exists( 'The_Neverending_Home_Page' ) && The_Neverending_Home_Page::archive_supports_infinity() )
|
883 |
-
wp_enqueue_script( 'jquery' );
|
884 |
-
}
|
885 |
-
|
886 |
-
/**
|
887 |
-
* Dynamically load the .js, if needed
|
888 |
-
*
|
889 |
-
* This hooks in late (priority 11) to infinite_scroll_render to determine
|
890 |
-
* a posteriori if a shortcode has been called.
|
891 |
-
*/
|
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;
|
916 |
-
|
917 |
-
}
|
918 |
-
}
|
919 |
-
}
|
920 |
-
|
921 |
-
// kick it all off
|
922 |
-
new PolldaddyShortcode();
|
923 |
-
|
924 |
-
if ( !function_exists( 'polldaddy_link' ) ) {
|
925 |
-
// http://polldaddy.com/poll/1562975/?view=results&msg=voted
|
926 |
-
function polldaddy_link( $content ) {
|
927 |
-
if ( false === strpos( $content, "polldaddy.com/" ) )
|
928 |
-
return $content;
|
929 |
-
$textarr = wp_html_split( $content );
|
930 |
-
unset( $content );
|
931 |
-
foreach( $textarr as &$element ) {
|
932 |
-
if ( '' === $element || '<' === $element{0} )
|
933 |
-
continue;
|
934 |
-
$element = 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", $element );
|
935 |
-
}
|
936 |
-
return join( $textarr );
|
937 |
-
}
|
938 |
-
|
939 |
-
// higher priority because we need it before auto-link and autop get to it
|
940 |
-
add_filter( 'the_content', 'polldaddy_link', 1 );
|
941 |
-
add_filter( 'the_content_rss', 'polldaddy_link', 1 );
|
942 |
-
}
|
943 |
-
|
944 |
-
}
|
945 |
-
|
946 |
add_action( 'init', 'polldaddy_loader' );
|
947 |
add_filter( 'widget_text', 'do_shortcode' );
|
948 |
|
@@ -1102,7 +629,7 @@ function polldaddy_login_warning() {
|
|
1102 |
global $cache_enabled, $hook_suffix;
|
1103 |
$page = isset( $_GET[ 'page' ] ) ? $_GET[ 'page' ] : '';
|
1104 |
if ( ( $hook_suffix == 'plugins.php' || $page == 'polls' ) && false == get_option( 'polldaddy_api_key' ) && function_exists( "admin_url" ) )
|
1105 |
-
echo '<div class="updated"><p><strong>' . sprintf( __( 'Warning! The
|
1106 |
}
|
1107 |
add_action( 'admin_notices', 'polldaddy_login_warning' );
|
1108 |
|
35 |
$this->rating_user_code = get_option( 'pd-rating-usercode' );
|
36 |
|
37 |
if ( empty( $this->rating_user_code ) ) {
|
38 |
+
$this->log( 'set_api_user_code: retrieve usercode from Crowdsignal' );
|
39 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
|
40 |
$polldaddy->reset();
|
41 |
|
152 |
$polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
|
153 |
$polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
|
154 |
|
155 |
+
$this->log( 'api_key_page_load: get Crowdsignal API key for account - '.$polldaddy_email );
|
156 |
|
157 |
if ( !$polldaddy_email )
|
158 |
$this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
|
181 |
);
|
182 |
|
183 |
if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
|
184 |
+
$polldaddy_api_key = wp_remote_post( polldaddy_api_url( '/key' ), array(
|
185 |
'body' => $details
|
186 |
) );
|
187 |
if ( is_wp_error( $polldaddy_api_key ) ) {
|
190 |
}
|
191 |
$response_code = wp_remote_retrieve_response_code( $polldaddy_api_key );
|
192 |
if ( 200 != $response_code ) {
|
193 |
+
$this->log( 'management_page_load: could not connect to Crowdsignal API key service' );
|
194 |
+
$this->errors->add( 'http_code', __( 'Could not connect to Crowdsignal API Key service', 'polldaddy' ) );
|
195 |
return false;
|
196 |
}
|
197 |
$polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
|
198 |
} else {
|
199 |
$fp = fsockopen(
|
200 |
+
polldaddy_api_url( '/', POLLDADDY_API_VERSION, 'tls' ),
|
201 |
+
443,
|
202 |
$err_num,
|
203 |
$err_str,
|
204 |
+
5
|
205 |
);
|
206 |
|
207 |
if ( !$fp ) {
|
208 |
+
$this->log( 'management_page_load: could not connect to Crowdsignal API key service' );
|
209 |
+
$this->errors->add( 'connect', __( "Can't connect to Crowdsignal.com", 'polldaddy' ) );
|
210 |
return false;
|
211 |
}
|
212 |
|
217 |
|
218 |
$request_body = http_build_query( $details, null, '&' );
|
219 |
|
220 |
+
$request = 'POST ' . polldaddy_api_path( '/key' ) . " HTTP/1.0\r\n";
|
221 |
+
$request .= 'Host: ' . POLLDADDY_API_HOST . "\r\n";
|
222 |
$request .= "User-agent: WordPress/$wp_version\r\n";
|
223 |
$request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
|
224 |
$request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
|
235 |
if ( isset( $polldaddy_api_key ) && strlen( $polldaddy_api_key ) > 0 ) {
|
236 |
update_option( 'polldaddy_api_key', $polldaddy_api_key );
|
237 |
} else {
|
238 |
+
$this->log( 'management_page_load: login to Crowdsignal failed' );
|
239 |
+
$this->errors->add( 'polldaddy_api_key', __( 'Login to Crowdsignal failed. Double check your email address and password.', 'polldaddy' ) );
|
240 |
if ( 1 !== $this->use_ssl ) {
|
241 |
$this->errors->add( 'polldaddy_api_key', __( 'If your email address and password are correct, your host may not support secure logins.', 'polldaddy' ) );
|
242 |
+
$this->errors->add( 'polldaddy_api_key', __( 'In that case, you may be able to log in to Crowdsignal by unchecking the "Use SSL to Log in" checkbox.', 'polldaddy' ) );
|
243 |
$this->use_ssl = 0;
|
244 |
}
|
245 |
update_option( 'polldaddy_use_ssl', $this->use_ssl );
|
250 |
$polldaddy->reset();
|
251 |
if ( !$polldaddy->get_usercode( $this->id ) ) {
|
252 |
$this->parse_errors( $polldaddy );
|
253 |
+
$this->log( 'management_page_load: get usercode from Crowdsignal failed' );
|
254 |
$this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
|
255 |
return false;
|
256 |
}
|
265 |
|
266 |
<div class="wrap">
|
267 |
|
268 |
+
<h2><?php _e( 'Crowdsignal Account', 'polldaddy' ); ?></h2>
|
269 |
|
270 |
+
<p><?php printf( __( 'Before you can use the Crowdsignal plugin, you need to enter your <a href="%s">Crowdsignal.com</a> account details.', 'polldaddy' ), 'https://app.crowdsignal.com/' ); ?></p>
|
271 |
|
272 |
<form action="" method="post">
|
273 |
<table class="form-table">
|
274 |
<tbody>
|
275 |
<tr class="form-field form-required">
|
276 |
<th valign="top" scope="row">
|
277 |
+
<label for="polldaddy-email"><?php _e( 'Crowdsignal Email Address', 'polldaddy' ); ?></label>
|
278 |
</th>
|
279 |
<td>
|
280 |
<input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php if ( isset( $_POST['polldaddy_email'] ) ) echo esc_attr( $_POST['polldaddy_email'] ); ?>" />
|
282 |
</tr>
|
283 |
<tr class="form-field form-required">
|
284 |
<th valign="top" scope="row">
|
285 |
+
<label for="polldaddy-password"><?php _e( 'Crowdsignal Password', 'polldaddy' ); ?></label>
|
286 |
</th>
|
287 |
<td>
|
288 |
<input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
|
299 |
</th>
|
300 |
<td>
|
301 |
<input type="checkbox" name="polldaddy_use_ssl" id="polldaddy-use-ssl" value="1" <?php echo $checked ?> style="width: auto"/>
|
302 |
+
<label for="polldaddy-use-ssl"><?php _e( 'This ensures a secure login to your Crowdsignal account. Only uncheck if you are having problems logging in.', 'polldaddy' ); ?></label>
|
303 |
<input type="hidden" name="polldaddy_use_ssl_checkbox" value="1" />
|
304 |
</td>
|
305 |
</tr>
|
341 |
<td>
|
342 |
<input type="checkbox" name="polldaddy-load-poll-inline" id="polldaddy-load-poll-inline" value="1" <?php echo $inline ?> style="width: auto" />
|
343 |
<span class="description">
|
344 |
+
<label for="polldaddy-load-poll-inline"><?php _e( 'This will load the Crowdsignal shortcodes inline rather than in the page footer.', 'polldaddy' ); ?></label>
|
345 |
</span>
|
346 |
</td>
|
347 |
</tr><tr class="form-field form-required">
|
348 |
<th valign="top" scope="row">
|
349 |
<label for="polldaddy-multiple-accounts">
|
350 |
+
<?php _e( 'Multiple Crowdsignal Accounts', 'polldaddy' ); ?>
|
351 |
</label>
|
352 |
</th>
|
353 |
<td>
|
354 |
<input type="checkbox" name="polldaddy-multiple-accounts" id="polldaddy-multiple-accounts" value="1" <?php echo $checked ?> style="width: auto" />
|
355 |
<span class="description">
|
356 |
+
<label for="polldaddy-multiple-accounts"><?php _e( 'This setting will allow each blog user to import a Crowdsignal account.', 'polldaddy' ); ?></label>
|
357 |
</span>
|
358 |
</td>
|
359 |
</tr>
|
366 |
<td>
|
367 |
<input type="checkbox" name="polldaddy-sync-account" id="polldaddy-sync-account" value="1" style="width: auto" />
|
368 |
<span class="description">
|
369 |
+
<label for="polldaddy-sync-account"><?php _e( 'This will synchronize your ratings Crowdsignal account.', 'polldaddy' ); ?></label>
|
370 |
</span>
|
371 |
</td>
|
372 |
</tr>
|
470 |
add_action( 'admin_menu', array( &$polldaddy_object, 'admin_menu' ) );
|
471 |
}
|
472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
add_action( 'init', 'polldaddy_loader' );
|
474 |
add_filter( 'widget_text', 'do_shortcode' );
|
475 |
|
629 |
global $cache_enabled, $hook_suffix;
|
630 |
$page = isset( $_GET[ 'page' ] ) ? $_GET[ 'page' ] : '';
|
631 |
if ( ( $hook_suffix == 'plugins.php' || $page == 'polls' ) && false == get_option( 'polldaddy_api_key' ) && function_exists( "admin_url" ) )
|
632 |
+
echo '<div class="updated"><p><strong>' . sprintf( __( 'Warning! The Crowdsignal plugin must be linked to your Crowdsignal.com account. Please visit the <a href="%s">plugin settings page</a> to login.', 'polldaddy' ), admin_url( 'options-general.php?page=polls&action=options' ) ) . '</strong></p></div>';
|
633 |
}
|
634 |
add_action( 'admin_notices', 'polldaddy_login_warning' );
|
635 |
|
polldaddy-shortcode.php
ADDED
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( function_exists( 'get_option' ) == false )
|
4 |
+
die( "Cheatin' eh?" );
|
5 |
+
|
6 |
+
if ( ! class_exists( 'PolldaddyShortcode' ) ) {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class wrapper for polldaddy shortcodes
|
10 |
+
*/
|
11 |
+
class PolldaddyShortcode {
|
12 |
+
|
13 |
+
static $add_script = false;
|
14 |
+
static $scripts = false;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Add all the actions & resgister the shortcode
|
18 |
+
*/
|
19 |
+
function __construct() {
|
20 |
+
if ( defined( 'GLOBAL_TAGS' ) == false ) {
|
21 |
+
add_shortcode( 'crowdsignal', array( $this, 'polldaddy_shortcode' ) );
|
22 |
+
add_shortcode( 'polldaddy', array( $this, 'polldaddy_shortcode' ) );
|
23 |
+
}
|
24 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'check_infinite' ) );
|
25 |
+
add_action( 'infinite_scroll_render', array( $this, 'polldaddy_shortcode_infinite' ), 11 );
|
26 |
+
}
|
27 |
+
|
28 |
+
private function get_async_code( array $settings, $survey_link ) {
|
29 |
+
$include = <<<CONTAINER
|
30 |
+
( function( d, c, j ) {
|
31 |
+
if ( !d.getElementById( j ) ) {
|
32 |
+
var pd = d.createElement( c ), s;
|
33 |
+
pd.id = j;
|
34 |
+
pd.src = 'https://polldaddy.com/survey.js';
|
35 |
+
s = d.getElementsByTagName( c )[0];
|
36 |
+
s.parentNode.insertBefore( pd, s );
|
37 |
+
}
|
38 |
+
}( document, 'script', 'pd-embed' ) );
|
39 |
+
CONTAINER;
|
40 |
+
|
41 |
+
// Compress it a bit
|
42 |
+
$include = $this->compress_it( $include );
|
43 |
+
|
44 |
+
$placeholder = '<div class="cs-embed pd-embed" data-settings="'.esc_attr( json_encode( $settings ) ).'"></div>';
|
45 |
+
if ( $type === 'button' )
|
46 |
+
$placeholder = '<a class="cs-embed pd-embed" href="'.esc_attr( $survey_link ).'" data-settings="'.esc_attr( json_encode( $settings ) ).'">'.esc_html( $settings['title'] ).'</a>';
|
47 |
+
|
48 |
+
$js_include = $placeholder."\n";
|
49 |
+
$js_include .= '<script type="text/javascript"><!--//--><![CDATA[//><!--'."\n";
|
50 |
+
$js_include .= $include."\n";
|
51 |
+
$js_include .= "//--><!]]></script>\n";
|
52 |
+
|
53 |
+
if ( $type !== 'button' )
|
54 |
+
$js_include .= '<noscript>'.$survey_link."</noscript>\n";
|
55 |
+
|
56 |
+
return $js_include;
|
57 |
+
}
|
58 |
+
|
59 |
+
private function compress_it( $js ) {
|
60 |
+
$js = str_replace( array( "\n", "\t", "\r" ), '', $js );
|
61 |
+
$js = preg_replace( '/\s*([,:\?\{;\-=\(\)])\s*/', '$1', $js );
|
62 |
+
return $js;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Shortcode for Crowdsignal
|
67 |
+
* [crowdsignal poll|survey|rating="123456"]
|
68 |
+
* [polldaddy poll|survey|rating="123456"]
|
69 |
+
*/
|
70 |
+
function polldaddy_shortcode( $atts ) {
|
71 |
+
global $post;
|
72 |
+
global $content_width;
|
73 |
+
|
74 |
+
extract( shortcode_atts( array(
|
75 |
+
'survey' => null,
|
76 |
+
'link_text' => 'Take Our Survey',
|
77 |
+
'poll' => 'empty',
|
78 |
+
'rating' => 'empty',
|
79 |
+
'unique_id' => null,
|
80 |
+
'item_id' => null,
|
81 |
+
'title' => null,
|
82 |
+
'permalink' => null,
|
83 |
+
'cb' => 0,
|
84 |
+
'type' => 'button',
|
85 |
+
'body' => '',
|
86 |
+
'button' => '',
|
87 |
+
'text_color' => '000000',
|
88 |
+
'back_color' => 'FFFFFF',
|
89 |
+
'align' => '',
|
90 |
+
'style' => '',
|
91 |
+
'width' => $content_width,
|
92 |
+
'height' => floor( $content_width * 3 / 4 ),
|
93 |
+
'delay' => 100,
|
94 |
+
'visit' => 'single',
|
95 |
+
'domain' => '',
|
96 |
+
'id' => ''
|
97 |
+
), $atts, 'crowdsignal' ) );
|
98 |
+
|
99 |
+
if ( ! is_array( $atts ) ) {
|
100 |
+
return '<!-- Crowdsignal shortcode passed invalid attributes -->';
|
101 |
+
}
|
102 |
+
|
103 |
+
$inline = !in_the_loop();
|
104 |
+
$no_script = false;
|
105 |
+
$infinite_scroll = false;
|
106 |
+
|
107 |
+
if ( is_home() && current_theme_supports( 'infinite-scroll' ) )
|
108 |
+
$infinite_scroll = true;
|
109 |
+
|
110 |
+
if ( defined( 'PADPRESS_LOADED' ) )
|
111 |
+
$inline = true;
|
112 |
+
|
113 |
+
if ( function_exists( 'get_option' ) && get_option( 'polldaddy_load_poll_inline' ) )
|
114 |
+
$inline = true;
|
115 |
+
|
116 |
+
if ( is_feed() || ( defined( 'DOING_AJAX' ) && !$infinite_scroll ) )
|
117 |
+
$no_script = false;
|
118 |
+
|
119 |
+
self::$add_script = $infinite_scroll;
|
120 |
+
|
121 |
+
if ( intval( $rating ) > 0 && !$no_script ) { //rating embed
|
122 |
+
|
123 |
+
if ( empty( $unique_id ) )
|
124 |
+
$unique_id = is_page() ? 'wp-page-'.$post->ID : 'wp-post-'.$post->ID;
|
125 |
+
|
126 |
+
if ( empty( $item_id ) )
|
127 |
+
$item_id = is_page() ? '_page_'.$post->ID : '_post_'.$post->ID;
|
128 |
+
|
129 |
+
if ( empty( $title ) )
|
130 |
+
$title = apply_filters( 'the_title', $post->post_title );
|
131 |
+
|
132 |
+
if ( empty( $permalink ) )
|
133 |
+
$permalink = get_permalink( $post->ID );
|
134 |
+
|
135 |
+
$rating = intval( $rating );
|
136 |
+
$unique_id = preg_replace( '/[^\-_a-z0-9]/i', '', wp_strip_all_tags( $unique_id ) );
|
137 |
+
$item_id = wp_strip_all_tags( $item_id );
|
138 |
+
$item_id = preg_replace( '/[^_a-z0-9]/i', '', $item_id );
|
139 |
+
|
140 |
+
$settings = json_encode( array(
|
141 |
+
'id' => $rating,
|
142 |
+
'unique_id' => $unique_id,
|
143 |
+
'title' => rawurlencode( trim( $title ) ),
|
144 |
+
'permalink' => esc_url( $permalink ),
|
145 |
+
'item_id' => $item_id
|
146 |
+
) );
|
147 |
+
|
148 |
+
$item_id = esc_js( $item_id );
|
149 |
+
|
150 |
+
if ( $inline ) {
|
151 |
+
return <<<SCRIPT
|
152 |
+
<div class="cs-rating pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
|
153 |
+
<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!--
|
154 |
+
PDRTJS_settings_{$rating}{$item_id}={$settings};
|
155 |
+
//--><!]]></script>
|
156 |
+
<script type="text/javascript" charset="UTF-8" src="https://polldaddy.com/js/rating/rating.js"></script>
|
157 |
+
SCRIPT;
|
158 |
+
} else {
|
159 |
+
if ( self::$scripts === false )
|
160 |
+
self::$scripts = array();
|
161 |
+
|
162 |
+
$data = array( 'id' => $rating, 'item_id' => $item_id, 'settings' => $settings );
|
163 |
+
|
164 |
+
self::$scripts['rating'][] = $data;
|
165 |
+
|
166 |
+
add_action( 'wp_footer', array( $this, 'generate_scripts' ) );
|
167 |
+
|
168 |
+
$data = esc_attr( json_encode( $data ) );
|
169 |
+
|
170 |
+
if ( $infinite_scroll )
|
171 |
+
return <<<CONTAINER
|
172 |
+
<div class="cs-rating pd-rating" id="pd_rating_holder_{$rating}{$item_id}" data-settings="{$data}"></div>
|
173 |
+
CONTAINER;
|
174 |
+
else
|
175 |
+
return <<<CONTAINER
|
176 |
+
<div class="cs-rating pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
|
177 |
+
CONTAINER;
|
178 |
+
}
|
179 |
+
} elseif ( intval( $poll ) > 0 ) { //poll embed
|
180 |
+
|
181 |
+
$poll = intval( $poll );
|
182 |
+
$poll_url = sprintf( 'https://poll.fm/%d', $poll );
|
183 |
+
$poll_js = sprintf( '%s.polldaddy.com/p/%d.js', '//static', $poll );
|
184 |
+
$poll_link = sprintf( '<a href="%s">Take Our Poll</a>', $poll_url );
|
185 |
+
|
186 |
+
if ( $no_script ) {
|
187 |
+
return $poll_link;
|
188 |
+
} else {
|
189 |
+
if ( $type == 'slider' && !$inline ) {
|
190 |
+
|
191 |
+
if( !in_array( $visit, array( 'single', 'multiple' ) ) )
|
192 |
+
$visit = 'single';
|
193 |
+
|
194 |
+
$settings = array(
|
195 |
+
'type' => 'slider',
|
196 |
+
'embed' => 'poll',
|
197 |
+
'delay' => intval( $delay ),
|
198 |
+
'visit' => $visit,
|
199 |
+
'id' => intval( $poll )
|
200 |
+
);
|
201 |
+
|
202 |
+
return $this->get_async_code( $settings, $poll_link );
|
203 |
+
} else {
|
204 |
+
$cb = ( $cb == 1 ? '?cb='. time() : false );
|
205 |
+
$margins = '';
|
206 |
+
$float = '';
|
207 |
+
|
208 |
+
if ( in_array( $align, array( 'right', 'left' ) ) ) {
|
209 |
+
$float = sprintf( 'float: %s;', $align );
|
210 |
+
|
211 |
+
if ( $align == 'left')
|
212 |
+
$margins = 'margin: 0px 10px 0px 0px;';
|
213 |
+
elseif ( $align == 'right' )
|
214 |
+
$margins = 'margin: 0px 0px 0px 10px';
|
215 |
+
}
|
216 |
+
|
217 |
+
// 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)
|
218 |
+
if ( is_singular() )
|
219 |
+
$inline = true;
|
220 |
+
|
221 |
+
if ( $cb === false && !$inline ) {
|
222 |
+
if ( self::$scripts === false )
|
223 |
+
self::$scripts = array();
|
224 |
+
|
225 |
+
$data = array( 'url' => $poll_js );
|
226 |
+
|
227 |
+
self::$scripts['poll'][] = $data;
|
228 |
+
|
229 |
+
add_action( 'wp_footer', array( $this, 'generate_scripts' ) );
|
230 |
+
|
231 |
+
$data = esc_attr( json_encode( $data ) );
|
232 |
+
|
233 |
+
$script_url = esc_url_raw( plugins_url( 'js/polldaddy-shortcode.js', __FILE__ ) );
|
234 |
+
|
235 |
+
$str = <<<CONTAINER
|
236 |
+
<a name="pd_a_{$poll}"></a>
|
237 |
+
<div class="CSS_Poll PDS_Poll" id="PDI_container{$poll}" data-settings="{$data}" style="display:inline-block;{$float}{$margins}"></div>
|
238 |
+
<div id="PD_superContainer"></div>
|
239 |
+
<noscript>{$poll_link}</noscript>
|
240 |
+
CONTAINER;
|
241 |
+
|
242 |
+
$loader = <<<SCRIPT
|
243 |
+
( function( d, c, j ) {
|
244 |
+
if ( !d.getElementById( j ) ) {
|
245 |
+
var pd = d.createElement( c ), s;
|
246 |
+
pd.id = j;
|
247 |
+
pd.src = '{$script_url}';
|
248 |
+
s = d.getElementsByTagName( c )[0];
|
249 |
+
s.parentNode.insertBefore( pd, s );
|
250 |
+
}
|
251 |
+
else if ( typeof jQuery !== 'undefined' )
|
252 |
+
jQuery( d.body ).trigger( 'pd-script-load' );
|
253 |
+
}( document, 'script', 'pd-polldaddy-loader' ) );
|
254 |
+
SCRIPT;
|
255 |
+
|
256 |
+
$loader = $this->compress_it( $loader );
|
257 |
+
$loader = "<script type='text/javascript'>\n".$loader."\n</script>";
|
258 |
+
|
259 |
+
return $str.$loader;
|
260 |
+
} else {
|
261 |
+
if ( $inline )
|
262 |
+
$cb = '';
|
263 |
+
|
264 |
+
return <<<CONTAINER
|
265 |
+
<a name="pd_a_{$poll}"></a>
|
266 |
+
<div class="CSS_Poll PDS_Poll" id="PDI_container{$poll}" style="display:inline-block;{$float}{$margins}"></div>
|
267 |
+
<div id="PD_superContainer"></div>
|
268 |
+
<script type="text/javascript" charset="UTF-8" src="{$poll_js}{$cb}"></script>
|
269 |
+
<noscript>{$poll_link}</noscript>
|
270 |
+
CONTAINER;
|
271 |
+
}
|
272 |
+
}
|
273 |
+
}
|
274 |
+
} elseif ( !empty( $survey ) ) { //survey embed
|
275 |
+
|
276 |
+
if ( in_array( $type, array( 'iframe', 'button', 'banner', 'slider' ) ) ) {
|
277 |
+
|
278 |
+
if ( empty( $title ) ) {
|
279 |
+
$title = __( 'Take Our Survey!', 'polldaddy' );
|
280 |
+
if( !empty( $link_text ) )
|
281 |
+
$title = $link_text;
|
282 |
+
}
|
283 |
+
|
284 |
+
if ( $type == 'banner' || $type == 'slider' )
|
285 |
+
$inline = false;
|
286 |
+
|
287 |
+
$survey = preg_replace( '/[^a-f0-9]/i', '', $survey );
|
288 |
+
$survey_url = esc_url( "https://survey.fm/{$survey}" );
|
289 |
+
$survey_link = sprintf( '<a href="%s">%s</a>', $survey_url, esc_html( $title ) );
|
290 |
+
|
291 |
+
if ( $no_script || $inline || $infinite_scroll )
|
292 |
+
return $survey_link;
|
293 |
+
|
294 |
+
if ( $type == 'iframe' ) {
|
295 |
+
if ( $height != 'auto' ) {
|
296 |
+
if ( isset( $content_width ) && is_numeric( $width ) && $width > $content_width )
|
297 |
+
$width = $content_width;
|
298 |
+
|
299 |
+
if ( !$width )
|
300 |
+
$width = '100%';
|
301 |
+
else
|
302 |
+
$width = (int) $width;
|
303 |
+
|
304 |
+
if ( !$height )
|
305 |
+
$height = '600';
|
306 |
+
else
|
307 |
+
$height = (int) $height;
|
308 |
+
|
309 |
+
return <<<CONTAINER
|
310 |
+
<iframe src="{$survey_url}?iframe=1" frameborder="0" width="{$width}" height="{$height}" scrolling="auto" allowtransparency="true" marginheight="0" marginwidth="0">{$survey_link}</iframe>
|
311 |
+
CONTAINER;
|
312 |
+
} elseif ( !empty( $domain ) && !empty( $id ) ) {
|
313 |
+
|
314 |
+
$domain = preg_replace( '/[^a-z0-9\-]/i', '', $domain );
|
315 |
+
$id = preg_replace( '/[\/\?&\{\}]/', '', $id );
|
316 |
+
|
317 |
+
$auto_src = esc_url( "https://{$domain}.survey.fm/{$id}" );
|
318 |
+
$auto_src = parse_url( $auto_src );
|
319 |
+
|
320 |
+
if ( !is_array( $auto_src ) || count( $auto_src ) == 0 )
|
321 |
+
return '<!-- no crowdsignal output -->';
|
322 |
+
|
323 |
+
if ( !isset( $auto_src['host'] ) || !isset( $auto_src['path'] ) )
|
324 |
+
return '<!-- no crowdsignal output -->';
|
325 |
+
|
326 |
+
$domain = $auto_src['host'] . '/';
|
327 |
+
$id = ltrim( $auto_src['path'], '/' );
|
328 |
+
|
329 |
+
$settings = array(
|
330 |
+
'type' => $type,
|
331 |
+
'auto' => true,
|
332 |
+
'domain' => $domain,
|
333 |
+
'id' => $id
|
334 |
+
);
|
335 |
+
}
|
336 |
+
} else {
|
337 |
+
$text_color = preg_replace( '/[^a-f0-9]/i', '', $text_color );
|
338 |
+
$back_color = preg_replace( '/[^a-f0-9]/i', '', $back_color );
|
339 |
+
|
340 |
+
if ( !in_array( $align, array( 'right', 'left', 'top-left', 'top-right', 'middle-left', 'middle-right', 'bottom-left', 'bottom-right' ) ) )
|
341 |
+
$align = '';
|
342 |
+
|
343 |
+
if ( !in_array( $style, array( 'inline', 'side', 'corner', 'rounded', 'square' ) ) )
|
344 |
+
$style = '';
|
345 |
+
|
346 |
+
$title = wp_strip_all_tags( $title );
|
347 |
+
$body = wp_strip_all_tags( $body );
|
348 |
+
$button = wp_strip_all_tags( $button );
|
349 |
+
|
350 |
+
$settings = array_filter( array(
|
351 |
+
'title' => $title,
|
352 |
+
'type' => $type,
|
353 |
+
'body' => $body,
|
354 |
+
'button' => $button,
|
355 |
+
'text_color' => $text_color,
|
356 |
+
'back_color' => $back_color,
|
357 |
+
'align' => $align,
|
358 |
+
'style' => $style,
|
359 |
+
'id' => $survey
|
360 |
+
) );
|
361 |
+
}
|
362 |
+
|
363 |
+
if ( empty( $settings ) )
|
364 |
+
return '<!-- no crowdsignal output -->';
|
365 |
+
|
366 |
+
return $this->get_async_code( $settings, $survey_link );
|
367 |
+
}
|
368 |
+
} else {
|
369 |
+
return '<!-- no crowdsignal output -->';
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
function generate_scripts() {
|
374 |
+
$script = '';
|
375 |
+
|
376 |
+
if ( is_array( self::$scripts ) ) {
|
377 |
+
if ( isset( self::$scripts['rating'] ) ) {
|
378 |
+
$script = "<script type='text/javascript' charset='UTF-8' id='polldaddyRatings'><!--//--><![CDATA[//><!--\n";
|
379 |
+
foreach( self::$scripts['rating'] as $rating ) {
|
380 |
+
$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']} );}}";
|
381 |
+
}
|
382 |
+
$script .= "\n//--><!]]></script><script type='text/javascript' charset='UTF-8' src='https://polldaddy.com/js/rating/rating.js'></script>";
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
if ( isset( self::$scripts['poll'] ) ) {
|
387 |
+
foreach( self::$scripts['poll'] as $poll ) {
|
388 |
+
$script .= "<script type='text/javascript' charset='UTF-8' src='{$poll['url']}'></script>";
|
389 |
+
}
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
self::$scripts = false;
|
394 |
+
echo $script;
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* If the theme uses infinite scroll, include jquery at the start
|
399 |
+
*/
|
400 |
+
function check_infinite() {
|
401 |
+
if ( current_theme_supports( 'infinite-scroll' ) && class_exists( 'The_Neverending_Home_Page' ) && The_Neverending_Home_Page::archive_supports_infinity() )
|
402 |
+
wp_enqueue_script( 'jquery' );
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Dynamically load the .js, if needed
|
407 |
+
*
|
408 |
+
* This hooks in late (priority 11) to infinite_scroll_render to determine
|
409 |
+
* a posteriori if a shortcode has been called.
|
410 |
+
*/
|
411 |
+
function polldaddy_shortcode_infinite() {
|
412 |
+
// only try to load if a shortcode has been called and theme supports infinite scroll
|
413 |
+
if( self::$add_script ) {
|
414 |
+
$script_url = esc_url_raw( plugins_url( 'js/polldaddy-shortcode.js', __FILE__ ) );
|
415 |
+
|
416 |
+
// if the script hasn't been loaded, load it
|
417 |
+
// if the script loads successfully, fire an 'pd-script-load' event
|
418 |
+
echo <<<SCRIPT
|
419 |
+
<script type='text/javascript'>
|
420 |
+
//<![CDATA[
|
421 |
+
( function( d, c, j ) {
|
422 |
+
if ( !d.getElementById( j ) ) {
|
423 |
+
var pd = d.createElement( c ), s;
|
424 |
+
pd.id = j;
|
425 |
+
pd.src = '{$script_url}';
|
426 |
+
s = d.getElementsByTagName( c )[0];
|
427 |
+
s.parentNode.insertBefore( pd, s );
|
428 |
+
}
|
429 |
+
else if ( typeof jQuery !== 'undefined' )
|
430 |
+
jQuery( d.body ).trigger( 'pd-script-load' );
|
431 |
+
}( document, 'script', 'pd-polldaddy-loader' ) );
|
432 |
+
//]]>
|
433 |
+
</script>
|
434 |
+
SCRIPT;
|
435 |
+
|
436 |
+
}
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
// kick it all off
|
441 |
+
new PolldaddyShortcode();
|
442 |
+
|
443 |
+
if ( !function_exists( 'polldaddy_link' ) ) {
|
444 |
+
// http://polldaddy.com/poll/1562975/?view=results&msg=voted
|
445 |
+
function polldaddy_link( $content ) {
|
446 |
+
if ( false === strpos( $content, "polldaddy.com/" ) )
|
447 |
+
return $content;
|
448 |
+
$textarr = wp_html_split( $content );
|
449 |
+
unset( $content );
|
450 |
+
foreach( $textarr as &$element ) {
|
451 |
+
if ( '' === $element || '<' === $element{0} )
|
452 |
+
continue;
|
453 |
+
$element = preg_replace( '!(?:\n|\A)https?://(polldaddy\.com/poll|poll\.fm)/([0-9]+?)(/.*)?(?:\n|\Z)!i', "\n<script type='text/javascript' charset='utf-8' src='//static.polldaddy.com/p/$2.js'></script><noscript> <a href='https://poll.fm/$2'>View Poll</a></noscript>\n", $element );
|
454 |
+
}
|
455 |
+
return join( $textarr );
|
456 |
+
}
|
457 |
+
|
458 |
+
// higher priority because we need it before auto-link and autop get to it
|
459 |
+
add_filter( 'the_content', 'polldaddy_link', 1 );
|
460 |
+
add_filter( 'the_content_rss', 'polldaddy_link', 1 );
|
461 |
+
}
|
462 |
+
|
463 |
+
}
|
polldaddy-xml.php
CHANGED
@@ -105,7 +105,7 @@ class Ghetto_XML_Object {
|
|
105 |
foreach ( $array as $key => $value ) {
|
106 |
if ( 0 === strpos( $key, $this->___ns_full ) )
|
107 |
$key = substr( $key, strlen( $this->___ns_full ) + 1 );
|
108 |
-
if ( is_null( $value ) || ( $this->___restrict && !array_key_exists( $key, $atts ) ) )
|
109 |
continue;
|
110 |
|
111 |
$this->$key = $value;
|
@@ -114,8 +114,15 @@ class Ghetto_XML_Object {
|
|
114 |
}
|
115 |
|
116 |
class Polldaddy_XML_Object extends Ghetto_XML_Object {
|
117 |
-
var $___ns
|
118 |
-
var $___ns_full
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
class Polldaddy_XML_Root extends Polldaddy_XML_Object {
|
@@ -610,49 +617,67 @@ class Polldaddy_Media extends Polldaddy_XML_Object {
|
|
610 |
class Polldaddy_XML_Parser {
|
611 |
var $parser;
|
612 |
var $polldaddy_objects = array(
|
613 |
-
'
|
614 |
-
'
|
615 |
-
'
|
616 |
-
'
|
617 |
-
'
|
618 |
-
'
|
619 |
-
'
|
620 |
-
'
|
621 |
-
'
|
622 |
-
'
|
623 |
-
'
|
624 |
-
'
|
625 |
-
'
|
626 |
-
'
|
627 |
-
'
|
628 |
-
'
|
629 |
-
'
|
630 |
-
'
|
631 |
-
'
|
632 |
-
'
|
633 |
-
'
|
634 |
-
'
|
635 |
-
'
|
636 |
-
'
|
637 |
-
'
|
638 |
-
'
|
639 |
-
'
|
640 |
-
'
|
641 |
-
'
|
642 |
-
'
|
643 |
-
'
|
644 |
-
'
|
645 |
-
'
|
646 |
-
'
|
647 |
-
'
|
648 |
-
'
|
649 |
-
'
|
650 |
-
'
|
651 |
-
'
|
652 |
-
'pack'
|
653 |
-
'phrase'
|
654 |
);// the parser matches the tag names to the class name and creates an object defined by that class
|
655 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
656 |
var $object_stack = array();
|
657 |
var $object_pos = null;
|
658 |
|
@@ -672,7 +697,6 @@ class Polldaddy_XML_Parser {
|
|
672 |
xml_set_character_data_handler( $this->parser, 'text' );
|
673 |
xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
|
674 |
xml_parser_set_option( $this->parser, XML_OPTION_SKIP_WHITE, 1 );
|
675 |
-
|
676 |
xml_parse( $this->parser, $xml );
|
677 |
xml_parser_free( $this->parser );
|
678 |
return $this->objects;
|
@@ -695,7 +719,7 @@ class Polldaddy_XML_Parser {
|
|
695 |
$this->object_stack[$object_pos]['args_tag'] = $tag;
|
696 |
}
|
697 |
|
698 |
-
if (
|
699 |
$this->object_stack[] = array(
|
700 |
'tag' => $tag,
|
701 |
'atts' => $attributes,
|
@@ -736,11 +760,11 @@ class Polldaddy_XML_Parser {
|
|
736 |
}
|
737 |
|
738 |
function tag_close( &$parser, $tag ) {
|
739 |
-
if (
|
740 |
if ( $tag !== $this->object_stack[$this->object_pos]['tag'] )
|
741 |
die( 'damn' );
|
742 |
|
743 |
-
$new = $this->
|
744 |
$new_object = new $new( $this->object_stack[$this->object_pos]['args'], $this->object_stack[$this->object_pos]['atts'] );
|
745 |
|
746 |
if ( is_numeric( $this->object_stack[$this->object_pos]['parent'] ) ) {
|
105 |
foreach ( $array as $key => $value ) {
|
106 |
if ( 0 === strpos( $key, $this->___ns_full ) )
|
107 |
$key = substr( $key, strlen( $this->___ns_full ) + 1 );
|
108 |
+
if ( is_null( $value ) || ( $this->___restrict && ! array_key_exists( $key, $atts ) ) )
|
109 |
continue;
|
110 |
|
111 |
$this->$key = $value;
|
114 |
}
|
115 |
|
116 |
class Polldaddy_XML_Object extends Ghetto_XML_Object {
|
117 |
+
var $___ns;
|
118 |
+
var $___ns_full;
|
119 |
+
|
120 |
+
function __construct( $args = null, $attributes = null ) {
|
121 |
+
$this->___ns = 'pd';
|
122 |
+
$this->___ns_full = polldaddy_api_url( '/pdapi.xsd' );
|
123 |
+
|
124 |
+
parent::__construct( $args, $attributes );
|
125 |
+
}
|
126 |
}
|
127 |
|
128 |
class Polldaddy_XML_Root extends Polldaddy_XML_Object {
|
617 |
class Polldaddy_XML_Parser {
|
618 |
var $parser;
|
619 |
var $polldaddy_objects = array(
|
620 |
+
'pdapi.xsd:pdAccess' => 'Polldaddy_Access',
|
621 |
+
'pdapi.xsd:pdInitiate' => 'Polldaddy_Initiate',
|
622 |
+
'pdapi.xsd:pdRequest' => 'Polldaddy_Request',
|
623 |
+
'pdapi.xsd:pdResponse' => 'Polldaddy_Response',
|
624 |
+
'pdapi.xsd:errors' => 'Polldaddy_Errors',
|
625 |
+
'pdapi.xsd:error' => 'Polldaddy_Error',
|
626 |
+
'pdapi.xsd:demands' => 'Polldaddy_Demands',
|
627 |
+
'pdapi.xsd:demand' => 'Polldaddy_Demand',
|
628 |
+
'pdapi.xsd:queries' => 'Polldaddy_Queries',
|
629 |
+
'pdapi.xsd:query' => 'Polldaddy_Query',
|
630 |
+
'pdapi.xsd:account' => 'Polldaddy_Account',
|
631 |
+
'pdapi.xsd:list' => 'Polldaddy_List',
|
632 |
+
'pdapi.xsd:polls' => 'Polldaddy_Polls',
|
633 |
+
'pdapi.xsd:search' => 'Polldaddy_Search',
|
634 |
+
'pdapi.xsd:poll' => 'Polldaddy_Poll',
|
635 |
+
'pdapi.xsd:emailAddress' => 'Polldaddy_Email',
|
636 |
+
'pdapi.xsd:message' => 'Polldaddy_Email_Message',
|
637 |
+
'pdapi.xsd:answers' => 'Polldaddy_Poll_Answers',
|
638 |
+
'pdapi.xsd:answer' => 'Polldaddy_Poll_Answer',
|
639 |
+
'pdapi.xsd:otherAnswers' => 'Polldaddy_Other_Answers',
|
640 |
+
'pdapi.xsd:result' => 'Polldaddy_Poll_Result',
|
641 |
+
'pdapi.xsd:comments' => 'Polldaddy_Comments',
|
642 |
+
'pdapi.xsd:comment' => 'Polldaddy_Comment',
|
643 |
+
'pdapi.xsd:extensions' => 'Polldaddy_Extensions',
|
644 |
+
'pdapi.xsd:folders' => 'Polldaddy_Folders',
|
645 |
+
'pdapi.xsd:folder' => 'Polldaddy_Folder',
|
646 |
+
'pdapi.xsd:styles' => 'Polldaddy_Styles',
|
647 |
+
'pdapi.xsd:style' => 'Polldaddy_Style',
|
648 |
+
'pdapi.xsd:packs' => 'Polldaddy_Packs',
|
649 |
+
'pdapi.xsd:pack' => 'Polldaddy_Pack',
|
650 |
+
'pdapi.xsd:languages' => 'Polldaddy_Languages',
|
651 |
+
'pdapi.xsd:language' => 'Polldaddy_Language',
|
652 |
+
'pdapi.xsd:activity' => 'Polldaddy_Activity',
|
653 |
+
'pdapi.xsd:rating_result' => 'Polldaddy_Rating_Result',
|
654 |
+
'pdapi.xsd:ratings' => 'Polldaddy_Ratings',
|
655 |
+
'pdapi.xsd:rating' => 'Polldaddy_Rating',
|
656 |
+
'pdapi.xsd:nonce' => 'Polldaddy_Nonce',
|
657 |
+
'pdapi.xsd:partner' => 'Polldaddy_Partner',
|
658 |
+
'pdapi.xsd:media' => 'Polldaddy_Media',
|
659 |
+
'pack' => 'Custom_Pack',
|
660 |
+
'phrase' => 'Custom_Pack_Phrase'
|
661 |
);// the parser matches the tag names to the class name and creates an object defined by that class
|
662 |
|
663 |
+
function get_polldaddy_object( $tag ) {
|
664 |
+
preg_match(
|
665 |
+
sprintf( '#%s/(.*)#', polldaddy_api_url( '/' ) ),
|
666 |
+
$tag,
|
667 |
+
$matches
|
668 |
+
);
|
669 |
+
|
670 |
+
if ( ! empty( $matches ) && array_key_exists( $matches[ 1 ], $this->polldaddy_objects ) ) {
|
671 |
+
return $this->polldaddy_objects[ $matches[ 1 ] ];
|
672 |
+
}
|
673 |
+
|
674 |
+
if ( array_key_exists( $tag, $this->polldaddy_objects ) ) {
|
675 |
+
return $this->polldaddy_objects[ $tag ];
|
676 |
+
}
|
677 |
+
|
678 |
+
return null;
|
679 |
+
}
|
680 |
+
|
681 |
var $object_stack = array();
|
682 |
var $object_pos = null;
|
683 |
|
697 |
xml_set_character_data_handler( $this->parser, 'text' );
|
698 |
xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
|
699 |
xml_parser_set_option( $this->parser, XML_OPTION_SKIP_WHITE, 1 );
|
|
|
700 |
xml_parse( $this->parser, $xml );
|
701 |
xml_parser_free( $this->parser );
|
702 |
return $this->objects;
|
719 |
$this->object_stack[$object_pos]['args_tag'] = $tag;
|
720 |
}
|
721 |
|
722 |
+
if ( $this->get_polldaddy_object( $tag ) ) {
|
723 |
$this->object_stack[] = array(
|
724 |
'tag' => $tag,
|
725 |
'atts' => $attributes,
|
760 |
}
|
761 |
|
762 |
function tag_close( &$parser, $tag ) {
|
763 |
+
if ( $this->get_polldaddy_object( $tag ) ) {
|
764 |
if ( $tag !== $this->object_stack[$this->object_pos]['tag'] )
|
765 |
die( 'damn' );
|
766 |
|
767 |
+
$new = $this->get_polldaddy_object( $tag );
|
768 |
$new_object = new $new( $this->object_stack[$this->object_pos]['args'], $this->object_stack[$this->object_pos]['atts'] );
|
769 |
|
770 |
if ( is_numeric( $this->object_stack[$this->object_pos]['parent'] ) ) {
|
polldaddy.php
CHANGED
@@ -1,17 +1,45 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Plugin Name:
|
5 |
* Plugin URI: http://wordpress.org/extend/plugins/polldaddy/
|
6 |
-
* Description: Create and manage
|
7 |
* Author: Automattic, Inc.
|
8 |
-
* Author URL:
|
9 |
-
* Version: 2.0
|
10 |
*/
|
11 |
|
12 |
// To hardcode your Polldaddy PartnerGUID (API Key), add the (uncommented) line below with the PartnerGUID to your `wp-config.php`
|
13 |
// define( 'WP_POLLDADDY__PARTNERGUID', '12345…' );
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
class WP_Polldaddy {
|
16 |
var $errors;
|
17 |
var $base_url;
|
@@ -203,7 +231,7 @@ class WP_Polldaddy {
|
|
203 |
'partner_userid' => $this->id
|
204 |
);
|
205 |
if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
|
206 |
-
$polldaddy_api_key = wp_remote_post( '
|
207 |
'body' => $details
|
208 |
) );
|
209 |
if ( is_wp_error( $polldaddy_api_key ) ) {
|
@@ -213,11 +241,11 @@ class WP_Polldaddy {
|
|
213 |
$polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
|
214 |
} else {
|
215 |
$fp = fsockopen(
|
216 |
-
'
|
217 |
-
|
218 |
$err_num,
|
219 |
$err_str,
|
220 |
-
|
221 |
);
|
222 |
|
223 |
if ( !$fp ) {
|
@@ -232,8 +260,8 @@ class WP_Polldaddy {
|
|
232 |
|
233 |
$request_body = http_build_query( $details, null, '&' );
|
234 |
|
235 |
-
$request =
|
236 |
-
$request .=
|
237 |
$request .= "User-agent: WordPress/$wp_version\r\n";
|
238 |
$request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ) . "\r\n";
|
239 |
$request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
|
@@ -316,16 +344,16 @@ class WP_Polldaddy {
|
|
316 |
?>
|
317 |
|
318 |
<div class="wrap">
|
319 |
-
<h2 id="polldaddy-header"><?php _e( '
|
320 |
|
321 |
-
<p><?php printf( __( 'Before you can use the
|
322 |
|
323 |
<form action="" method="post">
|
324 |
<table class="form-table">
|
325 |
<tbody>
|
326 |
<tr class="form-field form-required">
|
327 |
<th valign="top" scope="row">
|
328 |
-
<label for="polldaddy-email"><?php _e( '
|
329 |
</th>
|
330 |
<td>
|
331 |
<input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" />
|
@@ -333,7 +361,7 @@ class WP_Polldaddy {
|
|
333 |
</tr>
|
334 |
<tr class="form-field form-required">
|
335 |
<th valign="top" scope="row">
|
336 |
-
<label for="polldaddy-password"><?php _e( '
|
337 |
</th>
|
338 |
<td>
|
339 |
<input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
|
@@ -517,7 +545,7 @@ class WP_Polldaddy {
|
|
517 |
}
|
518 |
}
|
519 |
if ( isset( $_POST[ 'email' ] ) )
|
520 |
-
wp_mail( $current_user->user_email, "
|
521 |
update_option( 'polldaddy_settings', $settings );
|
522 |
break;
|
523 |
case 'restore-account' : // restore everything
|
@@ -1354,16 +1382,16 @@ class WP_Polldaddy {
|
|
1354 |
|
1355 |
<h2 id="poll-list-header"><?php
|
1356 |
if ( $this->is_author )
|
1357 |
-
printf( __( '
|
1358 |
else
|
1359 |
-
_e( '
|
1360 |
?></h2><?php
|
1361 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
|
1362 |
$account = $polldaddy->get_account();
|
1363 |
if ( !empty( $account ) )
|
1364 |
$account_email = esc_attr( $account->email );
|
1365 |
if ( isset( $account_email ) && current_user_can( 'manage_options' ) ) {
|
1366 |
-
echo "<p>" . sprintf( __( 'Linked to WordPress.com Account: <strong>%s</strong> (<a target="_blank" href="options-general.php?page=polls&action=options">Settings</a> / <a target="_blank" href="
|
1367 |
}
|
1368 |
|
1369 |
if ( !isset( $_GET['view'] ) )
|
@@ -2206,7 +2234,7 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
2206 |
<div class="inside">
|
2207 |
|
2208 |
<ul class="pd-tabs">
|
2209 |
-
<li class="selected" id="pd-styles"><a href="#"><?php _e( '
|
2210 |
<?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
|
2211 |
<li id="pd-custom-styles" <?php echo $hide; ?>><a href="#"><?php _e( 'Custom Styles', 'polldaddy' ); ?></a><input type="checkbox" style="display:none;" id="custom"/></li>
|
2212 |
|
@@ -2293,7 +2321,7 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
2293 |
<th class="cb">
|
2294 |
|
2295 |
<input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
|
2296 |
-
<label for="skin" onclick="javascript:pd_build_styles( 0 );"><?php _e( '
|
2297 |
|
2298 |
<?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
|
2299 |
|
@@ -2384,7 +2412,7 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
2384 |
<div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy' ); ?></div>
|
2385 |
<?php else : ?>
|
2386 |
<p><?php _e( 'You currently have no custom styles created.', 'polldaddy' ); ?> <a href="/wp-admin/edit.php?page=polls&action=create-style" class="add-new-h2"><?php _e( 'New Style', 'polldaddy');?></a></p>
|
2387 |
-
<p><?php printf( __( 'Did you know we have a new editor for building your own custom poll styles? Find out more <a href="%s" target="_blank">here</a>.', 'polldaddy' ), '
|
2388 |
<?php endif; ?>
|
2389 |
</div>
|
2390 |
|
@@ -2981,7 +3009,7 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
2981 |
</td>
|
2982 |
</tr>
|
2983 |
<tr>
|
2984 |
-
<td><?php _e( 'Image URL', 'polldaddy' ); ?>: <a href="
|
2985 |
<td>
|
2986 |
<input type="text" id="background-image" onblur="bind(this);"/>
|
2987 |
</td>
|
@@ -3431,7 +3459,7 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
3431 |
<!-- Scale Table -->
|
3432 |
<table class="CSSE_edit" id="editScale" style="display:none;">
|
3433 |
<tr>
|
3434 |
-
<td width="85"><?php _e( 'Width', 'polldaddy' ); ?> (px): <a href="
|
3435 |
<td>
|
3436 |
<input type="text" maxlength="4" class="elmColor" id="width" onblur="bind(this);"/>
|
3437 |
</td>
|
@@ -3761,7 +3789,7 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
3761 |
$rating_errors[] = $polldaddy->errors;
|
3762 |
}
|
3763 |
} elseif ( isset( $polldaddy->errors[ -1 ] ) && $polldaddy->errors[ -1 ] == "Can't connect" ) {
|
3764 |
-
$this->contact_support_message( __( 'Could not connect to the
|
3765 |
$error = true;
|
3766 |
} elseif ( isset( $polldaddy->errors[ -1 ] ) && $polldaddy->errors[ -1 ] == "Invalid API URL" ) {
|
3767 |
$this->contact_support_message( __( 'The API URL is incorrect' ), $rating_errors );
|
@@ -4968,17 +4996,17 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
4968 |
</h2>
|
4969 |
<?php if ( $this->is_admin || $this->multiple_accounts ) { ?>
|
4970 |
<h3>
|
4971 |
-
<?php _e( '
|
4972 |
</h3>
|
4973 |
-
<p><?php _e( '<em>
|
4974 |
-
<p><?php _e( 'Login to the
|
4975 |
<?php if ( isset( $account_email ) && $account_email != false ) { ?>
|
4976 |
<p><?php printf( __( 'Your account is currently linked to this API key: <strong>%s</strong>', 'polldaddy' ), WP_POLLDADDY__PARTNERGUID ); ?></p>
|
4977 |
<br />
|
4978 |
-
<h3><?php _e( 'Link to a different
|
4979 |
<?php } else { ?>
|
4980 |
<br />
|
4981 |
-
<h3><?php _e( 'Link to your
|
4982 |
<?php } ?>
|
4983 |
<form action="" method="post">
|
4984 |
<table class="form-table">
|
@@ -4986,7 +5014,7 @@ src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></scr
|
|
4986 |
<tr class="form-field form-required">
|
4987 |
<th valign="top" scope="row">
|
4988 |
<label for="polldaddy-key">
|
4989 |
-
<?php _e( '
|
4990 |
</label>
|
4991 |
</th>
|
4992 |
<td>
|
@@ -5108,7 +5136,7 @@ if ( false == is_object( $poll ) ) {
|
|
5108 |
}
|
5109 |
if ( $show_reset_form ) {
|
5110 |
echo "<h3>" . __( 'Reset Connection Settings', 'polldaddy' ) . "</h3>";
|
5111 |
-
echo "<p>" . __( 'If you are experiencing problems connecting to the
|
5112 |
echo "<p>" . __( 'The following settings will be reset:', 'polldaddy' ) . "</p>";
|
5113 |
echo "<table>";
|
5114 |
foreach( $settings as $key => $value ) {
|
@@ -5116,7 +5144,7 @@ if ( false == is_object( $poll ) ) {
|
|
5116 |
if ( strpos( $key, 'usercode' ) )
|
5117 |
$value = "***********" . substr( $value, -4 );
|
5118 |
elseif ( in_array( $key, array( 'pd-rating-pages-id', 'pd-rating-comments-id', 'pd-rating-posts-id' ) ) )
|
5119 |
-
$value = "$value (<a href='
|
5120 |
echo "<tr><th style='text-align: right'>$key:</th><td>$value</td></tr>\n";
|
5121 |
}
|
5122 |
}
|
@@ -5145,7 +5173,7 @@ if ( false == is_object( $poll ) ) {
|
|
5145 |
if ( strpos( $key, 'usercode' ) )
|
5146 |
$value = "***********" . substr( $value, -4 );
|
5147 |
elseif ( in_array( $key, array( 'pd-rating-pages-id', 'pd-rating-comments-id', 'pd-rating-posts-id' ) ) )
|
5148 |
-
$value = "$value (<a href='
|
5149 |
echo "<tr><th style='text-align: right'>$key:</th><td>$value</td></tr>\n";
|
5150 |
}
|
5151 |
}
|
@@ -5165,7 +5193,7 @@ if ( false == is_object( $poll ) ) {
|
|
5165 |
if ( $show_reset_form && isset( $settings[ 'pd-rating-posts-id' ] ) && $settings[ 'pd-rating-posts-id' ] != $previous_settings[ 'pd-rating-posts-id' ] ) {
|
5166 |
echo "<h3>" . __( 'Restore Ratings Settings', 'polldaddy' ) . "</h3>";
|
5167 |
echo "<p>" . __( 'Different rating settings detected. If you are missing ratings on your posts, pages or comments you can restore the original rating settings by clicking the button below.', 'polldaddy' ) . "</p>";
|
5168 |
-
echo "<p>" . __( 'This tells the plugin to look for this data in a different rating in your
|
5169 |
?>
|
5170 |
<form action="" method="post">
|
5171 |
<p class="submit">
|
@@ -5230,9 +5258,9 @@ if ( false == is_object( $poll ) ) {
|
|
5230 |
echo '<div class="error" id="polldaddy">';
|
5231 |
echo '<h1>' . $message . '</h1>';
|
5232 |
echo '<p>' . __( "There are a few things you can do:" );
|
5233 |
-
echo "<ul><ol>" . __( "Press reload on your browser and reload this page. There may have been a temporary problem communicating with
|
5234 |
echo "<ol>" . sprintf( __( "Go to the <a href='%s'>poll settings page</a>, scroll to the end of the page and reset your connection settings. Link your account again with the same API key.", "polldaddy" ), 'options-general.php?page=polls&action=options' ) . "</ol>";
|
5235 |
-
echo "<ol>" . sprintf( __( 'Contact <a href="%1$s" %2$s>
|
5236 |
echo "<ul><li> API Key: " . get_option( 'polldaddy_api_key' ) . "</li>";
|
5237 |
echo "<li> ID Usercode: " . get_option( 'pd-usercode-' . $current_user->ID ) . "</li>";
|
5238 |
echo "<li> pd-rating-usercode: " . get_option( 'pd-rating-usercode' ) . "</li>";
|
@@ -5246,5 +5274,6 @@ require dirname( __FILE__ ).'/rating.php';
|
|
5246 |
require dirname( __FILE__ ).'/ajax.php';
|
5247 |
require dirname( __FILE__ ).'/popups.php';
|
5248 |
require dirname( __FILE__ ).'/polldaddy-org.php';
|
|
|
5249 |
|
5250 |
$GLOBALS[ 'wp_log_plugins' ][] = 'polldaddy';
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Plugin Name: Crowdsignal Polls & Ratings
|
5 |
* Plugin URI: http://wordpress.org/extend/plugins/polldaddy/
|
6 |
+
* Description: Create and manage Crowdsignal polls and ratings in WordPress
|
7 |
* Author: Automattic, Inc.
|
8 |
+
* Author URL: https://crowdsignal.com/
|
9 |
+
* Version: 2.1.0
|
10 |
*/
|
11 |
|
12 |
// To hardcode your Polldaddy PartnerGUID (API Key), add the (uncommented) line below with the PartnerGUID to your `wp-config.php`
|
13 |
// define( 'WP_POLLDADDY__PARTNERGUID', '12345…' );
|
14 |
|
15 |
+
if ( ! defined( 'POLLDADDY_API_HOST' ) ) {
|
16 |
+
define( 'POLLDADDY_API_HOST', 'api.crowdsignal.com' );
|
17 |
+
}
|
18 |
+
|
19 |
+
if ( ! defined( 'POLLDADDY_API_VERSION' ) ) {
|
20 |
+
define( 'POLLDADDY_API_VERSION', 'v1');
|
21 |
+
}
|
22 |
+
|
23 |
+
function polldaddy_api_path( $path, $version = POLLDADDY_API_VERSION ) {
|
24 |
+
return sprintf( '/%s%s', $version, $path );
|
25 |
+
}
|
26 |
+
|
27 |
+
function polldaddy_api_url( $path, $version = POLLDADDY_API_VERSION, $protocol = 'https' ) {
|
28 |
+
return sprintf(
|
29 |
+
'%s://%s%s',
|
30 |
+
$protocol,
|
31 |
+
POLLDADDY_API_HOST,
|
32 |
+
rtrim( polldaddy_api_path( $path, $version ), '/' )
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
+
function polldaddy_add_oembed_provider() {
|
37 |
+
wp_oembed_add_provider( '#https?://(.+\.)?polldaddy\.com/.*#i', 'https://api.crowdsignal.com/oembed', true );
|
38 |
+
wp_oembed_add_provider( '#https?://.+\.survey\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
|
39 |
+
wp_oembed_add_provider( '#https?://poll\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
|
40 |
+
}
|
41 |
+
add_action( 'init', 'polldaddy_add_oembed_provider' );
|
42 |
+
|
43 |
class WP_Polldaddy {
|
44 |
var $errors;
|
45 |
var $base_url;
|
231 |
'partner_userid' => $this->id
|
232 |
);
|
233 |
if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
|
234 |
+
$polldaddy_api_key = wp_remote_post( polldaddy_api_url( '/key' ), array(
|
235 |
'body' => $details
|
236 |
) );
|
237 |
if ( is_wp_error( $polldaddy_api_key ) ) {
|
241 |
$polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
|
242 |
} else {
|
243 |
$fp = fsockopen(
|
244 |
+
polldaddy_api_url( '/', POLLDADDY_API_VERSION, 'tls' ),
|
245 |
+
443,
|
246 |
$err_num,
|
247 |
$err_str,
|
248 |
+
5
|
249 |
);
|
250 |
|
251 |
if ( !$fp ) {
|
260 |
|
261 |
$request_body = http_build_query( $details, null, '&' );
|
262 |
|
263 |
+
$request = 'POST ' . polldaddy_api_path( '/key' ) . " HTTP/1.0\r\n";
|
264 |
+
$request .= 'Host: ' . POLLDADDY_API_HOST . "\r\n";
|
265 |
$request .= "User-agent: WordPress/$wp_version\r\n";
|
266 |
$request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ) . "\r\n";
|
267 |
$request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
|
344 |
?>
|
345 |
|
346 |
<div class="wrap">
|
347 |
+
<h2 id="polldaddy-header"><?php _e( 'Crowdsignal', 'polldaddy' ); ?></h2>
|
348 |
|
349 |
+
<p><?php printf( __( 'Before you can use the Crowdsignal plugin, you need to enter your <a href="%s">Crowdsignal.com</a> account details.', 'polldaddy' ), 'https://app.crowdsignal.com/' ); ?></p>
|
350 |
|
351 |
<form action="" method="post">
|
352 |
<table class="form-table">
|
353 |
<tbody>
|
354 |
<tr class="form-field form-required">
|
355 |
<th valign="top" scope="row">
|
356 |
+
<label for="polldaddy-email"><?php _e( 'Crowdsignal Email Address', 'polldaddy' ); ?></label>
|
357 |
</th>
|
358 |
<td>
|
359 |
<input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" />
|
361 |
</tr>
|
362 |
<tr class="form-field form-required">
|
363 |
<th valign="top" scope="row">
|
364 |
+
<label for="polldaddy-password"><?php _e( 'Crowdsignal Password', 'polldaddy' ); ?></label>
|
365 |
</th>
|
366 |
<td>
|
367 |
<input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
|
545 |
}
|
546 |
}
|
547 |
if ( isset( $_POST[ 'email' ] ) )
|
548 |
+
wp_mail( $current_user->user_email, "Crowdsignal Settings", $msg );
|
549 |
update_option( 'polldaddy_settings', $settings );
|
550 |
break;
|
551 |
case 'restore-account' : // restore everything
|
1382 |
|
1383 |
<h2 id="poll-list-header"><?php
|
1384 |
if ( $this->is_author )
|
1385 |
+
printf( __( 'Crowdsignal Polls <a href="%s" class="add-new-h2">Add New</a>', 'polldaddy' ), esc_url( add_query_arg( array( 'action' => 'create-poll', 'poll' => false, 'message' => false ) ) ) );
|
1386 |
else
|
1387 |
+
_e( 'Crowdsignal Polls ', 'polldaddy' );
|
1388 |
?></h2><?php
|
1389 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
|
1390 |
$account = $polldaddy->get_account();
|
1391 |
if ( !empty( $account ) )
|
1392 |
$account_email = esc_attr( $account->email );
|
1393 |
if ( isset( $account_email ) && current_user_can( 'manage_options' ) ) {
|
1394 |
+
echo "<p>" . sprintf( __( 'Linked to WordPress.com Account: <strong>%s</strong> (<a target="_blank" href="options-general.php?page=polls&action=options">Settings</a> / <a target="_blank" href="https://app.crowdsignal.com/">Crowdsignal.com</a>)', 'polldaddy' ), $account_email ) . "</p>";
|
1395 |
}
|
1396 |
|
1397 |
if ( !isset( $_GET['view'] ) )
|
2234 |
<div class="inside">
|
2235 |
|
2236 |
<ul class="pd-tabs">
|
2237 |
+
<li class="selected" id="pd-styles"><a href="#"><?php _e( 'Crowdsignal Styles', 'polldaddy' ); ?></a><input type="checkbox" style="display:none;" id="regular"/></li>
|
2238 |
<?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
|
2239 |
<li id="pd-custom-styles" <?php echo $hide; ?>><a href="#"><?php _e( 'Custom Styles', 'polldaddy' ); ?></a><input type="checkbox" style="display:none;" id="custom"/></li>
|
2240 |
|
2321 |
<th class="cb">
|
2322 |
|
2323 |
<input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
|
2324 |
+
<label for="skin" onclick="javascript:pd_build_styles( 0 );"><?php _e( 'Crowdsignal Style', 'polldaddy' ); ?></label>
|
2325 |
|
2326 |
<?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
|
2327 |
|
2412 |
<div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy' ); ?></div>
|
2413 |
<?php else : ?>
|
2414 |
<p><?php _e( 'You currently have no custom styles created.', 'polldaddy' ); ?> <a href="/wp-admin/edit.php?page=polls&action=create-style" class="add-new-h2"><?php _e( 'New Style', 'polldaddy');?></a></p>
|
2415 |
+
<p><?php printf( __( 'Did you know we have a new editor for building your own custom poll styles? Find out more <a href="%s" target="_blank">here</a>.', 'polldaddy' ), 'https://crowdsignal.com/support/custom-poll-styles/' ); ?></p>
|
2416 |
<?php endif; ?>
|
2417 |
</div>
|
2418 |
|
3009 |
</td>
|
3010 |
</tr>
|
3011 |
<tr>
|
3012 |
+
<td><?php _e( 'Image URL', 'polldaddy' ); ?>: <a href="https://crowdsignal.com/support/custom-poll-styles/" class="noteLink" title="<?php _e( 'Click here for more information', 'polldaddy' ); ?>">(?)</a></td>
|
3013 |
<td>
|
3014 |
<input type="text" id="background-image" onblur="bind(this);"/>
|
3015 |
</td>
|
3459 |
<!-- Scale Table -->
|
3460 |
<table class="CSSE_edit" id="editScale" style="display:none;">
|
3461 |
<tr>
|
3462 |
+
<td width="85"><?php _e( 'Width', 'polldaddy' ); ?> (px): <a href="https://crowdsignal.com/support/custom-poll-styles/" class="noteLink" title="<?php _e( 'Click here for more information', 'polldaddy' ); ?>">(?)</a></td>
|
3463 |
<td>
|
3464 |
<input type="text" maxlength="4" class="elmColor" id="width" onblur="bind(this);"/>
|
3465 |
</td>
|
3789 |
$rating_errors[] = $polldaddy->errors;
|
3790 |
}
|
3791 |
} elseif ( isset( $polldaddy->errors[ -1 ] ) && $polldaddy->errors[ -1 ] == "Can't connect" ) {
|
3792 |
+
$this->contact_support_message( __( 'Could not connect to the Crowdsignal API' ), $rating_errors );
|
3793 |
$error = true;
|
3794 |
} elseif ( isset( $polldaddy->errors[ -1 ] ) && $polldaddy->errors[ -1 ] == "Invalid API URL" ) {
|
3795 |
$this->contact_support_message( __( 'The API URL is incorrect' ), $rating_errors );
|
4996 |
</h2>
|
4997 |
<?php if ( $this->is_admin || $this->multiple_accounts ) { ?>
|
4998 |
<h3>
|
4999 |
+
<?php _e( 'Crowdsignal Account Info', 'polldaddy' ); ?>
|
5000 |
</h3>
|
5001 |
+
<p><?php _e( '<em>Crowdsignal</em> and <em>WordPress.com</em> are now connected using <a href="http://en.support.wordpress.com/wpcc-faq/">WordPress.com Connect</a>. If you have a WordPress.com account you can use it to login to <a href="https://app.crowdsignal.com/">Crowdsignal.com</a>. Click on the Crowdsignal "sign in" button, authorize the connection and create your new Crowdsignal account.', 'polldaddy' ); ?></p>
|
5002 |
+
<p><?php _e( 'Login to the Crowdsignal website and scroll to the end of your <a href="https://app.crowdsignal.com/account/#apikey">account page</a> to create or retrieve an API key.', 'polldaddy' ); ?></p>
|
5003 |
<?php if ( isset( $account_email ) && $account_email != false ) { ?>
|
5004 |
<p><?php printf( __( 'Your account is currently linked to this API key: <strong>%s</strong>', 'polldaddy' ), WP_POLLDADDY__PARTNERGUID ); ?></p>
|
5005 |
<br />
|
5006 |
+
<h3><?php _e( 'Link to a different Crowdsignal account', 'polldaddy' ); ?></h3>
|
5007 |
<?php } else { ?>
|
5008 |
<br />
|
5009 |
+
<h3><?php _e( 'Link to your Crowdsignal account', 'polldaddy' ); ?></h3>
|
5010 |
<?php } ?>
|
5011 |
<form action="" method="post">
|
5012 |
<table class="form-table">
|
5014 |
<tr class="form-field form-required">
|
5015 |
<th valign="top" scope="row">
|
5016 |
<label for="polldaddy-key">
|
5017 |
+
<?php _e( 'Crowdsignal.com API Key', 'polldaddy' ); ?>
|
5018 |
</label>
|
5019 |
</th>
|
5020 |
<td>
|
5136 |
}
|
5137 |
if ( $show_reset_form ) {
|
5138 |
echo "<h3>" . __( 'Reset Connection Settings', 'polldaddy' ) . "</h3>";
|
5139 |
+
echo "<p>" . __( 'If you are experiencing problems connecting to the Crowdsignal website resetting your connection settings may help. A backup will be made. After resetting, link your account again with the same API key.', 'polldaddy' ) . "</p>";
|
5140 |
echo "<p>" . __( 'The following settings will be reset:', 'polldaddy' ) . "</p>";
|
5141 |
echo "<table>";
|
5142 |
foreach( $settings as $key => $value ) {
|
5144 |
if ( strpos( $key, 'usercode' ) )
|
5145 |
$value = "***********" . substr( $value, -4 );
|
5146 |
elseif ( in_array( $key, array( 'pd-rating-pages-id', 'pd-rating-comments-id', 'pd-rating-posts-id' ) ) )
|
5147 |
+
$value = "$value (<a href='https://app.crowdsignal.com/ratings/{$value}/edit/'>" . __( 'Edit', 'polldaddy' ) . "</a>)";
|
5148 |
echo "<tr><th style='text-align: right'>$key:</th><td>$value</td></tr>\n";
|
5149 |
}
|
5150 |
}
|
5173 |
if ( strpos( $key, 'usercode' ) )
|
5174 |
$value = "***********" . substr( $value, -4 );
|
5175 |
elseif ( in_array( $key, array( 'pd-rating-pages-id', 'pd-rating-comments-id', 'pd-rating-posts-id' ) ) )
|
5176 |
+
$value = "$value (<a href='https://app.crowdsignal.com/ratings/{$value}/edit/'>" . __( 'Edit', 'polldaddy' ) . "</a>)";
|
5177 |
echo "<tr><th style='text-align: right'>$key:</th><td>$value</td></tr>\n";
|
5178 |
}
|
5179 |
}
|
5193 |
if ( $show_reset_form && isset( $settings[ 'pd-rating-posts-id' ] ) && $settings[ 'pd-rating-posts-id' ] != $previous_settings[ 'pd-rating-posts-id' ] ) {
|
5194 |
echo "<h3>" . __( 'Restore Ratings Settings', 'polldaddy' ) . "</h3>";
|
5195 |
echo "<p>" . __( 'Different rating settings detected. If you are missing ratings on your posts, pages or comments you can restore the original rating settings by clicking the button below.', 'polldaddy' ) . "</p>";
|
5196 |
+
echo "<p>" . __( 'This tells the plugin to look for this data in a different rating in your Crowdsignal account.', 'polldaddy' ) . "</p>";
|
5197 |
?>
|
5198 |
<form action="" method="post">
|
5199 |
<p class="submit">
|
5258 |
echo '<div class="error" id="polldaddy">';
|
5259 |
echo '<h1>' . $message . '</h1>';
|
5260 |
echo '<p>' . __( "There are a few things you can do:" );
|
5261 |
+
echo "<ul><ol>" . __( "Press reload on your browser and reload this page. There may have been a temporary problem communicating with Crowdsignal.com", "polldaddy" ) . "</ol>";
|
5262 |
echo "<ol>" . sprintf( __( "Go to the <a href='%s'>poll settings page</a>, scroll to the end of the page and reset your connection settings. Link your account again with the same API key.", "polldaddy" ), 'options-general.php?page=polls&action=options' ) . "</ol>";
|
5263 |
+
echo "<ol>" . sprintf( __( 'Contact <a href="%1$s" %2$s>Crowdsignal support</a> and tell them your rating usercode is %3$s', 'polldaddy' ), 'https://crowdsignal.com/feedback/', 'target="_blank"', $this->rating_user_code ) . '<br />' . __( 'Also include the following information when contacting support to help us resolve your problem as quickly as possible:', 'polldaddy' ) . '';
|
5264 |
echo "<ul><li> API Key: " . get_option( 'polldaddy_api_key' ) . "</li>";
|
5265 |
echo "<li> ID Usercode: " . get_option( 'pd-usercode-' . $current_user->ID ) . "</li>";
|
5266 |
echo "<li> pd-rating-usercode: " . get_option( 'pd-rating-usercode' ) . "</li>";
|
5274 |
require dirname( __FILE__ ).'/ajax.php';
|
5275 |
require dirname( __FILE__ ).'/popups.php';
|
5276 |
require dirname( __FILE__ ).'/polldaddy-org.php';
|
5277 |
+
require dirname( __FILE__ ).'/polldaddy-shortcode.php';
|
5278 |
|
5279 |
$GLOBALS[ 'wp_log_plugins' ][] = 'polldaddy';
|
readme.txt
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
===
|
2 |
-
Contributors: eoigal, mdawaffe, donncha, johnny5, panosktn
|
3 |
-
Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 4.9.4
|
6 |
-
Stable tag: 2.0
|
7 |
|
8 |
-
Create and manage
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
The
|
13 |
|
14 |
-
The
|
15 |
|
16 |
-
|
17 |
|
18 |
* Arabic
|
19 |
* Bosnian
|
@@ -55,16 +55,16 @@ Polldaddy Polls is currently available in the following languages:
|
|
55 |
|
56 |
Want to help translate the plugin or keep an existing translation up-to-date? Head on over to the [translation site](http://translate.wordpress.com/projects/polldaddy/plugin).
|
57 |
|
58 |
-
Some strings are not translated when polls and surveys are embedded. You will have to translate them using a language pack on [
|
59 |
|
60 |
Development of the plugin will take place in [this Github repository](https://github.com/Automattic/polldaddy-plugin).
|
61 |
|
62 |
== Installation ==
|
63 |
|
64 |
-
Upload the plugin to your blog (or search for it and install it on your plugins page), activate it, then go to Settings->Polls to configure the plugin. You'll need a
|
65 |
-
|
66 |
|
67 |
-
You can find further help on our [support page](
|
68 |
|
69 |
== Screenshots ==
|
70 |
|
@@ -83,11 +83,11 @@ The Polls & Ratings menus can now be found under the Feedbacks top level menu.
|
|
83 |
|
84 |
= I have multiple authors on my blog? What happens? =
|
85 |
|
86 |
-
Each author that wants to create polls will need his or her own
|
87 |
|
88 |
= But, as an Administrator, can I edit my Authors' polls =
|
89 |
|
90 |
-
Yes. You'll be able to edit the polls they create from your blog. (You won't be able to edit any of their non-blog, personal polls they create through
|
91 |
|
92 |
= Neat! Um... can my Authors edit MY blog polls? =
|
93 |
|
@@ -101,9 +101,9 @@ More info [here](http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks)
|
|
101 |
|
102 |
= My ratings are gone after I reinstalled the plugin. How do I get them back? =
|
103 |
|
104 |
-
Login to your
|
105 |
|
106 |
-
= I cannot access my ratings settings, I am getting a "Sorry! There was an error creating your rating widget. Please contact
|
107 |
|
108 |
You need to select the synchronize ratings account in the WordPress options page at Settings->Polls & Ratings to make sure the ratings API key is valid.
|
109 |
|
@@ -115,12 +115,21 @@ Your rating uses the filter 'wp_title' by default when retrieving the post title
|
|
115 |
|
116 |
Your theme is getting the post content, without necessarily showing it. If the post has a poll, the poll javascript is loaded in the footer. To fix this, you need to enable the 'Load Shortcodes Inline' setting in the Polls & Ratings settings. This will load the poll shortcode inline and will only load the poll if the content of the post is actually displayed.
|
117 |
|
|
|
|
|
|
|
|
|
118 |
|
119 |
== Upgrade Notice ==
|
120 |
Don't autoload the usercode blog options
|
121 |
|
122 |
== Changelog ==
|
123 |
|
|
|
|
|
|
|
|
|
|
|
124 |
= 2.0.37 =
|
125 |
* The usercode blog options don't need to be autoloaded.
|
126 |
* Use HTTPS for the API url.
|
1 |
+
=== Crowdsignal Polls & Ratings ===
|
2 |
+
Contributors: eoigal, mdawaffe, donncha, johnny5, panosktn, ice9js
|
3 |
+
Tags: crowdsignal, polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 4.9.4
|
6 |
+
Stable tag: 2.1.0
|
7 |
|
8 |
+
Create and manage Crowdsignal polls and ratings from within WordPress.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
The Crowdsignal Polls and Ratings plugin allows you to create and manage polls and ratings from within your WordPress dashboard. You can create polls, choose from 20 different styles for your polls, and view all results for your polls as they come in. All Crowdsignal polls are fully customizable, you can set a close date for your poll, create multiple choice polls, choose whether to display the results or keep them private. You can also create your own custom style for your poll. You can even embed the polls you create on other websites. You can collect unlimited votes and create unlimited polls. The new ratings menu allows you to embed ratings into your posts, pages or comments. The rating editor allows you to fully customize your rating. You can also avail of the 'Top Rated' widget that will allow you to place the widget in your sidebar. This widget will show you the top rated posts, pages and comments today, this week and this month.
|
13 |
|
14 |
+
The Crowdsignal plugin requires PHP 5.
|
15 |
|
16 |
+
Crowdsignal Polls is currently available in the following languages:
|
17 |
|
18 |
* Arabic
|
19 |
* Bosnian
|
55 |
|
56 |
Want to help translate the plugin or keep an existing translation up-to-date? Head on over to the [translation site](http://translate.wordpress.com/projects/polldaddy/plugin).
|
57 |
|
58 |
+
Some strings are not translated when polls and surveys are embedded. You will have to translate them using a language pack on [Crowdsignal.com](https://crowdsignal.com/).
|
59 |
|
60 |
Development of the plugin will take place in [this Github repository](https://github.com/Automattic/polldaddy-plugin).
|
61 |
|
62 |
== Installation ==
|
63 |
|
64 |
+
Upload the plugin to your blog (or search for it and install it on your plugins page), activate it, then go to Settings->Polls to configure the plugin. You'll need a Crowdsignal API key available from your [Crowdsignal account page](https://app.crowdsignal.com/account/#apikey) to sync your account and pull in your existing polls and ratings.
|
65 |
+
Crowdsignal.com is now linked to WordPress.com using [WordPress.com Connect](http://en.support.wordpress.com/wpcc-faq/) which means you can use your WordPress.com username and password to login to Crowdsignal.com. If you have a WordPress.com account and have never used Crowdsignal.com you can login [here](https://app.crowdsignal.com/login/) to access Crowdsignal.com.
|
66 |
|
67 |
+
You can find further help on our [support page](https://crowdsignal.com/support/). If you have any problems please use the [support forum](http://wordpress.org/support/plugin/polldaddy). The plugin also logs activity to a file using the [WP Debug Logger](http://wordpress.org/extend/plugins/wp-debug-logger/) plugin which can be useful in determining the cause of a problem.
|
68 |
|
69 |
== Screenshots ==
|
70 |
|
83 |
|
84 |
= I have multiple authors on my blog? What happens? =
|
85 |
|
86 |
+
Each author that wants to create polls will need his or her own Crowdsignal.com account.
|
87 |
|
88 |
= But, as an Administrator, can I edit my Authors' polls =
|
89 |
|
90 |
+
Yes. You'll be able to edit the polls they create from your blog. (You won't be able to edit any of their non-blog, personal polls they create through Crowdsignal.com.)
|
91 |
|
92 |
= Neat! Um... can my Authors edit MY blog polls? =
|
93 |
|
101 |
|
102 |
= My ratings are gone after I reinstalled the plugin. How do I get them back? =
|
103 |
|
104 |
+
Login to your Crowdsignal.com account and [view the ratings](https://app.crowdsignal.com/dashboard/?content=rating) in your dashboard. You should see ratings named "blog name - " comments/posts/pages. You need the rating ID of each of those which is visible when you edit them. It's the number in the URL of your browser that looks like https://app.crowdsignal.com/ratings/1234567/edit/. After you connect the plugin to your Crowdsignal account go to Settings->Ratings and make sure the ratings are displayed on your posts/pages/comments as desired. You'll see a link at the bottom of the page saying, "Advanced Settings" that will toggle new configuration settings. One of those settings is "rating ID" which you should replace with the number you got from your Crowdsignal account. Now save the changes and the ratings on your site will be updated.
|
105 |
|
106 |
+
= I cannot access my ratings settings, I am getting a "Sorry! There was an error creating your rating widget. Please contact Crowdsignal support to fix this." message. =
|
107 |
|
108 |
You need to select the synchronize ratings account in the WordPress options page at Settings->Polls & Ratings to make sure the ratings API key is valid.
|
109 |
|
115 |
|
116 |
Your theme is getting the post content, without necessarily showing it. If the post has a poll, the poll javascript is loaded in the footer. To fix this, you need to enable the 'Load Shortcodes Inline' setting in the Polls & Ratings settings. This will load the poll shortcode inline and will only load the poll if the content of the post is actually displayed.
|
117 |
|
118 |
+
= My API key is valid but I cannot get the plugin to link with Crowdsignal
|
119 |
+
|
120 |
+
This is possible if your server or network is blocking outgoing calls to Crowdsignal's API.
|
121 |
+
Make sure to whitelist `api.crowdsignal.com` in your firewall to fix this.
|
122 |
|
123 |
== Upgrade Notice ==
|
124 |
Don't autoload the usercode blog options
|
125 |
|
126 |
== Changelog ==
|
127 |
|
128 |
+
= 2.1.0 =
|
129 |
+
* Added a [crowdsignal] shortcode that mimics [polldaddy] which is now deprecated.
|
130 |
+
* Updated the plugin to work with updated Crowdsignal URLs for polls & surveys
|
131 |
+
* Updated the API client to use `api.crowdsignal.com/v1`
|
132 |
+
|
133 |
= 2.0.37 =
|
134 |
* The usercode blog options don't need to be autoloaded.
|
135 |
* Use HTTPS for the API url.
|