PluginProbe
Crowdsignal Dashboard – Polls, Surveys & more / 3.1.3
Crowdsignal Dashboard – Polls, Surveys & more v3.1.3
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.3, 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 Polls & Ratings
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.3
9 * Text Domain: polldaddy
10 * Domain Path: /languages
11 */
12
13 // To hardcode your Polldaddy PartnerGUID (API Key), add the (uncommented) line below with the PartnerGUID to your `wp-config.php`
14 // define( 'WP_POLLDADDY__PARTNERGUID', '12345…' );
15
16 if ( ! defined( 'POLLDADDY_API_HOST' ) ) {
17 define( 'POLLDADDY_API_HOST', 'api.crowdsignal.com' );
18 }
19
20 if ( ! defined( 'POLLDADDY_API_VERSION' ) ) {
21 define( 'POLLDADDY_API_VERSION', 'v1' );
22 }
23
24 function polldaddy_api_path( $path, $version = POLLDADDY_API_VERSION ) {
25 return sprintf( '/%s%s', $version, $path );
26 }
27
28 function polldaddy_api_url( $path, $version = POLLDADDY_API_VERSION, $protocol = 'https' ) {
29 return sprintf(
30 '%s://%s%s',
31 $protocol,
32 POLLDADDY_API_HOST,
33 rtrim( polldaddy_api_path( $path, $version ), '/' )
34 );
35 }
36
37 function polldaddy_add_oembed_provider() {
38 wp_oembed_add_provider( '#https?://(.+\.)?polldaddy\.com/.*#i', 'https://api.crowdsignal.com/oembed', true );
39 wp_oembed_add_provider( '#https?://.+\.survey\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
40 wp_oembed_add_provider( '#https?://poll\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
41 }
42 add_action( 'init', 'polldaddy_add_oembed_provider' );
43
44 /**
45 * Get the nonce action string for polls media functionality.
46 *
47 * @return string Nonce action string specific to current user
48 */
49 function get_polls_media_nonce() {
50 return 'polls_media_' . get_current_user_id();
51 }
52
53 class WP_Polldaddy {
54 var $errors;
55 var $base_url;
56 var $is_admin;
57 var $is_author;
58 var $scheme;
59 var $version;
60 var $polldaddy_client_class;
61 var $polldaddy_clients;
62 var $id;
63 var $multiple_accounts;
64 var $user_code;
65 var $rating_user_code;
66 var $has_feedback_menu;
67 var $is_editor;
68 var $has_crowdsignal_blocks;
69
70 public $has_items = array();
71
72 function __construct() {
73 global $current_user;
74 $this->log( 'Created WP_Polldaddy Object: constructor' );
75 $this->errors = new WP_Error;
76 $this->scheme = 'https';
77 $this->version = '3.1.2';
78 $this->multiple_accounts = ! empty( get_option( 'polldaddy_usercode_user' ) );
79 $this->polldaddy_client_class = 'api_client';
80 $this->polldaddy_clients = array();
81 $this->is_admin = (bool) current_user_can( 'manage_options' );
82 $this->is_author = (bool) current_user_can( 'edit_posts' );
83 $this->is_editor = (bool) current_user_can( 'delete_others_pages' );
84 $this->user_code = null;
85 $this->rating_user_code = null;
86 $this->id = ($current_user instanceof WP_User) ? intval( $current_user->ID ): 0;
87 $this->has_feedback_menu = false;
88 $this->has_crowdsignal_blocks = ! empty( get_option( 'crowdsignal_user_code' ) );
89
90 if ( class_exists( 'Jetpack' ) ) {
91 if ( method_exists( 'Jetpack', 'is_active' ) && Jetpack::is_active() ) {
92 $jetpack_active_modules = get_option('jetpack_active_modules');
93 if ( $jetpack_active_modules && in_array( 'contact-form', $jetpack_active_modules ) )
94 $this->has_feedback_menu = true;
95 }
96
97 if ( class_exists( 'Jetpack_Sync' ) && defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '4.1', '<' ) ) {
98 Jetpack_Sync::sync_options( __FILE__, 'polldaddy_api_key' );
99 }
100
101 add_filter( 'jetpack_options_whitelist', array( $this, 'add_to_jetpack_options_whitelist' ) );
102 }
103
104 if ( ! post_type_exists( 'feedback' ) ) {
105 register_post_type(
106 'feedback', array(
107 'labels' => array(
108 ),
109 'menu_icon' => 'dashicons-feedback',
110 'show_ui' => true,
111 'show_in_menu' => 'edit.php?post_type=feedback',
112 'show_in_admin_bar' => false,
113 'public' => false,
114 'rewrite' => false,
115 'query_var' => false,
116 'capability_type' => 'page',
117 'show_in_rest' => true,
118 'rest_controller_class' => 'Grunion_Contact_Form_Endpoint',
119 'capabilities' => array(
120 'create_posts' => 'do_not_allow',
121 'publish_posts' => 'publish_pages',
122 'edit_posts' => 'edit_pages',
123 'edit_others_posts' => 'edit_others_pages',
124 'delete_posts' => 'delete_pages',
125 'delete_others_posts' => 'delete_others_pages',
126 'read_private_posts' => 'read_private_pages',
127 'edit_post' => 'edit_page',
128 'delete_post' => 'delete_page',
129 'read_post' => 'read_page',
130 ),
131 'map_meta_cap' => true,
132 )
133 );
134 add_action( 'admin_menu', array( $this, 'remove_feedback_menu' ) );
135 }
136 }
137
138 /**
139 * Remove the feedback "All Posts" submenu if not needed.
140 */
141 public function remove_feedback_menu() {
142 remove_submenu_page( 'edit.php?post_type=feedback', 'edit.php?post_type=feedback' );
143 }
144
145 /**
146 * Add the polldaddy option to the Jetpack options management whitelist.
147 *
148 * @param array $options The list of whitelisted option names.
149 * @return array The updated whitelist
150 */
151 public static function add_to_jetpack_options_whitelist( $options ) {
152 $options[] = 'polldaddy_api_key';
153 return $options;
154 }
155
156 function &get_client( $api_key, $userCode = null ) {
157 if ( isset( $this->polldaddy_clients[$api_key] ) ) {
158 if ( !is_null( $userCode ) )
159 $this->polldaddy_clients[$api_key]->userCode = $userCode;
160 return $this->polldaddy_clients[$api_key];
161 }
162 require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
163 $this->polldaddy_clients[$api_key] = $this->config_client( new $this->polldaddy_client_class( $api_key, $userCode ) );
164 return $this->polldaddy_clients[$api_key];
165 }
166
167 function config_client( $client ) {
168
169 return $client;
170 }
171
172 function admin_menu() {
173 if ( isset( $_GET['page'] ) && 'pollsettings' === $_GET['page'] ) {
174 wp_safe_redirect( admin_url( 'options-general.php?page=crowdsignal-settings' ) );
175 die();
176 }
177 add_action( 'wp_enqueue_scripts', array( &$this, 'register_polldaddy_styles' ) );
178 add_action( 'admin_enqueue_scripts', array( &$this, 'menu_alter' ) );
179
180 if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
181 $guid = get_option( 'polldaddy_api_key' );
182 if ( !$guid || !is_string( $guid ) )
183 $guid = false;
184 define( 'WP_POLLDADDY__PARTNERGUID', $guid );
185
186 }
187
188 $capability = 'edit_posts';
189 $function = array( &$this, 'management_page' );
190
191 $icon_encoded = 'PHN2ZyBpZD0iY29udGVudCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMjg4IDIyMCI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNGRkZGRkY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5pY29uLWJsdWU8L3RpdGxlPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTI2Mi40MSw4MC4xYy04LjQ3LTIyLjU1LTE5LjA1LTQyLjgzLTI5Ljc5LTU3LjFDMjIwLjc0LDcuMjQsMjEwLC41NywyMDEuNDcsMy43OWExMi4zMiwxMi4zMiwwLDAsMC0zLjcyLDIuM2wtLjA1LS4xNUwxNiwxNzMuOTRsOC4yLDE5LjEyLDMwLjU2LTEuOTJ2MTMuMDVhMTIuNTcsMTIuNTcsMCwwLDAsMTIuNTgsMTIuNTZjLjMzLDAsLjY3LDAsMSwwbDU4Ljg1LTQuNzdhMTIuNjUsMTIuNjUsMCwwLDAsMTEuNTYtMTIuNTNWMTg1Ljg2bDEyMS40NS03LjY0YTEzLjg4LDEzLjg4LDAsMCwwLDIuMDkuMjYsMTIuMywxMi4zLDAsMCwwLDQuNDEtLjhDMjg1LjMzLDE3MC43LDI3OC42MywxMjMuMzEsMjYyLjQxLDgwLjFabS0yLjI2LDg5Ljc3Yy0xMC40OC0zLjI1LTMwLjQ0LTI4LjE1LTQ2LjY4LTcxLjM5LTE1LjcyLTQxLjktMTcuNS03My4yMS0xMi4zNC04My41NGE2LjUyLDYuNTIsMCwwLDEsMy4yMi0zLjQ4LDMuODIsMy44MiwwLDAsMSwxLjQxLS4yNGMzLjg1LDAsMTAuOTQsNC4yNiwyMC4zMSwxNi43MUMyMzYuMzYsNDEuNTksMjQ2LjU0LDYxLjE1LDI1NC43NCw4M2MxOC40NCw0OS4xMiwxNy43NCw4My43OSw5LjEzLDg3QTUuOTMsNS45MywwLDAsMSwyNjAuMTUsMTY5Ljg3Wk0xMzAuNiwxOTkuNDFhNC40LDQuNCwwLDAsMS00LDQuMzdsLTU4Ljg1LDQuNzdBNC4zOSw0LjM5LDAsMCwxLDYzLDIwNC4xOVYxOTAuNjJsNjcuNjEtNC4yNVoiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik02LDE4NS4yNmExMC4yNSwxMC4yNSwwLDAsMCwxMC4yNSwxMC4yNSwxMC4wNSwxMC4wNSwwLDAsMCw0LjM0LTFsLTcuOTQtMTguNzNBMTAuMiwxMC4yLDAsMCwwLDYsMTg1LjI2WiIvPjwvc3ZnPgo=';
192
193 $slug = 'edit.php?post_type=feedback';
194
195 if ( ! $this->has_feedback_menu ) {
196 $hook = add_menu_page(
197 __( 'Feedback', 'polldaddy' ),
198 __( 'Feedback', 'polldaddy' ),
199 $capability,
200 $slug,
201 $function,
202 'data:image/svg+xml;base64,' . $icon_encoded
203 );
204 add_action( "load-$hook", array( &$this, 'management_page_load' ) );
205 }
206
207 foreach( array( 'polls' => __( 'Crowdsignal', 'polldaddy' ), 'ratings' => __( 'Ratings', 'polldaddy' ) ) as $menu_slug => $page_title ) {
208 $menu_title = $page_title;
209
210 $hook = add_submenu_page( $this->has_feedback_menu ? 'feedback' : $slug, $menu_title, $menu_title, $capability, $menu_slug, $function, 99 );
211 add_action( "load-$hook", array( &$this, 'management_page_load' ) );
212 }
213
214 // Add settings pages.
215 foreach( array( 'crowdsignal-settings' => __( 'Crowdsignal', 'polldaddy' ), 'ratingsettings' => __( 'Ratings', 'polldaddy' ) ) as $menu_slug => $page_title ) {
216 $settings_page_title = sprintf( esc_html( $page_title ) );
217 $hook = add_options_page( $settings_page_title, $settings_page_title, $menu_slug == 'ratingsettings' ? 'manage_options' : 'edit_others_posts', $menu_slug, array( $this, 'settings_page' ) );
218 add_action( "load-$hook", array( $this, 'management_page_load' ) );
219 }
220
221 }
222
223 function menu_alter() {
224 // Make sure we're working off a clean version.
225 include( ABSPATH . WPINC . '/version.php' );
226
227 if ( version_compare( $wp_version, '3.8', '<' ) ) {
228 $css = "
229 #toplevel_page_polldaddy .wp-menu-image {
230 background: url( " . plugins_url( 'img/polldaddy.png', __FILE__ ) . " ) 0 90% no-repeat;
231 }
232 /* Retina Polldaddy Menu Icon */
233 @media only screen and (-moz-min-device-pixel-ratio: 1.5),
234 only screen and (-o-min-device-pixel-ratio: 3/2),
235 only screen and (-webkit-min-device-pixel-ratio: 1.5),
236 only screen and (min-device-pixel-ratio: 1.5) {
237 #toplevel_page_polldaddy .wp-menu-image {
238 background: url( " . plugins_url( 'polldaddy@2x.png', __FILE__ ) . " ) 0 90% no-repeat;
239 background-size:30px 64px;
240 }
241 }
242 #toplevel_page_polldaddy.current .wp-menu-image,
243 #toplevel_page_polldaddy.wp-has-current-submenu .wp-menu-image,
244 #toplevel_page_polldaddy:hover .wp-menu-image {
245 background-position: top left;
246 }";
247 wp_add_inline_style( 'wp-admin', $css );
248 }
249 }
250
251 function api_key_page_load() {
252
253 if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
254 return false;
255
256 check_admin_referer( 'polldaddy-account' );
257
258 $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
259 $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
260
261 if ( !$polldaddy_email )
262 $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
263
264 if ( !$polldaddy_password )
265 $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) );
266
267 if ( $this->errors->get_error_codes() )
268 return false;
269
270 $details = array(
271 'uName' => get_bloginfo( 'name' ),
272 'uEmail' => $polldaddy_email,
273 'uPass' => $polldaddy_password,
274 'partner_userid' => $this->id
275 );
276 if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
277 $polldaddy_api_key = wp_remote_post( polldaddy_api_url( '/key' ), array(
278 'body' => $details
279 ) );
280 if ( is_wp_error( $polldaddy_api_key ) ) {
281 $this->errors = $polldaddy_api_key;
282 return false;
283 }
284 $polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
285 } else {
286 $fp = fsockopen(
287 polldaddy_api_url( '/', POLLDADDY_API_VERSION, 'tls' ),
288 443,
289 $err_num,
290 $err_str,
291 5
292 );
293
294 if ( !$fp ) {
295 $this->errors->add( 'connect', __( "Can't connect to Polldaddy.com", 'polldaddy' ) );
296 return false;
297 }
298
299 if ( function_exists( 'stream_set_timeout' ) )
300 stream_set_timeout( $fp, 3 );
301
302 global $wp_version;
303
304 $request_body = http_build_query( $details, null, '&' );
305
306 $request = 'POST ' . polldaddy_api_path( '/key' ) . " HTTP/1.0\r\n";
307 $request .= 'Host: ' . POLLDADDY_API_HOST . "\r\n";
308 $request .= "User-agent: WordPress/$wp_version\r\n";
309 $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ) . "\r\n";
310 $request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
311
312 fwrite( $fp, "$request\r\n$request_body" );
313
314 $response = '';
315 while ( !feof( $fp ) )
316 $response .= fread( $fp, 4096 );
317 fclose( $fp );
318 list( $headers, $polldaddy_api_key ) = explode( "\r\n\r\n", $response, 2 );
319 }
320
321 if ( !$polldaddy_api_key ) {
322 $this->errors->add( 'polldaddy_password', __( 'Invalid Account', 'polldaddy' ) );
323 return false;
324 }
325
326 update_option( 'polldaddy_api_key', $polldaddy_api_key );
327
328 $polldaddy = $this->get_client( $polldaddy_api_key );
329 $polldaddy->reset();
330 if ( !$polldaddy->get_usercode( $this->id ) ) {
331 $this->parse_errors( $polldaddy );
332 $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
333 return false;
334 }
335
336 return true;
337 }
338
339 function parse_errors( &$polldaddy ) {
340 if ( $polldaddy->errors )
341 foreach ( $polldaddy->errors as $code => $error )
342 $this->errors->add( $code, $error );
343
344 if ( isset( $this->errors->errors[4] ) ) {
345 //need to get latest usercode
346 global $wp_version;
347 if ( version_compare( $wp_version, '4.2', '<' ) ) {
348 delete_option( 'pd-usercode-' . $this->id );
349 add_option( 'pd-usercode-' . $this->id, '', '', false );
350 } else {
351 update_option( 'pd-usercode-' . $this->id, '', false );
352 }
353 $this->set_api_user_code();
354 }
355 }
356
357 function print_errors() {
358 if ( !$error_codes = $this->errors->get_error_codes() )
359 return;
360
361 $this->render_partial( 'errors', array( 'error_codes' => $error_codes, 'errors' => $this->errors ) );
362 $this->errors = new WP_Error;
363 }
364
365 function api_key_page() {
366 $this->print_errors();
367 ?>
368
369 <div class="wrap">
370 <h2 id="polldaddy-header"><?php _e( 'Crowdsignal', 'polldaddy' ); ?></h2>
371
372 <?php /* translators: %s is the URL to the Crowdsignal.com account details */ ?>
373 <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>
374
375 <form action="" method="post">
376 <table class="form-table">
377 <tbody>
378 <tr class="form-field form-required">
379 <th valign="top" scope="row">
380 <label for="polldaddy-email"><?php _e( 'Crowdsignal Email Address', 'polldaddy' ); ?></label>
381 </th>
382 <td>
383 <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" />
384 </td>
385 </tr>
386 <tr class="form-field form-required">
387 <th valign="top" scope="row">
388 <label for="polldaddy-password"><?php _e( 'Crowdsignal Password', 'polldaddy' ); ?></label>
389 </th>
390 <td>
391 <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
392 </td>
393 </tr>
394 </tbody>
395 </table>
396 <p class="submit">
397 <?php wp_nonce_field( 'polldaddy-account' ); ?>
398 <input type="hidden" name="action" value="account" />
399 <input type="hidden" name="account" value="import" />
400 <input class="button-secondary" type="submit" value="<?php echo esc_attr( __( 'Submit', 'polldaddy' ) ); ?>" />
401 </p>
402 </form>
403 </div>
404
405 <?php
406 }
407
408 function get_usercode( $for_current_user = false ) {
409 // sitewide access to Crowdsignal account
410 if ( ! $for_current_user && $user_id = get_option( 'polldaddy_usercode_user' ) ) {
411 return get_option( 'pd-usercode-' . $user_id );
412 } else {
413 return get_option( 'pd-usercode-' . $this->id );
414 }
415 }
416
417 function set_api_user_code() {
418
419 $this->user_code = get_option( 'pd-usercode-'.$this->id );
420
421 if ( empty( $this->user_code ) ) {
422 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
423 $polldaddy->reset();
424
425 $this->user_code = $polldaddy->get_usercode( $this->id );
426
427 if ( !empty( $this->user_code ) ) {
428 global $wp_version;
429 if ( version_compare( $wp_version, '4.2', '<' ) ) {
430 delete_option( 'pd-usercode-' . $this->id );
431 add_option( 'pd-usercode-' . $this->id, $this->user_code, '', false );
432 } else {
433 update_option( 'pd-usercode-' . $this->id, $this->user_code, false );
434 }
435 } elseif ( get_option( 'crowdsignal_api_key' ) === get_option( 'polldaddy_api_key' ) ) {
436 // attempt to get credentials from Crowdsignal Forms.
437 $this->user_code = get_option( 'crowdsignal_user_code' );
438 } elseif ( get_option( 'polldaddy_api_key' ) ) {
439 $this->contact_support_message( 'There was a problem linking your account', $polldaddy->errors );
440 }
441 }
442 }
443
444 function management_page_load() {
445 wp_reset_vars( array( 'page', 'action', 'poll', 'style', 'rating', 'id' ) );
446 global $plugin_page, $page, $action, $poll, $style, $rating, $id, $wp_locale;
447
448 if (
449 isset( $_GET['step'] ) && 2 === (int) $_GET['step']
450 && isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD']
451 && isset( $_POST['got_api_key'] ) && get_option( 'crowdsignal_api_key_secret' ) === $_POST['got_api_key']
452 && isset( $_POST['api_key'] )
453 ) {
454 $api_key = sanitize_key( wp_unslash( $_POST['api_key'] ) );
455 $crowdsignal = $this->get_client( $api_key );
456 $crowdsignal->reset();
457 $usercode = $crowdsignal->get_usercode( $this->id );
458 if ( $usercode ) {
459 update_option( 'polldaddy_api_key', $api_key );
460 update_option( 'crowdsignal_api_key', $api_key );
461 update_option( 'crowdsignal_user_code', $usercode );
462 update_option( 'pd-usercode-' . $this->id, $usercode );
463 delete_option( 'crowdsignal_api_key_secret' );
464 $connected = true;
465 } else {
466 $connected = false;
467 }
468 $this->render_partial(
469 'html-admin-setup-step-2',
470 array(
471 'is_connected' => $connected,
472 )
473 );
474 die();
475 }
476
477 if (
478 isset( $_POST['action'] )
479 && $_POST['action'] === 'disconnect'
480 && current_user_can( 'edit_others_posts' )
481 ) {
482 check_admin_referer( 'disconnect-api-key' );
483 delete_option( 'polldaddy_api_key' );
484 delete_option( 'crowdsignal_api_key' );
485 delete_option( 'crowdsignal_user_code' );
486 delete_option( 'pd-usercode-' . $this->id );
487 wp_safe_redirect( admin_url( 'options-general.php?page=crowdsignal-settings&msg=disconnected' ) );
488 }
489
490 $this->set_api_user_code();
491
492 if ( empty( $this->user_code ) && 'crowdsignal-settings' === $page && 'options' !== $action ) {
493 // one last try to get the user code automatically if possible
494 $this->user_code = apply_filters_ref_array( 'polldaddy_get_user_code', array( $this->user_code, &$this ) );
495 if ( false == $this->user_code && $action != 'restore-account' )
496 $action = 'signup';
497 }
498
499 require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
500
501 wp_enqueue_style( 'admin-styles', plugin_dir_url( __FILE__ ) . '/admin-styles.css', array(), '1.5.12' );
502 wp_enqueue_style( 'wp-components' );
503 wp_enqueue_script( 'polls', "{$this->base_url}js/polldaddy.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-form', 'wp-components' ), $this->version );
504 wp_enqueue_script( 'polls-common', "{$this->base_url}js/common.js", array(), $this->version );
505
506 // Localize script with nonce data for secure media uploads
507 if ( $page === 'polls' && in_array( $action, array( 'edit', 'edit-poll', 'create-poll' ) ) ) {
508 $user_id = get_current_user_id();
509 $nonce_action = get_polls_media_nonce();
510 wp_localize_script( 'polls', 'pollsMediaSecurity', array(
511 'nonce' => wp_create_nonce( $nonce_action ),
512 'user_id' => $user_id,
513 ) );
514 }
515
516 if ( $page == 'polls' ) {
517 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
518 $action = '';
519 }
520
521 switch ( $action ) {
522 case 'create-block-poll':
523 $post_id = wp_insert_post(
524 array(
525 'post_title' => esc_html__( 'Crowdsignal blocks in WordPress', 'polldaddy' ),
526
527 'post_content' => '
528 <!-- wp:paragraph -->
529 <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>
530 <!-- /wp:paragraph -->
531
532 <!-- wp:paragraph -->
533 <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>
534 <!-- /wp:paragraph -->
535
536 <!-- wp:spacer {"height":60} -->
537 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
538 <!-- /wp:spacer -->
539
540 <!-- wp:heading -->
541 <h2>Overview</h2>
542 <!-- /wp:heading -->
543
544 <!-- wp:paragraph -->
545 <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>
546 <!-- /wp:paragraph -->
547
548 <!-- wp:image {"align":"wide","id":241,"sizeSlug":"full","linkDestination":"none"} -->
549 <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>
550 <!-- /wp:image -->
551
552 <!-- wp:paragraph -->
553 <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>
554 <!-- /wp:paragraph -->
555
556 <!-- wp:spacer {"height":60} -->
557 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
558 <!-- /wp:spacer -->
559
560 <!-- wp:heading -->
561 <h2>Polls</h2>
562 <!-- /wp:heading -->
563
564 <!-- wp:paragraph -->
565 <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>
566 <!-- /wp:paragraph -->
567
568 <!-- wp:paragraph -->
569 <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>
570 <!-- /wp:paragraph -->
571
572 <!-- wp:paragraph -->
573 <p>Just click in the poll below and start editing. </p>
574 <!-- /wp:paragraph -->
575
576 <!-- 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"} /-->
577
578 <!-- wp:paragraph -->
579 <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>
580 <!-- /wp:paragraph -->
581
582 <!-- wp:paragraph -->
583 <p>Here is a short demo video for how to set up this block, not that you would need it ;) </p>
584 <!-- /wp:paragraph -->
585
586 <!-- wp:video {"src":"https://crowdsignal.files.wordpress.com/2021/11/add-poll-tutorial-720.mp4"} -->
587 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-poll-tutorial-720.mp4"></video></figure>
588 <!-- /wp:video -->
589
590 <!-- wp:spacer {"height":60} -->
591 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
592 <!-- /wp:spacer -->
593
594 <!-- wp:heading -->
595 <h2>Feedback Button</h2>
596 <!-- /wp:heading -->
597
598 <!-- wp:paragraph -->
599 <p>You might have spotted it already, in the bottom left corner of this page: Our Feedback button.</p>
600 <!-- /wp:paragraph -->
601
602 <!-- wp:paragraph -->
603 <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>
604 <!-- /wp:paragraph -->
605
606 <!-- wp:paragraph -->
607 <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>
608 <!-- /wp:paragraph -->
609
610 <!-- wp:paragraph -->
611 <p>Don\'t miss out on your customers\' feedback. Keep your door open anytime and place a feedback button on all your pages. </p>
612 <!-- /wp:paragraph -->
613
614 <!-- wp:video {"src":"https://crowdsignal.files.wordpress.com/2021/11/add-feedback-button-tutorial.mp4"} -->
615 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-feedback-button-tutorial.mp4"></video></figure>
616 <!-- /wp:video -->
617
618 <!-- wp:spacer {"height":60} -->
619 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
620 <!-- /wp:spacer -->
621
622 <!-- wp:heading -->
623 <h2>Voting</h2>
624 <!-- /wp:heading -->
625
626 <!-- wp:paragraph -->
627 <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>
628 <!-- /wp:paragraph -->
629
630 <!-- wp:paragraph -->
631 <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>
632 <!-- /wp:paragraph -->
633
634 <!-- wp:paragraph -->
635 <p>That’s what we thought! Say hello to our Voting Block:</p>
636 <!-- /wp:paragraph -->
637
638 <!-- wp:crowdsignal-forms/vote {"pollId":"","title":"Demo Vote block"} -->
639 <!-- wp:crowdsignal-forms/vote-item {"answerId":"","type":"up","textColor":"#066127","borderColor":"#066127"} /-->
640
641 <!-- wp:crowdsignal-forms/vote-item {"answerId":"","type":"down","textColor":"#c6302e","borderColor":"#c6302e"} /-->
642 <!-- /wp:crowdsignal-forms/vote -->
643
644 <!-- wp:paragraph -->
645 <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>
646 <!-- /wp:paragraph -->
647
648 <!-- wp:video {"src":"https://crowdsignal.files.wordpress.com/2021/11/add-vote-tutorial.mp4"} -->
649 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-vote-tutorial.mp4"></video></figure>
650 <!-- /wp:video -->
651
652 <!-- wp:spacer {"height":60} -->
653 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
654 <!-- /wp:spacer -->
655
656 <!-- wp:heading -->
657 <h2>Applause</h2>
658 <!-- /wp:heading -->
659
660 <!-- wp:image {"sizeSlug":"large"} -->
661 <figure class="wp-block-image size-large"><img src="https://crowdsignal.files.wordpress.com/2021/11/17claps-small.gif" alt=""/></figure>
662 <!-- /wp:image -->
663
664 <!-- wp:paragraph -->
665 <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>
666 <!-- /wp:paragraph -->
667
668 <!-- wp:paragraph -->
669 <p>Let your audience make some noise with a big round of applause.</p>
670 <!-- /wp:paragraph -->
671
672 <!-- wp:crowdsignal-forms/applause {"pollId":"","title":"Demo Applause block","answerId":"","size":"large","borderWidth":1,"borderRadius":5} /-->
673
674 <!-- wp:paragraph -->
675 <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>
676 <!-- /wp:paragraph -->
677
678 <!-- wp:paragraph -->
679 <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>
680 <!-- /wp:paragraph -->
681
682 <!-- wp:video {"src": "https://crowdsignal.files.wordpress.com/2021/11/add-applause-block-tutorial.mp4"} -->
683 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-applause-block-tutorial.mp4"></video></figure>
684 <!-- /wp:video -->
685
686 <!-- wp:spacer {"height":60} -->
687 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
688 <!-- /wp:spacer -->
689
690 <!-- wp:heading -->
691 <h2>Embed Surveys &amp; Forms</h2>
692 <!-- /wp:heading -->
693
694 <!-- wp:paragraph -->
695 <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>
696 <!-- /wp:paragraph -->
697
698 <!-- wp:embed {"url":"https://crowdsignal.survey.fm/product-market-fit-score","type":"rich","providerNameSlug":"crowdsignal","responsive":true,"align":"wide"} -->
699 <figure class="wp-block-embed alignwide is-type-rich is-provider-crowdsignal wp-block-embed-crowdsignal"><div class="wp-block-embed__wrapper">
700 https://crowdsignal.survey.fm/product-market-fit-score
701 </div></figure>
702 <!-- /wp:embed -->
703
704 <!-- wp:paragraph -->
705 <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>
706 <!-- /wp:paragraph -->
707
708 <!-- wp:paragraph -->
709 <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>
710 <!-- /wp:paragraph -->
711
712 <!-- wp:paragraph -->
713 <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>
714 <!-- /wp:paragraph -->
715
716 <!-- wp:paragraph -->
717 <p><strong>Ready to create one? Here’s how:</strong></p>
718 <!-- /wp:paragraph -->
719
720 <!-- wp:paragraph -->
721 <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>
722 <!-- /wp:paragraph -->
723
724 <!-- wp:paragraph -->
725 <p>- Create a new survey.</p>
726 <!-- /wp:paragraph -->
727
728 <!-- wp:paragraph -->
729 <p>- In the Editor, choose “Single Mode” at the top left.</p>
730 <!-- /wp:paragraph -->
731
732 <!-- wp:paragraph -->
733 <p>- Then create as many questions as you like and style your theme.</p>
734 <!-- /wp:paragraph -->
735
736 <!-- wp:paragraph -->
737 <p>- When you are ready click on Sharing and copy the URL of your survey.</p>
738 <!-- /wp:paragraph -->
739
740 <!-- wp:paragraph -->
741 <p>- Go back to your WordPress editor and paste the URL of your survey into your post</p>
742 <!-- /wp:paragraph -->
743
744 <!-- wp:paragraph -->
745 <p>- Done! Your survey will appear in your post.</p>
746 <!-- /wp:paragraph -->
747
748 <!-- wp:paragraph -->
749 <p>Here is a short demo video for you that shows you how it works in less than a minute:</p>
750 <!-- /wp:paragraph -->
751
752 <!-- wp:video {"src": "https://crowdsignal.files.wordpress.com/2021/11/add-survey-tutorial-yt.mp4"} -->
753 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-survey-tutorial-yt.mp4"></video></figure>
754 <!-- /wp:video -->
755
756 <!-- wp:spacer {"height":60} -->
757 <div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
758 <!-- /wp:spacer -->
759
760 <!-- wp:heading -->
761 <h2>Measure NPS</h2>
762 <!-- /wp:heading -->
763
764 <!-- wp:paragraph -->
765 <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>
766 <!-- /wp:paragraph -->
767
768 <!-- wp:paragraph -->
769 <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>
770 <!-- /wp:paragraph -->
771
772 <!-- wp:paragraph -->
773 <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>
774 <!-- /wp:paragraph -->
775
776 <!-- wp:crowdsignal-forms/nps {"surveyId":"","title":"Demo NPS block","viewThreshold":"2"} /-->
777
778 <!-- wp:paragraph -->
779 <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>
780 <!-- /wp:paragraph -->
781
782 <!-- wp:paragraph -->
783 <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>
784 <!-- /wp:paragraph -->
785
786 <!-- wp:paragraph -->
787 <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>
788 <!-- /wp:paragraph -->
789
790 <!-- wp:image {"sizeSlug":"large"} -->
791 <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>
792 <!-- /wp:image -->
793
794 <!-- wp:paragraph -->
795 <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>
796 <!-- /wp:paragraph -->
797
798 <!-- wp:paragraph -->
799 <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>
800 <!-- /wp:paragraph -->
801
802 <!-- wp:paragraph -->
803 <p>Here is a quick tutorial video on how it works.</p>
804 <!-- /wp:paragraph -->
805
806 <!-- wp:video {"src": "https://crowdsignal.files.wordpress.com/2021/11/add-nps-tutorial-long-3.mp4"} -->
807 <figure class="wp-block-video"><video controls src="https://crowdsignal.files.wordpress.com/2021/11/add-nps-tutorial-long-3.mp4"></video></figure>
808 <!-- /wp:video -->
809
810 <!-- wp:crowdsignal-forms/feedback {"surveyId":"","title":"Demo Feedback block"} /-->
811
812 <!-- wp:paragraph -->
813 <p></p>
814 <!-- /wp:paragraph -->
815 ',
816 )
817 );
818 if ( ! is_wp_error( $post_id ) ) {
819 wp_safe_redirect( admin_url( 'post.php?post=' . intval( $post_id ) . '&action=edit' ) );
820 } else {
821 // admin.php?page=polls
822 // wp_safe_redirect( admin_url( 'admin.php?page=polls' ) );
823 }
824 break;
825
826 case 'edit' :
827 case 'edit-poll' :
828 case 'create-poll' :
829 case 'add-media' :
830 wp_enqueue_script( 'media-upload', array(), $this->version );
831 wp_enqueue_script( 'polls-style', "{$this->base_url}js/poll-style-picker.js", array( 'polls', 'polls-common' ), $this->version );
832
833 if ( $action == 'create-poll' )
834 $plugin_page = 'polls&action=create-poll';
835
836 break;
837 case 'edit-style' :
838 case 'create-style' :
839 wp_enqueue_script( 'polls-style', "{$this->base_url}js/style-editor.js", array( 'polls', 'polls-common' ), $this->version );
840 wp_enqueue_script( 'polls-style-color', "{$this->base_url}js/jscolor.js", array(), $this->version );
841 wp_enqueue_style( 'polls', "{$this->base_url}css/style-editor.css", array(), $this->version );
842 $plugin_page = 'polls&action=list-styles';
843 break;
844 case 'list-styles' :
845 $plugin_page = 'polls&action=list-styles';
846 break;
847 }//end switch
848 } elseif ( $page == 'crowdsignal-settings' ) {
849 $plugin_page = 'crowdsignal-settings';
850 } elseif ( $page == 'ratings' ) {
851 if ( empty( $action ) ) {
852 $action = 'reports';
853 }
854 $plugin_page = 'ratings&action=reports';
855 } elseif ( $page == 'ratingsettings' ) {
856 $plugin_page = 'ratingsettings';
857 wp_enqueue_script( 'rating-text-color', "{$this->base_url}js/jscolor.js", array(), $this->version );
858 wp_enqueue_script( 'ratings', "{$this->base_url}js/rating.js", array(), $this->version );
859 wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
860 'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
861 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
862 }
863
864 wp_enqueue_style( 'polldaddy', "{$this->base_url}css/polldaddy.css", array(), $this->version );
865 wp_enqueue_script( 'admin-forms' );
866 add_thickbox();
867
868 if ( isset( $_GET['iframe'] ) ) {
869 add_action( 'admin_head', array( &$this, 'hide_admin_menu' ) );
870 }
871
872 if ( isset( $wp_locale->text_direction ) && 'rtl' == $wp_locale->text_direction )
873 wp_enqueue_style( 'polls-rtl', "{$this->base_url}css/polldaddy-rtl.css", array( 'global', 'wp-admin' ), $this->version );
874 add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
875
876 add_action( 'admin_notices', array( &$this, 'management_page_notices' ) );
877
878 $query_args = array();
879 $args = array();
880
881 $allowedtags = array(
882 'a' => array(
883 'href' => array(),
884 'title' => array(),
885 'target' => array() ),
886 'img' => array(
887 'alt' => array(),
888 'align' => array(),
889 'border' => array(),
890 'class' => array(),
891 'height' => array(),
892 'hspace' => array(),
893 'longdesc' => array(),
894 'vspace' => array(),
895 'src' => array(),
896 'width' => array() ),
897 'abbr' => array( 'title' => array() ),
898 'acronym' => array( 'title' => array() ),
899 'blockquote' => array( 'cite' => array() ),
900 'q' => array( 'cite' => array() ),
901 'b' => array(),
902 'cite' => array(),
903 'em' => array(),
904 'i' => array(),
905 'strike' => array(),
906 'strong' => array()
907 );
908
909 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
910
911 if ( 'polls' === $page || 'crowdsignal-settings' === $page ) {
912 switch ( $action ) {
913 case 'multi-account':
914 check_admin_referer( 'polldaddy-reset' . $this->id );
915 if ( ! isset( $_POST['crowdsignal_multiuser'] ) ) {
916 delete_option( 'polldaddy_usercode_user' );
917 }
918 break;
919 case 'reset-account' : // reset everything
920 global $current_user;
921 check_admin_referer( 'polldaddy-reset' . $this->id );
922 $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 );
923 $msg = __( "You have just reset your Polldaddy connection settings.", 'polldaddy' ) . "\n\n";
924 foreach( $fields as $field ) {
925 $value = get_option( $field );
926 if ( $value != false ) {
927 $settings[ $field ] = $value;
928 $msg .= "$field: $value\n";
929 delete_option( $field );
930 }
931 }
932 if ( isset( $_POST[ 'email' ] ) )
933 wp_mail( $current_user->user_email, "Crowdsignal Settings", $msg );
934 update_option( 'polldaddy_settings', $settings );
935 break;
936 case 'restore-account' : // restore everything
937 global $current_user;
938 check_admin_referer( 'polldaddy-restore' . $this->id );
939 $previous_settings = get_option( 'polldaddy_settings' );
940 foreach( $previous_settings as $key => $value )
941 update_option( $key, $value );
942 delete_option( 'polldaddy_settings' );
943 break;
944 case 'restore-ratings' : // restore ratings
945 global $current_user;
946 check_admin_referer( 'polldaddy-restore-ratings' . $this->id );
947 $previous_settings = get_option( 'polldaddy_settings' );
948 $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' );
949 foreach( $fields as $key ) {
950 if ( isset( $previous_settings[ $key ] ) )
951 update_option( $key, $previous_settings[ $key ] );
952 }
953 break;
954 case 'signup' : // sign up for first time
955 case 'account' : // reauthenticate
956 case 'import-account' : // reauthenticate
957 if ( !$is_POST )
958 return;
959
960 check_admin_referer( 'polldaddy-account' );
961
962 $this->user_code = '';
963 global $wp_version;
964 if ( version_compare( $wp_version, '4.2', '<' ) ) {
965 delete_option( 'pd-usercode-' . $this->id );
966 add_option( 'pd-usercode-' . $this->id, '', false );
967 } else {
968 update_option( 'pd-usercode-' . $this->id, '', false );
969 }
970
971 if ( $new_args = $this->management_page_load_signup() )
972 $query_args = array_merge( $query_args, $new_args );
973
974 if ( $this->errors->get_error_codes() )
975 return false;
976
977 $query_args['message'] = 'imported-account';
978
979 wp_reset_vars( array( 'action' ) );
980 if ( !empty( $_GET['reaction'] ) )
981 $query_args['action'] = $_GET['reaction'];
982 elseif ( !empty( $_GET['action'] ) && 'account' == $_GET['action'] )
983 $query_args['action'] = $_GET['action'];
984 else
985 $query_args['action'] = false;
986 if ( $action == 'import-account' )
987 $query_args[ 'action' ] = 'options'; // make sure we redirect back to the right page.
988 break;
989
990 case 'delete' :
991 if ( empty( $poll ) )
992 return;
993
994 if ( is_array( $poll ) )
995 check_admin_referer( 'action-poll_bulk' );
996 else
997 check_admin_referer( "delete-poll_$poll" );
998
999 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1000
1001 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
1002 $polldaddy->reset();
1003 $poll_object = $polldaddy->get_poll( $poll_id );
1004
1005 if ( !$this->can_edit( $poll_object ) ) {
1006 $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.', 'polldaddy' ) );
1007 return false;
1008 }
1009
1010 // Send Poll Author credentials
1011 if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
1012 $polldaddy->reset();
1013 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
1014 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
1015 }
1016 $polldaddy->userCode = $userCode;
1017 }
1018
1019 $polldaddy->reset();
1020 $polldaddy->delete_poll( $poll_id );
1021 }
1022
1023 $query_args['message'] = 'deleted';
1024 $query_args['deleted'] = count( (array) $poll );
1025 break;
1026 case 'open' :
1027 if ( empty( $poll ) )
1028 return;
1029
1030 if ( is_array( $poll ) )
1031 check_admin_referer( 'action-poll_bulk' );
1032 else
1033 check_admin_referer( "open-poll_$poll" );
1034
1035 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1036
1037 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
1038 $polldaddy->reset();
1039 $poll_object = $polldaddy->get_poll( $poll_id );
1040
1041 if ( !$this->can_edit( $poll_object ) ) {
1042 $this->errors->add( 'permission', __( 'You are not allowed to open this poll.', 'polldaddy' ) );
1043 return false;
1044 }
1045
1046 // Send Poll Author credentials
1047 if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
1048 $polldaddy->reset();
1049 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
1050 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
1051 }
1052 $polldaddy->userCode = $userCode;
1053 }
1054
1055 $polldaddy->reset();
1056 $polldaddy->open_poll( $poll_id );
1057 }
1058
1059 $query_args['message'] = 'opened';
1060 $query_args['opened'] = count( (array) $poll );
1061 break;
1062 case 'close' :
1063 if ( empty( $poll ) )
1064 return;
1065
1066 if ( is_array( $poll ) )
1067 check_admin_referer( 'action-poll_bulk' );
1068 else
1069 check_admin_referer( "close-poll_$poll" );
1070
1071 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1072
1073 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
1074 $polldaddy->reset();
1075 $poll_object = $polldaddy->get_poll( $poll_id );
1076
1077 if ( !$this->can_edit( $poll_object ) ) {
1078 $this->errors->add( 'permission', __( 'You are not allowed to close this poll.', 'polldaddy' ) );
1079 return false;
1080 }
1081
1082 // Send Poll Author credentials
1083 if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
1084 $polldaddy->reset();
1085 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
1086 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
1087 }
1088 $polldaddy->userCode = $userCode;
1089 }
1090
1091 $polldaddy->reset();
1092 $polldaddy->close_poll( $poll_id );
1093 }
1094
1095 $query_args['message'] = 'closed';
1096 $query_args['closed'] = count( (array) $poll );
1097 break;
1098 case 'edit-poll' : // TODO: use polldaddy_poll
1099 if ( !$is_POST || !$poll = (int) $poll )
1100 return;
1101
1102 check_admin_referer( "edit-poll_$poll" );
1103
1104 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1105 $polldaddy->reset();
1106
1107 $poll_object = $polldaddy->get_poll( $poll );
1108 $this->parse_errors( $polldaddy );
1109
1110 if ( !$this->can_edit( $poll_object ) ) {
1111 $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
1112 return false;
1113 }
1114
1115 // Send Poll Author credentials
1116 if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
1117 $polldaddy->reset();
1118 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
1119 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
1120 }
1121 $this->parse_errors( $polldaddy );
1122 $polldaddy->userCode = $userCode;
1123 }
1124
1125 if ( !$poll_object )
1126 $this->errors->add( 'GetPoll', __( 'Poll not found', 'polldaddy' ) );
1127
1128 if ( $this->errors->get_error_codes() )
1129 return false;
1130
1131 $media = $mediaType = array();
1132 if ( isset( $_POST['media'] ) ) {
1133 $media = $_POST['media'];
1134 unset( $_POST['media'] );
1135 }
1136
1137 if ( isset( $_POST['mediaType'] ) ) {
1138 $mediaType = $_POST['mediaType'];
1139 unset( $_POST['mediaType'] );
1140 }
1141
1142 $poll_data = get_object_vars( $poll_object );
1143 foreach ( $poll_data as $key => $value )
1144 if ( '_' === $key[0] )
1145 unset( $poll_data[$key] );
1146
1147 foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
1148 if ( isset( $_POST[$option] ) && $_POST[$option] )
1149 $poll_data[$option] = 'yes';
1150 else
1151 $poll_data[$option] = 'no';
1152 }
1153
1154 $blocks = array( 'off', 'cookie', 'cookieip' );
1155 if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
1156 $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
1157
1158 $results = array( 'show', 'percent', 'hide' );
1159 if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
1160 $poll_data['resultsType'] = $_POST['resultsType'];
1161 $poll_data['question'] = stripslashes( $_POST['question'] );
1162
1163 $comments = array( 'off', 'allow', 'moderate' );
1164 if ( isset( $_POST['comments'] ) && in_array( $_POST['comments'], $comments ) )
1165 $poll_data['comments'] = $_POST['comments'];
1166
1167 if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
1168 $this->errors->add( 'answer', __( 'Invalid answers', 'polldaddy' ) );
1169
1170 $answers = array();
1171 if ( ! empty( $_POST['answer'] ) ) {
1172 foreach ( $_POST['answer'] as $answer_id => $answer ) {
1173 $answer = stripslashes( trim( $answer ) );
1174
1175 if ( strlen( $answer ) > 0 ) {
1176 $answer = wp_kses( $answer, $allowedtags );
1177
1178 $args['text'] = (string) $answer;
1179
1180 $answer_id = str_replace( 'new', '', $answer_id );
1181 $mc = '';
1182 $mt = 0;
1183
1184 if ( isset( $media[ $answer_id ] ) ) {
1185 $mc = esc_html( $media[ $answer_id ] );
1186 }
1187
1188 if ( isset( $mediaType[ $answer_id ] ) ) {
1189 $mt = intval( $mediaType[ $answer_id ] );
1190 }
1191
1192 $args['mediaType'] = $mt;
1193 $args['mediaCode'] = $mc;
1194
1195 if ( $answer_id > 1000 ) {
1196 $answer = polldaddy_poll_answer( $args, $answer_id );
1197 } else {
1198 $answer = polldaddy_poll_answer( $args );
1199 }
1200
1201 if ( isset( $answer ) && is_a( $answer, 'Polldaddy_Poll_Answer' ) ) {
1202 $answers[] = $answer;
1203 }
1204 }
1205 }
1206 }
1207
1208 if ( 2 > count( $answers ) )
1209 $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
1210
1211 if ( $this->errors->get_error_codes() )
1212 return false;
1213
1214 $poll_data['answers'] = $answers;
1215
1216 $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
1217
1218 if ( isset ( $_POST['styleID'] ) ) {
1219 if ( $_POST['styleID'] == 'x' ) {
1220 $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
1221 return false;
1222 }
1223 }
1224 $poll_data['styleID'] = (int) $_POST['styleID'];
1225 $poll_data['choices'] = (int) $_POST['choices'];
1226
1227 if ( $poll_data['blockRepeatVotersType'] == 'cookie' ) {
1228 if ( isset( $_POST['cookieip_expiration'] ) )
1229 $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
1230 } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ) {
1231 if ( isset( $_POST['cookieip_expiration'] ) )
1232 $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
1233 }
1234
1235 if ( isset( $media[999999999] ) )
1236 $poll_data['mediaCode'] = esc_html( $media[999999999] );
1237
1238 if ( isset( $mediaType[999999999] ) )
1239 $poll_data['mediaType'] = intval( $mediaType[999999999] );
1240
1241 if( isset( $GLOBALS['blog_id'] ) )
1242 $poll_data['parentID'] = (int) $GLOBALS['blog_id'];
1243
1244 $polldaddy->reset();
1245
1246 $update_response = $polldaddy->update_poll( $poll, $poll_data );
1247 $this->parse_errors( $polldaddy );
1248
1249 if ( !$update_response )
1250 $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated', 'polldaddy' ) );
1251
1252 if ( $this->errors->get_error_codes() )
1253 return false;
1254
1255 $query_args['message'] = 'updated';
1256 if ( isset( $_POST['iframe'] ) )
1257 $query_args['iframe'] = '';
1258 break;
1259 case 'create-poll' :
1260 if ( !$is_POST )
1261 return;
1262
1263 check_admin_referer( 'create-poll' );
1264
1265 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1266 $polldaddy->reset();
1267
1268 $media = $mediaType = array();
1269 if ( isset( $_POST['media'] ) ) {
1270 $media = $_POST['media'];
1271 unset( $_POST['media'] );
1272 }
1273
1274 if ( isset( $_POST['mediaType'] ) ) {
1275 $mediaType = $_POST['mediaType'];
1276 unset( $_POST['mediaType'] );
1277 }
1278
1279 $answers = array();
1280
1281 if ( ! empty( $_POST['answer'] ) ) {
1282 foreach ( $_POST['answer'] as $answer_id => $answer ) {
1283 $answer = stripslashes( trim( $answer ) );
1284
1285 if ( strlen( $answer ) > 0 ) {
1286 $answer = wp_kses( $answer, $allowedtags );
1287
1288 $args['text'] = (string) $answer;
1289
1290 $answer_id = (int) str_replace( 'new', '', $answer_id );
1291 $mc = '';
1292 $mt = 0;
1293
1294 if ( isset( $media[ $answer_id ] ) ) {
1295 $mc = esc_html( $media[ $answer_id ] );
1296 }
1297
1298 if ( isset( $mediaType[ $answer_id ] ) ) {
1299 $mt = intval( $mediaType[ $answer_id ] );
1300 }
1301
1302 $args['mediaType'] = $mt;
1303 $args['mediaCode'] = $mc;
1304
1305 $answer = polldaddy_poll_answer( $args );
1306
1307 if ( isset( $answer ) && is_a( $answer, 'Polldaddy_Poll_Answer' ) ) {
1308 $answers[] = $answer;
1309 }
1310 }
1311 }
1312 }
1313
1314 if ( 2 > count( $answers ) ) {
1315 $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
1316 }
1317
1318 if ( $this->errors->get_error_codes() ) {
1319 return false;
1320 }
1321
1322 $poll_data = _polldaddy_poll_defaults();
1323
1324 foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
1325 if ( isset( $_POST[$option] ) && $_POST[$option] )
1326 $poll_data[$option] = 'yes';
1327 else
1328 $poll_data[$option] = 'no';
1329 }
1330
1331 $blocks = array( 'off', 'cookie', 'cookieip' );
1332 if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
1333 $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
1334
1335 $results = array( 'show', 'percent', 'hide' );
1336 if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
1337 $poll_data['resultsType'] = $_POST['resultsType'];
1338
1339 $comments = array( 'off', 'allow', 'moderate' );
1340 if ( isset( $_POST['comments'] ) && in_array( $_POST['comments'], $comments ) )
1341 $poll_data['comments'] = $_POST['comments'];
1342
1343 $poll_data['answers'] = $answers;
1344
1345 $poll_data['question'] = stripslashes( $_POST['question'] );
1346 $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
1347
1348 if ( isset ( $_POST['styleID'] ) ) {
1349 if ( $_POST['styleID'] == 'x' ) {
1350 $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
1351 return false;
1352 }
1353 }
1354 $poll_data['styleID'] = (int) $_POST['styleID'];
1355 $poll_data['choices'] = (int) $_POST['choices'];
1356
1357 if ( $poll_data['blockRepeatVotersType'] == 'cookie' ) {
1358 if ( isset( $_POST['cookieip_expiration'] ) )
1359 $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
1360 } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ) {
1361 if ( isset( $_POST['cookieip_expiration'] ) )
1362 $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
1363 }
1364
1365 if ( isset( $media[999999999] ) )
1366 $poll_data['mediaCode'] = esc_html( $media[999999999] );
1367
1368 if ( isset( $mediaType[999999999] ) )
1369 $poll_data['mediaType'] = intval( $mediaType[999999999] );
1370
1371 $poll = $polldaddy->create_poll( $poll_data );
1372 $this->parse_errors( $polldaddy );
1373
1374 if ( !$poll || empty( $poll->_id ) )
1375 $this->errors->add( 'CreatePoll', __( 'Poll could not be created', 'polldaddy' ) );
1376
1377 if ( $this->errors->get_error_codes() )
1378 return false;
1379
1380 $query_args['message'] = 'created';
1381 $query_args['action'] = 'edit-poll';
1382 $query_args['poll'] = $poll->_id;
1383 if ( isset( $_POST['iframe'] ) )
1384 $query_args['iframe'] = '';
1385 break;
1386 case 'delete-style' :
1387 if ( empty( $style ) )
1388 return;
1389
1390 if ( is_array( $style ) )
1391 check_admin_referer( 'action-style_bulk' );
1392 else
1393 check_admin_referer( "delete-style_$style" );
1394
1395 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1396
1397 foreach ( (array) $_REQUEST['style'] as $style_id ) {
1398 $polldaddy->reset();
1399 $polldaddy->delete_style( $style_id );
1400 }
1401
1402 $query_args['message'] = 'deleted-style';
1403 $query_args['deleted'] = count( (array) $style );
1404 break;
1405 case 'edit-style' :
1406 if ( !$is_POST || !$style = (int) $style )
1407 return;
1408
1409 check_admin_referer( "edit-style$style" );
1410
1411 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1412 $polldaddy->reset();
1413
1414 $style_data = _polldaddy_style_defaults();
1415
1416 if ( isset( $_POST['style-title'] ) )
1417 $style_data['title'] = stripslashes( trim( (string) $_POST['style-title'] ) );
1418
1419 if ( isset( $_POST['CSSXML'] ) )
1420 $style_data['css'] = urlencode( stripslashes( trim( (string) $_POST['CSSXML'] ) ) );
1421
1422 if ( isset( $_REQUEST['updatePollCheck'] ) && $_REQUEST['updatePollCheck'] == 'on' )
1423 $style_data['retro'] = 1;
1424
1425 $update_response = $polldaddy->update_style( $style, $style_data );
1426
1427 $this->parse_errors( $polldaddy );
1428
1429 if ( !$update_response )
1430 $this->errors->add( 'UpdateStyle', __( 'Style could not be updated', 'polldaddy' ) );
1431
1432 if ( $this->errors->get_error_codes() )
1433 return false;
1434
1435 $query_args['message'] = 'updated-style';
1436 if ( isset( $_POST['iframe'] ) )
1437 $query_args['iframe'] = '';
1438 break;
1439 case 'create-style' :
1440 if ( !$is_POST )
1441 return;
1442
1443 check_admin_referer( 'create-style' );
1444
1445 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1446 $polldaddy->reset();
1447
1448 $style_data = _polldaddy_style_defaults();
1449
1450 if ( isset( $_POST['style-title'] ) )
1451 $style_data['title'] = stripslashes( strip_tags( trim( (string) $_POST['style-title'] ) ) );
1452
1453 if ( isset( $_POST['CSSXML'] ) )
1454 $style_data['css'] = urlencode( stripslashes( trim( (string) $_POST['CSSXML'] ) ) );
1455
1456 $style = $polldaddy->create_style( $style_data );
1457 $this->parse_errors( $polldaddy );
1458
1459 if ( !$style || empty( $style->_id ) )
1460 $this->errors->add( 'CreateStyle', __( 'Style could not be created', 'polldaddy' ) );
1461
1462 if ( $this->errors->get_error_codes() )
1463 return false;
1464
1465 $query_args['message'] = 'created-style';
1466 $query_args['action'] = 'edit-style';
1467 $query_args['style'] = $style->_id;
1468 if ( isset( $_POST['iframe'] ) )
1469 $query_args['iframe'] = '';
1470 break;
1471 case 'update-options' :
1472 if ( !$is_POST )
1473 return;
1474
1475 check_admin_referer( 'polldaddy-account' );
1476
1477 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1478 $polldaddy->reset();
1479
1480 $poll_defaults = _polldaddy_poll_defaults();
1481
1482 $user_defaults = array();
1483
1484 foreach ( array( "multipleChoice", "randomiseAnswers", "otherAnswer", "sharing", "resultsType", "styleID", "blockRepeatVotersType", "blockExpiration" ) as $option ) {
1485 if ( isset( $poll_defaults[$option] ) && $poll_defaults[$option] )
1486 $user_defaults[$option] = $poll_defaults[$option];
1487 }
1488
1489 foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
1490 if ( isset( $_POST[$option] ) && $_POST[$option] )
1491 $user_defaults[$option] = 'yes';
1492 else
1493 $user_defaults[$option] = 'no';
1494 }
1495
1496 if ( ! empty( $_POST['multipleChoice'] ) ) {
1497 $user_defaults['choices'] = 1;
1498 }
1499
1500 $results = array( 'show', 'percent', 'hide' );
1501 if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
1502 $user_defaults['resultsType'] = $_POST['resultsType'];
1503
1504 if ( isset ( $_POST['styleID'] ) ) {
1505 $user_defaults['styleID'] = (int) $_POST['styleID'];
1506 }
1507
1508 $blocks = array( 'off', 'cookie', 'cookieip' );
1509 if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
1510 $user_defaults['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
1511
1512 if ( isset( $_POST['blockExpiration'] ) )
1513 $user_defaults['blockExpiration'] = (int) $_POST['blockExpiration'];
1514
1515 $polldaddy->update_poll_defaults( 0, $user_defaults );
1516
1517 $this->parse_errors( $polldaddy );
1518 if ( $this->errors->get_error_codes() )
1519 return false;
1520
1521 $query_args['message'] = 'updated-options';
1522 break;
1523 default :
1524 return;
1525 }//end switch
1526 } elseif ( 'ratings' === $page || 'ratingsettings' === $page ) {
1527
1528 switch ( $action ) {
1529 case 'delete' :
1530 if ( empty( $id ) )
1531 return;
1532 if ( empty( $rating ) )
1533 return;
1534
1535 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
1536
1537 if ( is_array( $rating ) ) {
1538 check_admin_referer( 'action-rating_bulk' );
1539
1540 foreach ( $rating as $key => $value ) {
1541 $polldaddy->reset();
1542 $polldaddy->delete_rating_result( $id, $value );
1543 }
1544 } else {
1545 check_admin_referer( "delete-rating_$rating" );
1546
1547 $polldaddy->delete_rating_result( $id, $rating );
1548 }
1549
1550 if ( isset( $_REQUEST['filter'] ) )
1551 $query_args['filter'] = $_REQUEST['filter'];
1552 if ( isset( $_REQUEST['change-report-to'] ) )
1553 $query_args['change-report-to'] = $_REQUEST['change-report-to'];
1554 $query_args['message'] = 'deleted-rating';
1555 $query_args['deleted'] = count( (array) $rating );
1556 break;
1557 default :
1558 return;
1559 }//end switch
1560 }
1561
1562 wp_safe_redirect( add_query_arg( $query_args, wp_get_referer() ) );
1563 exit;
1564 }
1565
1566 function hide_admin_menu() {
1567 echo '<style>#adminmenuback,#adminmenuwrap,#screen-meta-links,#footer{display:none;visibility:hidden;}#wpcontent{margin-left:10px;}</style>';
1568 }
1569
1570 function management_page_load_signup() {
1571
1572 switch ( $_POST['account'] ) {
1573 case 'import' :
1574 return array( $this->import_account() );
1575 break;
1576 default :
1577 return;
1578 }//end switch
1579 }
1580
1581 function import_account() {
1582 if ( isset( $_POST[ 'polldaddy_key' ] ) ) {
1583 $polldaddy_api_key = trim( stripslashes( $_POST[ 'polldaddy_key' ] ) );
1584 $polldaddy = $this->get_client( $polldaddy_api_key );
1585 $polldaddy->reset();
1586 if ( !$polldaddy->get_usercode( $this->id ) ) {
1587 $this->parse_errors( $polldaddy );
1588 $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Is your API code correct?', 'polldaddy' ) );
1589 return false;
1590 }
1591 update_option( 'polldaddy_api_key', $polldaddy_api_key );
1592 } else {
1593 $this->user_code = false;
1594 $this->errors->add( 'import-account', __( 'Account could not be imported. Did you enter the correct API key?', 'polldaddy' ) );
1595 return false;
1596 }
1597 }
1598
1599 function admin_body_class( $class ) {
1600 if ( isset( $_GET['iframe'] ) )
1601 $class .= 'poll-preview-iframe ';
1602 if ( isset( $_GET['TB_iframe'] ) )
1603 $class .= 'poll-preview-iframe-editor ';
1604 return $class;
1605 }
1606
1607 function management_page_notices( $message = false ) {
1608
1609 if ( isset( $_GET['message'] ) ) {
1610 switch ( (string) $_GET['message'] ) {
1611 case 'deleted' :
1612 $deleted = (int) $_GET['deleted'];
1613 if ( 1 == $deleted ) {
1614 $message = __( 'Poll deleted.', 'polldaddy' );
1615 } else {
1616 $message = sprintf(
1617 /* translators: %s is the number of polls deleted */
1618 _n( '%s Poll Deleted.', '%s Polls Deleted.', $deleted, 'polldaddy' ), number_format_i18n( $deleted ) );
1619 }
1620 break;
1621 case 'opened' :
1622 $opened = (int) $_GET['opened'];
1623 if ( 1 == $opened ) {
1624 $message = __( 'Poll opened.', 'polldaddy' );
1625 } else {
1626 $message = sprintf(
1627 /* translators: %s is the number of polls opened */
1628 _n( '%s Poll Opened.', '%s Polls Opened.', $opened, 'polldaddy' ), number_format_i18n( $opened ) );
1629 }
1630 break;
1631 case 'closed' :
1632 $closed = (int) $_GET['closed'];
1633 if ( 1 == $closed ) {
1634 $message = __( 'Poll closed.', 'polldaddy' );
1635 } else {
1636 $message = sprintf(
1637 /* translators: %s is the number of polls closed */
1638 _n( '%s Poll Closed.', '%s Polls Closed.', $closed, 'polldaddy' ), number_format_i18n( $closed ) );
1639 }
1640 break;
1641 case 'updated' :
1642 $message = __( 'Poll updated.', 'polldaddy' );
1643 break;
1644 case 'created' :
1645 $message = __( 'Poll created.', 'polldaddy' );
1646 if ( isset( $_GET['iframe'] ) ) {
1647 $message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . esc_attr( __( 'Embed in Post', 'polldaddy' ) ) . '" />';
1648 }
1649 break;
1650 case 'updated-style' :
1651 $message = __( 'Custom Style updated.', 'polldaddy' );
1652 break;
1653 case 'created-style' :
1654 $message = __( 'Custom Style created.', 'polldaddy' );
1655 break;
1656 case 'deleted-style' :
1657 $deleted = (int) $_GET['deleted'];
1658 if ( 1 == $deleted ) {
1659 $message = __( 'Custom Style deleted.', 'polldaddy' );
1660 } else {
1661 $message = sprintf(
1662 /* translators: %s is the number of styles deleted */
1663 _n( '%s Style Deleted.', '%s Custom Styles Deleted.', $deleted, 'polldaddy' ), number_format_i18n( $deleted ) );
1664 }
1665 break;
1666 case 'connected' :
1667 case 'imported-account' :
1668 $message = __( 'Account Linked.', 'polldaddy' );
1669 break;
1670 case 'api-key-not-added' :
1671 $message = __( 'There was a problem linking your account.', 'polldaddy' );
1672 break;
1673 case 'updated-options' :
1674 $message = __( 'Options Updated.', 'polldaddy' );
1675 break;
1676 case 'deleted-rating' :
1677 $deleted = (int) $_GET['deleted'];
1678 if ( 1 == $deleted ) {
1679 $message = __( 'Rating deleted.', 'polldaddy' );
1680 } else {
1681 $message = sprintf(
1682 /* translators: %s is the number of ratings deleted */
1683 _n( '%s Rating Deleted.', '%s Ratings Deleted.', $deleted, 'polldaddy' ), number_format_i18n( $deleted ) );
1684 }
1685 break;
1686 }//end switch
1687 }
1688
1689 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
1690
1691 if ( $is_POST ) {
1692 switch ( $GLOBALS['action'] ) {
1693 case 'create-poll' :
1694 $message = __( 'Error: An error has occurred; Poll not created.', 'polldaddy' );
1695 break;
1696 case 'edit-poll' :
1697 $message = __( 'Error: An error has occurred; Poll not updated.', 'polldaddy' );
1698 break;
1699 case 'account' :
1700 if ( 'import' == $_POST['account'] )
1701 $message = __( 'Error: An error has occurred; Account could not be imported. Perhaps your email address or password is incorrect?', 'polldaddy' );
1702 else
1703 $message = __( 'Error: An error has occurred; Account could not be created.', 'polldaddy' );
1704 break;
1705 }//end switch
1706 }
1707
1708 if ( !$message )
1709 return;
1710 ?>
1711 <div class='updated'><p><?php echo $message; ?></p></div>
1712 <?php
1713 $this->print_errors();
1714 }
1715
1716 function settings_page() {
1717 global $page, $action;
1718 ?>
1719 <div class="wrap" id="manage-polls">
1720 <div class="cs-wrapper">
1721 <?php
1722 $this->set_api_user_code();
1723
1724 if ( isset( $_GET['page'] ) ) { // phpcs:ignore
1725 $page = $_GET['page']; // phpcs:ignore
1726 }
1727 if ( 'crowdsignal-settings' === $page ) {
1728 if ( ! current_user_can( 'edit_others_posts' ) ) { // check user privileges has access to action.
1729 return;
1730 }
1731 $this->plugin_options();
1732 } elseif ( 'ratingsettings' === $page ) {
1733 if ( 'update-rating' === $action ) {
1734 $this->update_rating();
1735 }
1736
1737 $this->rating_settings();
1738 }
1739 ?>
1740 </div>
1741 </div>
1742 <?php
1743 }
1744
1745 function management_page() {
1746 global $page, $action, $poll, $style, $rating;
1747 $poll = (int) $poll;
1748 $style = (int) $style;
1749 $rating = esc_html( $rating );
1750 $wrap_style = $page === 'polls' ? 'polls' : 'ratings';
1751 ?>
1752
1753 <div class="wrap cs-dashboard__crowdsignal_<?php echo $wrap_style ; ?>_wrap" id="manage-polls">
1754 <div class="cs-wrapper">
1755 <?php
1756 if ( 'polls' === $page ) {
1757 ?><div class="cs-pre-wrap"></div><?php
1758 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.
1759 $action = '';
1760 }
1761 switch ( $action ) {
1762 case 'preview':
1763 if ( isset( $_GET['iframe'] ) ) {
1764 if ( isset( $_GET['popup'] ) ) {
1765 ?>
1766 <h2 id="poll-list-header"><?php
1767 /* translators: %s is the URL to all polls */
1768 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>
1769 <?php
1770 }
1771 }
1772
1773 echo do_shortcode( "[crowdsignal poll=$poll cb=1]" );
1774
1775 wp_print_scripts( 'polldaddy-poll-js' );
1776 break;
1777 case 'results':
1778 ?>
1779 <h2 id="poll-list-header">
1780 <?php
1781 /* translators: %s is the URL to all polls, %s is the URL to edit poll */
1782 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 ) ) ) ); ?>
1783 </h2>
1784 <?php
1785 $this->poll_results_page( $poll );
1786 break;
1787 case 'edit':
1788 case 'edit-poll':
1789 ?>
1790 <h2 id="poll-list-header">
1791 <?php
1792 printf(
1793 /* translators: %s is the URL to all polls, %s is the URL to view results */
1794 __( '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' ),
1795 esc_url( add_query_arg( array( 'action' => 'polls', 'poll' => false, 'message' => false ) ) ),
1796 esc_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll, 'message' => false ) ) )
1797 );
1798 ?>
1799 </h2>
1800 <?php
1801
1802 $this->poll_edit_form( $poll );
1803 break;
1804 case 'create-poll':
1805 ?>
1806 <h2 id="poll-list-header"><?php
1807 /* translators: %s is the URL to all polls */
1808 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>
1809 <?php
1810 $this->poll_edit_form();
1811 break;
1812 case 'list-styles':
1813 ?>
1814 <h2 id="polldaddy-header">
1815 <?php
1816 if ( $this->is_author ) {
1817 /* translators: %s is the URL to add new style */
1818 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 ) ) ) );
1819 } else {
1820 _e( 'Custom Styles', 'polldaddy' );
1821 }
1822 ?>
1823 </h2>
1824 <?php
1825 $this->styles_table();
1826 break;
1827 case 'edit-style':
1828 ?>
1829 <h2 id="polldaddy-header">
1830 <?php
1831 /* translators: %s is the URL to list styles */
1832 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 ) ) ) ); ?>
1833 </h2>
1834 <?php
1835
1836 $this->style_edit_form( $style );
1837 break;
1838 case 'create-style':
1839 ?>
1840 <h2 id="polldaddy-header">
1841 <?php
1842 /* translators: %s is the URL to list styles */
1843 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 ) ) ) ); ?>
1844 </h2>
1845 <?php
1846 $this->style_edit_form();
1847 break;
1848 case 'landing-page':
1849 $this->render_landing_page();
1850 break;
1851 default:
1852 $view_type = 'me'; // default (and only) config for self-hosted.
1853
1854 // cascaded attempt to "show something".
1855 if ( ! $this->has_items_for_view( $view_type ) ) {
1856 $this->render_landing_page();
1857 break;
1858 }
1859
1860 $this->polls_table( $view_type );
1861 } //end switch.
1862 } elseif ( 'ratings' === $page ) {
1863 if ( ! $this->is_admin && ! in_array( $action, array( 'delete', 'reports' ), true ) ) { // check user privileges has access to action.
1864 $action = 'reports';
1865 }
1866
1867 switch ( $action ) {
1868 case 'delete':
1869 case 'reports':
1870 $this->rating_reports();
1871 break;
1872 }//end switch
1873 }
1874 ?>
1875 </div>
1876 </div>
1877 <?php
1878 }
1879
1880 private function render_landing_page() {
1881 $this->render_partial(
1882 'crowdsignal-landing-page',
1883 array(
1884 'resource_path' => $this->base_url,
1885 )
1886 );
1887 }
1888
1889 private function has_items_for_view( $view = 'me' ) {
1890 if ( isset( $this->has_items[ $view ] ) ) {
1891 return $this->has_items[ $view ];
1892 }
1893
1894 $guid = WP_POLLDADDY__PARTNERGUID;
1895 // re-write the user_code based on the intended view.
1896 switch ( $view ) {
1897 case 'csforms':
1898 $this->user_code = get_option( 'crowdsignal_user_code' );
1899 $guid = get_option( 'crowdsignal_api_key' );
1900 break;
1901 case 'blog':
1902 $this->user_code = $this->get_usercode();
1903 break;
1904 default:
1905 $this->user_code = get_option( 'pd-usercode-' . $this->id );
1906 }
1907
1908 if ( empty( $this->user_code ) ) {
1909 // use set_api_user_code last attempt.
1910 $this->set_api_user_code();
1911 }
1912
1913 $polldaddy = $this->get_client( $guid, $this->user_code );
1914 $polldaddy->reset();
1915
1916 $polls_object = $polldaddy->get_items( 1, 1, 0, 'csforms' === $view ? get_site_url() : '' );
1917
1918 if ( ! $polls_object ) {
1919 return false;
1920 }
1921 $polls = & $polls_object->item;
1922
1923 if ( isset( $polls_object->_total ) ) {
1924 $total_polls = $polls_object->_total;
1925 } else {
1926 $total_polls = count( $polls );
1927 }
1928
1929 $this->has_items[ $view ] = $total_polls > 0;
1930
1931 return $this->has_items[ $view ];
1932 }
1933
1934
1935 function polls_table( $view = 'me' ) {
1936 $page = 1;
1937 if ( isset( $_GET['paged'] ) ) { // phpcs:ignore
1938 $page = absint( $_GET['paged'] ); // phpcs:ignore
1939 }
1940
1941 $guid = WP_POLLDADDY__PARTNERGUID;
1942 // re-write the user_code based on the intended view.
1943 switch ( $view ) {
1944 case 'csforms':
1945 $this->user_code = get_option( 'crowdsignal_user_code' );
1946 $guid = get_option( 'crowdsignal_api_key' );
1947 break;
1948 case 'blog':
1949 $this->user_code = $this->get_usercode();
1950 break;
1951 default:
1952 $this->user_code = get_option( 'pd-usercode-' . $this->id );
1953 }
1954
1955 if ( empty( $this->user_code ) ) {
1956 // use set_api_user_code last attempt.
1957 $this->set_api_user_code();
1958 }
1959
1960 $polldaddy = $this->get_client( $guid, $this->user_code );
1961 $polldaddy->reset();
1962
1963 $items = $polldaddy->get_items( $page, 20, 0, 'csforms' === $view ? get_site_url() : '' );
1964
1965 $this->parse_errors( $polldaddy );
1966 if ( in_array( 'API Key Not Found, 890', $polldaddy->errors, true ) ) {
1967 return false;
1968 }
1969
1970 $total = $items->_total;
1971 $items = $items->item;
1972 $connected_account = $polldaddy->get_account();
1973
1974 $this->print_errors();
1975
1976 $page_links = paginate_links(
1977 array(
1978 'base' => add_query_arg( 'paged', '%#%' ),
1979 'format' => '',
1980 'total' => ceil( $total / 10 ),
1981 'current' => $page,
1982 'prev_text' => '&laquo;',
1983 'next_text' => '&raquo;',
1984 )
1985 );
1986
1987 global $current_user;
1988
1989 $current_user_name = ( $current_user instanceof WP_User ) && $current_user->first_name && $current_user->last_name
1990 ? "{$current_user->first_name} {$current_user->last_name}"
1991 : $current_user->user_login;
1992
1993 $global_user_id = (int) get_option( 'polldaddy_usercode_user' );
1994 $global_user_name = '';
1995 if ( $global_user_id ) {
1996 $global_user_account = new WP_User( $global_user_id );
1997 $global_user_name = $global_user_account && $global_user_account->first_name && $global_user_account->last_name
1998 ? "{$global_user_account->first_name} {$global_user_account->last_name}"
1999 : ( $global_user_account ? $global_user_account->user_login : __( 'Disconnected user', 'polldaddy' ) );
2000 }
2001
2002 // reset $this vars at this point so we show a consistent list with less "tabbed" options.
2003 $this->has_crowdsignal_blocks = false;
2004 $this->multiple_accounts = false;
2005
2006 $cs_forms_account = $this->get_crowdsignal_connected_account();
2007
2008 switch ( $view ) {
2009 case 'csforms':
2010 $current_user_owns_connection = ! empty( $cs_forms_account ) && $cs_forms_account->email === $current_user->user_email;
2011 break;
2012 default: // me and blog case.
2013 $current_user_owns_connection = ! empty( $connected_account ) && $connected_account->email === $current_user->user_email;
2014 }
2015
2016 $this->render_partial(
2017 'polls-table',
2018 array(
2019 'page_links' => $page_links,
2020 'items' => $items,
2021 'can_manage_options' => current_user_can( 'manage_options' ),
2022 'connected_account_email' => ! empty( $connected_account ) ? $connected_account->email : '',
2023 'is_author' => $this->is_author,
2024 'is_admin' => $this->is_admin,
2025 'current_user_name' => $current_user_name,
2026 'resource_path' => $this->base_url,
2027 'has_multiple_accounts' => $this->multiple_accounts && $this->has_items_for_view( 'blog' ),
2028 'global_user_id' => $global_user_id,
2029 'global_user_name' => $global_user_name,
2030 'current_user_owns_connection' => $current_user_owns_connection,
2031 'user_id' => (int) $this->id,
2032 'view' => $view,
2033 'has_crowdsignal_blocks' => $this->has_crowdsignal_blocks && $this->has_items_for_view( 'csforms' ),
2034 'cs_forms_account_email' => $this->has_crowdsignal_blocks && $cs_forms_account ? $cs_forms_account->email : '',
2035 )
2036 );
2037 }
2038
2039 private function get_crowdsignal_connected_account() {
2040 if ( $this->has_crowdsignal_blocks ) {
2041 $polldaddy = $this->get_client( get_option( 'crowdsignal_api_key' ), get_option( 'crowdsignal_user_code' ) );
2042 $polldaddy->reset();
2043 return $polldaddy->get_account();
2044 }
2045
2046 return false;
2047 }
2048
2049
2050 function poll_table_add_option() {}
2051
2052 function poll_table_extra() {}
2053
2054 function poll_edit_form( $poll_id = 1 ) {
2055 $poll_id = (int) $poll_id;
2056
2057 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2058 $polldaddy->reset();
2059
2060 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
2061
2062 if ( $poll_id ) {
2063 $poll = $polldaddy->get_poll( $poll_id );
2064 $this->parse_errors( $polldaddy );
2065
2066 if ( !$this->can_edit( $poll ) ) {
2067 $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
2068 }
2069
2070 if ( $poll_id == 1 ) {
2071 $poll->answers = array();
2072 $poll_id = 0;
2073 }
2074
2075 } else {
2076 $poll = polldaddy_poll( array(), null, false );
2077 }
2078
2079 $question = $is_POST ? esc_attr( stripslashes( $_POST['question'] ) ) : esc_attr( $poll->question );
2080
2081 $answers = $media = $mediaType = array();
2082 if ( $is_POST ) {
2083 if ( isset( $_POST['mediaType'] ) )
2084 $mediaType = $_POST['mediaType'];
2085
2086 if ( isset( $_POST['media'] ) ) {
2087 $mc = $_POST['media'];
2088
2089 foreach ( $mc as $key => $value ) {
2090 if ( $mediaType[$key] == 1 ) {
2091 $media[$key] = $polldaddy->get_media( $value );
2092 }
2093 }
2094 }
2095
2096 if ( isset( $_POST['answer'] ) )
2097 foreach ( $_POST['answer'] as $answer_id => $answer )
2098 $answers[esc_attr($answer_id)] = esc_attr( stripslashes($answer) );
2099 } elseif ( isset( $poll->answers->answer ) ) {
2100 foreach ( $poll->answers->answer as $answer ) {
2101 $answers[(int) $answer->_id] = esc_attr( $answer->text );
2102
2103 if ( $answer->mediaType == 1 && !empty( $answer->mediaCode ) ) {
2104 $polldaddy->reset();
2105 $media[$answer->_id] = $polldaddy->get_media( $answer->mediaCode );
2106 $mediaType[$answer->_id] = 1;
2107 }
2108 elseif ( $answer->mediaType == 2 ) {
2109 $mediaType[$answer->_id] = 2;
2110 }
2111 }
2112
2113 if ( isset( $poll->mediaCode ) && isset( $poll->mediaType ) ) {
2114 if ( $poll->mediaType == 1 && !empty( $poll->mediaCode ) ) {
2115 $polldaddy->reset();
2116 $media[999999999] = $polldaddy->get_media( $poll->mediaCode );
2117 $mediaType[999999999] = 1;
2118 }
2119 elseif ( $poll->mediaType == 2 ) {
2120 $mediaType[999999999] = 2;
2121 }
2122 }
2123 }
2124 $this->print_errors();
2125
2126 $view_vars = [
2127 'delete_media_link' => $delete_media_link,
2128 'polldaddy' => $polldaddy,
2129 'controller' => $this,
2130 'poll' => $poll,
2131 'poll_id' => $poll_id,
2132 'is_post' => $is_POST,
2133 'base_url' => $this->base_url,
2134 'preview_img_dir' => plugins_url( 'img', __FILE__ ),
2135 'question' => $question,
2136 'answers' => $answers,
2137 'media' => $media,
2138 'media_type' => $mediaType,
2139 ];
2140
2141 $this->render_partial( 'poll-edit-form', $view_vars );
2142 }
2143
2144 function poll_results_page( $poll_id ) {
2145 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2146 $polldaddy->reset();
2147
2148 $results = $polldaddy->get_poll_results( $poll_id );
2149 $poll = $polldaddy->get_poll( $poll_id );
2150
2151 ?>
2152 <h3 style="line-height:21px;"><?php echo $poll->question; ?></h3>
2153 <table class="poll-results widefat">
2154 <thead>
2155 <tr>
2156 <th scope="col" class="column-title" style="width:40%;"><?php _e( 'Answer', 'polldaddy' ); ?></th>
2157 <th scope="col" class="column-vote" style="width:10%;text-align:center;"><?php _e( 'Votes', 'polldaddy' ); ?></th>
2158 <th scope="col" class="column-vote" style="width:10%;text-align:center;"><?php _e( 'Percent', 'polldaddy' ); ?></th>
2159 <th scope="col" class="column-vote" style="width:40%;">&nbsp;</th>
2160 </tr>
2161 </thead>
2162 <tbody>
2163
2164 <?php
2165 $class = '';
2166 foreach ( $results->answers as $answer ) :
2167 $answer->text = trim( strip_tags( $answer->text ) );
2168 if ( strlen( $answer->text ) == 0 ) {
2169 $answer->text = '-- empty HTML tag --';
2170 }
2171
2172 $class = $class ? '' : ' class="alternate"';
2173 /* translators: %s is the URL to other answers results */
2174 $content = $results->others && 'Other answer…' === $answer->text ? sprintf( __( 'Other (<a href="%s">see below</a>)', 'polldaddy' ), '#other-answers-results' ) : esc_html( $answer->text );
2175
2176 ?>
2177
2178 <tr<?php echo $class; ?>>
2179 <th scope="row" style="vertical-align:bottom" class="column-title"><?php echo $content; ?></th>
2180 <td class="column-vote" style="text-align:center;vertical-align:middle;">
2181 <?php echo number_format_i18n( $answer->_total ); ?>
2182 </td>
2183 <td style="text-align:center;vertical-align:middle;">
2184 <?php echo number_format_i18n( $answer->_percent, 2 ); ?>%
2185 </td>
2186 <td style="vertical-align:middle;">
2187 <span class="result-bar" style="width: <?php echo number_format( $answer->_percent, 2 ); ?>%;">&nbsp;</span>
2188 </td>
2189 </tr>
2190 <?php
2191 endforeach;
2192 ?>
2193
2194 </tbody>
2195 </table>
2196
2197 <?php
2198
2199 if ( !$results->others )
2200 return;
2201 ?>
2202
2203 <table id="other-answers-results" class="poll-others widefat">
2204 <thead>
2205 <tr>
2206 <th scope="col" class="column-title"><?php _e( 'Other Answer', 'polldaddy' ); ?></th>
2207 <th scope="col" class="column-vote"><?php _e( 'Votes', 'polldaddy' ); ?></th>
2208 </tr>
2209 </thead>
2210 <tbody>
2211
2212 <?php
2213 $class = '';
2214 $others = array_count_values( $results->others );
2215 arsort( $others );
2216 foreach ( $others as $other => $freq ) :
2217 $class = $class ? '' : ' class="alternate"';
2218 ?>
2219
2220 <tr<?php echo $class; ?>>
2221 <th scope="row" class="column-title"><?php echo esc_html( $other ); ?></th>
2222 <td class="column-vote"><?php echo number_format_i18n( $freq ); ?></td>
2223 </tr>
2224 <?php
2225 endforeach;
2226 ?>
2227
2228 </tbody>
2229 </table>
2230
2231 <?php
2232 }
2233
2234 function styles_table() {
2235 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2236 $polldaddy->reset();
2237
2238 $styles_object = $polldaddy->get_styles();
2239
2240 $this->parse_errors( $polldaddy );
2241 $this->print_errors();
2242 $styles = & $styles_object->style;
2243 $class = '';
2244 $styles_exist = false;
2245
2246 foreach ( (array)$styles as $style ) :
2247 if ( (int) $style->_type == 1 ):
2248 $styles_exist = true;
2249 break;
2250 endif;
2251 endforeach;
2252 ?>
2253
2254 <form method="post" action="">
2255 <div class="tablenav">
2256 <div class="alignleft">
2257 <select name="action">
2258 <option selected="selected" value=""><?php _e( 'Actions', 'polldaddy' ); ?></option>
2259 <option value="delete-style"><?php _e( 'Delete', 'polldaddy' ); ?></option>
2260 </select>
2261 <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
2262 <?php wp_nonce_field( 'action-style_bulk' ); ?>
2263 </div>
2264 <div class="tablenav-pages"></div>
2265 </div>
2266
2267 <table class="widefat">
2268 <thead>
2269 <tr>
2270 <th id="cb" class="manage-column column-cb check-column" scope="col"><input type="checkbox" /></th>
2271 <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Style', 'polldaddy' ); ?></th>
2272 <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Last Modified', 'polldaddy' ); ?></th>
2273 </tr>
2274 </thead>
2275 <tbody>
2276
2277 <?php
2278 if ( $styles_exist ) :
2279 foreach ( $styles as $style ) :
2280 if ( (int) $style->_type == 1 ):
2281 $style_id = (int) $style->_id;
2282
2283 $class = $class ? '' : ' class="alternate"';
2284 $edit_link = esc_url( add_query_arg( array( 'action' => 'edit-style', 'style' => $style_id, 'message' => false ) ) );
2285 $delete_link = esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-style', 'style' => $style_id, 'message' => false ) ), "delete-style_$style_id" ) );
2286 list( $style_time ) = explode( '.', $style->date );
2287 $style_time = strtotime( $style_time );
2288 ?>
2289
2290 <tr<?php echo $class; ?>>
2291 <th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $style_id; ?>" name="style[]" /></th>
2292 <td class="post-title column-title">
2293 <?php if ( $edit_link ) : ?>
2294 <strong><a class="row-title" href="<?php echo esc_url( $edit_link ); ?>"><?php echo esc_html( $style->title ); ?></a></strong>
2295 <div class="row-actions">
2296 <span class="edit"><a href="<?php echo esc_url( $edit_link ); ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
2297 <?php else : ?>
2298 <strong><?php echo esc_html( $style->title ); ?></strong>
2299 <?php endif; ?>
2300
2301 <span class="delete"><a class="delete-poll delete" href="<?php echo esc_url( $delete_link ); ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a></span>
2302 </div>
2303 </td>
2304 <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>
2305 </tr>
2306
2307 <?php
2308 endif;
2309 endforeach;
2310 else : // $styles
2311 ?>
2312
2313 <tr>
2314 <td colspan="4" id="empty-set">
2315
2316 <h3 style="margin-bottom:0px;"><?php _e( 'You haven\'t used our fancy style editor to create any custom styles!', 'polldaddy');?> </h3>
2317 <p style="margin-bottom:20px;"><?php _e( 'Why don\'t you go ahead and get started on that?', 'polldaddy' ); ?></p>
2318 <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>
2319
2320 </td>
2321 </tr>
2322 <?php endif; // $styles ?>
2323
2324 </tbody>
2325 </table>
2326 </form>
2327 <div class="tablenav">
2328 <div class="tablenav-pages"></div>
2329 </div>
2330 <br class="clear" />
2331
2332 <?php
2333 }
2334
2335 function style_edit_form( $style_id = 105 ) {
2336 $style_id = (int) $style_id;
2337
2338 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2339 $polldaddy->reset();
2340
2341 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
2342
2343 if ( $style_id ) {
2344 $style = $polldaddy->get_style( $style_id );
2345 $this->parse_errors( $polldaddy );
2346 } else {
2347 $style = polldaddy_style( array(), null, false );
2348 }
2349
2350 $style->css = trim( urldecode( $style->css ) );
2351
2352 $direction = 'ltr';
2353 if ( in_array( $style->_direction, array( 'ltr', 'rtl') ) )
2354 $direction = $style->_direction;
2355
2356 if ( $start = stripos( $style->css, '<data>' ) )
2357 $style->css = substr( $style->css, $start );
2358
2359 $style->css = addslashes( $style->css );
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 = addslashes( $preload_style->css );
2382 }
2383
2384 $this->print_errors();
2385
2386 echo '<script language="javascript">var CSSXMLString = "' . $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