PluginProbe
Crowdsignal Dashboard – Polls, Surveys & more / 3.1.2
Crowdsignal Dashboard – Polls, Surveys & more v3.1.2
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.2, at polldaddy.php

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