| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
Plugin Name: PollDaddy Polls |
| 5 |
Description: Create and manage PollDaddy polls in WordPress |
| 6 |
Author: Automattic, Inc. |
| 7 |
Author URL: http://automattic.com/ |
| 8 |
Version: 1.5 |
| 9 |
*/ |
| 10 |
|
| 11 |
// You can hardcode your PollDaddy PartnerGUID (API Key) here |
| 12 |
//define( 'WP_POLLDADDY__PARTNERGUID', '12345...' ); |
| 13 |
|
| 14 |
if ( !defined( 'WP_POLLDADDY__CLASS' ) ) |
| 15 |
define( 'WP_POLLDADDY__CLASS', 'WP_PollDaddy' ); |
| 16 |
|
| 17 |
if ( !defined( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH' ) ) |
| 18 |
define( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH', dirname( __FILE__ ) . '/polldaddy-client.php' ); |
| 19 |
|
| 20 |
// TODO: when user changes PollDaddy password, userCode changes |
| 21 |
class WP_PollDaddy { |
| 22 |
var $errors; |
| 23 |
var $polldaddy_client_class = 'PollDaddy_Client'; |
| 24 |
var $base_url = false; |
| 25 |
var $use_ssl = 0; |
| 26 |
var $scheme = 'https'; |
| 27 |
var $version = '1.5'; |
| 28 |
|
| 29 |
var $polldaddy_clients = array(); |
| 30 |
|
| 31 |
function &get_client( $api_key, $userCode = null ) { |
| 32 |
if ( isset( $this->polldaddy_clients[$api_key] ) ) { |
| 33 |
if ( !is_null( $userCode ) ) |
| 34 |
$this->polldaddy_clients[$api_key]->userCode = $userCode; |
| 35 |
return $this->polldaddy_clients[$api_key]; |
| 36 |
} |
| 37 |
require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH; |
| 38 |
$this->polldaddy_clients[$api_key] = new $this->polldaddy_client_class( $api_key, $userCode ); |
| 39 |
return $this->polldaddy_clients[$api_key]; |
| 40 |
} |
| 41 |
|
| 42 |
function admin_menu() { |
| 43 |
$this->errors = new WP_Error; |
| 44 |
|
| 45 |
if ( !$this->base_url ) |
| 46 |
$this->base_url = plugins_url() . '/' . dirname( plugin_basename( __FILE__ ) ) . '/'; |
| 47 |
|
| 48 |
if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) { |
| 49 |
$guid = get_option( 'polldaddy_api_key' ); |
| 50 |
if ( !$guid || !is_string( $guid ) ) |
| 51 |
$guid = false; |
| 52 |
define( 'WP_POLLDADDY__PARTNERGUID', $guid ); |
| 53 |
} |
| 54 |
|
| 55 |
if ( !WP_POLLDADDY__PARTNERGUID ) { |
| 56 |
$this->use_ssl = (int) get_option( 'polldaddy_use_ssl' ); |
| 57 |
|
| 58 |
if ( function_exists( 'add_object_page' ) ) // WP 2.7+ |
| 59 |
$hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" ); |
| 60 |
else |
| 61 |
$hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) ); |
| 62 |
|
| 63 |
add_action( "load-$hook", array( &$this, 'api_key_page_load' ) ); |
| 64 |
if ( empty( $_GET['page'] ) || 'polls' != $_GET['page'] ) |
| 65 |
add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "You need to <a href=\"%s\">input your PollDaddy.com account details</a>.", "edit.php?page=polls" ) . "</p></div>";' ) ); |
| 66 |
return false; |
| 67 |
} |
| 68 |
|
| 69 |
if ( function_exists( 'add_object_page' ) ) // WP 2.7+ |
| 70 |
$hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" ); |
| 71 |
else |
| 72 |
$hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) ); |
| 73 |
add_action( "load-$hook", array( &$this, 'management_page_load' ) ); |
| 74 |
|
| 75 |
// Hack-a-lack-a |
| 76 |
add_submenu_page( 'polls', __( 'Edit Polls' ), __( 'Edit' ), 'edit_posts', 'polls' ); //, array( &$this, 'management_page' ) ); |
| 77 |
add_submenu_page( 'polls', __( 'Add New Poll' ), __( 'Add New' ), 'edit_posts', 'polls&action=create-poll', array( &$this, 'management_page' ) ); |
| 78 |
|
| 79 |
add_action( 'media_buttons', array( &$this, 'media_buttons' ) ); |
| 80 |
} |
| 81 |
|
| 82 |
function api_key_page_load() { |
| 83 |
if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] ) |
| 84 |
return false; |
| 85 |
|
| 86 |
check_admin_referer( 'polldaddy-account' ); |
| 87 |
|
| 88 |
$polldaddy_email = stripslashes( $_POST['polldaddy_email'] ); |
| 89 |
$polldaddy_password = stripslashes( $_POST['polldaddy_password'] ); |
| 90 |
|
| 91 |
if ( !$polldaddy_email ) |
| 92 |
$this->errors->add( 'polldaddy_email', __( 'Email address required' ) ); |
| 93 |
|
| 94 |
if ( !$polldaddy_password ) |
| 95 |
$this->errors->add( 'polldaddy_password', __( 'Password required' ) ); |
| 96 |
|
| 97 |
if ( $this->errors->get_error_codes() ) |
| 98 |
return false; |
| 99 |
|
| 100 |
if ( !empty( $_POST['polldaddy_use_ssl_checkbox'] ) ) { |
| 101 |
if ( $polldaddy_use_ssl = (int) $_POST['polldaddy_use_ssl'] ) { |
| 102 |
$this->use_ssl = 0; //checked (by default) |
| 103 |
} else { |
| 104 |
$this->use_ssl = 1; //unchecked |
| 105 |
$this->scheme = 'http'; |
| 106 |
} |
| 107 |
update_option( 'polldaddy_use_ssl', $this->use_ssl ); |
| 108 |
} |
| 109 |
|
| 110 |
$details = array( |
| 111 |
'uName' => get_bloginfo( 'name' ), |
| 112 |
'uEmail' => $polldaddy_email, |
| 113 |
'uPass' => $polldaddy_password, |
| 114 |
'partner_userid' => $GLOBALS['current_user']->ID |
| 115 |
); |
| 116 |
|
| 117 |
if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+ |
| 118 |
$polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array( |
| 119 |
'body' => $details |
| 120 |
) ); |
| 121 |
if ( is_wp_error( $polldaddy_api_key ) ) { |
| 122 |
$this->errors = $polldaddy_api_key; |
| 123 |
return false; |
| 124 |
} |
| 125 |
$response_code = wp_remote_retrieve_response_code( $polldaddy_api_key ); |
| 126 |
if ( 200 != $response_code ) { |
| 127 |
$this->errors->add( 'http_code', __( 'Could not connect to PollDaddy API Key service' ) ); |
| 128 |
return false; |
| 129 |
} |
| 130 |
$polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key ); |
| 131 |
} else { |
| 132 |
$fp = fsockopen( |
| 133 |
'api.polldaddy.com', |
| 134 |
80, |
| 135 |
$err_num, |
| 136 |
$err_str, |
| 137 |
3 |
| 138 |
); |
| 139 |
|
| 140 |
if ( !$fp ) { |
| 141 |
$this->errors->add( 'connect', __( "Can't connect to PollDaddy.com" ) ); |
| 142 |
return false; |
| 143 |
} |
| 144 |
|
| 145 |
if ( function_exists( 'stream_set_timeout' ) ) |
| 146 |
stream_set_timeout( $fp, 3 ); |
| 147 |
|
| 148 |
global $wp_version; |
| 149 |
|
| 150 |
$request_body = http_build_query( $details, null, '&' ); |
| 151 |
|
| 152 |
$request = "POST /key.php HTTP/1.0\r\n"; |
| 153 |
$request .= "Host: api.polldaddy.com\r\n"; |
| 154 |
$request .= "User-agent: WordPress/$wp_version\r\n"; |
| 155 |
$request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n"; |
| 156 |
$request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n"; |
| 157 |
|
| 158 |
fwrite( $fp, "$request\r\n$request_body" ); |
| 159 |
|
| 160 |
$response = ''; |
| 161 |
while ( !feof( $fp ) ) |
| 162 |
$response .= fread( $fp, 4096 ); |
| 163 |
fclose( $fp ); |
| 164 |
list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 ); |
| 165 |
} |
| 166 |
|
| 167 |
if( isset( $polldaddy_api_key ) && strlen( $polldaddy_api_key ) > 0 ){ |
| 168 |
update_option( 'polldaddy_api_key', $polldaddy_api_key ); |
| 169 |
} |
| 170 |
else{ |
| 171 |
$this->errors->add( 'polldaddy_api_key', __( 'Login to PollDaddy failed. Double check your email address and password.' ) ); |
| 172 |
if ( 1 !== $this->use_ssl ) { |
| 173 |
$this->errors->add( 'polldaddy_api_key', __( 'If your email address and password are correct, your host may not support secure logins.' ) ); |
| 174 |
$this->errors->add( 'polldaddy_api_key', __( 'In that case, you may be able to log in to PollDaddy by unchecking the "Use SSL to Log in" checkbox.' ) ); |
| 175 |
$this->use_ssl = 0; |
| 176 |
} |
| 177 |
update_option( 'polldaddy_use_ssl', $this->use_ssl ); |
| 178 |
return false; |
| 179 |
} |
| 180 |
|
| 181 |
$polldaddy = $this->get_client( $polldaddy_api_key ); |
| 182 |
$polldaddy->reset(); |
| 183 |
if ( !$polldaddy->GetUserCode( $GLOBALS['current_user']->ID ) ) { |
| 184 |
$this->parse_errors( $polldaddy ); |
| 185 |
$this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?' ) ); |
| 186 |
return false; |
| 187 |
} |
| 188 |
|
| 189 |
wp_redirect( add_query_arg( array( 'page' => 'polls' ), wp_get_referer() ) ); |
| 190 |
exit; |
| 191 |
} |
| 192 |
|
| 193 |
function parse_errors( &$polldaddy ) { |
| 194 |
if ( $polldaddy->errors ) |
| 195 |
foreach ( $polldaddy->errors as $code => $error ) |
| 196 |
$this->errors->add( $code, $error ); |
| 197 |
if ( isset( $this->errors->errors[4] ) ) { |
| 198 |
$this->errors->errors[4] = array( sprintf( __( 'Obsolete PollDaddy User API Key: <a href="%s">Sign in again to re-authenticate</a>' ), add_query_arg( array( 'action' => 'signup', 'reaction' => empty( $_GET['action'] ) ? false : $_GET['action'] ) ) ) ); |
| 199 |
$this->errors->add_data( true, 4 ); |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
function print_errors() { |
| 204 |
if ( !$error_codes = $this->errors->get_error_codes() ) |
| 205 |
return; |
| 206 |
?> |
| 207 |
|
| 208 |
<div class="error"> |
| 209 |
|
| 210 |
<?php |
| 211 |
|
| 212 |
foreach ( $error_codes as $error_code ) : |
| 213 |
foreach ( $this->errors->get_error_messages( $error_code ) as $error_message ) : |
| 214 |
?> |
| 215 |
|
| 216 |
<p><?php echo $this->errors->get_error_data( $error_code ) ? $error_message : wp_specialchars( $error_message ); ?></p> |
| 217 |
|
| 218 |
<?php |
| 219 |
endforeach; |
| 220 |
endforeach; |
| 221 |
?> |
| 222 |
|
| 223 |
</div> |
| 224 |
<br class="clear" /> |
| 225 |
|
| 226 |
<?php |
| 227 |
} |
| 228 |
|
| 229 |
function api_key_page() { |
| 230 |
$this->print_errors(); |
| 231 |
?> |
| 232 |
|
| 233 |
<div class="wrap"> |
| 234 |
|
| 235 |
<h2><?php _e( 'PollDaddy Account' ); ?></h2> |
| 236 |
|
| 237 |
<p><?php printf( __('Before you can use the PollDaddy plugin, you need to enter your <a href="%s">PollDaddy.com</a> account details.' ), 'http://polldaddy.com/' ); ?></p> |
| 238 |
|
| 239 |
<form action="" method="post"> |
| 240 |
<table class="form-table"> |
| 241 |
<tbody> |
| 242 |
<tr class="form-field form-required"> |
| 243 |
<th valign="top" scope="row"> |
| 244 |
<label for="polldaddy-email">PollDaddy Email Address</label> |
| 245 |
</th> |
| 246 |
<td> |
| 247 |
<input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php if ( isset( $_POST['polldaddy_email'] ) ) echo attribute_escape( $_POST['polldaddy_email'] ); ?>" /> |
| 248 |
</td> |
| 249 |
</tr> |
| 250 |
<tr class="form-field form-required"> |
| 251 |
<th valign="top" scope="row"> |
| 252 |
<label for="polldaddy-password">PollDaddy Password</label> |
| 253 |
</th> |
| 254 |
<td> |
| 255 |
<input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" /> |
| 256 |
</td> |
| 257 |
</tr> |
| 258 |
<?php |
| 259 |
$checked = ''; |
| 260 |
if ( $this->use_ssl == 0 ) |
| 261 |
$checked = 'checked="checked"'; |
| 262 |
?> |
| 263 |
<tr class="form-field form-required"> |
| 264 |
<th valign="top" scope="row"> |
| 265 |
<label for="polldaddy-use-ssl">Use SSL to Log in</label> |
| 266 |
</th> |
| 267 |
<td> |
| 268 |
<input type="checkbox" name="polldaddy_use_ssl" id="polldaddy-use-ssl" value="1" <?php echo $checked ?> style="width: auto"/> |
| 269 |
<label for="polldaddy-use-ssl">This ensures a secure login to your PollDaddy account. Only uncheck if you are having problems logging in.</label> |
| 270 |
<input type="hidden" name="polldaddy_use_ssl_checkbox" value="1" /> |
| 271 |
</td> |
| 272 |
</tr> |
| 273 |
</tbody> |
| 274 |
</table> |
| 275 |
<p class="submit"> |
| 276 |
<?php wp_nonce_field( 'polldaddy-account' ); ?> |
| 277 |
<input type="hidden" name="action" value="account" /> |
| 278 |
<input type="hidden" name="account" value="import" /> |
| 279 |
<input type="submit" value="<?php echo attribute_escape( __( 'Submit' ) ); ?>" /> |
| 280 |
</p> |
| 281 |
</form> |
| 282 |
</div> |
| 283 |
|
| 284 |
<?php |
| 285 |
} |
| 286 |
|
| 287 |
function media_buttons() { |
| 288 |
$title = __( 'Add Poll' ); |
| 289 |
echo "<a href='admin.php?page=polls&iframe&TB_iframe=true' id='add_poll' class='thickbox' title='$title'><img src='{$this->base_url}polldaddy.png' alt='$title' /></a>"; |
| 290 |
} |
| 291 |
|
| 292 |
function management_page_load() { |
| 293 |
global $current_user; |
| 294 |
|
| 295 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID ); |
| 296 |
$polldaddy->reset(); |
| 297 |
|
| 298 |
if ( !defined( 'WP_POLLDADDY__USERCODE' ) ) |
| 299 |
define( 'WP_POLLDADDY__USERCODE', $polldaddy->GetUserCode( $current_user->ID ) ); |
| 300 |
|
| 301 |
wp_reset_vars( array( 'action', 'poll' ) ); |
| 302 |
global $action, $poll; |
| 303 |
|
| 304 |
if ( !WP_POLLDADDY__USERCODE ) |
| 305 |
$action = 'signup'; |
| 306 |
|
| 307 |
require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH; |
| 308 |
|
| 309 |
wp_enqueue_script( 'polls-style', "{$this->base_url}poll-style-picker.js", array(), $this->version ); |
| 310 |
wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version ); |
| 311 |
wp_enqueue_script( 'admin-forms' ); |
| 312 |
add_thickbox(); |
| 313 |
|
| 314 |
wp_enqueue_style( 'polls', "{$this->base_url}polldaddy.css", array( 'global', 'wp-admin' ), $this->version ); |
| 315 |
add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
| 316 |
|
| 317 |
add_action( 'admin_notices', array( &$this, 'management_page_notices' ) ); |
| 318 |
|
| 319 |
$query_args = array(); |
| 320 |
|
| 321 |
$is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ); |
| 322 |
|
| 323 |
switch ( $action ) : |
| 324 |
case 'signup' : // sign up for first time |
| 325 |
case 'account' : // reauthenticate |
| 326 |
if ( !$is_POST ) |
| 327 |
return; |
| 328 |
|
| 329 |
check_admin_referer( 'polldaddy-account' ); |
| 330 |
|
| 331 |
if ( $new_args = $this->management_page_load_signup() ) |
| 332 |
$query_args = array_merge( $query_args, $new_args ); |
| 333 |
if ( $this->errors->get_error_codes() ) |
| 334 |
return false; |
| 335 |
|
| 336 |
wp_reset_vars( array( 'action' ) ); |
| 337 |
if ( !empty( $_GET['reaction'] ) ) |
| 338 |
$query_args['action'] = $_GET['reaction']; |
| 339 |
elseif ( !empty( $_GET['action'] ) && 'signup' != $_GET['action'] ) |
| 340 |
$query_args['action'] = $_GET['action']; |
| 341 |
else |
| 342 |
$query_args['action'] = false; |
| 343 |
break; |
| 344 |
case 'delete' : |
| 345 |
if ( empty( $poll ) ) |
| 346 |
return; |
| 347 |
|
| 348 |
if ( is_array( $poll ) ) |
| 349 |
check_admin_referer( 'delete-poll_bulk' ); |
| 350 |
else |
| 351 |
check_admin_referer( "delete-poll_$poll" ); |
| 352 |
|
| 353 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE ); |
| 354 |
|
| 355 |
foreach ( (array) $_REQUEST['poll'] as $poll_id ) { |
| 356 |
$polldaddy->reset(); |
| 357 |
$poll_object = $polldaddy->GetPoll( $poll ); |
| 358 |
|
| 359 |
if ( !$this->can_edit( $poll_object ) ) { |
| 360 |
$this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) ); |
| 361 |
return false; |
| 362 |
} |
| 363 |
|
| 364 |
// Send Poll Author credentials |
| 365 |
if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) { |
| 366 |
$polldaddy->reset(); |
| 367 |
if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) { |
| 368 |
$this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) ); |
| 369 |
} |
| 370 |
$polldaddy->userCode = $userCode; |
| 371 |
} |
| 372 |
|
| 373 |
$polldaddy->reset(); |
| 374 |
$polldaddy->DeletePoll( $poll_id ); |
| 375 |
} |
| 376 |
|
| 377 |
$query_args['message'] = 'deleted'; |
| 378 |
$query_args['deleted'] = count( (array) $poll ); |
| 379 |
break; |
| 380 |
case 'open' : |
| 381 |
if ( empty( $poll ) ) |
| 382 |
return; |
| 383 |
|
| 384 |
if ( is_array( $poll ) ) |
| 385 |
check_admin_referer( 'action-poll_bulk' ); |
| 386 |
else |
| 387 |
check_admin_referer( "open-poll_$poll" ); |
| 388 |
|
| 389 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE ); |
| 390 |
|
| 391 |
foreach ( (array) $_REQUEST['poll'] as $poll_id ) { |
| 392 |
$polldaddy->reset(); |
| 393 |
$poll_object = $polldaddy->GetPoll( $poll ); |
| 394 |
|
| 395 |
if ( !$this->can_edit( $poll_object ) ) { |
| 396 |
$this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) ); |
| 397 |
return false; |
| 398 |
} |
| 399 |
|
| 400 |
// Send Poll Author credentials |
| 401 |
if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) { |
| 402 |
$polldaddy->reset(); |
| 403 |
if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) { |
| 404 |
$this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) ); |
| 405 |
} |
| 406 |
$polldaddy->userCode = $userCode; |
| 407 |
} |
| 408 |
|
| 409 |
$polldaddy->reset(); |
| 410 |
$polldaddy->OpenPoll( $poll_id ); |
| 411 |
} |
| 412 |
|
| 413 |
$query_args['message'] = 'opened'; |
| 414 |
$query_args['opened'] = count( (array) $poll ); |
| 415 |
break; |
| 416 |
case 'close' : |
| 417 |
if ( empty( $poll ) ) |
| 418 |
return; |
| 419 |
|
| 420 |
if ( is_array( $poll ) ) |
| 421 |
check_admin_referer( 'action-poll_bulk' ); |
| 422 |
else |
| 423 |
check_admin_referer( "close-poll_$poll" ); |
| 424 |
|
| 425 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE ); |
| 426 |
|
| 427 |
foreach ( (array) $_REQUEST['poll'] as $poll_id ) { |
| 428 |
$polldaddy->reset(); |
| 429 |
$poll_object = $polldaddy->GetPoll( $poll ); |
| 430 |
|
| 431 |
if ( !$this->can_edit( $poll_object ) ) { |
| 432 |
$this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) ); |
| 433 |
return false; |
| 434 |
} |
| 435 |
|
| 436 |
// Send Poll Author credentials |
| 437 |
if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) { |
| 438 |
$polldaddy->reset(); |
| 439 |
if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) { |
| 440 |
$this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) ); |
| 441 |
} |
| 442 |
$polldaddy->userCode = $userCode; |
| 443 |
} |
| 444 |
|
| 445 |
$polldaddy->reset(); |
| 446 |
$polldaddy->ClosePoll( $poll_id ); |
| 447 |
} |
| 448 |
|
| 449 |
$query_args['message'] = 'closed'; |
| 450 |
$query_args['closed'] = count( (array) $poll ); |
| 451 |
break; |
| 452 |
case 'edit-poll' : // TODO: use polldaddy_poll |
| 453 |
if ( !$is_POST || !$poll = (int) $poll ) |
| 454 |
return; |
| 455 |
|
| 456 |
check_admin_referer( "edit-poll_$poll" ); |
| 457 |
|
| 458 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE ); |
| 459 |
$polldaddy->reset(); |
| 460 |
|
| 461 |
$poll_object = $polldaddy->GetPoll( $poll ); |
| 462 |
$this->parse_errors( $polldaddy ); |
| 463 |
|
| 464 |
if ( !$this->can_edit( $poll_object ) ) { |
| 465 |
$this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) ); |
| 466 |
return false; |
| 467 |
} |
| 468 |
|
| 469 |
// Send Poll Author credentials |
| 470 |
|
| 471 |
if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) { |
| 472 |
$polldaddy->reset(); |
| 473 |
if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) { |
| 474 |
$this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) ); |
| 475 |
} |
| 476 |
$this->parse_errors( $polldaddy ); |
| 477 |
$polldaddy->userCode = $userCode; |
| 478 |
} |
| 479 |
|
| 480 |
if ( !$poll_object ) |
| 481 |
$this->errors->add( 'GetPoll', __( 'Poll not found' ) ); |
| 482 |
|
| 483 |
if ( $this->errors->get_error_codes() ) |
| 484 |
return false; |
| 485 |
|
| 486 |
$poll_data = get_object_vars( $poll_object ); |
| 487 |
foreach ( $poll_data as $key => $value ) |
| 488 |
if ( '_' === $key[0] ) |
| 489 |
unset( $poll_data[$key] ); |
| 490 |
|
| 491 |
foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer' ) as $option ) { |
| 492 |
if ( isset( $_POST[$option] ) && $_POST[$option] ) |
| 493 |
$poll_data[$option] = 'yes'; |
| 494 |
else |
| 495 |
$poll_data[$option] = 'no'; |
| 496 |
} |
| 497 |
|
| 498 |
$blocks = array( 'off', 'cookie', 'cookieIP' ); |
| 499 |
if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) ) |
| 500 |
$poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType']; |
| 501 |
|
| 502 |
$results = array( 'show', 'percent', 'hide' ); |
| 503 |
if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) ) |
| 504 |
$poll_data['resultsType'] = $_POST['resultsType']; |
| 505 |
$poll_data['question'] = stripslashes( $_POST['question'] ); |
| 506 |
|
| 507 |
if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) ) |
| 508 |
$this->errors->add( 'answer', __( 'Invalid answers' ) ); |
| 509 |
|
| 510 |
$answers = array(); |
| 511 |
foreach ( $_POST['answer'] as $answer_id => $answer ) { |
| 512 |
if ( !$answer = trim( stripslashes( $answer ) ) ) |
| 513 |
continue; |
| 514 |
|
| 515 |
if ( is_numeric( $answer_id ) ) |
| 516 |
$answers[] = polldaddy_poll_answer( $answer, $answer_id ); |
| 517 |
else |
| 518 |
$answers[] = polldaddy_poll_answer( $answer ); |
| 519 |
} |
| 520 |
|
| 521 |
if ( 2 > count( $answers ) ) |
| 522 |
$this->errors->add( 'answer', __( 'You must include at least 2 answers' ) ); |
| 523 |
|
| 524 |
if ( $this->errors->get_error_codes() ) |
| 525 |
return false; |
| 526 |
|
| 527 |
$poll_data['answers'] = $answers; |
| 528 |
|
| 529 |
if ( isset ( $_POST['styleID'] ) ){ |
| 530 |
if ( $_POST['styleID'] == 'x' ){ |
| 531 |
$this->errors->add( 'UpdatePoll', __( 'Please choose a poll style' ) ); |
| 532 |
return false; |
| 533 |
} |
| 534 |
} |
| 535 |
$poll_data['styleID'] = (int) $_POST['styleID']; |
| 536 |
|
| 537 |
$polldaddy->reset(); |
| 538 |
|
| 539 |
$update_response = $polldaddy->UpdatePoll( $poll, $poll_data ); |
| 540 |
|
| 541 |
$this->parse_errors( $polldaddy ); |
| 542 |
|
| 543 |
if ( !$update_response ) |
| 544 |
$this->errors->add( 'UpdatePoll', __( 'Poll could not be updated' ) ); |
| 545 |
|
| 546 |
if ( $this->errors->get_error_codes() ) |
| 547 |
return false; |
| 548 |
|
| 549 |
$query_args['message'] = 'updated'; |
| 550 |
if ( isset($_POST['iframe']) ) |
| 551 |
$query_args['iframe'] = ''; |
| 552 |
break; |
| 553 |
case 'create-poll' : |
| 554 |
if ( !$is_POST ) |
| 555 |
return; |
| 556 |
|
| 557 |
check_admin_referer( 'create-poll' ); |
| 558 |
|
| 559 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE ); |
| 560 |
$polldaddy->reset(); |
| 561 |
|
| 562 |
$answers = array(); |
| 563 |
foreach ( $_POST['answer'] as $answer ) |
| 564 |
if ( $answer = trim( stripslashes( $answer ) ) ) |
| 565 |
$answers[] = polldaddy_poll_answer( $answer ); |
| 566 |
if ( !$answers ) |
| 567 |
return false; |
| 568 |
|
| 569 |
$poll_data = _polldaddy_poll_defaults(); |
| 570 |
foreach ( $poll_data as $key => $value ) |
| 571 |
if ( isset($_POST[$key]) ) |
| 572 |
$poll_data[$key] = stripslashes( $_POST[$key] ); |
| 573 |
|
| 574 |
$poll_data['answers'] = $answers; |
| 575 |
if ( isset ( $_POST['styleID'] ) ){ |
| 576 |
if ( $_POST['styleID'] == 'x' ){ |
| 577 |
$this->errors->add( 'UpdatePoll', __( 'Please choose a poll style' ) ); |
| 578 |
return false; |
| 579 |
} |
| 580 |
} |
| 581 |
$poll_data['styleID'] = $_POST['styleID']; |
| 582 |
|
| 583 |
$poll = $polldaddy->CreatePoll( $poll_data ); |
| 584 |
$this->parse_errors( $polldaddy ); |
| 585 |
|
| 586 |
if ( !$poll || empty( $poll->_id ) ) |
| 587 |
$this->errors->add( 'CreatePoll', __( 'Poll could not be created' ) ); |
| 588 |
|
| 589 |
if ( $this->errors->get_error_codes() ) |
| 590 |
return false; |
| 591 |
|
| 592 |
$query_args['message'] = 'created'; |
| 593 |
$query_args['action'] = 'edit-poll'; |
| 594 |
$query_args['poll'] = $poll->_id; |
| 595 |
if ( isset($_POST['iframe']) ) |
| 596 |
$query_args['iframe'] = ''; |
| 597 |
break; |
| 598 |
default : |
| 599 |
return; |
| 600 |
endswitch; |
| 601 |
|
| 602 |
wp_redirect( add_query_arg( $query_args, wp_get_referer() ) ); |
| 603 |
exit; |
| 604 |
} |
| 605 |
|
| 606 |
function management_page_load_signup() { |
| 607 |
switch ( $_POST['account'] ) : |
| 608 |
case 'import' : |
| 609 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID ); |
| 610 |
$polldaddy->reset(); |
| 611 |
$email = trim( stripslashes( $_POST['polldaddy_email'] ) ); |
| 612 |
$password = trim( stripslashes( $_POST['polldaddy_password'] ) ); |
| 613 |
|
| 614 |
if ( !is_email( $email ) ) |
| 615 |
$this->errors->add( 'polldaddy_email', __( 'Email address required' ) ); |
| 616 |
|
| 617 |
if ( !$password ) |
| 618 |
$this->errors->add( 'polldaddy_password', __( 'Password required' ) ); |
| 619 |
|
| 620 |
if ( $this->errors->get_error_codes() ) |
| 621 |
return false; |
| 622 |
|
| 623 |
if ( !$polldaddy->Initiate( $email, $password, $GLOBALS['user_ID'] ) ) { |
| 624 |
$this->parse_errors( $polldaddy ); |
| 625 |
$this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?' ) ); |
| 626 |
return false; |
| 627 |
} |
| 628 |
break; |
| 629 |
default : |
| 630 |
return; |
| 631 |
endswitch; |
| 632 |
} |
| 633 |
|
| 634 |
function admin_body_class( $class ) { |
| 635 |
if ( isset( $_GET['iframe'] ) ) |
| 636 |
$class .= 'poll-preview-iframe '; |
| 637 |
if ( isset( $_GET['TB_iframe'] ) ) |
| 638 |
$class .= 'poll-preview-iframe-editor '; |
| 639 |
return $class; |
| 640 |
} |
| 641 |
|
| 642 |
function management_page_notices() { |
| 643 |
$message = false; |
| 644 |
switch ( (string) @$_GET['message'] ) : |
| 645 |
case 'deleted' : |
| 646 |
$deleted = (int) $_GET['deleted']; |
| 647 |
if ( 1 == $deleted ) |
| 648 |
$message = __( 'Poll deleted.' ); |
| 649 |
else |
| 650 |
$message = sprintf( __ngettext( '%s Poll Deleted.', '%s Polls Deleted.', $deleted ), number_format_i18n( $deleted ) ); |
| 651 |
break; |
| 652 |
case 'opened' : |
| 653 |
$opened = (int) $_GET['opened']; |
| 654 |
if ( 1 == $opened ) |
| 655 |
$message = __( 'Poll opened.' ); |
| 656 |
else |
| 657 |
$message = sprintf( __ngettext( '%s Poll Opened.', '%s Polls Opened.', $opened ), number_format_i18n( $opened ) ); |
| 658 |
break; |
| 659 |
case 'closed' : |
| 660 |
$closed = (int) $_GET['closed']; |
| 661 |
if ( 1 == $closed ) |
| 662 |
$message = __( 'Poll closed.' ); |
| 663 |
else |
| 664 |
$message = sprintf( __ngettext( '%s Poll Closed.', '%s Polls Closed.', $closed ), number_format_i18n( $closed ) ); |
| 665 |
break; |
| 666 |
case 'updated' : |
| 667 |
$message = __( 'Poll updated.' ); |
| 668 |
break; |
| 669 |
case 'created' : |
| 670 |
$message = __( 'Poll created.' ); |
| 671 |
if ( isset( $_GET['iframe'] ) ) |
| 672 |
$message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . attribute_escape( __( 'Send to Editor' ) ) . '" />'; |
| 673 |
break; |
| 674 |
endswitch; |
| 675 |
|
| 676 |
$is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ); |
| 677 |
|
| 678 |
if ( $is_POST ) { |
| 679 |
switch ( $GLOBALS['action'] ) : |
| 680 |
case 'create-poll' : |
| 681 |
$message = __( 'Error: An error has occurred; Poll not created.' ); |
| 682 |
break; |
| 683 |
case 'edit-poll' : |
| 684 |
$message = __( 'Error: An error has occurred; Poll not updated.' ); |
| 685 |
break; |
| 686 |
case 'account' : |
| 687 |
if ( 'import' == $_POST['account'] ) |
| 688 |
$message = __( 'Error: An error has occurred; Account could not be imported. Perhaps your email address or password is incorrect?' ); |
| 689 |
else |
| 690 |
$message = __( 'Error: An error has occurred; Account could not be created.' ); |
| 691 |
break; |
| 692 |
endswitch; |
| 693 |
} |
| 694 |
|
| 695 |
if ( !$message ) |
| 696 |
return; |
| 697 |
?> |
| 698 |
<div class='updated'><p><?php echo $message; ?></p></div> |
| 699 |
<?php |
| 700 |
$this->print_errors(); |
| 701 |
} |
| 702 |
|
| 703 |
function management_page() { |
| 704 |
global $action, $poll; |
| 705 |
$poll = (int) $poll; |
| 706 |
|
| 707 |
?> |
| 708 |
|
| 709 |
<div class="wrap" id="manage-polls"> |
| 710 |
|
| 711 |
<?php |
| 712 |
switch ( $action ) : |
| 713 |
case 'signup' : |
| 714 |
case 'account' : |
| 715 |
$this->signup(); |
| 716 |
break; |
| 717 |
case 'preview' : |
| 718 |
?> |
| 719 |
|
| 720 |
<h2 id="preview-header"><?php printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)' ), |
| 721 |
clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ), |
| 722 |
clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) |
| 723 |
); ?></h2> |
| 724 |
|
| 725 |
<?php |
| 726 |
echo do_shortcode( "[polldaddy poll=$poll cb=1]" ); |
| 727 |
break; |
| 728 |
case 'results' : |
| 729 |
?> |
| 730 |
|
| 731 |
<h2><?php printf( __( 'Poll Results (<a href="%s">Edit</a>)' ), clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ) ); ?></h2> |
| 732 |
|
| 733 |
<?php |
| 734 |
$this->poll_results_page( $poll ); |
| 735 |
break; |
| 736 |
case 'edit' : |
| 737 |
case 'edit-poll' : |
| 738 |
?> |
| 739 |
|
| 740 |
<h2><?php printf( __('Edit Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2> |
| 741 |
|
| 742 |
<?php |
| 743 |
|
| 744 |
$this->poll_edit_form( $poll ); |
| 745 |
break; |
| 746 |
case 'create-poll' : |
| 747 |
?> |
| 748 |
|
| 749 |
<h2><?php printf( __('Create Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2> |
| 750 |
|
| 751 |
<?php |
| 752 |
$this->poll_edit_form(); |
| 753 |
break; |
| 754 |
default : |
| 755 |
|
| 756 |
?> |
| 757 |
|
| 758 |
<h2 id="poll-list-header"><?php printf( __( 'Polls (<a href="%s">Add New</a>)' ), clean_url( add_query_arg( array( |
| 759 |
'action' => 'create-poll', |
| 760 |
'poll' => false, |
| 761 |
'message' => false |
| 762 |
) ) ) ); ?></h2> |
| 763 |
|
| 764 |
<?php |
| 765 |
$this->polls_table( isset( $_GET['view'] ) && 'user' == $_GET['view'] ? 'user' : 'blog' ); |
| 766 |
endswitch; |
| 767 |
?> |
| 768 |
|
| 769 |
</div> |
| 770 |
|
| 771 |
<?php |
| 772 |
|
| 773 |
} |
| 774 |
|
| 775 |
function polls_table( $view = 'blog' ) { |
| 776 |
$page = absint($_GET['paged']); |
| 777 |
if ( !$page ) |
| 778 |
$page = 1; |
| 779 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE ); |
| 780 |
$polldaddy->reset(); |
| 781 |
if ( 'user' == $view ) |
| 782 |
$polls_object = $polldaddy->listPolls( ( $page - 1 ) * 10 + 1, $page * 10 ); |
| 783 |
else |
| 784 |
$polls_object = $polldaddy->listPollsByBlog( ( $page - 1 ) * 10 + 1, $page * 10 ); |
| 785 |
$this->parse_errors( $polldaddy ); |
| 786 |
$this->print_errors(); |
| 787 |
$polls = & $polls_object->poll; |
| 788 |
$total_polls = $polls_object->_total; |
| 789 |
$class = ''; |
| 790 |
|
| 791 |
$page_links = paginate_links( array( |
| 792 |
'base' => add_query_arg( 'paged', '%#%' ), |
| 793 |
'format' => '', |
| 794 |
'total' => ceil( $total_polls / 10 ), |
| 795 |
'current' => $page |
| 796 |
) ); |
| 797 |
?> |
| 798 |
|
| 799 |
<ul class="subsubsub"> |
| 800 |
<li><a href="<?php echo clean_url( add_query_arg( array( 'view' => false, 'paged' => false ) ) ); ?>"<?php if ( 'blog' == $view ) echo ' class="current"'; ?>><?php _e( "All Blog's Polls" ); ?></a> | </li> |
| 801 |
<li><a href="<?php echo clean_url( add_query_arg( array( 'view' => 'user', 'paged' => false ) ) ); ?>"<?php if ( 'user' == $view ) echo ' class="current"'; ?>><?php _e( "All My Polls" ); ?></a></li> |
| 802 |
</ul> |
| 803 |
<form method="post" action=""> |
| 804 |
<div class="tablenav"> |
| 805 |
<div class="alignleft"> |
| 806 |
<select name="action"> |
| 807 |
<option selected="selected" value=""><?php _e( 'Actions' ); ?></option> |
| 808 |
<option value="delete"><?php _e( 'Delete' ); ?></option> |
| 809 |
<option value="close"><?php _e( 'Close' ); ?></option> |
| 810 |
<option value="open"><?php _e( 'Open' ); ?></option> |
| 811 |
</select> |
| 812 |
<input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply' ); ?>" /> |
| 813 |
<?php wp_nonce_field( 'action-poll_bulk' ); ?> |
| 814 |
</div> |
| 815 |
<div class="tablenav-pages"><?php echo $page_links; ?></div> |
| 816 |
</div> |
| 817 |
<br class="clear" /> |
| 818 |
<table class="widefat"> |
| 819 |
<thead> |
| 820 |
<tr> |
| 821 |
<th id="cb" class="manage-column column-cb check-column" scope="col" /><input type="checkbox" /></th> |
| 822 |
<th id="title" class="manage-column column-title" scope="col">Poll</th> |
| 823 |
<th id="votes" class="manage-column column-vote" scope="col">Votes</th> |
| 824 |
<th id="date" class="manage-column column-date" scope="col">Created</th> |
| 825 |
</tr> |
| 826 |
</thead> |
| 827 |
<tbody> |
| 828 |
|
| 829 |
<?php |
| 830 |
if ( $polls ) : |
| 831 |
foreach ( $polls as $poll ) : |
| 832 |
$poll_id = (int) $poll->_id; |
| 833 |
|
| 834 |
$poll_closed = (int) $poll->_closed; |
| 835 |
|
| 836 |
if ( $this->can_edit( $poll ) ) |
| 837 |
$edit_link = clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll_id, 'message' => false ) ) ); |
| 838 |
else |
| 839 |
$edit_link = false; |
| 840 |
|
| 841 |
$class = $class ? '' : ' class="alternate"'; |
| 842 |
$results_link = clean_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll_id, 'message' => false ) ) ); |
| 843 |
$delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'poll' => $poll_id, 'message' => false ) ), "delete-poll_$poll_id" ) ); |
| 844 |
$open_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'open', 'poll' => $poll_id, 'message' => false ) ), "open-poll_$poll_id" ) ); |
| 845 |
$close_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'close', 'poll' => $poll_id, 'message' => false ) ), "close-poll_$poll_id" ) ); |
| 846 |
$preview_link = clean_url( add_query_arg( array( 'action' => 'preview', 'poll' => $poll_id, 'message' => false ) ) ); //, 'iframe' => '', 'TB_iframe' => 'true' ) ) ); |
| 847 |
list($poll_time) = explode( '.', $poll->_created ); |
| 848 |
$poll_time = strtotime( $poll_time ); |
| 849 |
?> |
| 850 |
|
| 851 |
<tr<?php echo $class; ?>> |
| 852 |
<th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $poll_id; ?>" name="poll[]" /></th> |
| 853 |
<td class="post-title column-title"> |
| 854 |
<?php if ( $edit_link ) : ?> |
| 855 |
<strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $poll->___content ); ?></a></strong> |
| 856 |
<span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit' ); ?></a> | </span> |
| 857 |
<?php else : ?> |
| 858 |
<strong><?php echo wp_specialchars( $poll->___content ); ?></strong> |
| 859 |
<?php endif; ?> |
| 860 |
|
| 861 |
<span class="results"><a href="<?php echo $results_link; ?>"><?php _e( 'Results' ); ?></a> | </span> |
| 862 |
<span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete' ); ?></a> | </span> |
| 863 |
<?php if ( $poll_closed == 2 ) : ?> |
| 864 |
<span class="open"><a class="open-poll" href="<?php echo $open_link; ?>"><?php _e( 'Open' ); ?></a> | </span> |
| 865 |
<?php else : ?> |
| 866 |
<span class="close"><a class="close-poll" href="<?php echo $close_link; ?>"><?php _e( 'Close' ); ?></a> | </span> |
| 867 |
<?php endif; ?> |
| 868 |
<?php if ( isset( $_GET['iframe'] ) ) : ?> |
| 869 |
<span class="view"><a href="<?php echo $preview_link; ?>"><?php _e( 'Preview' ); ?></a> | </span> |
| 870 |
<span class="editor"> |
| 871 |
<a href="#" class="polldaddy-send-to-editor"><?php _e( 'Send to editor' ); ?></a> |
| 872 |
<input type="hidden" class="polldaddy-poll-id hack" value="<?php echo (int) $poll_id; ?>" /> | |
| 873 |
</span> |
| 874 |
<?php else : ?> |
| 875 |
<span class="view"><a class="thickbox" href="<?php echo $preview_link; ?>"><?php _e( 'Preview' ); ?></a> | </span> |
| 876 |
<?php endif; ?> |
| 877 |
<span class="shortcode"><a href="#" class="polldaddy-show-shortcode"><?php _e( 'HTML code' ); ?></a></span> |
| 878 |
</td> |
| 879 |
<td class="poll-votes column-vote"><?php echo number_format_i18n( $poll->_responses ); ?></td> |
| 880 |
<td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A'), $poll_time ); ?>"><?php echo date( __('Y/m/d'), $poll_time ); ?></abbr></td> |
| 881 |
</tr> |
| 882 |
<tr class="polldaddy-shortcode-row" style="display: none;"> |
| 883 |
<td colspan="4"> |
| 884 |
<h4><?php _e( 'Shortcode' ); ?></h4> |
| 885 |
<pre>[polldaddy poll=<?php echo (int) $poll_id; ?>]</pre> |
| 886 |
|
| 887 |
<h4><?php _e( 'JavaScript' ); ?></h4> |
| 888 |
<pre><script type="text/javascript" language="javascript" |
| 889 |
src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"></script> |
| 890 |
<noscript> |
| 891 |
<a href="http://answers.polldaddy.com/poll/1000076/"><?php echo wp_specialchars( $poll->___content ); ?></a><br/> |
| 892 |
<span style="font:9px;">(<a href="http://www.polldaddy.com">polls</a>)</span> |
| 893 |
</noscript></pre> |
| 894 |
</td> |
| 895 |
</tr> |
| 896 |
|
| 897 |
<?php |
| 898 |
endforeach; |
| 899 |
elseif ( $total_polls ) : // $polls |
| 900 |
?> |
| 901 |
|
| 902 |
<tr> |
| 903 |
<td colspan="4"><?php printf( __( 'What are you doing here? <a href="%s">Go back</a>.' ), clean_url( add_query_arg( 'paged', false ) ) ); ?></td> |
| 904 |
</tr> |
| 905 |
|
| 906 |
<?php |
| 907 |
else : // $polls |
| 908 |
?> |
| 909 |
|
| 910 |
<tr> |
| 911 |
<td colspan="4"><?php printf( __( 'No polls yet. <a href="%s">Create one</a>' ), clean_url( add_query_arg( array( 'action' => 'create-poll' ) ) ) ); ?></td> |
| 912 |
</tr> |
| 913 |
<?php endif; // $polls ?> |
| 914 |
|
| 915 |
</tbody> |
| 916 |
</table> |
| 917 |
</form> |
| 918 |
<div class="tablenav"> |
| 919 |
<div class="tablenav-pages"><?php echo $page_links; ?></div> |
| 920 |
</div> |
| 921 |
<br class="clear" /> |
| 922 |
|
| 923 |
<?php |
| 924 |
} |
| 925 |
|
| 926 |
function poll_edit_form( $poll_id = 0 ) { |
| 927 |
$poll_id = (int) $poll_id; |
| 928 |
|
| 929 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE ); |
| 930 |
$polldaddy->reset(); |
| 931 |
|
| 932 |
$is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ); |
| 933 |
|
| 934 |
if ( $poll_id ) { |
| 935 |
$poll = $polldaddy->GetPoll( $poll_id ); |
| 936 |
$this->parse_errors( $polldaddy ); |
| 937 |
|
| 938 |
if ( !$this->can_edit( $poll ) ) { |
| 939 |
$this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) ); |
| 940 |
} |
| 941 |
} else { |
| 942 |
$poll = polldaddy_poll( array(), null, false ); |
| 943 |
} |
| 944 |
|
| 945 |
$question = $is_POST ? attribute_escape( stripslashes( $_POST['question'] ) ) : attribute_escape( $poll->question ); |
| 946 |
|
| 947 |
$this->print_errors(); |
| 948 |
?> |
| 949 |
|
| 950 |
<form action="" method="post"> |
| 951 |
<div id="poststuff"><div id="post-body" class="has-sidebar has-right-sidebar"> |
| 952 |
|
| 953 |
<div class="inner-sidebar" id="side-info-column"> |
| 954 |
<div id="submitdiv" class="postbox"> |
| 955 |
<h3><?php _e( 'Publish' ); ?></h3> |
| 956 |
<div class="inside"> |
| 957 |
<div id="major-publishing-actions"> |
| 958 |
<p id="publishing-action"> |
| 959 |
<?php wp_nonce_field( $poll_id ? "edit-poll_$poll_id" : 'create-poll' ); ?> |
| 960 |
<input type="hidden" name="action" value="<?php echo $poll_id ? 'edit-poll' : 'create-poll'; ?>" /> |
| 961 |
<input type="hidden" class="polldaddy-poll-id" name="poll" value="<?php echo $poll_id; ?>" /> |
| 962 |
<input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Poll' ) ); ?>" /> |
| 963 |
|
| 964 |
<?php if ( isset( $_GET['iframe'] ) && $poll_id ) : ?> |
| 965 |
|
| 966 |
<input type="button" class="button polldaddy-send-to-editor" value="<?php echo attribute_escape( __( 'Send to Editor' ) ); ?>" /> |
| 967 |
|
| 968 |
<?php endif; ?> |
| 969 |
|
| 970 |
</p> |
| 971 |
<br class="clear" /> |
| 972 |
</div> |
| 973 |
</div> |
| 974 |
</div> |
| 975 |
|
| 976 |
<div class="postbox"> |
| 977 |
<h3><?php _e( 'Poll results' ); ?></h3> |
| 978 |
<div class="inside"> |
| 979 |
<ul class="poll-options"> |
| 980 |
|
| 981 |
<?php |
| 982 |
foreach ( array( 'show' => __( 'Show results to voters' ), 'percent' => __( 'Only show percentages' ), 'hide' => __( 'Hide all results' ) ) as $value => $label ) : |
| 983 |
if ( $is_POST ) |
| 984 |
$checked = $value === $_POST['resultsType'] ? ' checked="checked"' : ''; |
| 985 |
else |
| 986 |
$checked = $value === $poll->resultsType ? ' checked="checked"' : ''; |
| 987 |
?> |
| 988 |
|
| 989 |
<li> |
| 990 |
<label for="resultsType-<?php echo $value; ?>"><input type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="resultsType" id="resultsType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label> |
| 991 |
</li> |
| 992 |
|
| 993 |
<?php endforeach; ?> |
| 994 |
|
| 995 |
</ul> |
| 996 |
</div> |
| 997 |
</div> |
| 998 |
|
| 999 |
<div class="postbox"> |
| 1000 |
<h3><?php _e( 'Block repeat voters' ); ?></h3> |
| 1001 |
<div class="inside"> |
| 1002 |
<ul class="poll-options"> |
| 1003 |
|
| 1004 |
<?php |
| 1005 |
foreach ( array( 'off' => __( "Don't block repeat voters" ), 'cookie' => __( 'Block by cookie (recommended)' ), 'cookieIP' => __( 'Block by cookie and by IP address' ) ) as $value => $label ) : |
| 1006 |
if ( $is_POST ) |
| 1007 |
$checked = $value === $_POST['blockRepeatVotersType'] ? ' checked="checked"' : ''; |
| 1008 |
else |
| 1009 |
$checked = $value === $poll->blockRepeatVotersType ? ' checked="checked"' : ''; |
| 1010 |
?> |
| 1011 |
|
| 1012 |
<li> |
| 1013 |
<label for="blockRepeatVotersType-<?php echo $value; ?>"><input type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="blockRepeatVotersType" id="blockRepeatVotersType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label> |
| 1014 |
</li> |
| 1015 |
|
| 1016 |
<?php endforeach; ?> |
| 1017 |
|
| 1018 |
</ul> |
| 1019 |
<p>Note: Blocking by cookie and IP address can be problematic for some voters.</p> |
| 1020 |
</div> |
| 1021 |
</div> |
| 1022 |
</div> |
| 1023 |
|
| 1024 |
|
| 1025 |
<div id="post-body-content" class="has-sidebar-content"> |
| 1026 |
|
| 1027 |
<div id="titlediv"> |
| 1028 |
<div id="titlewrap"> |
| 1029 |
<input type="text" autocomplete="off" id="title" value="<?php echo $question; ?>" tabindex="1" size="30" name="question" /> |
| 1030 |
</div> |
| 1031 |
</div> |
| 1032 |
|
| 1033 |
<div id="answersdiv" class="postbox"> |
| 1034 |
<h3><?php _e( 'Answers' ); ?></h3> |
| 1035 |
|
| 1036 |
<div id="answerswrap" class="inside"> |
| 1037 |
<ul id="answers"> |
| 1038 |
<?php |
| 1039 |
$a = 0; |
| 1040 |
$answers = array(); |
| 1041 |
if ( $is_POST && $_POST['answer'] ) { |
| 1042 |
foreach( $_POST['answer'] as $answer_id => $answer ) |
| 1043 |
$answers[attribute_escape($answer_id)] = attribute_escape( stripslashes($answer) ); |
| 1044 |
} elseif ( isset( $poll->answers->answer ) ) { |
| 1045 |
foreach ( $poll->answers->answer as $answer ) |
| 1046 |
$answers[(int) $answer->_id] = attribute_escape( $answer->___content ); |
| 1047 |
} |
| 1048 |
|
| 1049 |
foreach ( $answers as $answer_id => $answer ) : |
| 1050 |
$a++; |
| 1051 |
$delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-answer', 'poll' => $poll_id, 'answer' => $answer_id, 'message' => false ) ), "delete-answer_$answer_id" ) ); |
| 1052 |
?> |
| 1053 |
|
| 1054 |
<li> |
| 1055 |
<span class="handle" title="<?php echo attribute_escape( 'click and drag to move' ); ?>">↕</span> |
| 1056 |
<div><input type="text" autocomplete="off" id="answer-<?php echo $answer_id; ?>" value="<?php echo $answer; ?>" tabindex="2" size="30" name="answer[<?php echo $answer_id; ?>]" /></div> |
| 1057 |
<a href="<?php echo $delete_link; ?>" class="delete-answer delete" title="<?php echo attribute_escape( 'delete this answer' ); ?>">×</a> |
| 1058 |
</li> |
| 1059 |
|
| 1060 |
<?php |
| 1061 |
endforeach; |
| 1062 |
|
| 1063 |
while ( 3 - $a > 0 ) : |
| 1064 |
$a++; |
| 1065 |
?> |
| 1066 |
|
| 1067 |
<li> |
| 1068 |
<span class="handle" title="<?php echo attribute_escape( 'click and drag to move' ); ?>">↕</span> |
| 1069 |
<div><input type="text" autocomplete="off" value="" tabindex="2" size="30" name="answer[new<?php echo $a; ?>]" /></div> |
| 1070 |
<a href="#" class="delete-answer delete" title="<?php echo attribute_escape( 'delete this answer' ); ?>">×</a> |
| 1071 |
</li> |
| 1072 |
|
| 1073 |
<?php |
| 1074 |
endwhile; |
| 1075 |
?> |
| 1076 |
|
| 1077 |
</ul> |
| 1078 |
|
| 1079 |
<p id="add-answer-holder"> |
| 1080 |
<button class="button"><?php echo wp_specialchars( __( 'Add another' ) ); ?></button> |
| 1081 |
</p> |
| 1082 |
|
| 1083 |
<ul id="answer-options"> |
| 1084 |
|
| 1085 |
<?php |
| 1086 |
foreach ( array( 'multipleChoice' => __( 'Multiple choice' ), 'randomiseAnswers' => __( 'Randomize answer order' ), 'otherAnswer' => __( 'Allow other answers' ) ) as $option => $label ) : |
| 1087 |
if ( $is_POST ) |
| 1088 |
$checked = 'yes' === $_POST[$option] ? ' checked="checked"' : ''; |
| 1089 |
else |
| 1090 |
$checked = 'yes' === $poll->$option ? ' checked="checked"' : ''; |
| 1091 |
?> |
| 1092 |
|
| 1093 |
<li> |
| 1094 |
<label for="<?php echo $option; ?>"><input type="checkbox"<?php echo $checked; ?> value="yes" id="<?php echo $option; ?>" name="<?php echo $option; ?>" /> <?php echo wp_specialchars( $label ); ?></label> |
| 1095 |
</li> |
| 1096 |
|
| 1097 |
<?php endforeach; ?> |
| 1098 |
|
| 1099 |
</ul> |
| 1100 |
</div> |
| 1101 |
</div> |
| 1102 |
|
| 1103 |
<div id="design" class="postbox"> |
| 1104 |
|
| 1105 |
<?php $style_ID = (int) ( $is_POST ? $_POST['styleID'] : $poll->styleID ); |
| 1106 |
|
| 1107 |
$polldaddy->reset(); |
| 1108 |
$styles = $polldaddy->GetStyles(); |
| 1109 |
|
| 1110 |
$show_custom = false; |
| 1111 |
if( isset( $styles ) && count( $styles ) > 0 ){ |
| 1112 |
$show_custom = true; |
| 1113 |
} |
| 1114 |
|
| 1115 |
if ( $style_ID > 18 ){ |
| 1116 |
$standard_style_ID = 0; |
| 1117 |
$custom_style_ID = $style_ID; |
| 1118 |
} |
| 1119 |
else{ |
| 1120 |
$standard_style_ID = $style_ID; |
| 1121 |
$custom_style_ID = 0; |
| 1122 |
} |
| 1123 |
?> |
| 1124 |
|
| 1125 |
<h3><?php _e( 'Design' ); ?></h3> |
| 1126 |
<input type="hidden" name="styleID" id="styleID" value="<?php echo $style_ID ?>"> |
| 1127 |
<div class="inside"> |
| 1128 |
<div class="design_standard"> |
| 1129 |
<table class="pollStyle"> |
| 1130 |
<thead> |
| 1131 |
<tr> |
| 1132 |
<th class="cb"> |
| 1133 |
<input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/> |
| 1134 |
</th> |
| 1135 |
<th> |
| 1136 |
<label for="skin" onclick="javascript:pd_build_styles( 0 );">PollDaddy Style</label> |
| 1137 |
</th> |
| 1138 |
<th/> |
| 1139 |
<th class="cb"> |
| 1140 |
<?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?> |
| 1141 |
<input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style($('customSelect').value);" <?php echo $disabled; ?>></input> |
| 1142 |
</th> |
| 1143 |
<th> |
| 1144 |
<label onclick="javascript:pd_change_style($('customSelect').value);">Custom Style</label> |
| 1145 |
</th> |
| 1146 |
</tr> |
| 1147 |
</thead> |
| 1148 |
<tr> |
| 1149 |
<td/> |
| 1150 |
<td class="selector"> |
| 1151 |
<table class="st_selector"> |
| 1152 |
<tr> |
| 1153 |
<td class="dir_left"> |
| 1154 |
<a href="javascript:pd_move('prev');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">«</a> |
| 1155 |
</td> |
| 1156 |
<td class="img"><div class="st_image_loader"><div id="st_image" onmouseover="st_results(this, 'show');" onmouseout="st_results(this, 'hide');"></div></div></td> |
| 1157 |
<td class="dir_right"> |
| 1158 |
<a href="javascript:pd_move('next');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">»</a> |
| 1159 |
</td> |
| 1160 |
</tr> |
| 1161 |
<tr> |
| 1162 |
<td></td> |
| 1163 |
<td class="counter"> |
| 1164 |
<div id="st_number"></div> |
| 1165 |
</td> |
| 1166 |
<td></td> |
| 1167 |
</tr> |
| 1168 |
<tr> |
| 1169 |
<td></td> |
| 1170 |
<td class="title"> |
| 1171 |
<div id="st_name"></div> |
| 1172 |
</td> |
| 1173 |
<td></td> |
| 1174 |
</tr> |
| 1175 |
<tr> |
| 1176 |
<td></td> |
| 1177 |
<td> |
| 1178 |
<div id="st_sizes"></div> |
| 1179 |
</td> |
| 1180 |
<td></td> |
| 1181 |
</tr> |
| 1182 |
<tr> |
| 1183 |
<td colspan="3"> |
| 1184 |
<div id="st_description"></div> |
| 1185 |
</td> |
| 1186 |
</tr> |
| 1187 |
</table> |
| 1188 |
</td> |
| 1189 |
<td width="100"></td> |
| 1190 |
<td/> |
| 1191 |
<td class="customSelect"> |
| 1192 |
<table> |
| 1193 |
<tr> |
| 1194 |
<td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?> |
| 1195 |
<select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>> |
| 1196 |
<?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?> |
| 1197 |
<option value="x"<?php echo $selected; ?>>Please choose a custom style...</option> |
| 1198 |
<?php foreach ( $styles->style as $style ) : |
| 1199 |
$selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?> |
| 1200 |
<option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option> |
| 1201 |
<?php endforeach;?> |
| 1202 |
</select> |
| 1203 |
<div id="styleIDErr" class="formErr" style="display:none;">Please choose a style.</div></td> |
| 1204 |
</tr> |
| 1205 |
<tr> |
| 1206 |
<td><?php $extra = $show_custom == false ? 'You currently have no custom styles created.' : ''; ?> |
| 1207 |
<p><?php echo $extra ?></p> |
| 1208 |
<p>Did you know we have a new editor for building your own custom poll styles? Find out more <a href="http://support.polldaddy.com/custom-poll-styles/" target="_blank">here</a>.</p> |
| 1209 |
</td> |
| 1210 |
</tr> |
| 1211 |
</table> |
| 1212 |
</td> |
| 1213 |
</tr> |
| 1214 |
</table> |
| 1215 |
|
| 1216 |
<script language="javascript"> |
| 1217 |
current_pos = 0; |
| 1218 |
pd_build_styles( current_pos ); |
| 1219 |
<?php if( $style_ID > 0 && $style_ID <= 1000 ){ ?> |
| 1220 |
pd_pick_style( <?php echo $style_ID ?> ); |
| 1221 |
<?php }else{ ?> |
| 1222 |
pd_change_style( <?php echo $style_ID ?> ); |
| 1223 |
<?php } ?> |
| 1224 |
</script> |
| 1225 |
</div> |
| 1226 |
</div> |
| 1227 |
</div> |
| 1228 |
|
| 1229 |
</div> |
| 1230 |
</div></div> |
| 1231 |
</form> |
| 1232 |
<br class="clear" /> |
| 1233 |
|
| 1234 |
<?php |
| 1235 |
} |
| 1236 |
|
| 1237 |
function poll_results_page( $poll_id ) { |
| 1238 |
$polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE ); |
| 1239 |
$polldaddy->reset(); |
| 1240 |
|
| 1241 |
$results = $polldaddy->GetPollResults( $poll_id ); |
| 1242 |
?> |
| 1243 |
|
| 1244 |
<table class="poll-results widefat"> |
| 1245 |
<thead> |
| 1246 |
<tr> |
| 1247 |
<th scope="col" class="column-title"><?php _e( 'Answer' ); ?></th> |
| 1248 |
<th scope="col" class="column-vote"><?php _e( 'Votes' ); ?></th> |
| 1249 |
</tr> |
| 1250 |
</thead> |
| 1251 |
<tbody> |
| 1252 |
|
| 1253 |
<?php |
| 1254 |
$class = ''; |
| 1255 |
foreach ( $results->answers as $answer ) : |
| 1256 |
$class = $class ? '' : ' class="alternate"'; |
| 1257 |
$content = $results->others && 'Other answer...' === $answer->___content ? sprintf( __( 'Other (<a href="%s">see below</a>)' ), '#other-answers-results' ) : wp_specialchars( $answer->___content ); |
| 1258 |
|
| 1259 |
?> |
| 1260 |
|
| 1261 |
<tr<?php echo $class; ?>> |
| 1262 |
<th scope="row" class="column-title"><?php echo $content; ?></th> |
| 1263 |
<td class="column-vote"> |
| 1264 |
<div class="result-holder"> |
| 1265 |
<span class="result-bar" style="width: <?php echo number_format( $answer->_percent, 2 ); ?>%;"> </span> |
| 1266 |
<span class="result-total alignleft"><?php echo number_format_i18n( $answer->_total ); ?></span> |
| 1267 |
<span class="result-percent alignright"><?php echo number_format_i18n( $answer->_percent ); ?>%</span> |
| 1268 |
</div> |
| 1269 |
</td> |
| 1270 |
</tr> |
| 1271 |
<?php |
| 1272 |
endforeach; |
| 1273 |
?> |
| 1274 |
|
| 1275 |
</tbody> |
| 1276 |
</table> |
| 1277 |
|
| 1278 |
<?php |
| 1279 |
|
| 1280 |
if ( !$results->others ) |
| 1281 |
return; |
| 1282 |
?> |
| 1283 |
|
| 1284 |
<table id="other-answers-results" class="poll-others widefat"> |
| 1285 |
<thead> |
| 1286 |
<tr> |
| 1287 |
<th scope="col" class="column-title"><?php _e( 'Other Answer' ); ?></th> |
| 1288 |
<th scope="col" class="column-vote"><?php _e( 'Votes' ); ?></th> |
| 1289 |
</tr> |
| 1290 |
</thead> |
| 1291 |
<tbody> |
| 1292 |
|
| 1293 |
<?php |
| 1294 |
$class = ''; |
| 1295 |
$others = array_count_values( $results->others ); |
| 1296 |
arsort( $others ); |
| 1297 |
foreach ( $others as $other => $freq ) : |
| 1298 |
$class = $class ? '' : ' class="alternate"'; |
| 1299 |
?> |
| 1300 |
|
| 1301 |
<tr<?php echo $class; ?>> |
| 1302 |
<th scope="row" class="column-title"><?php echo wp_specialchars( $other ); ?></th> |
| 1303 |
<td class="column-vote"><?php echo number_format_i18n( $freq ); ?></td> |
| 1304 |
</tr> |
| 1305 |
<?php |
| 1306 |
endforeach; |
| 1307 |
?> |
| 1308 |
|
| 1309 |
</tbody> |
| 1310 |
</table> |
| 1311 |
|
| 1312 |
<?php |
| 1313 |
} |
| 1314 |
|
| 1315 |
function signup() { |
| 1316 |
return $this->api_key_page(); |
| 1317 |
} |
| 1318 |
|
| 1319 |
function can_edit( &$poll ) { |
| 1320 |
global $current_user; |
| 1321 |
if ( empty( $poll->_owner ) ) |
| 1322 |
return true; |
| 1323 |
|
| 1324 |
if ( $current_user->ID == $poll->_owner ) |
| 1325 |
return true; |
| 1326 |
|
| 1327 |
return current_user_can( 'edit_others_posts' ); |
| 1328 |
} |
| 1329 |
} |
| 1330 |
|
| 1331 |
function polldaddy_loader() { |
| 1332 |
global $polldaddy_object; |
| 1333 |
$polldaddy_class = WP_POLLDADDY__CLASS; |
| 1334 |
$polldaddy_object = new $polldaddy_class; |
| 1335 |
add_action( 'admin_menu', array( &$polldaddy_object, 'admin_menu' ) ); |
| 1336 |
} |
| 1337 |
|
| 1338 |
add_action( 'init', 'polldaddy_loader' ); |
| 1339 |
|
| 1340 |
function polldaddy_shortcode($atts, $content=null) { |
| 1341 |
extract(shortcode_atts(array( |
| 1342 |
'poll' => 'empty', |
| 1343 |
'cb' => '', |
| 1344 |
), $atts)); |
| 1345 |
|
| 1346 |
$poll = (int) $poll; |
| 1347 |
$cb = ( $cb == 1 ? '?cb=' . mktime() : '' ); |
| 1348 |
|
| 1349 |
return "<script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/$poll.js$cb'></script><noscript> <a href='http://answers.polldaddy.com/poll/$poll/'>View Poll</a></noscript>"; |
| 1350 |
} |
| 1351 |
|
| 1352 |
add_shortcode('polldaddy', 'polldaddy_shortcode'); |
| 1353 |
|