PluginProbe
Crowdsignal Dashboard – Polls, Surveys & more / 3.1.6
Crowdsignal Dashboard – Polls, Surveys & more v3.1.6
3.1.8 3.1.7 trunk 0.8 0.9 1.0 1.2 1.3 1.4 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 All 97 releases
polldaddy / polldaddy.php

polldaddy.php in Crowdsignal Dashboard – Polls, Surveys & more 3.1.6, at polldaddy.php

4,750 lines 197.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Plugin Name: Crowdsignal Dashboard - Polls, Surveys & more
4 * Plugin URI: https://wordpress.org/plugins/polldaddy/
5 * Description: Create and manage Crowdsignal polls and ratings in WordPress
6 * Author: Automattic, Inc.
7 * Author URL: https://crowdsignal.com/
8 * Version: 3.1.6
9 * Text Domain: polldaddy
10 * Domain Path: /languages
11 * License: GPL-2.0+
12 * License URI: https://www.gnu.org/licenses/gpl-2.0.txt
13 */
14
15 // To hardcode your Polldaddy PartnerGUID (API Key), add the (uncommented) line below with the PartnerGUID to your `wp-config.php`
16 // define( 'WP_POLLDADDY__PARTNERGUID', '12345…' );
17
18 if ( ! defined( 'POLLDADDY_API_HOST' ) ) {
19 define( 'POLLDADDY_API_HOST', 'api.crowdsignal.com' );
20 }
21
22 if ( ! defined( 'POLLDADDY_API_VERSION' ) ) {
23 define( 'POLLDADDY_API_VERSION', 'v1' );
24 }
25
26 function polldaddy_api_path( $path, $version = POLLDADDY_API_VERSION ) {
27 return sprintf( '/%s%s', $version, $path );
28 }
29
30 function polldaddy_api_url( $path, $version = POLLDADDY_API_VERSION, $protocol = 'https' ) {
31 return sprintf(
32 '%s://%s%s',
33 $protocol,
34 POLLDADDY_API_HOST,
35 rtrim( polldaddy_api_path( $path, $version ), '/' )
36 );
37 }
38
39 function polldaddy_add_oembed_provider() {
40 wp_oembed_add_provider( '#https?://(.+\.)?polldaddy\.com/.*#i', 'https://api.crowdsignal.com/oembed', true );
41 wp_oembed_add_provider( '#https?://.+\.survey\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
42 wp_oembed_add_provider( '#https?://poll\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
43 }
44 add_action( 'init', 'polldaddy_add_oembed_provider' );
45
46 /**
47 * Get the nonce action string for polls media functionality.
48 *
49 * @return string Nonce action string specific to current user
50 */
51 function get_polls_media_nonce() {
52 return 'polls_media_' . get_current_user_id();
53 }
54
55 class WP_Polldaddy {
56 var $errors;
57 var $base_url;
58 var $is_admin;
59 var $is_author;
60 var $scheme;
61 var $version;
62 var $polldaddy_client_class;
63 var $polldaddy_clients;
64 var $id;
65 var $multiple_accounts;
66 var $user_code;
67 var $rating_user_code;
68 var $has_feedback_menu;
69 var $is_editor;
70 var $has_crowdsignal_blocks;
71
72 public $has_items = array();
73
74 function __construct() {
75 global $current_user;
76 $this->log( 'Created WP_Polldaddy Object: constructor' );
77 $this->errors = new WP_Error;
78 $this->scheme = 'https';
79 $this->version = '3.1.2';
80 $this->multiple_accounts = ! empty( get_option( 'polldaddy_usercode_user' ) );
81 $this->polldaddy_client_class = 'api_client';
82 $this->polldaddy_clients = array();
83 $this->is_admin = (bool) current_user_can( 'manage_options' );
84 $this->is_author = (bool) current_user_can( 'edit_posts' );
85 $this->is_editor = (bool) current_user_can( 'delete_others_pages' );
86 $this->user_code = null;
87 $this->rating_user_code = null;
88 $this->id = ($current_user instanceof WP_User) ? intval( $current_user->ID ): 0;
89 $this->has_feedback_menu = false;
90 $this->has_crowdsignal_blocks = ! empty( get_option( 'crowdsignal_user_code' ) );
91
92 if ( class_exists( 'Jetpack' ) ) {
93 if ( method_exists( 'Jetpack', 'is_active' ) && Jetpack::is_active() ) {
94 $jetpack_active_modules = get_option('jetpack_active_modules');
95 if ( $jetpack_active_modules && in_array( 'contact-form', $jetpack_active_modules ) )
96 $this->has_feedback_menu = true;
97 }
98
99 if ( class_exists( 'Jetpack_Sync' ) && defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '4.1', '<' ) ) {
100 Jetpack_Sync::sync_options( __FILE__, 'polldaddy_api_key' );
101 }
102
103 add_filter( 'jetpack_options_whitelist', array( $this, 'add_to_jetpack_options_whitelist' ) );
104 }
105
106 if ( ! post_type_exists( 'feedback' ) ) {
107 register_post_type(
108 'feedback', array(
109 'labels' => array(
110 ),
111 'menu_icon' => 'dashicons-feedback',
112 'show_ui' => true,
113 'show_in_menu' => 'edit.php?post_type=feedback',
114 'show_in_admin_bar' => false,
115 'public' => false,
116 'rewrite' => false,
117 'query_var' => false,
118 'capability_type' => 'page',
119 'show_in_rest' => true,
120 'rest_controller_class' => 'Grunion_Contact_Form_Endpoint',
121 'capabilities' => array(
122 'create_posts' => 'do_not_allow',
123 'publish_posts' => 'publish_pages',
124 'edit_posts' => 'edit_pages',
125 'edit_others_posts' => 'edit_others_pages',
126 'delete_posts' => 'delete_pages',
127 'delete_others_posts' => 'delete_others_pages',
128 'read_private_posts' => 'read_private_pages',
129 'edit_post' => 'edit_page',
130 'delete_post' => 'delete_page',
131 'read_post' => 'read_page',
132 ),
133 'map_meta_cap' => true,
134 )
135 );
136 add_action( 'admin_menu', array( $this, 'remove_feedback_menu' ) );
137 }
138 }
139
140 /**
141 * Remove the feedback "All Posts" submenu if not needed.
142 */
143 public function remove_feedback_menu() {
144 remove_submenu_page( 'edit.php?post_type=feedback', 'edit.php?post_type=feedback' );
145 }
146
147 /**
148 * Add the polldaddy option to the Jetpack options management whitelist.
149 *
150 * @param array $options The list of whitelisted option names.
151 * @return array The updated whitelist
152 */
153 public static function add_to_jetpack_options_whitelist( $options ) {
154 $options[] = 'polldaddy_api_key';
155 return $options;
156 }
157
158 function &get_client( $api_key, $userCode = null ) {
159 if ( isset( $this->polldaddy_clients[$api_key] ) ) {
160 if ( !is_null( $userCode ) )
161 $this->polldaddy_clients[$api_key]->userCode = $userCode;
162 return $this->polldaddy_clients[$api_key];
163 }
164 require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
165 $this->polldaddy_clients[$api_key] = $this->config_client( new $this->polldaddy_client_class( $api_key, $userCode ) );
166 return $this->polldaddy_clients[$api_key];
167 }
168
169 function config_client( $client ) {
170
171 return $client;
172 }
173
174 function admin_menu() {
175 if ( isset( $_GET['page'] ) && 'pollsettings' === $_GET['page'] ) {
176 wp_safe_redirect( admin_url( 'options-general.php?page=crowdsignal-settings' ) );
177 die();
178 }
179 add_action( 'admin_enqueue_scripts', array( &$this, 'menu_alter' ) );
180
181 if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
182 $guid = get_option( 'polldaddy_api_key' );
183 if ( !$guid || !is_string( $guid ) )
184 $guid = false;
185 define( 'WP_POLLDADDY__PARTNERGUID', $guid );
186
187 }
188
189 $capability = 'edit_posts';
190 $function = array( &$this, 'management_page' );
191
192 $icon_encoded = 'PHN2ZyBpZD0iY29udGVudCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMjg4IDIyMCI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNGRkZGRkY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5pY29uLWJsdWU8L3RpdGxlPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTI2Mi40MSw4MC4xYy04LjQ3LTIyLjU1LTE5LjA1LTQyLjgzLTI5Ljc5LTU3LjFDMjIwLjc0LDcuMjQsMjEwLC41NywyMDEuNDcsMy43OWExMi4zMiwxMi4zMiwwLDAsMC0zLjcyLDIuM2wtLjA1LS4xNUwxNiwxNzMuOTRsOC4yLDE5LjEyLDMwLjU2LTEuOTJ2MTMuMDVhMTIuNTcsMTIuNTcsMCwwLDAsMTIuNTgsMTIuNTZjLjMzLDAsLjY3LDAsMSwwbDU4Ljg1LTQuNzdhMTIuNjUsMTIuNjUsMCwwLDAsMTEuNTYtMTIuNTNWMTg1Ljg2bDEyMS40NS03LjY0YTEzLjg4LDEzLjg4LDAsMCwwLDIuMDkuMjYsMTIuMywxMi4zLDAsMCwwLDQuNDEtLjhDMjg1LjMzLDE3MC43LDI3OC42MywxMjMuMzEsMjYyLjQxLDgwLjFabS0yLjI2LDg5Ljc3Yy0xMC40OC0zLjI1LTMwLjQ0LTI4LjE1LTQ2LjY4LTcxLjM5LTE1LjcyLTQxLjktMTcuNS03My4yMS0xMi4zNC04My41NGE2LjUyLDYuNTIsMCwwLDEsMy4yMi0zLjQ4LDMuODIsMy44MiwwLDAsMSwxLjQxLS4yNGMzLjg1LDAsMTAuOTQsNC4yNiwyMC4zMSwxNi43MUMyMzYuMzYsNDEuNTksMjQ2LjU0LDYxLjE1LDI1NC43NCw4M2MxOC40NCw0OS4xMiwxNy43NCw4My43OSw5LjEzLDg3QTUuOTMsNS45MywwLDAsMSwyNjAuMTUsMTY5Ljg3Wk0xMzAuNiwxOTkuNDFhNC40LDQuNCwwLDAsMS00LDQuMzdsLTU4Ljg1LDQuNzdBNC4zOSw0LjM5LDAsMCwxLDYzLDIwNC4xOVYxOTAuNjJsNjcuNjEtNC4yNVoiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik02LDE4NS4yNmExMC4yNSwxMC4yNSwwLDAsMCwxMC4yNSwxMC4yNSwxMC4wNSwxMC4wNSwwLDAsMCw0LjM0LTFsLTcuOTQtMTguNzNBMTAuMiwxMC4yLDAsMCwwLDYsMTg1LjI2WiIvPjwvc3ZnPgo=';
193
194 $slug = 'edit.php?post_type=feedback';
195
196 if ( ! $this->has_feedback_menu ) {
197 $hook = add_menu_page(
198 __( 'Feedback', 'polldaddy' ),
199 __( 'Feedback', 'polldaddy' ),
200 $capability,
201 $slug,
202 $function,
203 'data:image/svg+xml;base64,' . $icon_encoded
204 );
205 add_action( "load-$hook", array( &$this, 'management_page_load' ) );
206 }
207
208 foreach( array( 'polls' => __( 'Crowdsignal', 'polldaddy' ), 'ratings' => __( 'Ratings', 'polldaddy' ) ) as $menu_slug => $page_title ) {
209 $menu_title = $page_title;
210
211 $hook = add_submenu_page( $this->has_feedback_menu ? 'feedback' : $slug, $menu_title, $menu_title, $capability, $menu_slug, $function, 99 );
212 add_action( "load-$hook", array( &$this, 'management_page_load' ) );
213 }
214
215 // Add settings pages.
216 foreach( array( 'crowdsignal-settings' => __( 'Crowdsignal', 'polldaddy' ), 'ratingsettings' => __( 'Ratings', 'polldaddy' ) ) as $menu_slug => $page_title ) {
217 $settings_page_title = sprintf( esc_html( $page_title ) );
218 $hook = add_options_page( $settings_page_title, $settings_page_title, $menu_slug == 'ratingsettings' ? 'manage_options' : 'edit_others_posts', $menu_slug, array( $this, 'settings_page' ) );
219 add_action( "load-$hook", array( $this, 'management_page_load' ) );
220 }
221
222 }
223
224 function menu_alter() {
225 // Make sure we're working off a clean version.
226 include( ABSPATH . WPINC . '/version.php' );
227
228 if ( version_compare( $wp_version, '3.8', '<' ) ) {
229 $css = "
230 #toplevel_page_polldaddy .wp-menu-image {
231 background: url( " . plugins_url( 'img/polldaddy.png', __FILE__ ) . " ) 0 90% no-repeat;
232 }
233 /* Retina Polldaddy Menu Icon */
234 @media only screen and (-moz-min-device-pixel-ratio: 1.5),
235 only screen and (-o-min-device-pixel-ratio: 3/2),
236 only screen and (-webkit-min-device-pixel-ratio: 1.5),
237 only screen and (min-device-pixel-ratio: 1.5) {
238 #toplevel_page_polldaddy .wp-menu-image {
239 background: url( " . plugins_url( 'polldaddy@2x.png', __FILE__ ) . " ) 0 90% no-repeat;
240 background-size:30px 64px;
241 }
242 }
243 #toplevel_page_polldaddy.current .wp-menu-image,
244 #toplevel_page_polldaddy.wp-has-current-submenu .wp-menu-image,
245 #toplevel_page_polldaddy:hover .wp-menu-image {
246 background-position: top left;
247 }";
248 wp_add_inline_style( 'wp-admin', $css );
249 }
250 }
251
252 function api_key_page_load() {
253
254 if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
255 return false;
256
257 check_admin_referer( 'polldaddy-account' );
258
259 $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
260 $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
261
262 if ( !$polldaddy_email )
263 $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
264
265 if ( !$polldaddy_password )
266 $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
267
268 if ( $this->errors->get_error_codes() )
269 return false;
270
271 $details = array(
272 'uName' => get_bloginfo( 'name' ),
273 'uEmail' => $polldaddy_email,
274 'uPass' => $polldaddy_password,
275 'partner_userid' => $this->id
276 );
277 if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
278 $polldaddy_api_key = wp_remote_post( polldaddy_api_url( '/key' ), array(
279 'body' => $details
280 ) );
281 if ( is_wp_error( $polldaddy_api_key ) ) {
282 $this->errors = $polldaddy_api_key;
283 return false;
284 }
285 $polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
286 } else {
287 $fp = fsockopen(
288 polldaddy_api_url( '/', POLLDADDY_API_VERSION, 'tls' ),
289 443,
290 $err_num,
291 $err_str,
292 5
293 );
294
295 if ( !$fp ) {
296 $this->errors->add( 'connect', __( "Can't connect to Polldaddy.com", 'polldaddy' ) );
297 return false;
298 }
299
300 if ( function_exists( 'stream_set_timeout' ) )
301 stream_set_timeout( $fp, 3 );
302
303 global $wp_version;
304
305 $request_body = http_build_query( $details, null, '&' );
306
307 $request = 'POST ' . polldaddy_api_path( '/key' ) . " HTTP/1.0\r\n";
308 $request .= 'Host: ' . POLLDADDY_API_HOST . "\r\n";
309 $request .= "User-agent: WordPress/$wp_version\r\n";
310 $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ) . "\r\n";
311 $request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
312
313 fwrite( $fp, "$request\r\n$request_body" );
314
315 $response = '';
316 while ( !feof( $fp ) )
317 $response .= fread( $fp, 4096 );
318 fclose( $fp );
319 list( $headers, $polldaddy_api_key ) = explode( "\r\n\r\n", $response, 2 );
320 }
321
322 if ( !$polldaddy_api_key ) {
323 $this->errors->add( 'polldaddy_password', __( 'Invalid Account', 'polldaddy' ) );
324 return false;
325 }
326
327 update_option( 'polldaddy_api_key', $polldaddy_api_key );
328
329 $polldaddy = $this->get_client( $polldaddy_api_key );
330 $polldaddy->reset();
331 if ( !$polldaddy->get_usercode( $this->id ) ) {
332 $this->parse_errors( $polldaddy );
333 $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
334 return false;
335 }
336
337 return true;
338 }
339
340 function parse_errors( &$polldaddy ) {
341 if ( $polldaddy->errors )
342 foreach ( $polldaddy->errors as $code => $error )
343 $this->errors->add( $code, $error );
344
345 if ( isset( $this->errors->errors[4] ) ) {
346 //need to get latest usercode
347 global $wp_version;
348 if ( version_compare( $wp_version, '4.2', '<' ) ) {
349 delete_option( 'pd-usercode-' . $this->id );
350 add_option( 'pd-usercode-' . $this->id, '', '', false );
351 } else {
352 update_option( 'pd-usercode-' . $this->id, '', false );
353 }
354 $this->set_api_user_code();
355 }
356 }
357
358 function print_errors() {
359 if ( !$error_codes = $this->errors->get_error_codes() )
360 return;
361
362 $this->render_partial( 'errors', array( 'error_codes' => $error_codes, 'errors' => $this->errors ) );
363 $this->errors = new WP_Error;
364 }
365
366 function api_key_page() {
367 $this->print_errors();
368 ?>
369
370 <div class="wrap">
371 <h2 id="polldaddy-header"><?php _e( 'Crowdsignal', 'polldaddy' ); ?></h2>
372
373 <?php /* translators: %s is the URL to the Crowdsignal.com account details */ ?>
374 <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>
375
376 <form action="" method="post">
377 <table class="form-table">
378 <tbody>
379 <tr class="form-field form-required">
380 <th valign="top" scope="row">
381 <label for="polldaddy-email"><?php _e( 'Crowdsignal Email Address', 'polldaddy' ); ?></label>
382 </th>
383 <td>
384 <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" />
385 </td>
386 </tr>
387 <tr class="form-field form-required">
388 <th valign="top" scope="row">
389 <label for="polldaddy-password"><?php _e( 'Crowdsignal Password', 'polldaddy' ); ?></label>
390 </th>
391 <td>
392 <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
393 </td>
394 </tr>
395 </tbody>
396 </table>
397 <p class="submit">
398 <?php wp_nonce_field( 'polldaddy-account' ); ?>
399 <input type="hidden" name="action" value="account" />
400 <input type="hidden" name="account" value="import" />
401 <input class="button-secondary" type="submit" value="<?php echo esc_attr( __( 'Submit', 'polldaddy' ) ); ?>" />
402 </p>
403 </form>
404 </div>
405
406 <?php
407 }
408
409 function get_usercode( $for_current_user = false ) {
410 // sitewide access to Crowdsignal account
411 if ( ! $for_current_user && $user_id = get_option( 'polldaddy_usercode_user' ) ) {
412 return get_option( 'pd-usercode-' . $user_id );
413 } else {
414 return get_option( 'pd-usercode-' . $this->id );
415 }
416 }
417
418 function set_api_user_code() {
419
420 $this->user_code = get_option( 'pd-usercode-'.$this->id );
421
422 if ( empty( $this->user_code ) ) {
423 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
424 $polldaddy->reset();
425
426 $this->user_code = $polldaddy->get_usercode( $this->id );
427
428 if ( !empty( $this->user_code ) ) {
429 global $wp_version;
430 if ( version_compare( $wp_version, '4.2', '<' ) ) {
431 delete_option( 'pd-usercode-' . $this->id );
432 add_option( 'pd-usercode-' . $this->id, $this->user_code, '', false );
433 } else {
434 update_option( 'pd-usercode-' . $this->id, $this->user_code, false );
435 }
436 } elseif ( get_option( 'crowdsignal_api_key' ) === get_option( 'polldaddy_api_key' ) ) {
437 // attempt to get credentials from Crowdsignal Forms.
438 $this->user_code = get_option( 'crowdsignal_user_code' );
439 } elseif ( get_option( 'polldaddy_api_key' ) ) {
440 $this->contact_support_message( 'There was a problem linking your account', $polldaddy->errors );
441 }
442 }
443 }
444
445 function management_page_load() {
446 wp_reset_vars( array( 'page', 'action', 'poll', 'style', 'rating', 'id' ) );
447 global $plugin_page, $page, $action, $poll, $style, $rating, $id, $wp_locale;
448
449 if (
450 isset( $_GET['step'] ) && 2 === (int) $_GET['step']
451 && isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD']
452 && isset( $_POST['got_api_key'] ) && get_option( 'crowdsignal_api_key_secret' ) === $_POST['got_api_key']
453 && isset( $_POST['api_key'] )
454 ) {
455 $api_key = sanitize_key( wp_unslash( $_POST['api_key'] ) );
456 $crowdsignal = $this->get_client( $api_key );
457 $crowdsignal->reset();
458 $usercode = $crowdsignal->get_usercode( $this->id );
459 if ( $usercode ) {
460 update_option( 'polldaddy_api_key', $api_key );
461 update_option( 'crowdsignal_api_key', $api_key );
462 update_option( 'crowdsignal_user_code', $usercode );
463 update_option( 'pd-usercode-' . $this->id, $usercode );
464 delete_option( 'crowdsignal_api_key_secret' );
465 $connected = true;
466 } else {
467 $connected = false;
468 }
469 $this->render_partial(
470 'html-admin-setup-step-2',
471 array(
472 'is_connected' => $connected,
473 )
474 );
475 die();
476 }
477
478 if (
479 isset( $_POST['action'] )
480 && $_POST['action'] === 'disconnect'
481 && current_user_can( 'edit_others_posts' )
482 ) {
483 check_admin_referer( 'disconnect-api-key' );
484 delete_option( 'polldaddy_api_key' );
485 delete_option( 'crowdsignal_api_key' );
486 delete_option( 'crowdsignal_user_code' );
487 delete_option( 'pd-usercode-' . $this->id );
488 wp_safe_redirect( admin_url( 'options-general.php?page=crowdsignal-settings&msg=disconnected' ) );
489 }
490
491 $this->set_api_user_code();
492
493 if ( empty( $this->user_code ) && 'crowdsignal-settings' === $page && 'options' !== $action ) {
494 // one last try to get the user code automatically if possible
495 $this->user_code = apply_filters_ref_array( 'polldaddy_get_user_code', array( $this->user_code, &$this ) );
496 if ( false == $this->user_code && $action != 'restore-account' )
497 $action = 'signup';
498 }
499
500 require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
501
502 wp_enqueue_style( 'admin-styles', plugin_dir_url( __FILE__ ) . '/admin-styles.css', array(), '1.5.12' );
503 wp_enqueue_style( 'wp-components' );
504 wp_enqueue_script( 'polls', "{$this->base_url}js/polldaddy.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-form', 'wp-components' ), $this->version );
505 wp_enqueue_script( 'polls-common', "{$this->base_url}js/common.js", array(), $this->version );
506
507 // Localize script with nonce data for secure media uploads
508 if ( $page === 'polls' && in_array( $action, array( 'edit', 'edit-poll', 'create-poll' ) ) ) {
509 $user_id = get_current_user_id();
510 $nonce_action = get_polls_media_nonce();
511 wp_localize_script( 'polls', 'pollsMediaSecurity', array(
512 'nonce' => wp_create_nonce( $nonce_action ),
513 'user_id' => $user_id,
514 ) );
515 }
516
517 if ( $page == 'polls' ) {
518 if ( !$this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles', 'options', 'update-options', 'import-account', 'create-block-poll' ) ) ) {//check user privileges has access to action
519 $action = '';
520 }
521
522 switch ( $action ) {
523 case 'create-block-poll':
524 check_admin_referer( 'create-block-poll' );
525 $post_id = wp_insert_post(
526 array(
527 'post_title' => esc_html__( 'Crowdsignal blocks in WordPress', 'polldaddy' ),
528
529 'post_content' => '
530 <!-- wp:paragraph -->
531 <p>Welcome to this little demo page! We would love to introduce you to our set of Crowdsignal blocks and created this post for you, so that you can test and play with all of them right inside of your editor. </p>
532 <!-- /wp:paragraph -->
533
534 <!-- wp:paragraph -->
535 <p><a href="https://wordpress.org/support/article/how-to-use-the-preview-function/">Preview this post</a> if you would like to test the Crowdsignal blocks from your visitors perspective. <em>Oh and please feel free to delete this draft post anytime</em>, it was only created for demo purposes.</p>
536 <!-- /wp:paragraph -->
537
538 <!-- wp:spacer {"height":60} -->
539 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
540 <!-- /wp:spacer -->
541
542 <!-- wp:heading -->
543 <h2>Overview</h2>
544 <!-- /wp:heading -->
545
546 <!-- wp:paragraph -->
547 <p>Let\'s start with a quick overview of all our current blocks available in your WordPress editor. You can <a href="https://wordpress.com/support/wordpress-editor/">find all these blocks inside your block library via searching</a> for their name or simply by searching "Crowdsignal".</p>
548 <!-- /wp:paragraph -->
549
550 <!-- wp:image {"align":"wide","id":241,"sizeSlug":"full","linkDestination":"none"} -->
551 <figure class="wp-block-image alignwide size-full"><img src="https://crowdsignal.files.wordpress.com/2021/11/crowdsignalcards.png" alt="" class="wp-image-241"/></figure>
552 <!-- /wp:image -->
553
554 <!-- wp:paragraph -->
555 <p>If you want to learn more about Crowdsignal please go to <a href="https://crowdsignal.com" data-type="URL" data-id="https://crowdsignal.com">crowdsignal.com</a> and join our little <a href="https://crowdsignalfeedback.wordpress.com/">community</a> all about feedback here.</p>
556 <!-- /wp:paragraph -->
557
558 <!-- wp:spacer {"height":60} -->
559 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
560 <!-- /wp:spacer -->
561
562 <!-- wp:heading -->
563 <h2>Polls</h2>
564 <!-- /wp:heading -->
565
566 <!-- wp:paragraph -->
567 <p>We all have opinions! Curious about the opinion of your audience? Start asking with our poll block. It makes creating a poll as fast and simple as listing bullet points.</p>
568 <!-- /wp:paragraph -->
569
570 <!-- wp:paragraph -->
571 <p>&nbsp;You can choose between a button or a list style for your answer options, and you can fully customize the styling of the block. &nbsp;By default the poll block will support your theme styling, but it’s up to you if you want to keep it. You can customize the style how you want, from font-family to border colours.</p>
572 <!-- /wp:paragraph -->
573
574 <!-- wp:paragraph -->
575 <p>Just click in the poll below and start editing. </p>
576 <!-- /wp:paragraph -->
577
578 <!-- wp:crowdsignal-forms/poll {"pollId":"","title":"Demo Poll block","question":"What do you think about this demo page","answers":[{"text":"Super useful","answerId":""},{"text":"Not sure yet","answerId":""},{"text":"I don\'t like it","answerId":""}],"borderWidth":5,"borderRadius":5,"hasBoxShadow":true,"fontFamily":"Open+Sans","className":"is-style-buttons"} /-->
579
580 <!-- wp:paragraph -->
581 <p>And everything else you expect from a Crowdsignal poll is also available — such as setting “single answer” or “multiple answer” choices, a customised confirmation message, poll timeframe, and avoidance of double voting.</p>
582 <!-- /wp:paragraph -->
583
584 <!-- wp:paragraph -->
585 <p>Here is a short demo video for how to set up this block, not that you would need it ;) </p>
586 <!-- /wp:paragraph -->
587
588 <!-- wp:video {"src":"https://crowdsignal.files.wordpress.com/2021/11/add-poll-tutorial-720.mp4"} -->
589 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-poll-tutorial-720.mp4"></video></figure>
590 <!-- /wp:video -->
591
592 <!-- wp:spacer {"height":60} -->
593 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
594 <!-- /wp:spacer -->
595
596 <!-- wp:heading -->
597 <h2>Feedback Button</h2>
598 <!-- /wp:heading -->
599
600 <!-- wp:paragraph -->
601 <p>You might have spotted it already, in the bottom left corner of this page: Our Feedback button.</p>
602 <!-- /wp:paragraph -->
603
604 <!-- wp:paragraph -->
605 <p>This is a floating button that lives above your site\'s content. Always visible this button makes giving feedback easy! User can send you a message and provide their email address so you could can get back to them. Needless to say that you can fully customize the design and text, including the label of the button itself. Feel free to make it a "Contact me" or "Say hello" button or anything you like.</p>
606 <!-- /wp:paragraph -->
607
608 <!-- wp:paragraph -->
609 <p>And yes, you can change its placement! You can put the button in any corner of your site. Just try it! Click in the feedback and start editing.</p>
610 <!-- /wp:paragraph -->
611
612 <!-- wp:paragraph -->
613 <p>Don\'t miss out on your customers\' feedback. Keep your door open anytime and place a feedback button on all your pages. </p>
614 <!-- /wp:paragraph -->
615
616 <!-- wp:video {"src":"https://crowdsignal.files.wordpress.com/2021/11/add-feedback-button-tutorial.mp4"} -->
617 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-feedback-button-tutorial.mp4"></video></figure>
618 <!-- /wp:video -->
619
620 <!-- wp:spacer {"height":60} -->
621 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
622 <!-- /wp:spacer -->
623
624 <!-- wp:heading -->
625 <h2>Voting</h2>
626 <!-- /wp:heading -->
627
628 <!-- wp:paragraph -->
629 <p>Sometimes we need just quick and fast feedback from our audience. A quick voting button might be all you need. Fully customizable of course.</p>
630 <!-- /wp:paragraph -->
631
632 <!-- wp:paragraph -->
633 <p>There is already a “like” button at the end of a WordPress post that you can click to express satisfaction or agreement. But what if you want to ask readers their opinion on a subject in the middle of a post? Or what if you want to present several ideas and find out which one is the most popular? Wouldn’t it be great to ask readers what they think without having to leave the editor or switch to another service or plugin?</p>
634 <!-- /wp:paragraph -->
635
636 <!-- wp:paragraph -->
637 <p>That’s what we thought! Say hello to our Voting Block:</p>
638 <!-- /wp:paragraph -->
639
640 <!-- wp:crowdsignal-forms/vote {"pollId":"","title":"Demo Vote block"} -->
641 <!-- wp:crowdsignal-forms/vote-item {"answerId":"","type":"up","textColor":"#066127","borderColor":"#066127"} /-->
642
643 <!-- wp:crowdsignal-forms/vote-item {"answerId":"","type":"down","textColor":"#c6302e","borderColor":"#c6302e"} /-->
644 <!-- /wp:crowdsignal-forms/vote -->
645
646 <!-- wp:paragraph -->
647 <p>It’s a simple block that adds two voting buttons—thumbs up, thumbs down—to your post wherever you want to place them. Customize the block in different sizes and colors, with or without a border, and with or without a visible vote counter. Put several in a single post, next to different ideas, to see how they stack up for readers. Make the block your own!</p>
648 <!-- /wp:paragraph -->
649
650 <!-- wp:video {"src":"https://crowdsignal.files.wordpress.com/2021/11/add-vote-tutorial.mp4"} -->
651 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-vote-tutorial.mp4"></video></figure>
652 <!-- /wp:video -->
653
654 <!-- wp:spacer {"height":60} -->
655 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
656 <!-- /wp:spacer -->
657
658 <!-- wp:heading -->
659 <h2>Applause</h2>
660 <!-- /wp:heading -->
661
662 <!-- wp:image {"sizeSlug":"large"} -->
663 <figure class="wp-block-image size-large"><img src="https://crowdsignal.files.wordpress.com/2021/11/17claps-small.gif" alt=""/></figure>
664 <!-- /wp:image -->
665
666 <!-- wp:paragraph -->
667 <p>The Applause block is a simpler and more playful version of our Voting block. The main differences are users only being able to give positive feedback and encouraging users to “make as much noise as they want”. Meaning this block does not only allow repeated voting, but even encourages it.</p>
668 <!-- /wp:paragraph -->
669
670 <!-- wp:paragraph -->
671 <p>Let your audience make some noise with a big round of applause.</p>
672 <!-- /wp:paragraph -->
673
674 <!-- wp:crowdsignal-forms/applause {"pollId":"","title":"Demo Applause block","answerId":"","size":"large","borderWidth":1,"borderRadius":5} /-->
675
676 <!-- wp:paragraph -->
677 <p><a href="https://wordpress.org/support/article/how-to-use-the-preview-function/">Preview this post</a> and try clapping yourself! It\'s fun.</p>
678 <!-- /wp:paragraph -->
679
680 <!-- wp:paragraph -->
681 <p>The block currently comes in three different sizes, and can be customised with a button-like styling, including a border, border radius and some colour customisation options.</p>
682 <!-- /wp:paragraph -->
683
684 <!-- wp:video {"src": "https://crowdsignal.files.wordpress.com/2021/11/add-applause-block-tutorial.mp4"} -->
685 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-applause-block-tutorial.mp4"></video></figure>
686 <!-- /wp:video -->
687
688 <!-- wp:spacer {"height":60} -->
689 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
690 <!-- /wp:spacer -->
691
692 <!-- wp:heading -->
693 <h2>Embed Surveys &amp; Forms</h2>
694 <!-- /wp:heading -->
695
696 <!-- wp:paragraph -->
697 <p>So far we only talked about quick and fast ways to collect feedback or opinions from your audience. But what if you have many questions or want to create simple forms? You can do this with Crowdsignal, too! Create a survey or form on app.crowdsignal.com and embed it into your WordPress post or site. Similar like here:</p>
698 <!-- /wp:paragraph -->
699
700 <!-- wp:embed {"url":"https://crowdsignal.survey.fm/product-market-fit-score","type":"rich","providerNameSlug":"crowdsignal","responsive":true,"align":"wide"} -->
701 <figure class="wp-block-embed alignwide is-type-rich is-provider-crowdsignal wp-block-embed-crowdsignal"><div class="wp-block-embed__wrapper">
702 https://crowdsignal.survey.fm/product-market-fit-score
703 </div></figure>
704 <!-- /wp:embed -->
705
706 <!-- wp:paragraph -->
707 <p>The Crowdsignal survey above was embedded using our "Single question per page mode."&nbsp;It’s exactly what it sounds like: In this mode, no matter how many questions your survey has, your respondents will always see one question at a time. Single Mode shines when you embed a survey into your website or blog post. Surveys with multiple questions can take up a lot of space, overwhelming your site. If you’re not sure whether your readers will take the survey at all, it disrupts the reading experience. With Single Mode, a survey&nbsp; uses the same amount of space as an image, even a really long survey.</p>
708 <!-- /wp:paragraph -->
709
710 <!-- wp:paragraph -->
711 <p>Once they provide an answer (or skip the question),&nbsp; the next question loads. It has a playful&nbsp; feel, like flipping through a slide show. Every answered question feels like progress.</p>
712 <!-- /wp:paragraph -->
713
714 <!-- wp:paragraph -->
715 <p>You can choose between several transition options, and decide whether the questions should move from top to bottom, or from left to right.</p>
716 <!-- /wp:paragraph -->
717
718 <!-- wp:paragraph -->
719 <p><strong>Ready to create one? Here’s how:</strong></p>
720 <!-- /wp:paragraph -->
721
722 <!-- wp:paragraph -->
723 <p>- Go to <a href="https://app.crowdsignal.com/dashboard">app.crowdsignal.com</a> (we will log you in with your WordPress.com account - magic ;)) .</p>
724 <!-- /wp:paragraph -->
725
726 <!-- wp:paragraph -->
727 <p>- Create a new survey.</p>
728 <!-- /wp:paragraph -->
729
730 <!-- wp:paragraph -->
731 <p>- In the Editor, choose “Single Mode” at the top left.</p>
732 <!-- /wp:paragraph -->
733
734 <!-- wp:paragraph -->
735 <p>- Then create as many questions as you like and style your theme.</p>
736 <!-- /wp:paragraph -->
737
738 <!-- wp:paragraph -->
739 <p>- When you are ready click on Sharing and copy the URL of your survey.</p>
740 <!-- /wp:paragraph -->
741
742 <!-- wp:paragraph -->
743 <p>- Go back to your WordPress editor and paste the URL of your survey into your post</p>
744 <!-- /wp:paragraph -->
745
746 <!-- wp:paragraph -->
747 <p>- Done! Your survey will appear in your post.</p>
748 <!-- /wp:paragraph -->
749
750 <!-- wp:paragraph -->
751 <p>Here is a short demo video for you that shows you how it works in less than a minute:</p>
752 <!-- /wp:paragraph -->
753
754 <!-- wp:video {"src": "https://crowdsignal.files.wordpress.com/2021/11/add-survey-tutorial-yt.mp4"} -->
755 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-survey-tutorial-yt.mp4"></video></figure>
756 <!-- /wp:video -->
757
758 <!-- wp:spacer {"height":60} -->
759 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
760 <!-- /wp:spacer -->
761
762 <!-- wp:heading -->
763 <h2>Measure NPS</h2>
764 <!-- /wp:heading -->
765
766 <!-- wp:paragraph -->
767 <p>While we are driving our projects, working hard on our products, we all wonder: How are we doing? Are people satisfied with our service? Are we doing better since last month?&nbsp;</p>
768 <!-- /wp:paragraph -->
769
770 <!-- wp:paragraph -->
771 <p>Sometimes you want to measure your progress over time. <a href="https://crowdsignal.com/2021/03/16/measure-nps/">Measure and monitor the customer satisfaction and growth potential of your product with a Net Promoter Score</a>. </p>
772 <!-- /wp:paragraph -->
773
774 <!-- wp:paragraph -->
775 <p>We have built a Gutenberg block for you that makes it easier than ever before to track your Net Promoter Score on WordPress. If you have <a href="https://wordpress.org/support/article/how-to-use-the-preview-function/">previewed this post</a> before, you might have seen the NPS question already in a modal window. </p>
776 <!-- /wp:paragraph -->
777
778 <!-- wp:crowdsignal-forms/nps {"surveyId":"","title":"Demo NPS block","viewThreshold":"2"} /-->
779
780 <!-- wp:paragraph -->
781 <p>The moment you add the block, you are basically done. The design of the block is based on your site’s theme. You can still customize the styling of the block, or edit the questions, but that might not even be necessary.</p>
782 <!-- /wp:paragraph -->
783
784 <!-- wp:paragraph -->
785 <p>To get the most out of your NPS data, it is important to show the question only to users that are already familiar with your service or product. You can configure the block to only show to repeat visitors. It’s more likely you will get feedback from someone who knows what they are talking about, and you can make sure new users are not interrupted during their first visit to your site.</p>
786 <!-- /wp:paragraph -->
787
788 <!-- wp:paragraph -->
789 <p>After you publish the block go to the results page of the block and monitor your results. We have built a special results page for you to track your NPS score and to analyse any additional feedback. </p>
790 <!-- /wp:paragraph -->
791
792 <!-- wp:image {"sizeSlug":"large"} -->
793 <figure class="wp-block-image size-large"><img src="https://s0.wp.com/wp-content/themes/a8c/crowd-signal/assets/images/AnalyseResults.png" alt=""/></figure>
794 <!-- /wp:image -->
795
796 <!-- wp:paragraph -->
797 <p>We provide an analytics dashboard with our block that automatically calculates the Net Promoter Score for you in real-time and allows you to monitor your score over time. Are the differences geographic? Filter your results based on countries.</p>
798 <!-- /wp:paragraph -->
799
800 <!-- wp:paragraph -->
801 <p>By the way, did you know you also can get email notifications or a ping in your Slack channel any time you get an NPS rating? Just click on the little “connect” button on your results page.</p>
802 <!-- /wp:paragraph -->
803
804 <!-- wp:paragraph -->
805 <p>Here is a quick tutorial video on how it works.</p>
806 <!-- /wp:paragraph -->
807
808 <!-- wp:video {"src": "https://crowdsignal.files.wordpress.com/2021/11/add-nps-tutorial-long-3.mp4"} -->
809 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-nps-tutorial-long-3.mp4"></video></figure>
810 <!-- /wp:video -->
811
812 <!-- wp:crowdsignal-forms/feedback {"surveyId":"","title":"Demo Feedback block"} /-->
813
814 <!-- wp:paragraph -->
815 <p></p>
816 <!-- /wp:paragraph -->
817 ',
818 )
819 );
820 if ( ! is_wp_error( $post_id ) ) {
821 wp_safe_redirect( admin_url( 'post.php?post=' . intval( $post_id ) . '&action=edit' ) );
822 } else {
823 // admin.php?page=polls
824 // wp_safe_redirect( admin_url( 'admin.php?page=polls' ) );
825 }
826 break;
827
828 case 'edit' :
829 case 'edit-poll' :
830 case 'create-poll' :
831 case 'add-media' :
832 wp_enqueue_script( 'media-upload', array(), $this->version );
833 wp_enqueue_script( 'polls-style', "{$this->base_url}js/poll-style-picker.js", array( 'polls', 'polls-common' ), $this->version );
834
835 if ( $action == 'create-poll' )
836 $plugin_page = 'polls&action=create-poll';
837
838 break;
839 case 'edit-style' :
840 case 'create-style' :
841 wp_enqueue_script( 'polls-style', "{$this->base_url}js/style-editor.js", array( 'polls', 'polls-common' ), $this->version );
842 wp_enqueue_script( 'polls-style-color', "{$this->base_url}js/jscolor.js", array(), $this->version );
843 wp_enqueue_style( 'polls', "{$this->base_url}css/style-editor.css", array(), $this->version );
844 $plugin_page = 'polls&action=list-styles';
845 break;
846 case 'list-styles' :
847 $plugin_page = 'polls&action=list-styles';
848 break;
849 }//end switch
850 } elseif ( $page == 'crowdsignal-settings' ) {
851 $plugin_page = 'crowdsignal-settings';
852 } elseif ( $page == 'ratings' ) {
853 if ( empty( $action ) ) {
854 $action = 'reports';
855 }
856 $plugin_page = 'ratings&action=reports';
857 } elseif ( $page == 'ratingsettings' ) {
858 $plugin_page = 'ratingsettings';
859 wp_enqueue_script( 'rating-text-color', "{$this->base_url}js/jscolor.js", array(), $this->version );
860 wp_enqueue_script( 'ratings', "{$this->base_url}js/rating.js", array(), $this->version );
861 wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
862 'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
863 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
864 }
865
866 wp_enqueue_style( 'polldaddy', "{$this->base_url}css/polldaddy.css", array(), $this->version );
867 wp_enqueue_script( 'admin-forms' );
868 add_thickbox();
869
870 if ( isset( $_GET['iframe'] ) ) {
871 add_action( 'admin_head', array( &$this, 'hide_admin_menu' ) );
872 }
873
874 if ( isset( $wp_locale->text_direction ) && 'rtl' == $wp_locale->text_direction )
875 wp_enqueue_style( 'polls-rtl', "{$this->base_url}css/polldaddy-rtl.css", array( 'global', 'wp-admin' ), $this->version );
876 add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
877
878 add_action( 'admin_notices', array( &$this, 'management_page_notices' ) );
879
880 $query_args = array();
881 $args = array();
882
883 $allowedtags = array(
884 'a' => array(
885 'href' => array(),
886 'title' => array(),
887 'target' => array() ),
888 'img' => array(
889 'alt' => array(),
890 'align' => array(),
891 'border' => array(),
892 'class' => array(),
893 'height' => array(),
894 'hspace' => array(),
895 'longdesc' => array(),
896 'vspace' => array(),
897 'src' => array(),
898 'width' => array() ),
899 'abbr' => array( 'title' => array() ),
900 'acronym' => array( 'title' => array() ),
901 'blockquote' => array( 'cite' => array() ),
902 'q' => array( 'cite' => array() ),
903 'b' => array(),
904 'cite' => array(),
905 'em' => array(),
906 'i' => array(),
907 'strike' => array(),
908 'strong' => array()
909 );
910
911 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
912
913 if ( 'polls' === $page || 'crowdsignal-settings' === $page ) {
914 switch ( $action ) {
915 case 'multi-account':
916 check_admin_referer( 'polldaddy-reset' . $this->id );
917 if ( ! isset( $_POST['crowdsignal_multiuser'] ) ) {
918 delete_option( 'polldaddy_usercode_user' );
919 }
920 break;
921 case 'reset-account' : // reset everything
922 global $current_user;
923 check_admin_referer( 'polldaddy-reset' . $this->id );
924 $fields = array( 'polldaddy_api_key', 'pd-rating-comments', 'pd-rating-comments-id', 'pd-rating-comments-pos', 'pd-rating-exclude-post-ids', 'pd-rating-pages', 'pd-rating-pages-id', 'pd-rating-posts', 'pd-rating-posts-id', 'pd-rating-posts-index', 'pd-rating-posts-index-id', 'pd-rating-posts-index-pos', 'pd-rating-posts-pos', 'pd-rating-title-filter', 'pd-rating-usercode', 'pd-rich-snippets', 'pd-usercode-' . $current_user->ID );
925 $msg = __( "You have just reset your Polldaddy connection settings.", 'polldaddy' ) . "\n\n";
926 foreach( $fields as $field ) {
927 $value = get_option( $field );
928 if ( $value != false ) {
929 $settings[ $field ] = $value;
930 $msg .= "$field: $value\n";
931 delete_option( $field );
932 }
933 }
934 if ( isset( $_POST[ 'email' ] ) )
935 wp_mail( $current_user->user_email, "Crowdsignal Settings", $msg );
936 update_option( 'polldaddy_settings', $settings );
937 break;
938 case 'restore-account' : // restore everything
939 global $current_user;
940 check_admin_referer( 'polldaddy-restore' . $this->id );
941 $previous_settings = get_option( 'polldaddy_settings' );
942 foreach( $previous_settings as $key => $value )
943 update_option( $key, $value );
944 delete_option( 'polldaddy_settings' );
945 break;
946 case 'restore-ratings' : // restore ratings
947 global $current_user;
948 check_admin_referer( 'polldaddy-restore-ratings' . $this->id );
949 $previous_settings = get_option( 'polldaddy_settings' );
950 $fields = array( 'pd-rating-comments', 'pd-rating-comments-id', 'pd-rating-comments-pos', 'pd-rating-exclude-post-ids', 'pd-rating-pages', 'pd-rating-pages-id', 'pd-rating-posts', 'pd-rating-posts-id', 'pd-rating-posts-index', 'pd-rating-posts-index-id', 'pd-rating-posts-index-pos', 'pd-rating-posts-pos', 'pd-rating-title-filter' );
951 foreach( $fields as $key ) {
952 if ( isset( $previous_settings[ $key ] ) )
953 update_option( $key, $previous_settings[ $key ] );
954 }
955 break;
956 case 'signup' : // sign up for first time
957 case 'account' : // reauthenticate
958 case 'import-account' : // reauthenticate
959 if ( !$is_POST )
960 return;
961
962 check_admin_referer( 'polldaddy-account' );
963
964 $this->user_code = '';
965 global $wp_version;
966 if ( version_compare( $wp_version, '4.2', '<' ) ) {
967 delete_option( 'pd-usercode-' . $this->id );
968 add_option( 'pd-usercode-' . $this->id, '', false );
969 } else {
970 update_option( 'pd-usercode-' . $this->id, '', false );
971 }
972
973 if ( $new_args = $this->management_page_load_signup() )
974 $query_args = array_merge( $query_args, $new_args );
975
976 if ( $this->errors->get_error_codes() )
977 return false;
978
979 $query_args['message'] = 'imported-account';
980
981 wp_reset_vars( array( 'action' ) );
982 if ( !empty( $_GET['reaction'] ) )
983 $query_args['action'] = $_GET['reaction'];
984 elseif ( !empty( $_GET['action'] ) && 'account' == $_GET['action'] )
985 $query_args['action'] = $_GET['action'];
986 else
987 $query_args['action'] = false;
988 if ( $action == 'import-account' )
989 $query_args[ 'action' ] = 'options'; // make sure we redirect back to the right page.
990 break;
991
992 case 'delete' :
993 if ( empty( $poll ) )
994 return;
995
996 if ( is_array( $poll ) )
997 check_admin_referer( 'action-poll_bulk' );
998 else
999 check_admin_referer( "delete-poll_$poll" );
1000
1001 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1002
1003 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
1004 $polldaddy->reset();
1005 $poll_object = $polldaddy->get_poll( $poll_id );
1006
1007 if ( !$this->can_edit( $poll_object ) ) {
1008 $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.', 'polldaddy' ) );
1009 return false;
1010 }
1011
1012 // Send Poll Author credentials
1013 if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
1014 $polldaddy->reset();
1015 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
1016 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
1017 }
1018 $polldaddy->userCode = $userCode;
1019 }
1020
1021 $polldaddy->reset();
1022 $polldaddy->delete_poll( $poll_id );
1023 }
1024
1025 $query_args['message'] = 'deleted';
1026 $query_args['deleted'] = count( (array) $poll );
1027 break;
1028 case 'open' :
1029 if ( empty( $poll ) )
1030 return;
1031
1032 if ( is_array( $poll ) )
1033 check_admin_referer( 'action-poll_bulk' );
1034 else
1035 check_admin_referer( "open-poll_$poll" );
1036
1037 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1038
1039 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
1040 $polldaddy->reset();
1041 $poll_object = $polldaddy->get_poll( $poll_id );
1042
1043 if ( !$this->can_edit( $poll_object ) ) {
1044 $this->errors->add( 'permission', __( 'You are not allowed to open this poll.', 'polldaddy' ) );
1045 return false;
1046 }
1047
1048 // Send Poll Author credentials
1049 if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
1050 $polldaddy->reset();
1051 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
1052 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
1053 }
1054 $polldaddy->userCode = $userCode;
1055 }
1056
1057 $polldaddy->reset();
1058 $polldaddy->open_poll( $poll_id );
1059 }
1060
1061 $query_args['message'] = 'opened';
1062 $query_args['opened'] = count( (array) $poll );
1063 break;
1064 case 'close' :
1065 if ( empty( $poll ) )
1066 return;
1067
1068 if ( is_array( $poll ) )
1069 check_admin_referer( 'action-poll_bulk' );
1070 else
1071 check_admin_referer( "close-poll_$poll" );
1072
1073 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1074
1075 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
1076 $polldaddy->reset();
1077 $poll_object = $polldaddy->get_poll( $poll_id );
1078
1079 if ( !$this->can_edit( $poll_object ) ) {
1080 $this->errors->add( 'permission', __( 'You are not allowed to close this poll.', 'polldaddy' ) );
1081 return false;
1082 }
1083
1084 // Send Poll Author credentials
1085 if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
1086 $polldaddy->reset();
1087 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
1088 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
1089 }
1090 $polldaddy->userCode = $userCode;
1091 }
1092
1093 $polldaddy->reset();
1094 $polldaddy->close_poll( $poll_id );
1095 }
1096
1097 $query_args['message'] = 'closed';
1098 $query_args['closed'] = count( (array) $poll );
1099 break;
1100 case 'edit-poll' : // TODO: use polldaddy_poll
1101 if ( !$is_POST || !$poll = (int) $poll )
1102 return;
1103
1104 check_admin_referer( "edit-poll_$poll" );
1105
1106 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1107 $polldaddy->reset();
1108
1109 $poll_object = $polldaddy->get_poll( $poll );
1110 $this->parse_errors( $polldaddy );
1111
1112 if ( !$this->can_edit( $poll_object ) ) {
1113 $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
1114 return false;
1115 }
1116
1117 // Send Poll Author credentials
1118 if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
1119 $polldaddy->reset();
1120 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
1121 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
1122 }
1123 $this->parse_errors( $polldaddy );
1124 $polldaddy->userCode = $userCode;
1125 }
1126
1127 if ( !$poll_object )
1128 $this->errors->add( 'GetPoll', __( 'Poll not found', 'polldaddy' ) );
1129
1130 if ( $this->errors->get_error_codes() )
1131 return false;
1132
1133 $media = $mediaType = array();
1134 if ( isset( $_POST['media'] ) ) {
1135 $media = $_POST['media'];
1136 unset( $_POST['media'] );
1137 }
1138
1139 if ( isset( $_POST['mediaType'] ) ) {
1140 $mediaType = $_POST['mediaType'];
1141 unset( $_POST['mediaType'] );
1142 }
1143
1144 $poll_data = get_object_vars( $poll_object );
1145 foreach ( $poll_data as $key => $value )
1146 if ( '_' === $key[0] )
1147 unset( $poll_data[$key] );
1148
1149 foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
1150 if ( isset( $_POST[$option] ) && $_POST[$option] )
1151 $poll_data[$option] = 'yes';
1152 else
1153 $poll_data[$option] = 'no';
1154 }
1155
1156 $blocks = array( 'off', 'cookie', 'cookieip' );
1157 if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
1158 $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
1159
1160 $results = array( 'show', 'percent', 'hide' );
1161 if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
1162 $poll_data['resultsType'] = $_POST['resultsType'];
1163 $poll_data['question'] = stripslashes( $_POST['question'] );
1164
1165 $comments = array( 'off', 'allow', 'moderate' );
1166 if ( isset( $_POST['comments'] ) && in_array( $_POST['comments'], $comments ) )
1167 $poll_data['comments'] = $_POST['comments'];
1168
1169 if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
1170 $this->errors->add( 'answer', __( 'Invalid answers', 'polldaddy' ) );
1171
1172 $answers = array();
1173 if ( ! empty( $_POST['answer'] ) ) {
1174 foreach ( $_POST['answer'] as $answer_id => $answer ) {
1175 $answer = stripslashes( trim( $answer ) );
1176
1177 if ( strlen( $answer ) > 0 ) {
1178 $answer = wp_kses( $answer, $allowedtags );
1179
1180 $args['text'] = (string) $answer;
1181
1182 $answer_id = str_replace( 'new', '', $answer_id );
1183 $mc = '';
1184 $mt = 0;
1185
1186 if ( isset( $media[ $answer_id ] ) ) {
1187 $mc = esc_html( $media[ $answer_id ] );
1188 }
1189
1190 if ( isset( $mediaType[ $answer_id ] ) ) {
1191 $mt = intval( $mediaType[ $answer_id ] );
1192 }
1193
1194 $args['mediaType'] = $mt;
1195 $args['mediaCode'] = $mc;
1196
1197 if ( $answer_id > 1000 ) {
1198 $answer = polldaddy_poll_answer( $args, $answer_id );
1199 } else {
1200 $answer = polldaddy_poll_answer( $args );
1201 }
1202
1203 if ( isset( $answer ) && is_a( $answer, 'Polldaddy_Poll_Answer' ) ) {
1204 $answers[] = $answer;
1205 }
1206 }
1207 }
1208 }
1209
1210 if ( 2 > count( $answers ) )
1211 $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
1212
1213 if ( $this->errors->get_error_codes() )
1214 return false;
1215
1216 $poll_data['answers'] = $answers;
1217
1218 $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
1219
1220 if ( isset ( $_POST['styleID'] ) ) {
1221 if ( $_POST['styleID'] == 'x' ) {
1222 $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
1223 return false;
1224 }
1225 }
1226 $poll_data['styleID'] = (int) $_POST['styleID'];
1227 $poll_data['choices'] = (int) $_POST['choices'];
1228
1229 if ( $poll_data['blockRepeatVotersType'] == 'cookie' ) {
1230 if ( isset( $_POST['cookieip_expiration'] ) )
1231 $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
1232 } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ) {
1233 if ( isset( $_POST['cookieip_expiration'] ) )
1234 $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
1235 }
1236
1237 if ( isset( $media[999999999] ) )
1238 $poll_data['mediaCode'] = esc_html( $media[999999999] );
1239
1240 if ( isset( $mediaType[999999999] ) )
1241 $poll_data['mediaType'] = intval( $mediaType[999999999] );
1242
1243 if( isset( $GLOBALS['blog_id'] ) )
1244 $poll_data['parentID'] = (int) $GLOBALS['blog_id'];
1245
1246 $polldaddy->reset();
1247
1248 $update_response = $polldaddy->update_poll( $poll, $poll_data );
1249 $this->parse_errors( $polldaddy );
1250
1251 if ( !$update_response )
1252 $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated', 'polldaddy' ) );
1253
1254 if ( $this->errors->get_error_codes() )
1255 return false;
1256
1257 $query_args['message'] = 'updated';
1258 if ( isset( $_POST['iframe'] ) )
1259 $query_args['iframe'] = '';
1260 break;
1261 case 'create-poll' :
1262 if ( !$is_POST )
1263 return;
1264
1265 check_admin_referer( 'create-poll' );
1266
1267 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1268 $polldaddy->reset();
1269
1270 $media = $mediaType = array();
1271 if ( isset( $_POST['media'] ) ) {
1272 $media = $_POST['media'];
1273 unset( $_POST['media'] );
1274 }
1275
1276 if ( isset( $_POST['mediaType'] ) ) {
1277 $mediaType = $_POST['mediaType'];
1278 unset( $_POST['mediaType'] );
1279 }
1280
1281 $answers = array();
1282
1283 if ( ! empty( $_POST['answer'] ) ) {
1284 foreach ( $_POST['answer'] as $answer_id => $answer ) {
1285 $answer = stripslashes( trim( $answer ) );
1286
1287 if ( strlen( $answer ) > 0 ) {
1288 $answer = wp_kses( $answer, $allowedtags );
1289
1290 $args['text'] = (string) $answer;
1291
1292 $answer_id = (int) str_replace( 'new', '', $answer_id );
1293 $mc = '';
1294 $mt = 0;
1295
1296 if ( isset( $media[ $answer_id ] ) ) {
1297 $mc = esc_html( $media[ $answer_id ] );
1298 }
1299
1300 if ( isset( $mediaType[ $answer_id ] ) ) {
1301 $mt = intval( $mediaType[ $answer_id ] );
1302 }
1303
1304 $args['mediaType'] = $mt;
1305 $args['mediaCode'] = $mc;
1306
1307 $answer = polldaddy_poll_answer( $args );
1308
1309 if ( isset( $answer ) && is_a( $answer, 'Polldaddy_Poll_Answer' ) ) {
1310 $answers[] = $answer;
1311 }
1312 }
1313 }
1314 }
1315
1316 if ( 2 > count( $answers ) ) {
1317 $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
1318 }
1319
1320 if ( $this->errors->get_error_codes() ) {
1321 return false;
1322 }
1323
1324 $poll_data = _polldaddy_poll_defaults();
1325
1326 foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
1327 if ( isset( $_POST[$option] ) && $_POST[$option] )
1328 $poll_data[$option] = 'yes';
1329 else
1330 $poll_data[$option] = 'no';
1331 }
1332
1333 $blocks = array( 'off', 'cookie', 'cookieip' );
1334 if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
1335 $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
1336
1337 $results = array( 'show', 'percent', 'hide' );
1338 if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
1339 $poll_data['resultsType'] = $_POST['resultsType'];
1340
1341 $comments = array( 'off', 'allow', 'moderate' );
1342 if ( isset( $_POST['comments'] ) && in_array( $_POST['comments'], $comments ) )
1343 $poll_data['comments'] = $_POST['comments'];
1344
1345 $poll_data['answers'] = $answers;
1346
1347 $poll_data['question'] = stripslashes( $_POST['question'] );
1348 $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
1349
1350 if ( isset ( $_POST['styleID'] ) ) {
1351 if ( $_POST['styleID'] == 'x' ) {
1352 $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
1353 return false;
1354 }
1355 }
1356 $poll_data['styleID'] = (int) $_POST['styleID'];
1357 $poll_data['choices'] = (int) $_POST['choices'];
1358
1359 if ( $poll_data['blockRepeatVotersType'] == 'cookie' ) {
1360 if ( isset( $_POST['cookieip_expiration'] ) )
1361 $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
1362 } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ) {
1363 if ( isset( $_POST['cookieip_expiration'] ) )
1364 $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
1365 }
1366
1367 if ( isset( $media[999999999] ) )
1368 $poll_data['mediaCode'] = esc_html( $media[999999999] );
1369
1370 if ( isset( $mediaType[999999999] ) )
1371 $poll_data['mediaType'] = intval( $mediaType[999999999] );
1372
1373 $poll = $polldaddy->create_poll( $poll_data );
1374 $this->parse_errors( $polldaddy );
1375
1376 if ( !$poll || empty( $poll->_id ) )
1377 $this->errors->add( 'CreatePoll', __( 'Poll could not be created', 'polldaddy' ) );
1378
1379 if ( $this->errors->get_error_codes() )
1380 return false;
1381
1382 $query_args['message'] = 'created';
1383 $query_args['action'] = 'edit-poll';
1384 $query_args['poll'] = $poll->_id;
1385 if ( isset( $_POST['iframe'] ) )
1386 $query_args['iframe'] = '';
1387 break;
1388 case 'delete-style' :
1389 if ( empty( $style ) )
1390 return;
1391
1392 if ( is_array( $style ) )
1393 check_admin_referer( 'action-style_bulk' );
1394 else
1395 check_admin_referer( "delete-style_$style" );
1396
1397 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1398
1399 foreach ( (array) $_REQUEST['style'] as $style_id ) {
1400 $polldaddy->reset();
1401 $polldaddy->delete_style( $style_id );
1402 }
1403
1404 $query_args['message'] = 'deleted-style';
1405 $query_args['deleted'] = count( (array) $style );
1406 break;
1407 case 'edit-style' :
1408 if ( !$is_POST || !$style = (int) $style )
1409 return;
1410
1411 check_admin_referer( "edit-style$style" );
1412
1413 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1414 $polldaddy->reset();
1415
1416 $style_data = _polldaddy_style_defaults();
1417
1418 if ( isset( $_POST['style-title'] ) )
1419 $style_data['title'] = stripslashes( trim( (string) $_POST['style-title'] ) );
1420
1421 if ( isset( $_POST['CSSXML'] ) )
1422 $style_data['css'] = urlencode( stripslashes( trim( (string) $_POST['CSSXML'] ) ) );
1423
1424 if ( isset( $_REQUEST['updatePollCheck'] ) && $_REQUEST['updatePollCheck'] == 'on' )
1425 $style_data['retro'] = 1;
1426
1427 $update_response = $polldaddy->update_style( $style, $style_data );
1428
1429 $this->parse_errors( $polldaddy );
1430
1431 if ( !$update_response )
1432 $this->errors->add( 'UpdateStyle', __( 'Style could not be updated', 'polldaddy' ) );
1433
1434 if ( $this->errors->get_error_codes() )
1435 return false;
1436
1437 $query_args['message'] = 'updated-style';
1438 if ( isset( $_POST['iframe'] ) )
1439 $query_args['iframe'] = '';
1440 break;
1441 case 'create-style' :
1442 if ( !$is_POST )
1443 return;
1444
1445 check_admin_referer( 'create-style' );
1446
1447 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1448 $polldaddy->reset();
1449
1450 $style_data = _polldaddy_style_defaults();
1451
1452 if ( isset( $_POST['style-title'] ) )
1453 $style_data['title'] = stripslashes( strip_tags( trim( (string) $_POST['style-title'] ) ) );
1454
1455 if ( isset( $_POST['CSSXML'] ) )
1456 $style_data['css'] = urlencode( stripslashes( trim( (string) $_POST['CSSXML'] ) ) );
1457
1458 $style = $polldaddy->create_style( $style_data );
1459 $this->parse_errors( $polldaddy );
1460
1461 if ( !$style || empty( $style->_id ) )
1462 $this->errors->add( 'CreateStyle', __( 'Style could not be created', 'polldaddy' ) );
1463
1464 if ( $this->errors->get_error_codes() )
1465 return false;
1466
1467 $query_args['message'] = 'created-style';
1468 $query_args['action'] = 'edit-style';
1469 $query_args['style'] = $style->_id;
1470 if ( isset( $_POST['iframe'] ) )
1471 $query_args['iframe'] = '';
1472 break;
1473 case 'update-options' :
1474 if ( !$is_POST )
1475 return;
1476
1477 check_admin_referer( 'polldaddy-account' );
1478
1479 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1480 $polldaddy->reset();
1481
1482 $poll_defaults = _polldaddy_poll_defaults();
1483
1484 $user_defaults = array();
1485
1486 foreach ( array( "multipleChoice", "randomiseAnswers", "otherAnswer", "sharing", "resultsType", "styleID", "blockRepeatVotersType", "blockExpiration" ) as $option ) {
1487 if ( isset( $poll_defaults[$option] ) && $poll_defaults[$option] )
1488 $user_defaults[$option] = $poll_defaults[$option];
1489 }
1490
1491 foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
1492 if ( isset( $_POST[$option] ) && $_POST[$option] )
1493 $user_defaults[$option] = 'yes';
1494 else
1495 $user_defaults[$option] = 'no';
1496 }
1497
1498 if ( ! empty( $_POST['multipleChoice'] ) ) {
1499 $user_defaults['choices'] = 1;
1500 }
1501
1502 $results = array( 'show', 'percent', 'hide' );
1503 if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
1504 $user_defaults['resultsType'] = $_POST['resultsType'];
1505
1506 if ( isset ( $_POST['styleID'] ) ) {
1507 $user_defaults['styleID'] = (int) $_POST['styleID'];
1508 }
1509
1510 $blocks = array( 'off', 'cookie', 'cookieip' );
1511 if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
1512 $user_defaults['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
1513
1514 if ( isset( $_POST['blockExpiration'] ) )
1515 $user_defaults['blockExpiration'] = (int) $_POST['blockExpiration'];
1516
1517 $polldaddy->update_poll_defaults( 0, $user_defaults );
1518
1519 $this->parse_errors( $polldaddy );
1520 if ( $this->errors->get_error_codes() )
1521 return false;
1522
1523 $query_args['message'] = 'updated-options';
1524 break;
1525 default :
1526 return;
1527 }//end switch
1528 } elseif ( 'ratings' === $page || 'ratingsettings' === $page ) {
1529
1530 switch ( $action ) {
1531 case 'delete' :
1532 if ( empty( $id ) )
1533 return;
1534 if ( empty( $rating ) )
1535 return;
1536
1537 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
1538
1539 if ( is_array( $rating ) ) {
1540 check_admin_referer( 'action-rating_bulk' );
1541
1542 foreach ( $rating as $key => $value ) {
1543 $polldaddy->reset();
1544 $polldaddy->delete_rating_result( $id, $value );
1545 }
1546 } else {
1547 check_admin_referer( "delete-rating_$rating" );
1548
1549 $polldaddy->delete_rating_result( $id, $rating );
1550 }
1551
1552 if ( isset( $_REQUEST['filter'] ) )
1553 $query_args['filter'] = $_REQUEST['filter'];
1554 if ( isset( $_REQUEST['change-report-to'] ) )
1555 $query_args['change-report-to'] = $_REQUEST['change-report-to'];
1556 $query_args['message'] = 'deleted-rating';
1557 $query_args['deleted'] = count( (array) $rating );
1558 break;
1559 default :
1560 return;
1561 }//end switch
1562 }
1563
1564 wp_safe_redirect( add_query_arg( $query_args, wp_get_referer() ) );
1565 exit;
1566 }
1567
1568 function hide_admin_menu() {
1569 echo '<style>#adminmenuback,#adminmenuwrap,#screen-meta-links,#footer{display:none;visibility:hidden;}#wpcontent{margin-left:10px;}</style>';
1570 }
1571
1572 function management_page_load_signup() {
1573
1574 switch ( $_POST['account'] ) {
1575 case 'import' :
1576 return array( $this->import_account() );
1577 break;
1578 default :
1579 return;
1580 }//end switch
1581 }
1582
1583 function import_account() {
1584 if ( isset( $_POST[ 'polldaddy_key' ] ) ) {
1585 $polldaddy_api_key = trim( stripslashes( $_POST[ 'polldaddy_key' ] ) );
1586 $polldaddy = $this->get_client( $polldaddy_api_key );
1587 $polldaddy->reset();
1588 if ( !$polldaddy->get_usercode( $this->id ) ) {
1589 $this->parse_errors( $polldaddy );
1590 $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Is your API code correct?', 'polldaddy' ) );
1591 return false;
1592 }
1593 update_option( 'polldaddy_api_key', $polldaddy_api_key );
1594 } else {
1595 $this->user_code = false;
1596 $this->errors->add( 'import-account', __( 'Account could not be imported. Did you enter the correct API key?', 'polldaddy' ) );
1597 return false;
1598 }
1599 }
1600
1601 function admin_body_class( $class ) {
1602 if ( isset( $_GET['iframe'] ) )
1603 $class .= 'poll-preview-iframe ';
1604 if ( isset( $_GET['TB_iframe'] ) )
1605 $class .= 'poll-preview-iframe-editor ';
1606 return $class;
1607 }
1608
1609 function management_page_notices( $message = false ) {
1610
1611 if ( isset( $_GET['message'] ) ) {
1612 switch ( (string) $_GET['message'] ) {
1613 case 'deleted' :
1614 $deleted = (int) $_GET['deleted'];
1615 if ( 1 == $deleted ) {
1616 $message = __( 'Poll deleted.', 'polldaddy' );
1617 } else {
1618 $message = sprintf(
1619 /* translators: %s is the number of polls deleted */
1620 _n( '%s Poll Deleted.', '%s Polls Deleted.', $deleted, 'polldaddy' ), number_format_i18n( $deleted ) );
1621 }
1622 break;
1623 case 'opened' :
1624 $opened = (int) $_GET['opened'];
1625 if ( 1 == $opened ) {
1626 $message = __( 'Poll opened.', 'polldaddy' );
1627 } else {
1628 $message = sprintf(
1629 /* translators: %s is the number of polls opened */
1630 _n( '%s Poll Opened.', '%s Polls Opened.', $opened, 'polldaddy' ), number_format_i18n( $opened ) );
1631 }
1632 break;
1633 case 'closed' :
1634 $closed = (int) $_GET['closed'];
1635 if ( 1 == $closed ) {
1636 $message = __( 'Poll closed.', 'polldaddy' );
1637 } else {
1638 $message = sprintf(
1639 /* translators: %s is the number of polls closed */
1640 _n( '%s Poll Closed.', '%s Polls Closed.', $closed, 'polldaddy' ), number_format_i18n( $closed ) );
1641 }
1642 break;
1643 case 'updated' :
1644 $message = __( 'Poll updated.', 'polldaddy' );
1645 break;
1646 case 'created' :
1647 $message = __( 'Poll created.', 'polldaddy' );
1648 if ( isset( $_GET['iframe'] ) ) {
1649 $message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . esc_attr( __( 'Embed in Post', 'polldaddy' ) ) . '" />';
1650 }
1651 break;
1652 case 'updated-style' :
1653 $message = __( 'Custom Style updated.', 'polldaddy' );
1654 break;
1655 case 'created-style' :
1656 $message = __( 'Custom Style created.', 'polldaddy' );
1657 break;
1658 case 'deleted-style' :
1659 $deleted = (int) $_GET['deleted'];
1660 if ( 1 == $deleted ) {
1661 $message = __( 'Custom Style deleted.', 'polldaddy' );
1662 } else {
1663 $message = sprintf(
1664 /* translators: %s is the number of styles deleted */
1665 _n( '%s Style Deleted.', '%s Custom Styles Deleted.', $deleted, 'polldaddy' ), number_format_i18n( $deleted ) );
1666 }
1667 break;
1668 case 'connected' :
1669 case 'imported-account' :
1670 $message = __( 'Account Linked.', 'polldaddy' );
1671 break;
1672 case 'api-key-not-added' :
1673 $message = __( 'There was a problem linking your account.', 'polldaddy' );
1674 break;
1675 case 'updated-options' :
1676 $message = __( 'Options Updated.', 'polldaddy' );
1677 break;
1678 case 'deleted-rating' :
1679 $deleted = (int) $_GET['deleted'];
1680 if ( 1 == $deleted ) {
1681 $message = __( 'Rating deleted.', 'polldaddy' );
1682 } else {
1683 $message = sprintf(
1684 /* translators: %s is the number of ratings deleted */
1685 _n( '%s Rating Deleted.', '%s Ratings Deleted.', $deleted, 'polldaddy' ), number_format_i18n( $deleted ) );
1686 }
1687 break;
1688 }//end switch
1689 }
1690
1691 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
1692
1693 if ( $is_POST ) {
1694 switch ( $GLOBALS['action'] ) {
1695 case 'create-poll' :
1696 $message = __( 'Error: An error has occurred; Poll not created.', 'polldaddy' );
1697 break;
1698 case 'edit-poll' :
1699 $message = __( 'Error: An error has occurred; Poll not updated.', 'polldaddy' );
1700 break;
1701 case 'account' :
1702 if ( 'import' == $_POST['account'] )
1703 $message = __( 'Error: An error has occurred; Account could not be imported. Perhaps your email address or password is incorrect?', 'polldaddy' );
1704 else
1705 $message = __( 'Error: An error has occurred; Account could not be created.', 'polldaddy' );
1706 break;
1707 }//end switch
1708 }
1709
1710 if ( !$message )
1711 return;
1712 ?>
1713 <div class='updated'><p><?php echo $message; ?></p></div>
1714 <?php
1715 $this->print_errors();
1716 }
1717
1718 function settings_page() {
1719 global $page, $action;
1720 ?>
1721 <div class="wrap" id="manage-polls">
1722 <div class="cs-wrapper">
1723 <?php
1724 $this->set_api_user_code();
1725
1726 if ( isset( $_GET['page'] ) ) { // phpcs:ignore
1727 $page = $_GET['page']; // phpcs:ignore
1728 }
1729 if ( 'crowdsignal-settings' === $page ) {
1730 if ( ! current_user_can( 'edit_others_posts' ) ) { // check user privileges has access to action.
1731 return;
1732 }
1733 $this->plugin_options();
1734 } elseif ( 'ratingsettings' === $page ) {
1735 if ( 'update-rating' === $action ) {
1736 $this->update_rating();
1737 }
1738
1739 $this->rating_settings();
1740 }
1741 ?>
1742 </div>
1743 </div>
1744 <?php
1745 }
1746
1747 function management_page() {
1748 global $page, $action, $poll, $style, $rating;
1749 $poll = (int) $poll;
1750 $style = (int) $style;
1751 $rating = esc_html( $rating );
1752 $wrap_style = $page === 'polls' ? 'polls' : 'ratings';
1753 ?>
1754
1755 <div class="wrap cs-dashboard__crowdsignal_<?php echo $wrap_style ; ?>_wrap" id="manage-polls">
1756 <div class="cs-wrapper">
1757 <?php
1758 if ( 'polls' === $page ) {
1759 ?><div class="cs-pre-wrap"></div><?php
1760 if ( ! $this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles' ), true ) ) { // check user privileges has access to action.
1761 $action = '';
1762 }
1763 switch ( $action ) {
1764 case 'preview':
1765 if ( isset( $_GET['iframe'] ) ) {
1766 if ( isset( $_GET['popup'] ) ) {
1767 ?>
1768 <h2 id="poll-list-header"><?php
1769 /* translators: %s is the URL to all polls */
1770 printf( __( 'Preview Poll <a href="%s" class="add-new-h2">All Polls</a>', 'polldaddy' ), esc_url( add_query_arg( array( 'action' => 'polls', 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1771 <?php
1772 }
1773 }
1774
1775 echo do_shortcode( "[crowdsignal poll=$poll cb=1]" );
1776
1777 wp_print_scripts( 'polldaddy-poll-js' );
1778 break;
1779 case 'results':
1780 ?>
1781 <h2 id="poll-list-header">
1782 <?php
1783 /* translators: %s is the URL to all polls, %s is the URL to edit poll */
1784 printf( __( 'Poll Results <a href="%1$s" class="add-new-h2">All Polls</a> <a href="%2$s" class="add-new-h2">Edit Poll</a>', 'polldaddy' ), esc_url( add_query_arg( array( 'action' => 'polls', 'poll' => false, 'message' => false ) ) ), esc_url( add_query_arg( array( 'action' => 'edit-poll', 'poll' => $poll, 'message' => false ) ) ) ); ?>
1785 </h2>
1786 <?php
1787 $this->poll_results_page( $poll );
1788 break;
1789 case 'edit':
1790 case 'edit-poll':
1791 ?>
1792 <h2 id="poll-list-header">
1793 <?php
1794 printf(
1795 /* translators: %s is the URL to all polls, %s is the URL to view results */
1796 __( 'Edit Poll <a href="%1$s" class="add-new-h2">All Polls</a> <a href="%2$s" class="add-new-h2">View Results</a>', 'polldaddy' ),
1797 esc_url( add_query_arg( array( 'action' => 'polls', 'poll' => false, 'message' => false ) ) ),
1798 esc_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll, 'message' => false ) ) )
1799 );
1800 ?>
1801 </h2>
1802 <?php
1803
1804 $this->poll_edit_form( $poll );
1805 break;
1806 case 'create-poll':
1807 ?>
1808 <h2 id="poll-list-header"><?php
1809 /* translators: %s is the URL to all polls */
1810 printf( __( 'Add New Poll <a href="%s" class="add-new-h2">All Polls</a>', 'polldaddy' ), esc_url( add_query_arg( array( 'action' => 'polls', 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1811 <?php
1812 $this->poll_edit_form();
1813 break;
1814 case 'list-styles':
1815 ?>
1816 <h2 id="polldaddy-header">
1817 <?php
1818 if ( $this->is_author ) {
1819 /* translators: %s is the URL to add new style */
1820 printf( __( 'Custom Styles <a href="%s" class="add-new-h2">Add New</a>', 'polldaddy' ), esc_url( add_query_arg( array( 'action' => 'create-style', 'poll' => false, 'message' => false ) ) ) );
1821 } else {
1822 _e( 'Custom Styles', 'polldaddy' );
1823 }
1824 ?>
1825 </h2>
1826 <?php
1827 $this->styles_table();
1828 break;
1829 case 'edit-style':
1830 ?>
1831 <h2 id="polldaddy-header">
1832 <?php
1833 /* translators: %s is the URL to list styles */
1834 printf( __( 'Edit Style <a href="%s" class="add-new-h2">List Styles</a>', 'polldaddy' ), esc_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?>
1835 </h2>
1836 <?php
1837
1838 $this->style_edit_form( $style );
1839 break;
1840 case 'create-style':
1841 ?>
1842 <h2 id="polldaddy-header">
1843 <?php
1844 /* translators: %s is the URL to list styles */
1845 printf( __( 'Create Style <a href="%s" class="add-new-h2">List Styles</a>', 'polldaddy' ), esc_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?>
1846 </h2>
1847 <?php
1848 $this->style_edit_form();
1849 break;
1850 case 'landing-page':
1851 $this->render_landing_page();
1852 break;
1853 default:
1854 $view_type = 'me'; // default (and only) config for self-hosted.
1855
1856 // cascaded attempt to "show something".
1857 if ( ! $this->has_items_for_view( $view_type ) ) {
1858 $this->render_landing_page();
1859 break;
1860 }
1861
1862 $this->polls_table( $view_type );
1863 } //end switch.
1864 } elseif ( 'ratings' === $page ) {
1865 if ( ! $this->is_admin && ! in_array( $action, array( 'delete', 'reports' ), true ) ) { // check user privileges has access to action.
1866 $action = 'reports';
1867 }
1868
1869 switch ( $action ) {
1870 case 'delete':
1871 case 'reports':
1872 $this->rating_reports();
1873 break;
1874 }//end switch
1875 }
1876 ?>
1877 </div>
1878 </div>
1879 <?php
1880 }
1881
1882 private function render_landing_page() {
1883 $this->render_partial(
1884 'crowdsignal-landing-page',
1885 array(
1886 'resource_path' => $this->base_url,
1887 )
1888 );
1889 }
1890
1891 private function has_items_for_view( $view = 'me' ) {
1892 if ( isset( $this->has_items[ $view ] ) ) {
1893 return $this->has_items[ $view ];
1894 }
1895
1896 $guid = WP_POLLDADDY__PARTNERGUID;
1897 // re-write the user_code based on the intended view.
1898 switch ( $view ) {
1899 case 'csforms':
1900 $this->user_code = get_option( 'crowdsignal_user_code' );
1901 $guid = get_option( 'crowdsignal_api_key' );
1902 break;
1903 case 'blog':
1904 $this->user_code = $this->get_usercode();
1905 break;
1906 default:
1907 $this->user_code = get_option( 'pd-usercode-' . $this->id );
1908 }
1909
1910 if ( empty( $this->user_code ) ) {
1911 // use set_api_user_code last attempt.
1912 $this->set_api_user_code();
1913 }
1914
1915 $polldaddy = $this->get_client( $guid, $this->user_code );
1916 $polldaddy->reset();
1917
1918 $polls_object = $polldaddy->get_items( 1, 1, 0, 'csforms' === $view ? get_site_url() : '' );
1919
1920 if ( ! $polls_object ) {
1921 return false;
1922 }
1923 $polls = & $polls_object->item;
1924
1925 if ( isset( $polls_object->_total ) ) {
1926 $total_polls = $polls_object->_total;
1927 } else {
1928 $total_polls = count( $polls );
1929 }
1930
1931 $this->has_items[ $view ] = $total_polls > 0;
1932
1933 return $this->has_items[ $view ];
1934 }
1935
1936
1937 function polls_table( $view = 'me' ) {
1938 $page = 1;
1939 if ( isset( $_GET['paged'] ) ) { // phpcs:ignore
1940 $page = absint( $_GET['paged'] ); // phpcs:ignore
1941 }
1942
1943 $guid = WP_POLLDADDY__PARTNERGUID;
1944 // re-write the user_code based on the intended view.
1945 switch ( $view ) {
1946 case 'csforms':
1947 $this->user_code = get_option( 'crowdsignal_user_code' );
1948 $guid = get_option( 'crowdsignal_api_key' );
1949 break;
1950 case 'blog':
1951 $this->user_code = $this->get_usercode();
1952 break;
1953 default:
1954 $this->user_code = get_option( 'pd-usercode-' . $this->id );
1955 }
1956
1957 if ( empty( $this->user_code ) ) {
1958 // use set_api_user_code last attempt.
1959 $this->set_api_user_code();
1960 }
1961
1962 $polldaddy = $this->get_client( $guid, $this->user_code );
1963 $polldaddy->reset();
1964
1965 $items = $polldaddy->get_items( $page, 20, 0, 'csforms' === $view ? get_site_url() : '' );
1966
1967 $this->parse_errors( $polldaddy );
1968 if ( in_array( 'API Key Not Found, 890', $polldaddy->errors, true ) ) {
1969 return false;
1970 }
1971
1972 $total = $items->_total;
1973 $items = $items->item;
1974 $connected_account = $polldaddy->get_account();
1975
1976 $this->print_errors();
1977
1978 $page_links = paginate_links(
1979 array(
1980 'base' => add_query_arg( 'paged', '%#%' ),
1981 'format' => '',
1982 'total' => ceil( $total / 10 ),
1983 'current' => $page,
1984 'prev_text' => '&laquo;',
1985 'next_text' => '&raquo;',
1986 )
1987 );
1988
1989 global $current_user;
1990
1991 $current_user_name = ( $current_user instanceof WP_User ) && $current_user->first_name && $current_user->last_name
1992 ? "{$current_user->first_name} {$current_user->last_name}"
1993 : $current_user->user_login;
1994
1995 $global_user_id = (int) get_option( 'polldaddy_usercode_user' );
1996 $global_user_name = '';
1997 if ( $global_user_id ) {
1998 $global_user_account = new WP_User( $global_user_id );
1999 $global_user_name = $global_user_account && $global_user_account->first_name && $global_user_account->last_name
2000 ? "{$global_user_account->first_name} {$global_user_account->last_name}"
2001 : ( $global_user_account ? $global_user_account->user_login : __( 'Disconnected user', 'polldaddy' ) );
2002 }
2003
2004 // reset $this vars at this point so we show a consistent list with less "tabbed" options.
2005 $this->has_crowdsignal_blocks = false;
2006 $this->multiple_accounts = false;
2007
2008 $cs_forms_account = $this->get_crowdsignal_connected_account();
2009
2010 switch ( $view ) {
2011 case 'csforms':
2012 $current_user_owns_connection = ! empty( $cs_forms_account ) && $cs_forms_account->email === $current_user->user_email;
2013 break;
2014 default: // me and blog case.
2015 $current_user_owns_connection = ! empty( $connected_account ) && $connected_account->email === $current_user->user_email;
2016 }
2017
2018 $this->render_partial(
2019 'polls-table',
2020 array(
2021 'page_links' => $page_links,
2022 'items' => $items,
2023 'can_manage_options' => current_user_can( 'manage_options' ),
2024 'connected_account_email' => ! empty( $connected_account ) ? $connected_account->email : '',
2025 'is_author' => $this->is_author,
2026 'is_admin' => $this->is_admin,
2027 'current_user_name' => $current_user_name,
2028 'resource_path' => $this->base_url,
2029 'has_multiple_accounts' => $this->multiple_accounts && $this->has_items_for_view( 'blog' ),
2030 'global_user_id' => $global_user_id,
2031 'global_user_name' => $global_user_name,
2032 'current_user_owns_connection' => $current_user_owns_connection,
2033 'user_id' => (int) $this->id,
2034 'view' => $view,
2035 'has_crowdsignal_blocks' => $this->has_crowdsignal_blocks && $this->has_items_for_view( 'csforms' ),
2036 'cs_forms_account_email' => $this->has_crowdsignal_blocks && $cs_forms_account ? $cs_forms_account->email : '',
2037 )
2038 );
2039 }
2040
2041 private function get_crowdsignal_connected_account() {
2042 if ( $this->has_crowdsignal_blocks ) {
2043 $polldaddy = $this->get_client( get_option( 'crowdsignal_api_key' ), get_option( 'crowdsignal_user_code' ) );
2044 $polldaddy->reset();
2045 return $polldaddy->get_account();
2046 }
2047
2048 return false;
2049 }
2050
2051
2052 function poll_table_add_option() {}
2053
2054 function poll_table_extra() {}
2055
2056 function poll_edit_form( $poll_id = 1 ) {
2057 $poll_id = (int) $poll_id;
2058
2059 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2060 $polldaddy->reset();
2061
2062 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
2063
2064 if ( $poll_id ) {
2065 $poll = $polldaddy->get_poll( $poll_id );
2066 $this->parse_errors( $polldaddy );
2067
2068 if ( !$this->can_edit( $poll ) ) {
2069 $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
2070 }
2071
2072 if ( $poll_id == 1 ) {
2073 $poll->answers = array();
2074 $poll_id = 0;
2075 }
2076
2077 } else {
2078 $poll = polldaddy_poll( array(), null, false );
2079 }
2080
2081 $question = $is_POST ? esc_attr( stripslashes( $_POST['question'] ) ) : esc_attr( $poll->question );
2082
2083 $answers = $media = $mediaType = array();
2084 if ( $is_POST ) {
2085 if ( isset( $_POST['mediaType'] ) )
2086 $mediaType = $_POST['mediaType'];
2087
2088 if ( isset( $_POST['media'] ) ) {
2089 $mc = $_POST['media'];
2090
2091 foreach ( $mc as $key => $value ) {
2092 if ( $mediaType[$key] == 1 ) {
2093 $media[$key] = $polldaddy->get_media( $value );
2094 }
2095 }
2096 }
2097
2098 if ( isset( $_POST['answer'] ) )
2099 foreach ( $_POST['answer'] as $answer_id => $answer )
2100 $answers[esc_attr($answer_id)] = esc_attr( stripslashes($answer) );
2101 } elseif ( isset( $poll->answers->answer ) ) {
2102 foreach ( $poll->answers->answer as $answer ) {
2103 $answers[(int) $answer->_id] = esc_attr( $answer->text );
2104
2105 if ( $answer->mediaType == 1 && !empty( $answer->mediaCode ) ) {
2106 $polldaddy->reset();
2107 $media[$answer->_id] = $polldaddy->get_media( $answer->mediaCode );
2108 $mediaType[$answer->_id] = 1;
2109 }
2110 elseif ( $answer->mediaType == 2 ) {
2111 $mediaType[$answer->_id] = 2;
2112 }
2113 }
2114
2115 if ( isset( $poll->mediaCode ) && isset( $poll->mediaType ) ) {
2116 if ( $poll->mediaType == 1 && !empty( $poll->mediaCode ) ) {
2117 $polldaddy->reset();
2118 $media[999999999] = $polldaddy->get_media( $poll->mediaCode );
2119 $mediaType[999999999] = 1;
2120 }
2121 elseif ( $poll->mediaType == 2 ) {
2122 $mediaType[999999999] = 2;
2123 }
2124 }
2125 }
2126 $this->print_errors();
2127
2128 $view_vars = [
2129 'delete_media_link' => $delete_media_link,
2130 'polldaddy' => $polldaddy,
2131 'controller' => $this,
2132 'poll' => $poll,
2133 'poll_id' => $poll_id,
2134 'is_post' => $is_POST,
2135 'base_url' => $this->base_url,
2136 'preview_img_dir' => plugins_url( 'img', __FILE__ ),
2137 'question' => $question,
2138 'answers' => $answers,
2139 'media' => $media,
2140 'media_type' => $mediaType,
2141 ];
2142
2143 $this->render_partial( 'poll-edit-form', $view_vars );
2144 }
2145
2146 function poll_results_page( $poll_id ) {
2147 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2148 $polldaddy->reset();
2149
2150 $results = $polldaddy->get_poll_results( $poll_id );
2151 $poll = $polldaddy->get_poll( $poll_id );
2152
2153 ?>
2154 <h3 style="line-height:21px;"><?php echo $poll->question; ?></h3>
2155 <table class="poll-results widefat">
2156 <thead>
2157 <tr>
2158 <th scope="col" class="column-title" style="width:40%;"><?php _e( 'Answer', 'polldaddy' ); ?></th>
2159 <th scope="col" class="column-vote" style="width:10%;text-align:center;"><?php _e( 'Votes', 'polldaddy' ); ?></th>
2160 <th scope="col" class="column-vote" style="width:10%;text-align:center;"><?php _e( 'Percent', 'polldaddy' ); ?></th>
2161 <th scope="col" class="column-vote" style="width:40%;">&nbsp;</th>
2162 </tr>
2163 </thead>
2164 <tbody>
2165
2166 <?php
2167 $class = '';
2168 foreach ( $results->answers as $answer ) :
2169 $answer->text = trim( strip_tags( $answer->text ) );
2170 if ( strlen( $answer->text ) == 0 ) {
2171 $answer->text = '-- empty HTML tag --';
2172 }
2173
2174 $class = $class ? '' : ' class="alternate"';
2175 /* translators: %s is the URL to other answers results */
2176 $content = $results->others && 'Other answer…' === $answer->text ? sprintf( __( 'Other (<a href="%s">see below</a>)', 'polldaddy' ), '#other-answers-results' ) : esc_html( $answer->text );
2177
2178 ?>
2179
2180 <tr<?php echo $class; ?>>
2181 <th scope="row" style="vertical-align:bottom" class="column-title"><?php echo $content; ?></th>
2182 <td class="column-vote" style="text-align:center;vertical-align:middle;">
2183 <?php echo number_format_i18n( $answer->_total ); ?>
2184 </td>
2185 <td style="text-align:center;vertical-align:middle;">
2186 <?php echo number_format_i18n( $answer->_percent, 2 ); ?>%
2187 </td>
2188 <td style="vertical-align:middle;">
2189 <span class="result-bar" style="width: <?php echo number_format( $answer->_percent, 2 ); ?>%;">&nbsp;</span>
2190 </td>
2191 </tr>
2192 <?php
2193 endforeach;
2194 ?>
2195
2196 </tbody>
2197 </table>
2198
2199 <?php
2200
2201 if ( !$results->others )
2202 return;
2203 ?>
2204
2205 <table id="other-answers-results" class="poll-others widefat">
2206 <thead>
2207 <tr>
2208 <th scope="col" class="column-title"><?php _e( 'Other Answer', 'polldaddy' ); ?></th>
2209 <th scope="col" class="column-vote"><?php _e( 'Votes', 'polldaddy' ); ?></th>
2210 </tr>
2211 </thead>
2212 <tbody>
2213
2214 <?php
2215 $class = '';
2216 $others = array_count_values( $results->others );
2217 arsort( $others );
2218 foreach ( $others as $other => $freq ) :
2219 $class = $class ? '' : ' class="alternate"';
2220 ?>
2221
2222 <tr<?php echo $class; ?>>
2223 <th scope="row" class="column-title"><?php echo esc_html( $other ); ?></th>
2224 <td class="column-vote"><?php echo number_format_i18n( $freq ); ?></td>
2225 </tr>
2226 <?php
2227 endforeach;
2228 ?>
2229
2230 </tbody>
2231 </table>
2232
2233 <?php
2234 }
2235
2236 function styles_table() {
2237 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2238 $polldaddy->reset();
2239
2240 $styles_object = $polldaddy->get_styles();
2241
2242 $this->parse_errors( $polldaddy );
2243 $this->print_errors();
2244 $styles = & $styles_object->style;
2245 $class = '';
2246 $styles_exist = false;
2247
2248 foreach ( (array)$styles as $style ) :
2249 if ( (int) $style->_type == 1 ):
2250 $styles_exist = true;
2251 break;
2252 endif;
2253 endforeach;
2254 ?>
2255
2256 <form method="post" action="">
2257 <div class="tablenav">
2258 <div class="alignleft">
2259 <select name="action">
2260 <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
2261 <option value="delete-style"><?php _e( 'Delete', 'polldaddy' ); ?></option>
2262 </select>
2263 <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
2264 <?php wp_nonce_field( 'action-style_bulk' ); ?>
2265 </div>
2266 <div class="tablenav-pages"></div>
2267 </div>
2268
2269 <table class="widefat">
2270 <thead>
2271 <tr>
2272 <th id="cb" class="manage-column column-cb check-column" scope="col"><input type="checkbox" /></th>
2273 <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Style', 'polldaddy' ); ?></th>
2274 <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Last Modified', 'polldaddy' ); ?></th>
2275 </tr>
2276 </thead>
2277 <tbody>
2278
2279 <?php
2280 if ( $styles_exist ) :
2281 foreach ( $styles as $style ) :
2282 if ( (int) $style->_type == 1 ):
2283 $style_id = (int) $style->_id;
2284
2285 $class = $class ? '' : ' class="alternate"';
2286 $edit_link = esc_url( add_query_arg( array( 'action' => 'edit-style', 'style' => $style_id, 'message' => false ) ) );
2287 $delete_link = esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-style', 'style' => $style_id, 'message' => false ) ), "delete-style_$style_id" ) );
2288 list( $style_time ) = explode( '.', $style->date );
2289 $style_time = strtotime( $style_time );
2290 ?>
2291
2292 <tr<?php echo $class; ?>>
2293 <th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $style_id; ?>" name="style[]" /></th>
2294 <td class="post-title column-title">
2295 <?php if ( $edit_link ) : ?>
2296 <strong><a class="row-title" href="<?php echo esc_url( $edit_link ); ?>"><?php echo esc_html( $style->title ); ?></a></strong>
2297 <div class="row-actions">
2298 <span class="edit"><a href="<?php echo esc_url( $edit_link ); ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
2299 <?php else : ?>
2300 <strong><?php echo esc_html( $style->title ); ?></strong>
2301 <?php endif; ?>
2302
2303 <span class="delete"><a class="delete-poll delete" href="<?php echo esc_url( $delete_link ); ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a></span>
2304 </div>
2305 </td>
2306 <td class="date column-date"><abbr title="<?php echo date( __( 'Y/m/d g:i:s A', 'polldaddy' ), $style_time ); ?>"><?php echo date( __( 'Y/m/d', 'polldaddy' ), $style_time ); ?></abbr></td>
2307 </tr>
2308
2309 <?php
2310 endif;
2311 endforeach;
2312 else : // $styles
2313 ?>
2314
2315 <tr>
2316 <td colspan="4" id="empty-set">
2317
2318 <h3 style="margin-bottom:0px;"><?php _e( 'You haven\'t used our fancy style editor to create any custom styles!', 'polldaddy');?> </h3>
2319 <p style="margin-bottom:20px;"><?php _e( 'Why don\'t you go ahead and get started on that?', 'polldaddy' ); ?></p>
2320 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'create-style' ) ) ); ?>" class="button-primary"><?php _e( 'Create a Custom Style Now', 'polldaddy' ); ?></a>
2321
2322 </td>
2323 </tr>
2324 <?php endif; // $styles ?>
2325
2326 </tbody>
2327 </table>
2328 </form>
2329 <div class="tablenav">
2330 <div class="tablenav-pages"></div>
2331 </div>
2332 <br class="clear" />
2333
2334 <?php
2335 }
2336
2337 function style_edit_form( $style_id = 105 ) {
2338 $style_id = (int) $style_id;
2339
2340 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2341 $polldaddy->reset();
2342
2343 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
2344
2345 if ( $style_id ) {
2346 $style = $polldaddy->get_style( $style_id );
2347 $this->parse_errors( $polldaddy );
2348 } else {
2349 $style = polldaddy_style( array(), null, false );
2350 }
2351
2352 $style->css = trim( urldecode( $style->css ) );
2353
2354 $direction = 'ltr';
2355 if ( in_array( $style->_direction, array( 'ltr', 'rtl') ) )
2356 $direction = $style->_direction;
2357
2358 if ( $start = stripos( $style->css, '<data>' ) )
2359 $style->css = substr( $style->css, $start );
2360
2361 $preload_style_id = 0;
2362 $preload_style = null;
2363
2364 if ( isset ( $_REQUEST['preload'] ) ) {
2365 $preload_style_id = (int) $_REQUEST['preload'];
2366
2367 if ( $preload_style_id > 1000 || $preload_style_id < 100 )
2368 $preload_style_id = 0;
2369
2370 if ( $preload_style_id > 0 ) {
2371 $polldaddy->reset();
2372 $preload_style = $polldaddy->get_style( $preload_style_id );
2373 $this->parse_errors( $polldaddy );
2374 }
2375
2376 $preload_style->css = trim( urldecode( $preload_style->css ) );
2377
2378 if ( $start = stripos( $preload_style->css, '<data>' ) )
2379 $preload_style->css = substr( $preload_style->css, $start );
2380
2381 $style->css = $preload_style->css;
2382 }
2383
2384 $this->print_errors();
2385
2386 echo '<script language="javascript">var CSSXMLString = ' . wp_json_encode( $style->css ) . ';</script>';
2387 ?>
2388
2389 <form action="" method="post">
2390 <div id="poststuff">
2391 <div id="post-body">
2392 <br/>
2393 <table>
2394 <tr>
2395 <td class="pd-editor-label">
2396 <label class="CSSE_title_label"><?php _e( 'Style Name', 'polldaddy' ); ?></label>
2397 </td>
2398 <td>
2399 <div id="titlediv" style="margin:0px;">
2400 <div id="titlewrap">
2401 <input type="text" autocomplete="off" value="<?php echo $style_id > 1000 ? esc_html( $style->title ) : ''; ?>" tabindex="1" style="width:25em;" name="style-title" />
2402 </div>
2403 </div>
2404 </td>
2405 </tr>
2406 <tr>
2407 <td class="pd-editor-label">
2408 <label class="CSSE_title_label"><?php _e( 'Preload Basic Style', 'polldaddy' ); ?></label>
2409 </td>
2410 <td>
2411 <div class="CSSE_preload">
2412 <select id="preload_value">
2413 <option value="0"></option>
2414 <option value="102"><?php _e( 'Aluminum', 'polldaddy' ); ?></option>
2415 <option value="105"><?php _e( 'Plain White', 'polldaddy' ); ?></option>
2416 <option value="108"><?php _e( 'Plain Black', 'polldaddy' ); ?></option>
2417 <option value="111"><?php _e( 'Paper', 'polldaddy' ); ?></option>
2418 <option value="114"><?php _e( 'Skull Dark', 'polldaddy' ); ?></option>
2419 <option value="117"><?php _e( 'Skull Light', 'polldaddy' ); ?></option>
2420 <option value="157"><?php _e( 'Micro', 'polldaddy' ); ?></option>
2421 </select>
2422 <a tabindex="4" id="style-preload" href="javascript:preload_style();" class="button"><?php echo esc_attr( __( 'Load Style', 'polldaddy' ) ); ?></a>
2423 </div>
2424 </td>
2425 </tr>
2426 <tr>
2427 <td class="pd-editor-label">
2428 <label class="CSSE_title_label"><?php _e( 'Text Direction', 'polldaddy' ); ?></label>
2429 </td>
2430 <td>
2431 <div class="CSSE_rtl_ltr">
2432 <a tabindex="4" id="style-force-rtl" href="#" onclick="javascript:force_rtl();" class="button" style="<?php echo $direction == 'rtl' ? 'display:none;' : '' ;?>"><?php echo esc_attr( __( 'Force RTL', 'polldaddy' ) ); ?></a>
2433 <a tabindex="4" id="style-force-ltr" href="#" onclick="javascript:force_ltr();" class="button" style="<?php echo $direction == 'ltr' ? 'display:none;' : '' ;?>"><?php echo esc_attr( __( 'Force LTR', 'polldaddy' ) ); ?></a>
2434 </div>
2435 </td>
2436 </tr>
2437 </table>
2438
2439 <h3><?php _e( 'Style Editor', 'polldaddy' ); ?></h3>
2440
2441 <table>
2442 <tr>
2443 <td class="pd-editor-label"><label for="styleName"><?php _e( 'Select a template part to edit:', 'polldaddy' ); ?></label></td>
2444 <td>
2445 <select id="styleName" onchange="renderStyleEdit(this.value);">
2446 <option value="pds-box" selected="selected"><?php _e( 'Poll Box', 'polldaddy' ); ?></option>
2447 <option value="pds-question-top"><?php _e( 'Question', 'polldaddy' ); ?></option>
2448 <option value="pds-answer-group"><?php _e( 'Answer Group', 'polldaddy' ); ?></option>
2449 <option value="pds-answer-input"><?php _e( 'Answer Check', 'polldaddy' ); ?></option>
2450 <option value="pds-answer"><?php _e( 'Answers', 'polldaddy' ); ?></option>
2451 <option value="pds-textfield"><?php _e( 'Other Input', 'polldaddy' ); ?></option>
2452 <option value="pds-vote-button"><?php _e( 'Vote Button', 'polldaddy' ); ?></option>
2453 <option value="pds-link"><?php _e( 'Links', 'polldaddy' ); ?></option>
2454 <option value="pds-feedback-group"><?php _e( 'Feedback Group', 'polldaddy' ); ?></option>
2455 <option value="pds-feedback-result"><?php _e( 'Results Group', 'polldaddy' ); ?></option>
2456 <option value="pds-feedback-per"><?php _e( 'Results Percent', 'polldaddy' ); ?></option>
2457 <option value="pds-feedback-votes"><?php _e( 'Results Votes', 'polldaddy' ); ?></option>
2458 <option value="pds-answer-text"><?php _e( 'Results Text', 'polldaddy' ); ?></option>
2459 <option value="pds-answer-feedback"><?php _e( 'Results Background', 'polldaddy' ); ?></option>
2460 <option value="pds-answer-feedback-bar"><?php _e( 'Results Bar', 'polldaddy' ); ?></option>
2461 <option value="pds-totalvotes-inner"><?php _e( 'Total Votes', 'polldaddy' ); ?></option>
2462 </select>
2463
2464 </td>
2465 </tr>
2466
2467 </table>
2468
2469
2470 <table width="100%">
2471 <tr>
2472 <td valign="top">
2473 <table class="CSSE_main">
2474 <tr>
2475 <td class="CSSE_main_l" valign="top">
2476 <div class="off" id="D_Font">
2477 <a href="javascript:CSSE_changeView('Font');" id="A_Font" class="Aoff"><?php _e( 'Font', 'polldaddy' ); ?></a>
2478 </div>
2479 <div class="on" id="D_Background">
2480 <a href="javascript:CSSE_changeView('Background');" id="A_Background" class="Aon"><?php _e( 'Background', 'polldaddy' ); ?></a>
2481 </div>
2482 <div class="off" id="D_Border">
2483 <a href="javascript:CSSE_changeView('Border');" id="A_Border" class="Aoff"><?php _e( 'Border', 'polldaddy' ); ?></a>
2484 </div>
2485 <div class="off" id="D_Margin">
2486 <a href="javascript:CSSE_changeView('Margin');" id="A_Margin" class="Aoff"><?php _e( 'Margin', 'polldaddy' ); ?></a>
2487 </div>
2488 <div class="off" id="D_Padding">
2489 <a href="javascript:CSSE_changeView('Padding');" id="A_Padding" class="Aoff"><?php _e( 'Padding', 'polldaddy' ); ?></a>
2490 </div>
2491 <div class="off" id="D_Scale">
2492 <a href="javascript:CSSE_changeView('Scale');" id="A_Scale" class="Aoff"><?php _e( 'Width', 'polldaddy' ); ?></a>
2493 </div>
2494 <div class="off" id="D_Height">
2495 <a href="javascript:CSSE_changeView('Height');" id="A_Height" class="Aoff"><?php _e( 'Height', 'polldaddy' ); ?></a>
2496 </div>
2497 <div class="off" id="D_Position">
2498 <a href="javascript:CSSE_changeView('Position');" id="A_Position" class="Aoff"><?php _e( 'Position', 'polldaddy' ); ?></a>
2499 </div>
2500 </td>
2501 <td class="CSSE_main_r" valign="top">
2502 <table class="CSSE_sub">
2503 <tr>
2504 <td class="top"/>
2505 </tr>
2506 <tr>
2507 <td class="mid">
2508 <!-- Font Table -->
2509 <table class="CSSE_edit" id="editFont" style="display:none;">
2510 <tr>
2511 <td width="85"><?php _e( 'Font Size', 'polldaddy' ); ?>:</td>
2512 <td>
2513 <select id="font-size" onchange="bind(this);">
2514 <option value="6px">6px</option>
2515 <option value="8px">8px</option>
2516 <option value="9px">9px</option>
2517 <option value="10px">10px</option>
2518 <option value="11px">11px</option>
2519 <option value="12px">12px</option>
2520 <option value="13px">13px</option>
2521 <option value="14px">14px</option>
2522 <option value="15px">15px</option>
2523 <option value="16px">16px</option>
2524 <option value="18px">18px</option>
2525 <option value="20px">20px</option>
2526 <option value="24px">24px</option>
2527 <option value="30px">30px</option>
2528 <option value="36px">36px</option>
2529 </select>
2530 </td>
2531 </tr>
2532 <tr>
2533 <td><?php _e( 'Font Size', 'polldaddy' ); ?></td>
2534 <td>
2535 <select id="font-family" onchange="bind(this);">
2536 <option value="Arial">Arial</option>
2537 <option value="Comic Sans MS">Comic Sans MS</option>
2538 <option value="Courier">Courier</option>
2539 <option value="Georgia">Georgia</option>
2540 <option value="Lucida Grande">Lucida Grande</option>
2541 <option value="Trebuchet MS">Trebuchet MS</option>
2542 <option value="Times">Times</option>
2543 <option value="Verdana">Verdana</option>
2544 </select>
2545 </td>
2546 </tr>
2547 <tr>
2548 <td><?php _e( 'Color', 'polldaddy' ); ?> (#hex):</td>
2549 <td>
2550 <input type="text" maxlength="11" id="color" class="elmColor jscolor-picker" onblur="bind(this);" style="float:left;"/>
2551 </td>
2552 </tr>
2553 <tr>
2554 <td><?php _e( 'Bold', 'polldaddy' ); ?>:</td>
2555 <td>
2556 <input type="checkbox" id="font-weight" value="bold" onclick="bind(this);"/>
2557 </td>
2558 </tr>
2559 <tr>
2560 <td><?php _e( 'Italic', 'polldaddy' ); ?>:</td>
2561 <td>
2562 <input type="checkbox" id="font-style" value="italic" onclick="bind(this);"/>
2563 </td>
2564 </tr>
2565 <tr>
2566 <td><?php _e( 'Underline', 'polldaddy' ); ?>:</td>
2567 <td>
2568 <input type="checkbox" id="text-decoration" value="underline" onclick="bind(this);"/>
2569 </td>
2570 </tr>
2571 <tr>
2572 <td><?php _e( 'Line Height', 'polldaddy' ); ?>:</td>
2573 <td>
2574 <select id="line-height" onchange="bind(this);">
2575 <option value="6px">6px</option>
2576 <option value="8px">8px</option>
2577 <option value="9px">9px</option>
2578 <option value="10px">10px</option>
2579 <option value="11px">11px</option>
2580 <option value="12px">12px</option>
2581 <option value="13px">13px</option>
2582 <option value="14px">14px</option>
2583 <option value="15px">15px</option>
2584 <option value="16px">16px</option>
2585 <option value="18px">18px</option>
2586 <option value="20px">20px</option>
2587 <option value="24px">24px</option>
2588 <option value="30px">30px</option>
2589 <option value="36px">36px</option>
2590 </select>
2591 </td>
2592 </tr>
2593 <tr>
2594 <td><?php _e( 'Align', 'polldaddy' ); ?>:</td>
2595 <td>
2596 <select id="text-align" onchange="bind(this);">
2597 <option value="left"><?php _e( 'Left', 'polldaddy' ); ?></option>
2598 <option value="center"><?php _e( 'Center', 'polldaddy' ); ?></option>
2599 <option value="right"><?php _e( 'Right', 'polldaddy' ); ?></option>
2600 </select>
2601 </td>
2602 </tr>
2603 </table>
2604 <!-- Background Table -->
2605 <table class="CSSE_edit" id="editBackground" style="display:none;">
2606 <tr>
2607 <td width="85"><?php _e( 'Color', 'polldaddy' ); ?> (#hex):</td>
2608 <td>
2609 <input type="text" maxlength="11" id="background-color" class="elmColor jscolor-picker" onblur="bind(this);"/>
2610 </td>
2611 </tr>
2612 <tr>
2613 <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>
2614 <td>
2615 <input type="text" id="background-image" onblur="bind(this);"/>
2616 </td>
2617 </tr>
2618 <tr>
2619 <td><?php _e( 'Image Repeat', 'polldaddy' ); ?>:</td>
2620 <td>
2621 <select id="background-repeat" onchange="bind(this);">
2622 <option value="repeat"><?php _e( 'repeat', 'polldaddy' ); ?></option>
2623 <option value="no-repeat"><?php _e( 'no-repeat', 'polldaddy' ); ?></option>
2624 <option value="repeat-x"><?php _e( 'repeat-x', 'polldaddy' ); ?></option>
2625 <option value="repeat-y"><?php _e( 'repeat-y', 'polldaddy' ); ?></option>
2626 </select>
2627 </td>
2628 </tr>
2629 <tr>
2630 <td><?php _e( 'Image Position', 'polldaddy' ); ?>:</td>
2631 <td>
2632 <select id="background-position" onchange="bind(this);">
2633 <option value="left top"><?php _e( 'left top', 'polldaddy' ); ?></option>
2634 <option value="left center"><?php _e( 'left center', 'polldaddy' ); ?></option>
2635 <option value="left bottom"><?php _e( 'left bottom', 'polldaddy' ); ?></option>
2636 <option value="center top"><?php _e( 'center top', 'polldaddy' ); ?></option>
2637 <option value="center center"><?php _e( 'center center', 'polldaddy' ); ?></option>
2638 <option value="center bottom"><?php _e( 'center bottom', 'polldaddy' ); ?></option>
2639 <option value="right top"><?php _e( 'right top', 'polldaddy' ); ?></option>
2640 <option value="right center"><?php _e( 'right center', 'polldaddy' ); ?></option>
2641 <option value="right bottom"><?php _e( 'right bottom', 'polldaddy' ); ?></option>
2642 </select>
2643 </td>
2644 </tr>
2645 </table>
2646 <!-- Border Table -->
2647 <table class="CSSE_edit" id="editBorder" style="display:none;">
2648 <tr>
2649 <td width="85"><?php _e( 'Width', 'polldaddy' ); ?>:</td>
2650 <td>
2651 <select id="border-width" onchange="bind(this);">
2652 <option value="0px">0px</option>
2653 <option value="1px">1px</option>
2654 <option value="2px">2px</option>
2655 <option value="3px">3px</option>
2656 <option value="4px">4px</option>
2657 <option value="5px">5px</option>
2658 <option value="6px">6px</option>
2659 <option value="7px">7px</option>
2660 <option value="8px">8px</option>
2661 <option value="9px">9px</option>
2662 <option value="10px">10px</option>
2663 <option value="11px">11px</option>
2664 <option value="12px">12px</option>
2665 <option value="13px">13px</option>
2666 <option value="14px">14px</option>
2667 <option value="15px">15px</option>
2668 <option value="16px">16px</option>
2669 <option value="17px">17px</option>
2670 <option value="18px">18px</option>
2671 <option value="19px">19px</option>
2672 <option value="20px">20px</option>
2673 <option value="21px">21px</option>
2674 <option value="22px">22px</option>
2675 <option value="23px">23px</option>
2676 <option value="24px">24px</option>
2677 <option value="25px">25px</option>
2678 <option value="26px">26px</option>
2679 <option value="27px">27px</option>
2680 <option value="28px">28px</option>
2681 <option value="29px">29px</option>
2682 <option value="30px">30px</option>
2683 </select>
2684 </td>
2685 </tr>
2686 <tr>
2687 <td><?php _e( 'Style', 'polldaddy' ); ?>:</td>
2688 <td>
2689 <select id="border-style" onchange="bind(this);">
2690 <option value="none"><?php _e( 'none', 'polldaddy' ); ?></option>
2691 <option value="solid"><?php _e( 'solid', 'polldaddy' ); ?></option>
2692 <option value="dotted"><?php _e( 'dotted', 'polldaddy' ); ?></option>
2693 <option value="dashed"><?php _e( 'dashed', 'polldaddy' ); ?></option>
2694 <option value="double"><?php _e( 'double', 'polldaddy' ); ?></option>
2695 <option value="groove"><?php _e( 'groove', 'polldaddy' ); ?></option>
2696 <option value="inset"><?php _e( 'inset', 'polldaddy' ); ?></option>
2697 <option value="outset"><?php _e( 'outset', 'polldaddy' ); ?></option>
2698 <option value="ridge"><?php _e( 'ridge', 'polldaddy' ); ?></option>
2699 <option value="hidden"><?php _e( 'hidden', 'polldaddy' ); ?></option>
2700 </select>
2701 </td>
2702 </tr>
2703 <tr>
2704 <td><?php _e( 'Color', 'polldaddy' ); ?> (#hex):</td>
2705 <td>
2706 <input type="text" maxlength="11" class="elmColor jscolor-picker" id="border-color" onblur="bind(this);"/>
2707 </td>
2708 </tr>
2709 <tr>
2710 <td width="85"><?php _e( 'Rounded Corners', 'polldaddy' ); ?>:</td>
2711 <td>
2712 <select id="border-radius" onchange="bind(this);">
2713 <option value="0px">0px</option>
2714 <option value="1px">1px</option>
2715 <option value="2px">2px</option>
2716 <option value="3px">3px</option>
2717 <option value="4px">4px</option>
2718 <option value="5px">5px</option>
2719 <option value="6px">6px</option>
2720 <option value="7px">7px</option>
2721 <option value="8px">8px</option>
2722 <option value="9px">9px</option>
2723 <option value="10px">10px</option>
2724 <option value="11px">11px</option>
2725 <option value="12px">12px</option>
2726 <option value="13px">13px</option>
2727 <option value="14px">14px</option>
2728 <option value="15px">15px</option>
2729 <option value="16px">16px</option>
2730 <option value="17px">17px</option>
2731 <option value="18px">18px</option>
2732 <option value="19px">19px</option>
2733 <option value="20px">20px</option>
2734 <option value="21px">21px</option>
2735 <option value="22px">22px</option>
2736 <option value="23px">23px</option>
2737 <option value="24px">24px</option>
2738 <option value="25px">25px</option>
2739 <option value="26px">26px</option>
2740 <option value="27px">27px</option>
2741 <option value="28px">28px</option>
2742 <option value="29px">29px</option>
2743 <option value="30px">30px</option>
2744 </select>
2745 <br/>
2746 <?php _e( 'Not supported in Internet Explorer.', 'polldaddy' ); ?>
2747 </td>
2748 </tr>
2749 </table>
2750 <!-- Margin Table -->
2751 <table class="CSSE_edit" id="editMargin" style="display:none;">
2752 <tr>
2753 <td width="85"><?php _e( 'Top', 'polldaddy' ); ?>: </td>
2754 <td>
2755 <select id="margin-top" onchange="bind(this);">
2756 <option value="0px">0px</option>
2757 <option value="1px">1px</option>
2758 <option value="2px">2px</option>
2759 <option value="3px">3px</option>
2760 <option value="4px">4px</option>
2761 <option value="5px">5px</option>
2762 <option value="6px">6px</option>
2763 <option value="7px">7px</option>
2764 <option value="8px">8px</option>
2765 <option value="9px">9px</option>
2766 <option value="10px">10px</option>
2767 <option value="11px">11px</option>
2768 <option value="12px">12px</option>
2769 <option value="13px">13px</option>
2770 <option value="14px">14px</option>
2771 <option value="15px">15px</option>
2772 <option value="16px">16px</option>
2773 <option value="17px">17px</option>
2774 <option value="18px">18px</option>
2775 <option value="19px">19px</option>
2776 <option value="20px">20px</option>
2777 <option value="21px">21px</option>
2778 <option value="22px">22px</option>
2779 <option value="23px">23px</option>
2780 <option value="24px">24px</option>
2781 <option value="25px">25px</option>
2782 <option value="26px">26px</option>
2783 <option value="27px">27px</option>
2784 <option value="28px">28px</option>
2785 <option value="29px">29px</option>
2786 <option value="30px">30px</option>
2787 </select>
2788 </td>
2789 </tr>
2790 <tr>
2791 <td><?php _e( 'Right', 'polldaddy' ); ?>:</td>
2792 <td>
2793 <select id="margin-right" onchange="bind(this);">
2794 <option value="0px">0px</option>
2795 <option value="1px">1px</option>
2796 <option value="2px">2px</option>
2797 <option value="3px">3px</option>
2798 <option value="4px">4px</option>
2799 <option value="5px">5px</option>
2800 <option value="6px">6px</option>
2801 <option value="7px">7px</option>
2802 <option value="8px">8px</option>
2803 <option value="9px">9px</option>
2804 <option value="10px">10px</option>
2805 <option value="11px">11px</option>
2806 <option value="12px">12px</option>
2807 <option value="13px">13px</option>
2808 <option value="14px">14px</option>
2809 <option value="15px">15px</option>
2810 <option value="16px">16px</option>
2811 <option value="17px">17px</option>
2812 <option value="18px">18px</option>
2813 <option value="19px">19px</option>
2814 <option value="20px">20px</option>
2815 <option value="21px">21px</option>
2816 <option value="22px">22px</option>
2817 <option value="23px">23px</option>
2818 <option value="24px">24px</option>
2819 <option value="25px">25px</option>
2820 <option value="26px">26px</option>
2821 <option value="27px">27px</option>
2822 <option value="28px">28px</option>
2823 <option value="29px">29px</option>
2824 <option value="30px">30px</option>
2825 </select>
2826 </td>
2827 </tr>
2828 <tr>
2829 <td><?php _e( 'Bottom', 'polldaddy' ); ?>:</td>
2830 <td>
2831 <select id="margin-bottom" onchange="bind(this);">
2832 <option value="0px">0px</option>
2833 <option value="1px">1px</option>
2834 <option value="2px">2px</option>
2835 <option value="3px">3px</option>
2836 <option value="4px">4px</option>
2837 <option value="5px">5px</option>
2838 <option value="6px">6px</option>
2839 <option value="7px">7px</option>
2840 <option value="8px">8px</option>
2841 <option value="9px">9px</option>
2842 <option value="10px">10px</option>
2843 <option value="11px">11px</option>
2844 <option value="12px">12px</option>
2845 <option value="13px">13px</option>
2846 <option value="14px">14px</option>
2847 <option value="15px">15px</option>
2848 <option value="16px">16px</option>
2849 <option value="17px">17px</option>
2850 <option value="18px">18px</option>
2851 <option value="19px">19px</option>
2852 <option value="20px">20px</option>
2853 <option value="21px">21px</option>
2854 <option value="22px">22px</option>
2855 <option value="23px">23px</option>
2856 <option value="24px">24px</option>
2857 <option value="25px">25px</option>
2858 <option value="26px">26px</option>
2859 <option value="27px">27px</option>
2860 <option value="28px">28px</option>
2861 <option value="29px">29px</option>
2862 <option value="30px">30px</option>
2863 </select>
2864 </td>
2865 </tr>
2866 <tr>
2867 <td><?php _e( 'Left', 'polldaddy' ); ?>:</td>
2868 <td>
2869 <select id="margin-left" onchange="bind(this);">
2870 <option value="0px">0px</option>
2871 <option value="1px">1px</option>
2872 <option value="2px">2px</option>
2873 <option value="3px">3px</option>
2874 <option value="4px">4px</option>
2875 <option value="5px">5px</option>
2876 <option value="6px">6px</option>
2877 <option value="7px">7px</option>
2878 <option value="8px">8px</option>
2879 <option value="9px">9px</option>
2880 <option value="10px">10px</option>
2881 <option value="11px">11px</option>
2882 <option value="12px">12px</option>
2883 <option value="13px">13px</option>
2884 <option value="14px">14px</option>
2885 <option value="15px">15px</option>
2886 <option value="16px">16px</option>
2887 <option value="17px">17px</option>
2888 <option value="18px">18px</option>
2889 <option value="19px">19px</option>
2890 <option value="20px">20px</option>
2891 <option value="21px">21px</option>
2892 <option value="22px">22px</option>
2893 <option value="23px">23px</option>
2894 <option value="24px">24px</option>
2895 <option value="25px">25px</option>
2896 <option value="26px">26px</option>
2897 <option value="27px">27px</option>
2898 <option value="28px">28px</option>
2899 <option value="29px">29px</option>
2900 <option value="30px">30px</option>
2901 </select>
2902 </td>
2903 </tr>
2904 </table>
2905 <!-- Padding Table -->
2906 <table class="CSSE_edit" id="editPadding" style="display:none;">
2907 <tr>
2908 <td width="85"><?php _e( 'Top', 'polldaddy' ); ?>:</td>
2909 <td>
2910 <select id="padding-top" onchange="bind(this);">
2911 <option value="0px">0px</option>
2912 <option value="1px">1px</option>
2913 <option value="2px">2px</option>
2914 <option value="3px">3px</option>
2915 <option value="4px">4px</option>
2916 <option value="5px">5px</option>
2917 <option value="6px">6px</option>
2918 <option value="7px">7px</option>
2919 <option value="8px">8px</option>
2920 <option value="9px">9px</option>
2921 <option value="10px">10px</option>
2922 <option value="11px">11px</option>
2923 <option value="12px">12px</option>
2924 <option value="13px">13px</option>
2925 <option value="14px">14px</option>
2926 <option value="15px">15px</option>
2927 <option value="16px">16px</option>
2928 <option value="17px">17px</option>
2929 <option value="18px">18px</option>
2930 <option value="19px">19px</option>
2931 <option value="20px">20px</option>
2932 <option value="21px">21px</option>
2933 <option value="22px">22px</option>
2934 <option value="23px">23px</option>
2935 <option value="24px">24px</option>
2936 <option value="25px">25px</option>
2937 <option value="26px">26px</option>
2938 <option value="27px">27px</option>
2939 <option value="28px">28px</option>
2940 <option value="29px">29px</option>
2941 <option value="30px">30px</option>
2942 </select>
2943 </td>
2944 </tr>
2945 <tr>
2946 <td><?php _e( 'Right', 'polldaddy' ); ?>:</td>
2947 <td>
2948 <select id="padding-right" onchange="bind(this);">
2949 <option value="0px">0px</option>
2950 <option value="1px">1px</option>
2951 <option value="2px">2px</option>
2952 <option value="3px">3px</option>
2953 <option value="4px">4px</option>
2954 <option value="5px">5px</option>
2955 <option value="6px">6px</option>
2956 <option value="7px">7px</option>
2957 <option value="8px">8px</option>
2958 <option value="9px">9px</option>
2959 <option value="10px">10px</option>
2960 <option value="11px">11px</option>
2961 <option value="12px">12px</option>
2962 <option value="13px">13px</option>
2963 <option value="14px">14px</option>
2964 <option value="15px">15px</option>
2965 <option value="16px">16px</option>
2966 <option value="17px">17px</option>
2967 <option value="18px">18px</option>
2968 <option value="19px">19px</option>
2969 <option value="20px">20px</option>
2970 <option value="21px">21px</option>
2971 <option value="22px">22px</option>
2972 <option value="23px">23px</option>
2973 <option value="24px">24px</option>
2974 <option value="25px">25px</option>
2975 <option value="26px">26px</option>
2976 <option value="27px">27px</option>
2977 <option value="28px">28px</option>
2978 <option value="29px">29px</option>
2979 <option value="30px">30px</option>
2980 </select>
2981 </td>
2982 </tr>
2983 <tr>
2984 <td><?php _e( 'Bottom', 'polldaddy' ); ?>:</td>
2985 <td>
2986 <select id="padding-bottom" onchange="bind(this);">
2987 <option value="0px">0px</option>
2988 <option value="1px">1px</option>
2989 <option value="2px">2px</option>
2990 <option value="3px">3px</option>
2991 <option value="4px">4px</option>
2992 <option value="5px">5px</option>
2993 <option value="6px">6px</option>
2994 <option value="7px">7px</option>
2995 <option value="8px">8px</option>
2996 <option value="9px">9px</option>
2997 <option value="10px">10px</option>
2998 <option value="11px">11px</option>
2999 <option value="12px">12px</option>
3000 <option value="13px">13px</option>
3001 <option value="14px">14px</option>
3002 <option value="15px">15px</option>
3003 <option value="16px">16px</option>
3004 <option value="17px">17px</option>
3005 <option value="18px">18px</option>
3006 <option value="19px">19px</option>
3007 <option value="20px">20px</option>
3008 <option value="21px">21px</option>
3009 <option value="22px">22px</option>
3010 <option value="23px">23px</option>
3011 <option value="24px">24px</option>
3012 <option value="25px">25px</option>
3013 <option value="26px">26px</option>
3014 <option value="27px">27px</option>
3015 <option value="28px">28px</option>
3016 <option value="29px">29px</option>
3017 <option value="30px">30px</option>
3018 </select>
3019 </td>
3020 </tr>
3021 <tr>
3022 <td><?php _e( 'Left', 'polldaddy' ); ?>:</td>
3023 <td>
3024 <select id="padding-left" onchange="bind(this);">
3025 <option value="0px">0px</option>
3026 <option value="1px">1px</option>
3027 <option value="2px">2px</option>
3028 <option value="3px">3px</option>
3029 <option value="4px">4px</option>
3030 <option value="5px">5px</option>
3031 <option value="6px">6px</option>
3032 <option value="7px">7px</option>
3033 <option value="8px">8px</option>
3034 <option value="9px">9px</option>
3035 <option value="10px">10px</option>
3036 <option value="11px">11px</option>
3037 <option value="12px">12px</option>
3038 <option value="13px">13px</option>
3039 <option value="14px">14px</option>
3040 <option value="15px">15px</option>
3041 <option value="16px">16px</option>
3042 <option value="17px">17px</option>
3043 <option value="18px">18px</option>
3044 <option value="19px">19px</option>
3045 <option value="20px">20px</option>
3046 <option value="21px">21px</option>
3047 <option value="22px">22px</option>
3048 <option value="23px">23px</option>
3049 <option value="24px">24px</option>
3050 <option value="25px">25px</option>
3051 <option value="26px">26px</option>
3052 <option value="27px">27px</option>
3053 <option value="28px">28px</option>
3054 <option value="29px">29px</option>
3055 <option value="30px">30px</option>
3056 </select>
3057 </td>
3058 </tr>
3059 </table>
3060 <!-- Scale Table -->
3061 <table class="CSSE_edit" id="editScale" style="display:none;">
3062 <tr>
3063 <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>
3064 <td>
3065 <input type="text" maxlength="4" class="elmColor" id="width" onblur="bind(this);"/>
3066 </td>
3067 </tr>
3068 <tr>
3069 <td width="85"></td>
3070 <td>
3071 <?php _e( 'If you change the width of the<br/> poll you may also need to change<br/> the width of your answers.', 'polldaddy' ); ?>
3072 </td>
3073 </tr>
3074 </table>
3075
3076 <!-- Height Table -->
3077 <table class="CSSE_edit" id="editHeight" style="display:none;">
3078 <tr>
3079 <td width="85"><?php _e( 'Height', 'polldaddy' ); ?> (px):</td>
3080 <td>
3081 <input type="text" maxlength="4" class="elmColor" id="height" onblur="bind(this);"/>
3082 </td>
3083 </tr>
3084 </table>
3085
3086 <table class="CSSE_edit" id="editPosition" style="display:none;">
3087 <tr>
3088 <td width="85"><?php _e( 'Position', 'polldaddy' ); ?> (px):</td>
3089 <td>
3090 <select class="set-width" id="float" onchange="bind(this);">
3091 <option value="left">Left</option>
3092 <option value="right">Right</option>
3093 </select>
3094 <input type="hidden" id="position" />
3095 <input type="hidden" id="direction" />
3096 </td>
3097 </tr>
3098 </table>
3099 </td>
3100 </tr>
3101 <tr>
3102 <td class="btm"/>
3103 </tr>
3104 </table>
3105 </td>
3106 </tr>
3107 </table>
3108 </td>
3109 <td width="10"> </td>
3110 <td valign="top">
3111 <div style="overflow-x:auto;">
3112 <!-- POLL XHTML START -->
3113 <div class="pds-box" id="pds-box">
3114 <div class="pds-box-outer">
3115 <div class="pds-box-inner">
3116 <div class="pds-box-top">
3117 <div class="pds-question">
3118 <div class="pds-question-outer">
3119 <div class="pds-question-inner">
3120 <div class="pds-question-top" id="pds-question-top"><?php _e( 'Do you mostly use the internet at work, in school or at home?', 'polldaddy' ); ?></div>
3121 </div>
3122 </div>
3123 </div>
3124 <div>
3125 <!-- divAnswers -->
3126 <div id="divAnswers">
3127 <span id="pds-answer143974">
3128
3129 <span class="pds-answer-group" id="pds-answer-group">
3130 <span class="pds-answer-input" id="pds-answer-input">
3131 <input type="radio" name="PDI_answer" value="1" id="p1" class="pds-checkbox"/>
3132 </span>
3133 <label for="p1" class="pds-answer" id="pds-answer"><span class="pds-answer-span"><?php _e( 'I use it in school.', 'polldaddy' ); ?></span></label>
3134 <span class="pds-clear"></span>
3135 </span>
3136
3137 <span class="pds-answer-group" id="pds-answer-group1">
3138 <span class="pds-answer-input" id="pds-answer-input1">
3139 <input type="radio" name="PDI_answer" value="2" id="p2" class="pds-checkbox"/>
3140 </span>
3141 <label for="p2" class="pds-answer" id="pds-answer1"><span class="pds-answer-span"><?php _e( 'I use it at home.', 'polldaddy' ); ?></span></label>
3142 <span class="pds-clear"></span>
3143 </span>
3144
3145 <span class="pds-answer-group" id="pds-answer-group2">
3146 <span class="pds-answer-input" id="pds-answer-input2">
3147 <input type="radio" name="PDI_answer" value="3" id="p3" class="pds-checkbox"/>
3148 </span>
3149 <label for="p3" class="pds-answer" id="pds-answer2"><span class="pds-answer-span"><?php _e( 'I use it every where I go, at work and home and anywhere else that I can!', 'polldaddy' ); ?></span></label>
3150 <span class="pds-clear"></span>
3151 </span>
3152
3153 <span class="pds-answer-group" id="pds-answer-group3">
3154 <span class="pds-answer-input" id="pds-answer-input3">
3155 <input type="radio" name="PDI_answer" value="4" id="p4" class="pds-checkbox"/>
3156 </span>
3157 <label for="p4" class="pds-answer" id="pds-answer3"><span class="pds-answer-span"><?php _e( 'Other', 'polldaddy' ); ?>:</span></label>
3158 <span class="pds-clear"></span>
3159 <span class="pds-answer-other">
3160 <input type="text" name="PDI_OtherText1761982" id="pds-textfield" maxlength="80" class="pds-textfield"/>
3161 </span>
3162 <span class="pds-clear"></span>
3163 </span>
3164
3165 </span>
3166 <br/>
3167 <div class="pds-vote" id="pds-links">
3168 <div class="pds-votebutton-outer">
3169 <a href="javascript:renderStyleEdit('pds-answer-feedback');" id="pds-vote-button" style="display:block;float:left;" class="pds-vote-button"><span><?php _e( 'Vote', 'polldaddy' ); ?></span></a>
3170 <span class="pds-links">
3171 <div style="padding: 0px 0px 0px 15px; float:left;"><a href="javascript:renderStyleEdit('pds-answer-feedback');" class="pds-link" id="pds-link"><?php _e( 'View Results', 'polldaddy' ); ?></a></div>
3172 <span class="pds-clear"></span>
3173 </span>
3174 <span class="pds-clear"></span>
3175 </div>
3176 </div>
3177
3178 </div>
3179 <!-- End divAnswers -->
3180 <!-- divResults -->
3181 <div id="divResults">
3182
3183 <div class="pds-feedback-group" id="pds-feedback-group" >
3184 <label class="pds-feedback-label" id="pds-feedback-label">
3185 <span class="pds-answer-text" id="pds-answer-text"><?php _e( 'I use it in school!', 'polldaddy' ); ?></span>
3186 <span class="pds-feedback-result" id="pds-feedback-result">
3187 <span class="pds-feedback-per" id="pds-feedback-per">&nbsp;46%</span>&nbsp;<span class="pds-feedback-votes" id="pds-feedback-votes"> <?php
3188 /* translators: %d is the number of votes */
3189 printf( __( '(%d votes)', 'polldaddy' ), 620 ); ?></span>
3190 </span>
3191 </label>
3192 <span style="display: block;clear: both;height:1px;line-height:1px;" class="pds-clear">&nbsp;</span>
3193 <div class="pds-answer-feedback" id="pds-answer-feedback">
3194 <div style="width:46%" class="pds-answer-feedback-bar" id="pds-answer-feedback-bar"></div>
3195 </div>
3196 <span style="display: block;clear: both;height:1px;line-height:1px;" class="pds-clear">&nbsp;</span>
3197 </div>
3198
3199 <div class="pds-feedback-group" id="pds-feedback-group1">
3200 <label class="pds-feedback-label" id="pds-feedback-label1">
3201 <span class="pds-answer-text" id="pds-answer-text1"><?php _e( 'I use it at home.', 'polldaddy' ); ?></span>
3202 <span class="pds-feedback-result" id="pds-feedback-result1">
3203 <?php /* translators: %d is the number of votes */ ?>
3204 <span class="pds-feedback-per" id="pds-feedback-per1">&nbsp;30%</span>&nbsp;<span class="pds-feedback-votes" id="pds-feedback-votes1"> <?php printf( __( '(%d votes)', 'polldaddy' ), 400 ); ?></span>
3205 </span>
3206 </label>
3207 <span style="display: block;clear: both;height:1px;line-height:1px;" class="pds-clear">&nbsp;</span>
3208 <div class="pds-answer-feedback" id="pds-answer-feedback1">
3209 <div style="width:30%" class="pds-answer-feedback-bar" id="pds-answer-feedback-bar1"></div>
3210 </div>
3211 <span style="display: block;clear: both;height:1px;line-height:1px;" class="pds-clear">&nbsp;</span>
3212 </div>
3213
3214 <div class="pds-feedback-group" id="pds-feedback-group2">
3215 <label class="pds-feedback-label" id="pds-feedback-label2">
3216 <span class="pds-answer-text" id="pds-answer-text2"><?php _e( 'I use it every where I go, at work and home and anywhere else that I can!', 'polldaddy' ); ?></span>
3217 <span class="pds-feedback-result" id="pds-feedback-result2">
3218 <?php /* translators: %d is the number of votes */ ?>
3219 <span class="pds-feedback-per" id="pds-feedback-per2">&nbsp;16%</span>&nbsp;<span class="pds-feedback-votes" id="pds-feedback-votes2"> <?php printf( __( '(%d votes)', 'polldaddy' ), 220 ); ?></span>
3220 </span>
3221 </label>
3222 <span style="display: block;clear: both;height:1px;line-height:1px;" class="pds-clear">&nbsp;</span>
3223 <div class="pds-answer-feedback" id="pds-answer-feedback2">
3224 <div style="width:16%" class="pds-answer-feedback-bar" id="pds-answer-feedback-bar2"></div>
3225 </div>
3226 <span style="display: block;clear: both;height:1px;line-height:1px;" class="pds-clear">&nbsp;</span>
3227 </div>
3228
3229 <div class="pds-feedback-group" id="pds-feedback-group3">
3230 <label class="pds-feedback-label" id="pds-feedback-label3">
3231 <span class="pds-answer-text" id="pds-answer-text3"><?php _e( 'Other', 'polldaddy' ); ?></span>
3232 <span class="pds-feedback-result" id="pds-feedback-result3">
3233 <?php /* translators: %d is the number of votes */ ?>
3234 <span class="pds-feedback-per" id="pds-feedback-per3">&nbsp;8%</span>&nbsp;<span class="pds-feedback-votes" id="pds-feedback-votes3"> <?php printf( __( '(%d votes)', 'polldaddy' ), 110 ); ?></span>
3235 </span>
3236 </label>
3237 <span style="display: block;clear: both;height:1px;line-height:1px;" class="pds-clear">&nbsp;</span>
3238 <div class="pds-answer-feedback" id="pds-answer-feedback3">
3239 <div style="width:8%" class="pds-answer-feedback-bar" id="pds-answer-feedback-bar3"></div>
3240 </div>
3241 <span style="display: block;clear: both;height:1px;line-height:1px;" class="pds-clear">&nbsp;</span>
3242 </div>
3243
3244 </div>
3245 <!-- End divResults -->
3246 <span class="pds-clear"></span>
3247 <div style="height: 10px;"></div>
3248 <div id="pds-totalvotes-inner"><?php _e( 'Total Votes', 'polldaddy' ); ?>: <strong>1,350</strong></div>
3249 </div>
3250 <div class="pds-vote" id="pds-links-back">
3251 <div class="pds-totalvotes-outer">
3252 <span class="pds-links-back">
3253 <br/>
3254 <a href="javascript:" class="pds-link" id="pds-link1"><?php _e( 'Comments', 'polldaddy' ); ?> <strong>(19)</strong></a>
3255 <xsl:text> </xsl:text>
3256 <a href="javascript:renderStyleEdit('pds-box');" class="pds-link" id="pds-link2"><?php _e( 'Return To Poll', 'polldaddy' ); ?></a>
3257 <span class="pds-clear"></span>
3258 </span>
3259 <span class="pds-clear"></span>
3260 </div>
3261 </div>
3262 </div>
3263 </div>
3264 </div>
3265 </div>
3266 <!-- POLL XHTML END -->
3267 </div>
3268 </td>
3269 </tr>
3270 </table>
3271 <div id="editBox"></div>
3272 <p class="pds-clear"></p>
3273 <p>
3274 <?php wp_nonce_field( $style_id > 1000 ? "edit-style$style_id" : 'create-style' ); ?>
3275 <input type="hidden" name="action" value="<?php echo $style_id > 1000 ? 'edit-style' : 'create-style'; ?>" />
3276 <input type="hidden" class="polldaddy-style-id" name="style" value="<?php echo esc_attr( $style_id ); ?>" />
3277 <input type="submit" class="button-primary" value="<?php echo esc_attr( __( 'Save Style', 'polldaddy' ) ); ?>" />
3278 <?php if ( $style_id > 1000 ) { ?>
3279 <input name="updatePollCheck" id="updatePollCheck" type="checkbox"> <label for="updatePollCheck"><?php _e( 'Check this box if you wish to update the polls that use this style.', 'polldaddy' ); ?></label>
3280 <?php } ?>
3281 </p>
3282 </div>
3283 </div>
3284 <textarea id="S_www" name="CSSXML" style="display:none;width: 1000px; height: 500px;" rows="10" cols="10"> </textarea>
3285 </form>
3286 <script language="javascript">
3287 jQuery( document ).ready(function(){
3288 plugin = new Plugin( {
3289 <?php /* translators: %s is the name of the rating being deleted */ ?>
3290 delete_rating: '<?php echo esc_attr( __( 'Are you sure you want to delete the rating for "%s"?', 'polldaddy' ) ); ?>',
3291 <?php /* translators: %s is the name of the poll being deleted */ ?>
3292 delete_poll: '<?php echo esc_attr( __( 'Are you sure you want to delete "%s"?', 'polldaddy' ) ); ?>',
3293 delete_answer: '<?php echo esc_attr( __( 'Are you sure you want to delete this answer?', 'polldaddy' ) ); ?>',
3294 delete_answer_title: '<?php echo esc_attr( __( 'delete this answer', 'polldaddy' ) ); ?>',
3295 standard_styles: '<?php echo esc_attr( __( 'Standard Styles', 'polldaddy' ) ); ?>',
3296 custom_styles: '<?php echo esc_attr( __( 'Custom Styles', 'polldaddy' ) ); ?>'
3297 } );
3298 });
3299 pd_map = {
3300 thankyou : '<?php echo esc_attr( __( 'Thank you for voting!', 'polldaddy' ) ); ?>',
3301 question : '<?php echo esc_attr( __( 'Do you mostly use the internet at work, in school or at home?', 'polldaddy' ) ); ?>'
3302 }
3303 </script>
3304 <script type="text/javascript" language="javascript">window.onload = function() {
3305 var CSSXML;
3306 loadStyle();
3307 showResults( false );
3308 renderStyleEdit( _$('styleName').value );
3309 }</script>
3310 <br class="clear" />
3311
3312 <?php
3313 }
3314
3315 function rating_settings() {
3316 global $action, $rating;
3317 $rich_snippets = $show_posts = $show_posts_index = $show_pages = $show_comments = $pos_posts = $pos_posts_index = $pos_pages = $pos_comments = 0;
3318 $show_settings = $rating_updated = ( $action == 'update-rating' ? true : false );
3319 $error = false;
3320
3321 $settings_style = 'display: none;';
3322 if ( $show_settings )
3323 $settings_style = 'display: block;';
3324
3325 $rating_id = get_option( 'pd-rating-posts-id' );
3326 $report_type = 'posts';
3327 $updated = false;
3328
3329 if ( isset( $rating ) ) {
3330 switch ( $rating ) {
3331 case 'pages':
3332 $report_type = 'pages';
3333 $rating_id = (int) get_option( 'pd-rating-pages-id' );
3334 break;
3335 case 'comments':
3336 $report_type = 'comments';
3337 $rating_id = (int) get_option( 'pd-rating-comments-id' );
3338 break;
3339 case 'posts':
3340 $report_type = 'posts';
3341 $rating_id = (int) get_option( 'pd-rating-posts-id' );
3342 break;
3343 }//end switch
3344 }
3345
3346 $new_type = 0;
3347 if ( $report_type == 'comments' )
3348 $new_type = 1;
3349
3350 $blog_name = get_option( 'blogname' );
3351
3352 if ( empty( $blog_name ) )
3353 $blog_name = 'WordPress Blog';
3354 $blog_name .= ' - ' . $report_type;
3355
3356 if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) )
3357 return false;
3358
3359 if ( $this->rating_user_code == '' )
3360 die();
3361 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
3362 $polldaddy->reset();
3363
3364 $error = false;
3365 $rating_errors = array();
3366 if ( empty( $rating_id ) ) {
3367 $pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
3368 if ( !empty( $pd_rating ) ) {
3369 $rating_id = (int) $pd_rating->_id;
3370 update_option ( 'pd-rating-' . $report_type . '-id', $rating_id );
3371 update_option ( 'pd-rating-' . $report_type, 0 );
3372 } else {
3373 $rating_errors[] = $polldaddy->errors;
3374 }
3375 } else
3376 $pd_rating = $polldaddy->get_rating( $rating_id );
3377
3378 if ( empty( $pd_rating ) || (int) $pd_rating->_id == 0 ) {
3379
3380 $this->log( 'rating_settings: unable to get rating id - '.$rating_id );
3381
3382 if ( $polldaddy->errors ) {
3383 if ( array_key_exists( 4, $polldaddy->errors ) ) { //Obsolete key
3384 $this->log( 'rating_settings: obsolete key - '.$this->rating_user_code );
3385 $this->rating_user_code = '';
3386 update_option( 'pd-rating-usercode', '' );
3387 $this->set_api_user_code(); // get latest key
3388
3389 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
3390 $polldaddy->reset();
3391 $pd_rating = $polldaddy->get_rating( $rating_id ); //see it exists
3392 $rating_errors[] = $polldaddy->errors;
3393
3394 if ( empty( $pd_rating ) || (int) $pd_rating->_id == 0 ) { //if not then create a rating for blog
3395 $polldaddy->reset();
3396 $pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
3397 $rating_errors[] = $polldaddy->errors;
3398 }
3399 } elseif ( isset( $polldaddy->errors[ -1 ] ) && $polldaddy->errors[ -1 ] == "Can't connect" ) {
3400 $this->contact_support_message( __( 'Could not connect to the Crowdsignal API', 'polldaddy' ), $rating_errors );
3401 $error = true;
3402 } elseif ( isset( $polldaddy->errors[ -1 ] ) && $polldaddy->errors[ -1 ] == "Invalid API URL" ) {
3403 $this->contact_support_message( __( 'The API URL is incorrect', 'polldaddy' ), $rating_errors );
3404 $error = true;
3405 } elseif ( isset( $polldaddy->errors[ -2 ] ) && $polldaddy->errors[ -2 ] == "No Data" ) {
3406 $this->contact_support_message( __( 'Your API request did not return any data', 'polldaddy' ), $rating_errors );
3407 $error = true;
3408 }
3409 }
3410
3411 if ( $error == false && empty( $pd_rating ) ) { //something's up!
3412 $this->contact_support_message( __( 'There was an error creating your rating widget', 'polldaddy' ), $rating_errors );
3413 $error = true;
3414 } else {
3415 $rating_id = (int) $pd_rating->_id;
3416 update_option ( 'pd-rating-' . $report_type . '-id', $rating_id );
3417 update_option ( 'pd-rating-' . $report_type, 0 );
3418
3419 switch ( $report_type ) {
3420 case 'posts':
3421 $show_posts = 0;
3422 break;
3423 case 'pages':
3424 $show_pages = 0;
3425 break;
3426 case 'comments':
3427 $show_comments = 0;
3428 break;
3429 }//end switch
3430 }
3431 }
3432
3433 if ( isset( $_POST[ 'pd_rating_action_type' ] ) ) {
3434 check_admin_referer( 'action-rating_settings_' . $_POST[ 'pd_rating_action_type' ] );
3435
3436 switch ( $_POST[ 'pd_rating_action_type' ] ) {
3437 case 'posts' :
3438 delete_option( 'pd-rich-snippets' );
3439 if ( wp_next_scheduled( 'polldaddy_rating_update_job' ) ) {
3440 wp_clear_scheduled_hook( 'polldaddy_rating_update_job' );
3441 }
3442
3443 if ( isset( $_POST[ 'pd_show_posts' ] ) && (int) $_POST[ 'pd_show_posts' ] == 1 )
3444 $show_posts = get_option( 'pd-rating-posts-id' );
3445
3446 update_option( 'pd-rating-posts', $show_posts );
3447
3448 if ( isset( $_POST[ 'pd_show_posts_index' ] ) && (int) $_POST[ 'pd_show_posts_index' ] == 1 )
3449 $show_posts_index = get_option( 'pd-rating-posts-id' );
3450
3451 update_option( 'pd-rating-posts-index', $show_posts_index );
3452
3453 if ( isset( $_POST[ 'posts_pos' ] ) && (int) $_POST[ 'posts_pos' ] == 1 )
3454 $pos_posts = 1;
3455
3456 update_option( 'pd-rating-posts-pos', $pos_posts );
3457
3458 if ( isset( $_POST[ 'posts_index_pos' ] ) && (int) $_POST[ 'posts_index_pos' ] == 1 )
3459 $pos_posts_index = 1;
3460
3461 update_option( 'pd-rating-posts-index-pos', $pos_posts_index );
3462 $rating_updated = true;
3463 break;
3464
3465 case 'pages';
3466 if ( isset( $_POST[ 'pd_show_pages' ] ) && (int) $_POST[ 'pd_show_pages' ] == 1 )
3467 $show_pages = get_option( 'pd-rating-pages-id' );
3468
3469 update_option( 'pd-rating-pages', $show_pages );
3470
3471 if ( isset( $_POST[ 'pages_pos' ] ) && (int) $_POST[ 'pages_pos' ] == 1 )
3472 $pos_pages = 1;
3473
3474 update_option( 'pd-rating-pages-pos', $pos_pages );
3475 $rating_updated = true;
3476 break;
3477
3478 case 'comments':
3479 if ( isset( $_POST[ 'pd_show_comments' ] ) && (int) $_POST[ 'pd_show_comments' ] == 1 )
3480 $show_comments = get_option( 'pd-rating-comments-id' );
3481
3482 update_option( 'pd-rating-comments', $show_comments );
3483
3484 if ( isset( $_POST[ 'comments_pos' ] ) && (int) $_POST[ 'comments_pos' ] == 1 )
3485 $pos_comments = 1;
3486
3487 update_option( 'pd-rating-comments-pos', $pos_comments );
3488
3489 $rating_updated = true;
3490 break;
3491 }//end switch
3492 }
3493
3494 $show_posts = (int) get_option( 'pd-rating-posts' );
3495 $show_pages = (int) get_option( 'pd-rating-pages' );
3496 $show_comments = (int) get_option( 'pd-rating-comments' );
3497 $show_posts_index = (int) get_option( 'pd-rating-posts-index' );
3498
3499 $pos_posts = (int) get_option( 'pd-rating-posts-pos' );
3500 $pos_pages = (int) get_option( 'pd-rating-pages-pos' );
3501 $pos_comments = (int) get_option( 'pd-rating-comments-pos' );
3502 $pos_posts_index = (int) get_option( 'pd-rating-posts-index-pos' );
3503
3504 if ( !empty( $pd_rating ) ) {
3505 $settings_text = $pd_rating->settings;
3506 $settings = json_decode( $settings_text );
3507
3508 $popup_disabled = ( isset( $settings->popup ) && $settings->popup == 'off' );
3509
3510 $rating_type = 0;
3511
3512 if ( $settings->type == 'stars' )
3513 $rating_type = 0;
3514 else
3515 $rating_type = 1;
3516
3517 if ( empty( $settings->font_color ) )
3518 $settings->font_color = '#000000';
3519 }?>
3520 <div class="wrap">
3521 <div class="icon32" id="icon-options-general"><br/></div>
3522 <h2>
3523 <?php _e( 'Rating Settings', 'polldaddy' ); ?>
3524 </h2>
3525 <?php if ( $rating_updated )
3526 echo '<div class="updated"><p>'.__( 'Rating updated', 'polldaddy' ).'</p></div>';
3527
3528 if ( !$error ) { ?>
3529 <div id="side-sortables">
3530 <div id="categorydiv" class="categorydiv">
3531 <ul id="category-tabs" class="category-tabs wp-tab-bar"><?php
3532 $this_class = '';
3533 $posts_link = esc_url( add_query_arg( array( 'rating' => 'posts', 'message' => false ) ) );
3534 $pages_link = esc_url( add_query_arg( array( 'rating' => 'pages', 'message' => false ) ) );
3535 $comments_link = esc_url( add_query_arg( array( 'rating' => 'comments', 'message' => false ) ) );
3536 if ( $report_type == 'posts' )
3537 $this_class = ' class="tabs"';?>
3538 <li <?php echo $this_class; ?>><a tabindex="3" href="<?php echo esc_url( $posts_link ); ?>"><?php _e( 'Posts', 'polldaddy' );?></a></li><?php
3539 $this_class = '';
3540 if ( $report_type == 'pages' )
3541 $this_class = ' class="tabs"'; ?>
3542 <li <?php echo $this_class; ?>><a tabindex="3" href="<?php echo esc_url( $pages_link ); ?>"><?php _e( 'Pages', 'polldaddy' );?></a></li><?php
3543 $this_class = '';
3544 if ( $report_type == 'comments' )
3545 $this_class = ' class="tabs"'; ?>
3546 <li <?php echo $this_class; ?>><a href="<?php echo esc_url( $comments_link ); ?>"><?php _e( 'Comments', 'polldaddy' );?></a></li>
3547 </ul>
3548 <div class="tabs-panel" id="categories-all" style="background: #FFFFFF;height: auto; overflow: visible;max-height:500px;">
3549 <form action="" method="post">
3550 <input type="hidden" name="pd_rating_action_type" value="<?php echo esc_attr( $report_type ); ?>" />
3551 <?php wp_nonce_field( 'action-rating_settings_' . $report_type ); ?>
3552 <table class="form-table" style="width: normal;">
3553 <tbody>
3554 <?php if ( $report_type == 'posts' ) { ?>
3555 <tr valign="top">
3556 <th scope="row"><label><?php _e( 'Show Ratings on', 'polldaddy' );?></label></th>
3557 <td>
3558 <label><input type="checkbox" name="pd_show_posts_index" id="pd_show_posts_index" <?php if ( $show_posts_index > 0 ) echo ' checked="checked" '; ?> value="1" /> <?php _e( 'Front Page, Archive Pages, and Search Results', 'polldaddy' );?></label>
3559 <br><label><input type="checkbox" name="pd_show_posts" id="pd_show_posts" <?php if ( $show_posts > 0 ) echo ' checked="checked" '; ?> value="1" /> <?php _e( 'Posts', 'polldaddy' );?></label>
3560 </td>
3561 </tr>
3562 <tr valign="top">
3563 <th scope="row"><label><?php _e( 'Position Front Page, Archive Pages, and Search Results Ratings', 'polldaddy' );?></label></th>
3564 <td>
3565 <select name="posts_index_pos"><?php
3566 $select = array( __( 'Above each blog post', 'polldaddy' ) => '0', __( 'Below each blog post', 'polldaddy' ) => '1' );
3567 foreach ( $select as $option => $value ) :
3568 $selected = '';
3569 if ( $value == $pos_posts_index )
3570 $selected = ' selected="selected"';
3571 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3572 endforeach;?>
3573 </select>
3574 </td>
3575 </tr>
3576 <tr valign="top">
3577 <th scope="row"><label><?php _e( 'Position Post Ratings', 'polldaddy' );?></label></th>
3578 <td>
3579 <select name="posts_pos"><?php
3580 $select = array( __( 'Above each blog post', 'polldaddy' ) => '0', __( 'Below each blog post', 'polldaddy' ) => '1' );
3581 foreach ( $select as $option => $value ) :
3582 $selected = '';
3583 if ( $value == $pos_posts )
3584 $selected = ' selected="selected"';
3585 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3586 endforeach;?>
3587 </select>
3588 </td>
3589 </tr><?php
3590 }
3591 if ( $report_type == 'pages' ) {?>
3592 <tr valign="top">
3593 <th scope="row"><label><?php _e( 'Show Ratings on', 'polldaddy' );?></label></th>
3594 <td>
3595 <label><input type="checkbox" name="pd_show_pages" id="pd_show_pages" <?php if ( $show_pages > 0 ) echo ' checked="checked" '; ?> value="1" /> <?php _e( 'Pages', 'polldaddy' );?></label>
3596 </td>
3597 </tr>
3598 <tr valign="top">
3599 <th scope="row"><label><?php _e( 'Position Page Ratings', 'polldaddy' );?></label></th>
3600 <td>
3601 <select name="pages_pos"><?php
3602 $select = array( __( 'Above each blog page', 'polldaddy' ) => '0', __( 'Below each blog page', 'polldaddy' ) => '1' );
3603 foreach ( $select as $option => $value ) :
3604 $selected = '';
3605 if ( $value == $pos_pages )
3606 $selected = ' selected="selected"';
3607 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3608 endforeach;?>
3609 </select>
3610 </td>
3611 </tr><?php
3612 }
3613 if ( $report_type == 'comments' ) {?>
3614 <tr valign="top">
3615 <th scope="row"><label><?php _e( 'Show Ratings on', 'polldaddy' );?></label></th>
3616 <td>
3617 <label><input type="checkbox" name="pd_show_comments" id="pd_show_comments" <?php if ( $show_comments > 0 ) echo ' checked="checked" '; ?> value="1" /> <?php _e( 'Comments', 'polldaddy' );?></label>
3618 </td>
3619 </tr>
3620 <tr valign="top">
3621 <th scope="row"><label><?php _e( 'Position Comment Ratings', 'polldaddy' );?></label></th>
3622 <td>
3623 <select name="comments_pos"><?php
3624 $select = array( __( 'Above each comment', 'polldaddy' ) => '0', __( 'Below each comment', 'polldaddy' ) => '1' );
3625 foreach ( $select as $option => $value ) :
3626 $selected = '';
3627 if ( $value == $pos_comments )
3628 $selected = ' selected="selected"';
3629 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3630 endforeach;?>
3631 </select>
3632 </td>
3633 </tr><?php
3634 } ?>
3635 <tr valign="top">
3636 <td height="30"><input class="button-primary" type="submit" value="<?php esc_attr_e( 'Save Changes', 'polldaddy' );?>" name="Submit" /></td>
3637 </tr>
3638 </tbody>
3639 </table>
3640 </form>
3641 <?php // check for previous settings
3642 $previous_settings = get_option( 'polldaddy_settings' );
3643 $current_setting = get_option( 'pd-rating-posts-id' );
3644 if ( $current_setting && isset( $previous_settings[ 'pd-rating-posts-id' ] ) && $current_setting != $previous_settings[ 'pd-rating-posts-id' ] ) {
3645 echo "<p>" . sprintf(
3646 /* translators: %s is the URL to Crowdsignal settings page */
3647 __( "Previous settings for ratings on this site discovered. You can restore them on the <a href='%s'>poll settings page</a> if your site is missing ratings after resetting your connection settings.", 'polldaddy' ),
3648 "options-general.php?page=crowdsignal-settings"
3649 ) . "</p>";
3650 }
3651 ?>
3652 </div>
3653
3654 <div style="padding:20px 0px 0px 0px"><?php
3655 if ( $report_type == 'posts' ) {
3656 if ( $show_posts > 0 || $show_posts_index > 0 )
3657 $show_settings = true;
3658 }
3659 if ( $report_type == 'pages' && $show_pages > 0 )
3660 $show_settings = true;
3661 if ( $report_type == 'comments' && $show_comments > 0 )
3662 $show_settings = true;
3663 if ( $show_settings == true )
3664 echo '<a href="javascript:" onclick="show_settings();">'.__( 'Advanced Settings', 'polldaddy' ).'</a>';?></div>
3665 </div>
3666 </div>
3667
3668 <?php if ( $show_settings == true ) { ?>
3669 <br />
3670 <form method="post" action="">
3671 <div id="poststuff" style="<?php echo esc_attr( $settings_style ); ?>">
3672 <div class="has-sidebar has-right-sidebar">
3673 <div class="inner-sidebar-ratings">
3674 <div id="submitdiv" class="postbox ">
3675 <h2 class="postbox-title"><span><?php _e( 'Save Advanced Settings', 'polldaddy' );?></span></h2>
3676
3677 <div class="inside">
3678 <div class="submitbox" id="submitpost">
3679 <div id="minor-publishing" style="padding:10px;">
3680 <input type="submit" name="save_menu" class="button button-primary menu-save" value="<?php echo esc_attr( __( 'Save Changes', 'polldaddy' ) );?>">
3681 <input type="hidden" name="type" value="<?php echo esc_attr( $report_type ); ?>" />
3682 <input type="hidden" name="rating_id" value="<?php echo esc_attr( $rating_id ); ?>" />
3683 <input type="hidden" name="action" value="update-rating" />
3684 <?php wp_nonce_field( 'action-update-rating_' . $report_type ); ?>
3685 </div>
3686 </div>
3687 </div>
3688 </div>
3689 <div class="postbox">
3690 <h2 class="postbox-title"><?php _e( 'Preview', 'polldaddy' );?></h2>
3691 <div class="inside">
3692 <p><?php _e( 'This is a demo of what your rating widget will look like', 'polldaddy' ); ?>.</p>
3693 <p>
3694 <div id="pd_rating_holder_1"></div>
3695 </p>
3696 </div>
3697 </div>
3698 <div class="postbox">
3699 <h2 class="postbox-title"><?php _e( 'Customize Labels', 'polldaddy' );?></h2>
3700 <div class="inside">
3701 <table width="99.5%">
3702 <tr>
3703 <td><p style="margin-bottom: 0px;"><?php _e( 'Vote', 'polldaddy' );?></p></td>
3704 </tr>
3705 <tr>
3706 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_vote" id="text_vote" value="<?php echo empty( $settings->text_vote ) ? 'Vote' : esc_html( $settings->text_vote ); ?>" maxlength="20" />
3707 </tr>
3708 <tr>
3709 <td><p style="margin-bottom: 0px;"><?php _e( 'Votes', 'polldaddy' );?></p></td>
3710 </tr>
3711 <tr>
3712 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_votes" id="text_votes" value="<?php echo empty( $settings->text_votes ) ? 'Votes' : esc_html( $settings->text_votes ); ?>" maxlength="20" />
3713 </tr>
3714 <tr>
3715 <td><p style="margin-bottom: 0px;"><?php _e( 'Rate This', 'polldaddy' );?></p></td>
3716 </tr>
3717 <tr>
3718 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_rate_this" id="text_rate_this" value="<?php echo empty( $settings->text_rate_this ) ? 'Rate This' : esc_html( $settings->text_rate_this ); ?>" maxlength="20" />
3719 </tr>
3720 <tr>
3721 <td><p style="margin-bottom: 0px;"><?php
3722 /* translators: %d is the number of stars */
3723 printf( __( '%d star', 'polldaddy' ), 1 );?></p></td>
3724 </tr>
3725 <tr>
3726 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_1_star" id="text_1_star" value="<?php echo empty( $settings->text_1_star ) ? '1 star' : esc_html( $settings->text_1_star ); ?>" maxlength="20" />
3727 </tr>
3728 <tr>
3729 <td><p style="margin-bottom: 0px;"><?php
3730 /* translators: %d is the number of stars */
3731 printf( __( '%d stars', 'polldaddy' ), 2 );?></p></td>
3732 </tr>
3733 <tr>
3734 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_2_star" id="text_2_star" value="<?php echo empty( $settings->text_2_star ) ? '2 stars' : esc_html( $settings->text_2_star ); ?>" maxlength="20" />
3735 </tr>
3736 <tr>
3737 <td><p style="margin-bottom: 0px;"><?php
3738 /* translators: %d is the number of stars */
3739 printf( __( '%d stars', 'polldaddy' ), 3 );?></p></td>
3740 </tr>
3741 <tr>
3742 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_3_star" id="text_3_star" value="<?php echo empty( $settings->text_3_star ) ? '3 stars' : esc_html( $settings->text_3_star ); ?>" maxlength="20" />
3743 </tr>
3744 <tr>
3745 <td><p style="margin-bottom: 0px;"><?php
3746 /* translators: %d is the number of stars */
3747 printf( __( '%d stars', 'polldaddy' ), 4 );?></p></td>
3748 </tr>
3749 <tr>
3750 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_4_star" id="text_4_star" value="<?php echo empty( $settings->text_4_star ) ? '4 stars' : esc_html( $settings->text_4_star ); ?>" maxlength="20" />
3751 </tr>
3752 <tr>
3753 <td><p style="margin-bottom: 0px;"><?php
3754 /* translators: %d is the number of stars */
3755 printf( __( '%d stars', 'polldaddy' ), 5 );?></p></td>
3756 </tr>
3757 <tr>
3758 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_5_star" id="text_5_star" value="<?php echo empty( $settings->text_5_star ) ? '5 stars' : esc_html( $settings->text_5_star ); ?>" maxlength="20" />
3759 </tr>
3760 <tr>
3761 <td><p style="margin-bottom: 0px;"><?php _e( 'Thank You', 'polldaddy' );?></p></td>
3762 </tr>
3763 <tr>
3764 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_thank_you" id="text_thank_you" value="<?php echo empty( $settings->text_thank_you ) ? 'Thank You' : esc_html( $settings->text_thank_you ); ?>" maxlength="20" />
3765 </tr>
3766 <tr>
3767 <td><p style="margin-bottom: 0px;"><?php _e( 'Rate Up', 'polldaddy' );?></p></td>
3768 </tr>
3769 <tr>
3770 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_rate_up" id="text_rate_up" value="<?php echo empty( $settings->text_rate_up ) ? 'Rate Up' : esc_html( $settings->text_rate_up ); ?>" maxlength="20" />
3771 </tr>
3772 <tr>
3773 <td><p style="margin-bottom: 0px;"><?php _e( 'Rate Down', 'polldaddy' );?></p></td>
3774 </tr>
3775 <tr>
3776 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_rate_down" id="text_rate_down" value="<?php echo empty( $settings->text_rate_down ) ? 'Rate Down' : esc_html( $settings->text_rate_down ); ?>" maxlength="20" />
3777 </tr>
3778 <tr>
3779 <td><p style="margin-bottom: 0px;"><?php _e( 'Most Popular Content', 'polldaddy' );?></p></td>
3780 </tr>
3781 <tr>
3782 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_popcontent" id="text_popcontent" value="<?php echo empty( $settings->text_popcontent ) ? 'Most Popular Content' : esc_html( $settings->text_popcontent ); ?>" maxlength="20" />
3783 </tr>
3784 <tr>
3785 <td><p style="margin-bottom: 0px;"><?php _e( 'Close', 'polldaddy' );?></p></td>
3786 </tr>
3787 <tr>
3788 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_close" id="text_close" value="<?php echo empty( $settings->text_close ) ? 'Close' : esc_html( $settings->text_close ); ?>" maxlength="20" />
3789 </tr>
3790 <tr>
3791 <td><p style="margin-bottom: 0px;"><?php _e( 'All', 'polldaddy' );?></p></td>
3792 </tr>
3793 <tr>
3794 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_all" id="text_all" value="<?php echo empty( $settings->text_all ) ? 'All' : esc_html( $settings->text_all ); ?>" maxlength="20" />
3795 </tr>
3796 <tr>
3797 <td><p style="margin-bottom: 0px;"><?php _e( 'Today', 'polldaddy' );?></p></td>
3798 </tr>
3799 <tr>
3800 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_today" id="text_today" value="<?php echo empty( $settings->text_today ) ? 'Today' : esc_html( $settings->text_today ); ?>" maxlength="20" />
3801 </tr>
3802 <tr>
3803 <td><p style="margin-bottom: 0px;"><?php _e( 'This Week', 'polldaddy' );?></p></td>
3804 </tr>
3805 <tr>
3806 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_thisweek" id="text_thisweek" value="<?php echo empty( $settings->text_thisweek ) ? 'This Week' : esc_html( $settings->text_thisweek ); ?>" maxlength="20" />
3807 </tr>
3808 <tr>
3809 <td><p style="margin-bottom: 0px;"><?php _e( 'This Month', 'polldaddy' );?></p></td>
3810 </tr>
3811 <tr>
3812 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_thismonth" id="text_thismonth" value="<?php echo empty( $settings->text_thismonth ) ? 'This Month' : esc_html( $settings->text_thismonth ); ?>" maxlength="20" />
3813 </tr>
3814 <tr>
3815 <td><p style="margin-bottom: 0px;"><?php _e( 'Rated', 'polldaddy' );?></p></td>
3816 </tr>
3817 <tr>
3818 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_rated" id="text_rated" value="<?php echo empty( $settings->text_rated ) ? 'Rated' : esc_html( $settings->text_rated ); ?>" maxlength="20" />
3819 </tr>
3820 <tr>
3821 <td><p style="margin-bottom: 0px;"><?php _e( 'There are no rated items for this period', 'polldaddy' );?></p></td>
3822 </tr>
3823 <tr>
3824 <td><input onblur="pd_bind(this);" type="text" style="width: 100%;" name="text_noratings" id="text_noratings" value="<?php echo empty( $settings->text_noratings ) ? 'There are no rated items for this period' : esc_html( $settings->text_noratings ); ?>" maxlength="50" />
3825 </tr>
3826 </table>
3827 </div>
3828 </div>
3829 </div>
3830 <div id="post-body-content" class="has-sidebar-content">
3831 <div class="postbox">
3832 <h2 class="postbox-title"><?php _e( 'Rating Type', 'polldaddy' );?></h2>
3833 <div class="inside">
3834 <p><?php _e( 'Here you can choose how you want your rating to display. The 5 star rating is the most commonly used. The Nero rating is useful for keeping it simple.', 'polldaddy' ); ?></p>
3835 <ul>
3836 <li style="display: inline;margin-right: 10px;">
3837 <label for="stars"><?php
3838 $checked = '';
3839 if ( $settings->type == 'stars' )
3840 $checked = ' checked="checked"';?>
3841 <input type="radio" onchange="pd_change_type( 0 );" <?php echo $checked; ?> value="stars" id="stars" name="rating_type" />
3842 <?php
3843 /* translators: %d is the number of stars */
3844 printf( __( '%d Star Rating', 'polldaddy' ), 5 );?>
3845 </label>
3846 </li>
3847 <li style="display: inline;">
3848 <label><?php
3849 $checked = '';
3850 if ( $settings->type == 'nero' )
3851 $checked = ' checked="checked"';?>
3852 <input type="radio" onchange="pd_change_type( 1 );" <?php echo $checked; ?> value="nero" id="nero" name="rating_type" />
3853 <?php _e( 'Nero Rating', 'polldaddy' );?>
3854 </label>
3855 </li>
3856 </ul>
3857 </div>
3858 </div>
3859 <div class="postbox">
3860 <h2 class="postbox-title"><?php _e( 'Rating Style', 'polldaddy' );?></h2>
3861 <div class="inside">
3862 <table>
3863 <tr>
3864 <td height="30" width="100" id="editor_star_size_text"><?php _e( 'Star Size', 'polldaddy' );?></td>
3865 <td>
3866 <select name="size" id="size" onchange="pd_bind(this);"><?php
3867 $select = array( __( 'Small', 'polldaddy' )." (16px)" => "sml", __( 'Medium', 'polldaddy' )." (20px)" => "med", __( 'Large', 'polldaddy' )." (24px)" => "lrg" );
3868 foreach ( $select as $option => $value ) :
3869 $selected = '';
3870 if ( $settings->size == $value )
3871 $selected = ' selected="selected"';
3872 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3873 endforeach;?>
3874 </select>
3875 </td>
3876 </tr>
3877 <tr>
3878 <td height="30" id="editor_star_color_text"><?php echo 'bubu'; _e( 'Star Color', 'polldaddy' );?></td>
3879 <td>
3880 <select name="star_color" id="star_color" onchange="pd_bind(this);" style="display: none;"><?php
3881 $select = array( __( 'Yellow', 'polldaddy' ) => "yellow", __( 'Red', 'polldaddy' ) => "red", __( 'Blue', 'polldaddy' ) => "blue", __( 'Green', 'polldaddy' ) => "green", __( 'Grey', 'polldaddy' ) => "grey" );
3882 foreach ( $select as $option => $value ) :
3883 $selected = '';
3884 if ( $settings->star_color == $value )
3885 $selected = ' selected="selected"';
3886 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3887 endforeach;?>
3888 </select>
3889 <select name="nero_style" id="nero_style" onchange="pd_bind(this);" style="display: none;"><?php
3890 $select = array( __( 'Hand', 'polldaddy' ) => "hand" );
3891 foreach ( $select as $option => $value ) :
3892 $selected = '';
3893 if ( $settings->star_color == $value )
3894 $selected = ' selected="selected"';
3895 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3896 endforeach;?>
3897 </select>
3898 </td>
3899 </tr>
3900 <tr>
3901 <td height="30"><?php _e( 'Custom Image', 'polldaddy' );?></td>
3902 <td><input type="text" onblur="pd_bind(this);" name="custom_star" id="custom_star" value="<?php echo esc_url( $settings->custom_star ); ?>" maxlength="200" />
3903 </tr>
3904 </table>
3905 </div>
3906 </div>
3907 <div class="postbox">
3908 <h2 class="postbox-title"><?php _e( 'Text Layout & Font', 'polldaddy' );?></h2>
3909 <div class="inside">
3910 <table>
3911 <tr>
3912 <td width="100" height="30"><?php _e( 'Align', 'polldaddy' );?></td>
3913 <td>
3914 <select id="font_align" onchange="pd_bind(this);" name="font_align"><?php
3915 $select = array( __( 'Left', 'polldaddy' ) => "left", __( 'Center', 'polldaddy' ) => "center", __( 'Right', 'polldaddy' ) => "right" );
3916 foreach ( $select as $option => $value ):
3917 $selected = '';
3918 if ( $settings->font_align == $value )
3919 $selected = ' selected="selected"';
3920 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3921 endforeach;?>
3922 </select>
3923 </td>
3924 </tr>
3925 <tr>
3926 <td height="30"><?php _e( 'Position', 'polldaddy' );?></td>
3927 <td>
3928 <select name="font_position" onchange="pd_bind(this);" id="font_position"><?php
3929 $select = array( __( 'Top', 'polldaddy' ) => "top", __( 'Right', 'polldaddy' ) => "right", __( 'Bottom', 'polldaddy' ) => "bottom" );
3930 foreach ( $select as $option => $value ) :
3931 $selected = '';
3932 if ( $settings->font_position == $value )
3933 $selected = ' selected="selected"';
3934 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3935 endforeach;?>
3936 </select>
3937 </td>
3938 </tr>
3939 <tr>
3940 <td height="30"><?php _e( 'Font', 'polldaddy' );?></td>
3941 <td>
3942 <select name="font_family" id="font_family" onchange="pd_bind(this);"><?php
3943 $select = array( __( 'Inherit', 'polldaddy' ) => "", "Arial" => "arial", "Comic Sans MS" => "comic sans ms", "Courier" => "courier", "Georgia" => "georgia", "Lucida Grande" => "lucida grande", "Tahoma" => "tahoma", "Times" => "times", "Trebuchet MS" => "trebuchet ms", "Verdana" => "verdana" );
3944 foreach ( $select as $option => $value ) :
3945 $selected = '';
3946 if ( $settings->font_family == $value )
3947 $selected = ' selected="selected"';
3948 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3949 endforeach;?>
3950 </select>
3951 </td>
3952 </tr>
3953 <tr>
3954 <td height="30"><?php _e( 'Color', 'polldaddy' );?></td>
3955 <td><input type="text" onblur="pd_bind(this);" class="elmColor jscolor-picker" name="font_color" id="font_color" value="<?php echo esc_html( $settings->font_color ); ?>" maxlength="11" autocomplete="off"/>
3956 </td>
3957 </tr>
3958 <tr>
3959 <td><?php _e( 'Size', 'polldaddy' );?></td>
3960 <td>
3961 <select name="font_size" id="font_size" onchange="pd_bind(this);"><?php
3962 $select = array( __( 'Inherit', 'polldaddy' ) => "", "6px" => "6px", "8px" => "8px", "9px" => "9px", "10px" => "10px", "11px" => "11px", "12px" => "12px", "14px" => "14px", "16px" => "16px", "18px" => "18px", "20px" => "20px", "24px" => "24px", "30px" => "30px", "36px" => "36px", );
3963 foreach ( $select as $option => $value ) :
3964 $selected = '';
3965 if ( $settings->font_size == $value )
3966 $selected = ' selected="selected"';
3967 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3968 endforeach;?>
3969 </select>
3970 </td>
3971 </tr>
3972 <tr>
3973 <td height="30"><?php _e( 'Line Height', 'polldaddy' );?></td>
3974 <td>
3975 <select name="font_line_height" id="font_line_height" onchange="pd_bind(this);"><?php
3976 $select = array( __( 'Inherit', 'polldaddy' ) => "", "6px" => "6px", "8px" => "8px", "9px" => "9px", "10px" => "10px", "11px" => "11px", "12px" => "12px", "14px" => "14px", "16px" => "16px", "18px" => "18px", "20px" => "20px", "24px" => "24px", "30px" => "30px", "36px" => "36px", );
3977 foreach ( $select as $option => $value ) :
3978 $selected = '';
3979 if ( $settings->font_line_height == $value )
3980 $selected = ' selected="selected"';
3981 echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3982 endforeach; ?>
3983 </select>
3984 </td>
3985 </tr>
3986 <tr>
3987 <td height="30"><?php _e( 'Bold', 'polldaddy' );?></td>
3988 <td><?php
3989 $checked = '';
3990 if ( $settings->font_bold == 'bold' )
3991 $checked = ' checked="checked"';?>
3992 <input type="checkbox" name="font_bold" onclick="pd_bind(this);" id="font_bold" value="bold" <?php echo $checked; ?> />
3993 </td>
3994 </tr>
3995 <tr>
3996 <td height="30"><?php _e( 'Italic', 'polldaddy' );?></td><?php
3997 $checked = '';
3998 if ( $settings->font_italic == 'italic' )
3999 $checked = ' checked="checked"';?>
4000 <td><input type="checkbox" name="font_italic" onclick="pd_bind(this);" id="font_italic" value="italic" <?php echo $checked; ?>/></td>
4001 </tr>
4002 </table>
4003 </div>
4004 </div>
4005 <?php
4006 if ( $this->is_admin ) { ?>
4007 <div class="postbox">
4008 <h2 class="postbox-title"><?php _e( 'Extra Settings', 'polldaddy' );?></h2>
4009 <div class="inside">
4010 <table>
4011 <tr>
4012 <td width="100" height="30"><?php _e( 'Results Popup', 'polldaddy' );?></td>
4013 <td>
4014 <input type="checkbox" onchange="pd_bind(this);" value="on" name="polldaddy-rating-popup" id="polldaddy-rating-popup" <?php echo !$popup_disabled ? 'checked="checked"' : ''; ?> />
4015 </td>
4016 <td>
4017 <span class="description">
4018 <label for="polldaddy-rating-popup"><?php _e( 'Uncheck this box to disable the results popup', 'polldaddy' ); ?></label>
4019 </span>
4020 </td>
4021 </tr><?php
4022 if ( $report_type == 'posts' ) {
4023 $exclude_post_ids = esc_html( get_option( 'pd-rating-exclude-post-ids' ) ); ?>
4024 <tr>
4025 <td width="100" height="30"><?php _e( 'Rating ID', 'polldaddy' );?></td>
4026 <td>
4027 <input type="text" name="polldaddy-post-rating-id" id="polldaddy-post-rating-id" value="<?php echo esc_attr( $rating_id ); ?>" />
4028 </td>
4029 <td>
4030 <span class="description">
4031 <label for="polldaddy-post-rating-id"><?php _e( 'This is the rating ID used in posts', 'polldaddy' ); ?></label>
4032 </span>
4033 </td>
4034 </tr>
4035 <tr>
4036 <td width="100" height="30"><?php _e( 'Exclude Posts', 'polldaddy' );?></td>
4037 <td>
4038 <input type="text" name="exclude-post-ids" id="exclude-post-ids" value="<?php echo esc_attr( $exclude_post_ids ); ?>" />
4039 </td>
4040 <td>
4041 <span class="description">
4042 <label for="exclude-post-ids"><?php _e( 'Enter the Post IDs where you want to exclude ratings from. Please use a comma-delimited list, eg. 1,2,3', 'polldaddy' ); ?></label>
4043 </span>
4044 </td>
4045 </tr><?php
4046 } elseif ( $report_type == 'pages' ) {
4047 $exclude_page_ids = esc_html( get_option( 'pd-rating-exclude-page-ids' ) ); ?>
4048 <tr>
4049 <td width="100" height="30"><?php _e( 'Rating ID', 'polldaddy' );?></td>
4050 <td>
4051 <input type="text" name="polldaddy-page-rating-id" id="polldaddy-page-rating-id" value="<?php echo esc_attr( $rating_id ); ?>" />
4052 </td>
4053 <td>
4054 <span class="description">
4055 <label for="polldaddy-page-rating-id"><?php _e( 'This is the rating ID used in pages', 'polldaddy' ); ?></label>
4056 </span>
4057 </td>
4058 </tr>
4059 <tr>
4060 <td width="100" height="30"><?php _e( 'Exclude Pages', 'polldaddy' );?></td>
4061 <td>
4062 <input type="text" name="exclude-page-ids" id="exclude-page-ids" value="<?php echo esc_attr( $exclude_page_ids ); ?>" />
4063 </td>
4064 <td>
4065 <span class="description">
4066 <label for="exclude-page-ids"><?php _e( 'Enter the Page IDs where you want to exclude ratings from. Please use a comma-delimited list, eg. 1,2,3', 'polldaddy' ); ?></label>
4067 </span>
4068 </td>
4069 </tr><?php
4070 } elseif ( $report_type == 'comments' ) { ?>
4071 <tr>
4072 <td width="100" height="30"><?php _e( 'Rating ID', 'polldaddy' );?></td>
4073 <td>
4074 <input type="text" name="polldaddy-comment-rating-id" id="polldaddy-comment-rating-id" value="<?php echo esc_attr( $rating_id ); ?>" />
4075 </td>
4076 <td>
4077 <span class="description">
4078 <label for="polldaddy-comment-rating-id"><?php _e( 'This is the rating ID used in comments', 'polldaddy' ); ?></label>
4079 </span>
4080 </td>
4081 </tr><?php
4082 } ?>
4083 </table>
4084 </div>
4085 </div>
4086 <?php } ?>
4087 </div>
4088 </div>
4089 </form>
4090 <script language="javascript">
4091 jQuery( document ).ready(function(){
4092 plugin = new Plugin( {
4093 <?php /* translators: %s is the name of the rating being deleted */ ?>
4094 delete_rating: '<?php echo esc_attr( __( 'Are you sure you want to delete the rating for "%s"?', 'polldaddy' ) ); ?>',
4095 <?php /* translators: %s is the name of the poll being deleted */ ?>
4096 delete_poll: '<?php echo esc_attr( __( 'Are you sure you want to delete "%s"?', 'polldaddy' ) ); ?>',
4097 delete_answer: '<?php echo esc_attr( __( 'Are you sure you want to delete this answer?', 'polldaddy' ) ); ?>',
4098 delete_answer_title: '<?php echo esc_attr( __( 'delete this answer', 'polldaddy' ) ); ?>',
4099 standard_styles: '<?php echo esc_attr( __( 'Standard Styles', 'polldaddy' ) ); ?>',
4100 custom_styles: '<?php echo esc_attr( __( 'Custom Styles', 'polldaddy' ) ); ?>'
4101 } );
4102 });
4103 pd_map = { image_path : '<?php echo plugins_url( 'img', __FILE__ );?>' };
4104 </script>
4105 <script type="text/javascript">
4106 PDRTJS_settings = <?php echo $settings_text; ?>;
4107 PDRTJS_settings.id = "1";
4108 PDRTJS_settings.unique_id = "xxx";
4109 PDRTJS_settings.title = "";
4110 PDRTJS_settings.override = "<?php echo esc_attr( $rating_id ); ?>";
4111 PDRTJS_settings.permalink = "";
4112 PDRTJS_1 = new PDRTJS_RATING( PDRTJS_settings );
4113 pd_change_type( <?php echo $rating_type?> );
4114 </script><?php
4115 } ?>
4116 </div><?php
4117 } // from if !error ?>
4118 </div><?php
4119 }
4120
4121 function update_rating() {
4122 $rating_type = 0;
4123 $rating_id = 0;
4124 $new_rating_id = 0;
4125 $type = 'post';
4126 $set = new stdClass;
4127
4128 check_admin_referer( 'action-update-rating_' . $_POST[ 'type' ] );
4129
4130 if ( isset( $_REQUEST['rating_id'] ) )
4131 $rating_id = (int) $_REQUEST['rating_id'];
4132
4133 if ( isset( $_REQUEST['polldaddy-post-rating-id'] ) ) {
4134 $new_rating_id = (int) $_REQUEST['polldaddy-post-rating-id'];
4135 $type = 'posts';
4136 }
4137 elseif ( isset( $_REQUEST['polldaddy-page-rating-id'] ) ) {
4138 $new_rating_id = (int) $_REQUEST['polldaddy-page-rating-id'];
4139 $type = 'pages';
4140 }
4141 elseif ( isset( $_REQUEST['polldaddy-comment-rating-id'] ) ) {
4142 $new_rating_id = (int) $_REQUEST['polldaddy-comment-rating-id'];
4143 $type = 'comments';
4144 } else {
4145 $new_rating_id = $rating_id;
4146 }
4147
4148 if ( $rating_id > 0 && $rating_id == $new_rating_id ) {
4149 if ( isset( $_REQUEST['rating_type'] ) && $_REQUEST['rating_type'] == 'stars' ) {
4150 $set->type = 'stars';
4151 $rating_type = 0;
4152 if ( isset( $_REQUEST['star_color'] ) )
4153 $set->star_color = esc_attr( $_REQUEST['star_color'] );
4154 } else {
4155 $set->type = 'nero';
4156 $rating_type = 1;
4157 if ( isset( $_REQUEST['nero_style'] ) )
4158 $set->star_color = esc_attr( $_REQUEST['nero_style'] );
4159 }
4160
4161 $set->size = esc_html( $_REQUEST['size'], 1 );
4162 $set->custom_star = esc_html( esc_url( $_REQUEST['custom_star'] ) , 1 );
4163 $set->font_align = esc_html( $_REQUEST['font_align'], 1 );
4164 $set->font_position = esc_html( $_REQUEST['font_position'], 1 );
4165 $set->font_family = esc_html( $_REQUEST['font_family'], 1 );
4166 $set->font_size = esc_html( $_REQUEST['font_size'], 1 );
4167 $set->font_line_height = esc_html( $_REQUEST['font_line_height'], 1 );
4168
4169 if ( isset( $_REQUEST['font_bold'] ) && $_REQUEST['font_bold'] == 'bold' )
4170 $set->font_bold = 'bold';
4171 else
4172 $set->font_bold = 'normal';
4173
4174 if ( isset( $_REQUEST['font_italic'] ) && $_REQUEST['font_italic'] == 'italic' )
4175 $set->font_italic = 'italic';
4176 else
4177 $set->font_italic = 'normal';
4178
4179 $set->text_vote = rawurlencode( stripslashes( esc_html( $_REQUEST['text_vote'], 1 ) ) );
4180 $set->text_votes = rawurlencode( stripslashes( esc_html( $_REQUEST['text_votes'], 1 ) ) );
4181 $set->text_rate_this = rawurlencode( stripslashes( esc_html( $_REQUEST['text_rate_this'], 1 ) ) );
4182 $set->text_1_star = rawurlencode( stripslashes( esc_html( $_REQUEST['text_1_star'], 1 ) ) );
4183 $set->text_2_star = rawurlencode( stripslashes( esc_html( $_REQUEST['text_2_star'], 1 ) ) );
4184 $set->text_3_star = rawurlencode( stripslashes( esc_html( $_REQUEST['text_3_star'], 1 ) ) );
4185 $set->text_4_star = rawurlencode( stripslashes( esc_html( $_REQUEST['text_4_star'], 1 ) ) );
4186 $set->text_5_star = rawurlencode( stripslashes( esc_html( $_REQUEST['text_5_star'], 1 ) ) );
4187 $set->text_thank_you = rawurlencode( stripslashes( esc_html( $_REQUEST['text_thank_you'], 1 ) ) );
4188 $set->text_rate_up = rawurlencode( stripslashes( esc_html( $_REQUEST['text_rate_up'], 1 ) ) );
4189 $set->text_rate_down = rawurlencode( stripslashes( esc_html( $_REQUEST['text_rate_down'], 1 ) ) );
4190 $set->font_color = rawurlencode( stripslashes( esc_html( $_REQUEST['font_color'], 1 ) ) );
4191
4192 $set->text_popcontent= rawurlencode( stripslashes( esc_html( $_REQUEST['text_popcontent'], 1 ) ) );
4193 $set->text_close = rawurlencode( stripslashes( esc_html( $_REQUEST['text_close'], 1 ) ) );
4194 $set->text_all = rawurlencode( stripslashes( esc_html( $_REQUEST['text_all'], 1 ) ) );
4195 $set->text_today = rawurlencode( stripslashes( esc_html( $_REQUEST['text_today'], 1 ) ) );
4196 $set->text_thisweek = rawurlencode( stripslashes( esc_html( $_REQUEST['text_thisweek'], 1 ) ) );
4197 $set->text_thismonth = rawurlencode( stripslashes( esc_html( $_REQUEST['text_thismonth'], 1 ) ) );
4198 $set->text_rated = rawurlencode( stripslashes( esc_html( $_REQUEST['text_rated'], 1 ) ) );
4199 $set->text_noratings = rawurlencode( stripslashes( esc_html( $_REQUEST['text_noratings'], 1 ) ) );
4200
4201 $set->popup = 'off';
4202 if ( isset( $_REQUEST['polldaddy-rating-popup'] ) )
4203 $set->popup = ( $_REQUEST['polldaddy-rating-popup'] == 'on' ? 'on' : 'off' );
4204
4205 $settings_text = json_encode( $set );
4206
4207 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
4208 $polldaddy->reset();
4209 $rating = $polldaddy->update_rating( $rating_id, $settings_text, $rating_type );
4210 } elseif ( $this->is_admin && $new_rating_id > 0 ) {
4211 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
4212 $pd_rating = $polldaddy->get_rating( $new_rating_id );
4213 if ( false !== $pd_rating ) {
4214 switch ( $type ) {
4215 case 'pages':
4216 update_option( 'pd-rating-pages-id', $new_rating_id );
4217 if ( (int) get_option( 'pd-rating-pages' ) > 0 )
4218 update_option( 'pd-rating-pages', $new_rating_id );
4219 break;
4220 case 'comments':
4221 update_option( 'pd-rating-comments-id', $new_rating_id );
4222 if ( (int) get_option( 'pd-rating-comments' ) > 0 )
4223 update_option( 'pd-rating-comments', $new_rating_id );
4224 break;
4225 case 'posts':
4226 update_option( 'pd-rating-posts-id', $new_rating_id );
4227 if ( (int) get_option( 'pd-rating-posts' ) > 0 )
4228 update_option( 'pd-rating-posts', $new_rating_id );
4229 }
4230 }
4231 }
4232
4233 if ( $this->is_admin ) {
4234 if ( $type=='posts' && isset( $_REQUEST['exclude-post-ids'] ) ) {
4235 $exclude_post_ids = $_REQUEST['exclude-post-ids'];
4236 if ( empty( $exclude_post_ids ) ) {
4237 update_option( 'pd-rating-exclude-post-ids', '' );
4238 } else {
4239 $post_ids = array();
4240 $ids = explode( ',', $exclude_post_ids );
4241 if ( !empty( $ids ) ) {
4242 foreach ( (array) $ids as $id ) {
4243 if ( (int) $id > 0 )
4244 $post_ids[] = (int) $id;
4245 }
4246 }
4247 if ( !empty( $post_ids ) ) {
4248 $exclude_post_ids = implode( ',', $post_ids );
4249 update_option( 'pd-rating-exclude-post-ids', $exclude_post_ids );
4250 }
4251 }
4252 }
4253
4254 if ( $type=='pages' && isset( $_REQUEST['exclude-page-ids'] ) ) {
4255 $exclude_page_ids = $_REQUEST['exclude-page-ids'];
4256 if ( empty( $exclude_page_ids ) ) {
4257 update_option( 'pd-rating-exclude-page-ids', '' );
4258 } else {
4259 $page_ids = array();
4260 $ids = explode( ',', $exclude_page_ids );
4261 if ( !empty( $ids ) ) {
4262 foreach ( (array) $ids as $id ) {
4263 if ( (int) $id > 0 )
4264 $page_ids[] = (int) $id;
4265 }
4266 }
4267 if ( !empty( $page_ids ) ) {
4268 $exclude_page_ids = implode( ',', $page_ids );
4269 update_option( 'pd-rating-exclude-page-ids', $exclude_page_ids );
4270 }
4271 }
4272 }
4273 }
4274 }
4275 function rating_reports() {
4276 if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) || WP_POLLDADDY__PARTNERGUID == false )
4277 return false;
4278
4279 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
4280 $rating_id = get_option( 'pd-rating-posts-id' );
4281
4282 $report_type = 'posts';
4283 $period = '7';
4284 $show_rating = 0;
4285
4286 if ( isset( $_REQUEST['change-report-to'] ) ) {
4287 switch ( $_REQUEST['change-report-to'] ) {
4288 case 'pages':
4289 $report_type = 'pages';
4290 $rating_id = (int) get_option( 'pd-rating-pages-id' );
4291 break;
4292
4293 case 'comments':
4294 $report_type = 'comments';
4295 $rating_id = get_option( 'pd-rating-comments-id' );
4296 break;
4297
4298 case 'posts':
4299 $report_type = 'posts';
4300 $rating_id = get_option( 'pd-rating-posts-id' );
4301 break;
4302 }//end switch
4303 }
4304
4305 if ( isset( $_REQUEST['filter'] ) && $_REQUEST['filter'] ) {
4306 switch ( $_REQUEST['filter'] ) {
4307 case '1':
4308 $period = '1';
4309 break;
4310
4311 case '7':
4312 $period = '7';
4313 break;
4314
4315 case '31':
4316 $period = '31';
4317 break;
4318
4319 case '90':
4320 $period = '90';
4321 break;
4322
4323 case '365':
4324 $period = '365';
4325 break;
4326
4327 case 'all':
4328 $period = 'all';
4329 break;
4330 }//end switch
4331 }
4332
4333 $page_size = 15;
4334 $current_page = 1;
4335
4336 if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'change-report' ) {
4337 $current_page = 1;
4338 } else {
4339 if ( isset( $_REQUEST['paged'] ) ) {
4340 $current_page = (int) $_REQUEST['paged'];
4341 if ( $current_page == 0 )
4342 $current_page = 1;
4343 }
4344 }
4345
4346 $start = ( $current_page * $page_size ) - $page_size;
4347 $end = $page_size;
4348
4349 $response = $polldaddy->get_rating_results( $rating_id, $period, $start, $end );
4350
4351 $total = $total_pages = 0;
4352 $ratings = null;
4353
4354 if ( !empty( $response ) ) {
4355 $ratings = $response->rating;
4356 $total = (int) $response->_total;
4357 $total_pages = ceil( $total / $page_size );
4358 }
4359
4360 $page_links = paginate_links( array(
4361 'base' => add_query_arg( array ( 'paged' => '%#%', 'change-report-to' => $report_type, 'filter' => $period ) ),
4362 'format' => '',
4363 'prev_text' => __( '&laquo;', 'polldaddy' ),
4364 'next_text' => __( '&raquo;', 'polldaddy' ),
4365 'total' => $total_pages,
4366 'current' => $current_page,
4367 'prev_text' => '&laquo;',
4368 'next_text' => '&raquo;'
4369 ) );
4370 ?>
4371 <div class="wrap">
4372 <?php if ( $this->is_admin ) : ?>
4373 <h2 id="polldaddy-header"><?php
4374 /* translators: %s is the URL to Crowdsignal settings page */
4375 printf( __( 'Rating Results <a href="%s" class="add-new-h2">Settings</a>', 'polldaddy' ), esc_url( 'options-general.php?page=ratingsettings' ) ); ?></h2>
4376 <?php else : ?>
4377 <h2 id="polldaddy-header"><?php _e( 'Rating Results', 'polldaddy' ); ?></h2>
4378 <?php endif; ?>
4379 <div class="clear"></div>
4380 <form method="post" action="">
4381 <div class="tablenav">
4382 <div class="alignleft actions">
4383 <?php if ( $this->is_editor ) { ?>
4384 <select name="action">
4385 <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
4386 <option value="delete"><?php _e( 'Delete', 'polldaddy' ); ?></option>
4387 </select>
4388 <input type="hidden" name="id" id="id" value="<?php echo (int) $rating_id; ?>" />
4389 <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
4390 <?php wp_nonce_field( 'action-rating_bulk' ); ?>
4391 <?php } ?>
4392 <select name="change-report-to"><?php
4393 $select = array( __( 'Posts', 'polldaddy' ) => "posts", __( 'Pages', 'polldaddy' ) => "pages", __( 'Comments', 'polldaddy' ) => "comments" );
4394 foreach ( $select as $option => $value ) :
4395 $selected = '';
4396 if ( $value == $report_type )
4397 $selected = ' selected="selected"';?>
4398 <option value="<?php echo esc_attr( $value ); ?>" <?php echo $selected; ?>><?php echo $option; ?></option>
4399 <?php endforeach; ?>
4400 </select>
4401 <select name="filter"><?php
4402 $select = array( __( 'Last 24 hours', 'polldaddy' ) => "1", __( 'Last 7 days', 'polldaddy' ) => "7", __( 'Last 31 days', 'polldaddy' ) => "31", __( 'Last 3 months', 'polldaddy' ) => "90", __( 'Last 12 months', 'polldaddy' ) => "365", __( 'All time', 'polldaddy' ) => "all" );
4403 foreach ( $select as $option => $value ) :
4404 $selected = '';
4405 if ( $value == $period )
4406 $selected = ' selected="selected"';?>
4407 <option value="<?php echo esc_attr( $value ); ?>" <?php echo $selected; ?>><?php echo $option; ?></option>
4408 <?php endforeach; ?>
4409 </select>
4410 <input class="button-secondary action" type="submit" value="<?php _e( 'Filter', 'polldaddy' );?>" />
4411 <?php if ( in_array( $period, array( 1, 7 ) ) ) : ?>
4412 <label><?php _e( '* The results are cached and are updated every hour', 'polldaddy' ); ?></label>
4413 <?php elseif ( $period == 31 ) : ?>
4414 <label><?php _e( '* The results are cached and are updated every day', 'polldaddy' ); ?></label>
4415 <?php else : ?>
4416 <label><?php _e( '* The results are cached and are updated every 3 days', 'polldaddy' ); ?></label>
4417 <?php endif; ?>
4418 </div>
4419 <div class="alignright">
4420 <div class="tablenav-pages">
4421 <?php echo $page_links; ?>
4422 </div>
4423 </div>
4424 </div>
4425
4426 <table class="widefat"><?php
4427 if ( empty( $ratings ) ) { ?>
4428 <tbody>
4429 <tr>
4430 <td colspan="4"><?php
4431 /* translators: %s is the report type */
4432 printf( __( 'No ratings have been collected for your %s yet.', 'polldaddy' ), $report_type ); ?></td>
4433 </tr>
4434 </tbody><?php
4435 } else {
4436 ?>
4437 <thead>
4438 <tr>
4439 <?php if ( $this->is_editor ) { ?>
4440 <th scope="col" class="manage-column column-cb check-column" id="cb"><input type="checkbox"></th>
4441 <?php } else { ?>
4442 <th scope="col" class="manage-column column-cb check-column" id="cb"></th>
4443 <?php } ?>
4444 <th scope="col" class="manage-column column-title" id="title"><?php _e( 'Title', 'polldaddy' );?></th>
4445 <th scope="col" class="manage-column column-id" id="id"><?php _e( 'Unique ID', 'polldaddy' );?></th>
4446 <th scope="col" class="manage-column column-date" id="date"><?php _e( 'Start Date', 'polldaddy' );?></th>
4447 <th scope="col" class="manage-column column-vote num" id="votes"><?php _e( 'Votes', 'polldaddy' );?></th>
4448 <th scope="col" class="manage-column column-rating num" id="rating"><?php _e( 'Average Rating', 'polldaddy' );?></th>
4449 </tr>
4450 </thead>
4451 <tbody><?php
4452 $alt_counter = 0;
4453 $alt = '';
4454
4455 foreach ( $ratings as $rating ) :
4456 $delete_link = esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $rating_id, 'rating' => $rating->uid, 'change-report-to' => $report_type, 'message' => false ) ), "delete-rating_$rating->uid" ) );
4457 $alt_counter++;?>
4458 <tr <?php echo ( $alt_counter & 1 ) ? ' class="alternate"' : ''; ?>>
4459 <th class="check-column" scope="row"><input type="checkbox" value="<?php echo esc_html( $rating->uid ); ?>" name="rating[]" /></th>
4460 <td class="post-title column-title">
4461 <strong><a href="<?php echo esc_url( $rating->permalink ); ?>"><?php echo strlen( esc_html( $rating->title ) ) > 75 ? substr( esc_html( $rating->title ), 0, 72 ) . '&hellip' : esc_html( $rating->title ); ?></a></strong>
4462 <div class="row-actions">
4463 <?php if ( $this->is_editor && $delete_link ) { ?>
4464 <span class="delete"><a class="delete-rating delete" href="<?php echo esc_url( $delete_link ); ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a></span>
4465 <?php } ?>
4466 </div>
4467 </td>
4468 <td class="column-id">
4469 <?php echo esc_html( $rating->uid ); ?>
4470 </td>
4471 <td class="date column-date">
4472 <abbr title="<?php echo date( __( 'Y/m/d g:i:s A', 'polldaddy' ), strtotime( $rating->date ) ); ?>"><?php echo str_replace( '-', '/', substr( esc_html( $rating->date ), 0, 10 ) ); ?></abbr>
4473 </td>
4474 <td class="column-vote num"><?php echo number_format( $rating->_votes ); ?></td>
4475 <td class="column-rating num"><table width="100%"><tr align="center"><td style="border:none;"><?php
4476 if ( $rating->_type == 0 ) {
4477 $avg_rating = $this->round( $rating->average_rating, 0.5 );?>
4478 <div style="width:100px"><?php
4479 $image_pos = '';
4480
4481 for ( $c = 1; $c <= 5; $c++ ) :
4482 if ( $avg_rating > 0 ) {
4483 if ( $avg_rating < $c )
4484 $image_pos = 'bottom left';
4485 if ( $avg_rating == ( $c - 1 + 0.5 ) )
4486 $image_pos = 'center left';
4487 } ?>
4488 <div style="width: 20px; height: 20px; background: url(<?php echo plugins_url( 'img/star-yellow-med.png', __FILE__ ); ?>) <?php echo $image_pos; ?>; float: left;"></div><?php
4489 endfor; ?>
4490 <br class="clear" />
4491 </div><?php
4492 } else { ?>
4493 <div>
4494 <div style="margin: 0px 0px 0px 20px; background: transparent url(<?php echo plugins_url( 'img/rate-graph-up.png', __FILE__ ); ?>); width: 20px; height: 20px; float: left;"></div>
4495 <div style="float:left; line-height: 20px; padding: 0px 10px 0px 5px;"><?php echo number_format( $rating->total1 );?></div>
4496 <div style="margin: 0px; background: transparent url(<?php echo plugins_url( 'img/rate-graph-dn.png', __FILE__ ); ?>); width: 20px; height: 20px; float: left;"></div>
4497 <div style="float:left; line-height: 20px; padding: 0px 10px 0px 5px;"><?php echo number_format( $rating->total2 );?></div>
4498 <br class="clear" />
4499 </div><?php
4500 } ?>
4501 </td></tr></table>
4502 </td>
4503 </tr><?php
4504 endforeach;
4505 ?>
4506 </tbody><?php
4507 } ?>
4508 </table>
4509 <div class="tablenav">
4510 <div class="alignright">
4511 <div class="tablenav-pages">
4512 <?php echo $page_links; ?>
4513 </div>
4514 </div>
4515 </div>
4516 </form>
4517 </div>
4518 <p></p>
4519 <script language="javascript">
4520 jQuery( document ).ready(function(){
4521 plugin = new Plugin( {
4522 <?php /* translators: %s is the name of the rating being deleted */ ?>
4523 delete_rating: '<?php echo esc_attr( __( 'Are you sure you want to delete the rating for "%s"?', 'polldaddy' ) ); ?>',
4524 <?php /* translators: %s is the name of the poll being deleted */ ?>
4525 delete_poll: '<?php echo esc_attr( __( 'Are you sure you want to delete "%s"?', 'polldaddy' ) ); ?>',
4526 delete_answer: '<?php echo esc_attr( __( 'Are you sure you want to delete this answer?', 'polldaddy' ) ); ?>',
4527 delete_answer_title: '<?php echo esc_attr( __( 'delete this answer', 'polldaddy' ) ); ?>',
4528 standard_styles: '<?php echo esc_attr( __( 'Standard Styles', 'polldaddy' ) ); ?>',
4529 custom_styles: '<?php echo esc_attr( __( 'Custom Styles', 'polldaddy' ) ); ?>'
4530 } );
4531 });
4532 </script><?php
4533 }
4534
4535 function plugin_options() {
4536 if ( isset( $_POST['polldaddy_email'] ) ) {
4537 $account_email = false;
4538 } else {
4539 $connected = false;
4540 $account_email = '';
4541 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
4542 $account = $polldaddy->get_account();
4543
4544 if ( ! empty( $account ) ) {
4545 $connected = true;
4546 $account_email = $account->email;
4547 }
4548
4549 $polldaddy->reset();
4550 $poll = $polldaddy->get_poll( 1 );
4551
4552 $options = array(
4553 101 => __( 'Aluminum Narrow', 'polldaddy' ),
4554 102 => __( 'Aluminum Medium', 'polldaddy' ),
4555 103 => __( 'Aluminum Wide', 'polldaddy' ),
4556 104 => __( 'Plain White Narrow', 'polldaddy' ),
4557 105 => __( 'Plain White Medium', 'polldaddy' ),
4558 106 => __( 'Plain White Wide', 'polldaddy' ),
4559 107 => __( 'Plain Black Narrow', 'polldaddy' ),
4560 108 => __( 'Plain Black Medium', 'polldaddy' ),
4561 109 => __( 'Plain Black Wide', 'polldaddy' ),
4562 110 => __( 'Paper Narrow', 'polldaddy' ),
4563 111 => __( 'Paper Medium', 'polldaddy' ),
4564 112 => __( 'Paper Wide', 'polldaddy' ),
4565 113 => __( 'Skull Dark Narrow', 'polldaddy' ),
4566 114 => __( 'Skull Dark Medium', 'polldaddy' ),
4567 115 => __( 'Skull Dark Wide', 'polldaddy' ),
4568 116 => __( 'Skull Light Narrow', 'polldaddy' ),
4569 117 => __( 'Skull Light Medium', 'polldaddy' ),
4570 118 => __( 'Skull Light Wide', 'polldaddy' ),
4571 157 => __( 'Micro', 'polldaddy' ),
4572 119 => __( 'Plastic White Narrow', 'polldaddy' ),
4573 120 => __( 'Plastic White Medium', 'polldaddy' ),
4574 121 => __( 'Plastic White Wide', 'polldaddy' ),
4575 122 => __( 'Plastic Grey Narrow', 'polldaddy' ),
4576 123 => __( 'Plastic Grey Medium', 'polldaddy' ),
4577 124 => __( 'Plastic Grey Wide', 'polldaddy' ),
4578 125 => __( 'Plastic Black Narrow', 'polldaddy' ),
4579 126 => __( 'Plastic Black Medium', 'polldaddy' ),
4580 127 => __( 'Plastic Black Wide', 'polldaddy' ),
4581 128 => __( 'Manga Narrow', 'polldaddy' ),
4582 129 => __( 'Manga Medium', 'polldaddy' ),
4583 130 => __( 'Manga Wide', 'polldaddy' ),
4584 131 => __( 'Tech Dark Narrow', 'polldaddy' ),
4585 132 => __( 'Tech Dark Medium', 'polldaddy' ),
4586 133 => __( 'Tech Dark Wide', 'polldaddy' ),
4587 134 => __( 'Tech Grey Narrow', 'polldaddy' ),
4588 135 => __( 'Tech Grey Medium', 'polldaddy' ),
4589 136 => __( 'Tech Grey Wide', 'polldaddy' ),
4590 137 => __( 'Tech Light Narrow', 'polldaddy' ),
4591 138 => __( 'Tech Light Medium', 'polldaddy' ),
4592 139 => __( 'Tech Light Wide', 'polldaddy' ),
4593 140 => __( 'Working Male Narrow', 'polldaddy' ),
4594 141 => __( 'Working Male Medium', 'polldaddy' ),
4595 142 => __( 'Working Male Wide', 'polldaddy' ),
4596 143 => __( 'Working Female Narrow', 'polldaddy' ),
4597 144 => __( 'Working Female Medium', 'polldaddy' ),
4598 145 => __( 'Working Female Wide', 'polldaddy' ),
4599 146 => __( 'Thinking Male Narrow', 'polldaddy' ),
4600 147 => __( 'Thinking Male Medium', 'polldaddy' ),
4601 148 => __( 'Thinking Male Wide', 'polldaddy' ),
4602 149 => __( 'Thinking Female Narrow', 'polldaddy' ),
4603 150 => __( 'Thinking Female Medium', 'polldaddy' ),
4604 151 => __( 'Thinking Female Wide', 'polldaddy' ),
4605 152 => __( 'Sunset Narrow', 'polldaddy' ),
4606 153 => __( 'Sunset Medium', 'polldaddy' ),
4607 154 => __( 'Sunset Wide', 'polldaddy' ),
4608 155 => __( 'Music Medium', 'polldaddy' ),
4609 156 => __( 'Music Wide', 'polldaddy' ),
4610 );
4611
4612 $polldaddy->reset();
4613 $styles = $polldaddy->get_styles();
4614
4615 if ( ! empty( $styles ) && ! empty( $styles->style ) && count( $styles->style ) > 0 ) {
4616 foreach ( (array) $styles->style as $style ) {
4617 $options[ (int) $style->_id ] = $style->title;
4618 }
4619 }
4620 }
4621
4622 $this->print_errors();
4623
4624 $this->render_partial( 'html-admin-setup-header' );
4625 if ( ! $connected ) {
4626 update_option( 'crowdsignal_api_key_secret', md5( time() . wp_rand() ) );
4627 $this->render_partial( 'html-admin-setup-step-1' );
4628 } else {
4629 $this->render_partial(
4630 'settings',
4631 array(
4632 'is_connected' => $connected,
4633 'api_key' => get_option( 'polldaddy_api_key' ),
4634 )
4635 );
4636
4637 if ( ! is_plugin_active( 'crowdsignal-forms/crowdsignal-forms.php' ) ) {
4638 $this->render_partial( 'html-admin-teaser' );
4639 } else {
4640 $this->render_partial( 'html-admin-setup-step-3' );
4641 }
4642
4643 $this->render_partial(
4644 'settings-2',
4645 array(
4646 'is_connected' => $connected,
4647 'api_key' => get_option( 'polldaddy_api_key' ),
4648 'poll' => $poll,
4649 'options' => $options,
4650 'controller' => $this,
4651 'account_email' => $account_email,
4652 )
4653 );
4654 }
4655 $this->render_partial( 'html-admin-setup-footer' );
4656 }
4657
4658 function plugin_options_add() {}
4659
4660 function round( $number, $increments ) {
4661 $increments = 1 / $increments;
4662 return round( $number * $increments ) / $increments;
4663 }
4664
4665 function signup() {
4666 return $this->api_key_page();
4667 }
4668
4669 function can_edit( &$poll ) {
4670 if ( empty( $poll->_owner ) ) {
4671 $this->log( 'can_edit: poll owner is empty.' );
4672 return true;
4673 }
4674
4675 if ( $this->id == $poll->_owner ) {
4676 $this->log( 'can_edit: poll owner equals id.' );
4677 return true;
4678 }
4679
4680 if ( $poll->parentID == (int) $GLOBALS['blog_id'] && current_user_can( 'edit_others_posts' ) ) {
4681 $this->log( 'can_edit: poll was created on this blog and current user can edit_others_posts' );
4682 return true;
4683 }
4684
4685 if ( false == (bool) current_user_can( 'edit_others_posts' ) )
4686 $this->log( 'can_edit: current user cannot edit_others_posts.' );
4687
4688 return (bool) current_user_can( 'edit_others_posts' );
4689 }
4690
4691 function log( $message ) {
4692 // error_log( print_r( $message, true ) );
4693 }
4694
4695 function contact_support_message( $message, $errors ) {
4696 global $current_user;
4697 echo '<div class="error" id="polldaddy">';
4698 echo '<h1>' . $message . '</h1>';
4699 echo '<p>' . __( "There are a few things you can do:", 'polldaddy' );
4700 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>";
4701 /* translators: %1$s is the URL to Crowdsignal settings page */
4702 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=crowdsignal-settings' ) . "</ol>";
4703 /* translators: %1$s is the URL to Crowdsignal support, %2$s is the target attribute, %3$s is the rating usercode */
4704 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' ) . '';
4705 echo "<ul><li> API Key: " . get_option( 'polldaddy_api_key' ) . "</li>";
4706 echo "<li> ID Usercode: " . get_option( 'pd-usercode-' . $current_user->ID ) . "</li>";
4707 echo "<li> pd-rating-usercode: " . get_option( 'pd-rating-usercode' ) . "</li>";
4708 echo "<li> pd-rating-posts-id: " . get_option( 'pd-rating-posts-id' ) . "</li>";
4709 echo "<li> Errors: " . print_r( $errors, 1 ) . "</li></ul>";
4710 echo "</ol></ul></div>";
4711 }
4712
4713 /**
4714 * Renders a partial/template.
4715 *
4716 * The global $current_user is made available for any rendered template.
4717 *
4718 * @param string $partial - Filename under ./partials directory, with or without .php (appended if absent).
4719 * @param array $page_vars - Variables made available for the template.
4720 */
4721 public function render_partial( $partial, array $page_vars = array() ) {
4722 if ( substr( $partial, -4 ) !== '.php' ) {
4723 $partial .= '.php';
4724 }
4725
4726 if ( strpos( $partial, 'partials/' ) !== 0 ) {
4727 $partial = 'partials/' . $partial;
4728 }
4729
4730 $path = __DIR__ . '/' . $partial;
4731 if ( ! file_exists( $path ) ) {
4732 return;
4733 }
4734
4735 foreach ( $page_vars as $key => $val ) {
4736 $$key = $val;
4737 }
4738 global $current_user;
4739 include $path;
4740 }
4741 }
4742
4743 require dirname( __FILE__ ).'/rating.php';
4744 require dirname( __FILE__ ).'/ajax.php';
4745 require dirname( __FILE__ ).'/popups.php';
4746 require dirname( __FILE__ ).'/polldaddy-org.php';
4747 require dirname( __FILE__ ).'/polldaddy-shortcode.php';
4748
4749 $GLOBALS[ 'wp_log_plugins' ][] = 'polldaddy';
4750