Crowdsignal Dashboard – Polls, Surveys & more - Version 1.8.10

Version Description

  • Updated shortcodes to use latest Polldaddy code
  • Fixed minor bug in rating results
  • Fixed minor bug in poll editor to allow use of 0 as poll answer
  • Added extra check to edit permissions on whether user is a blog member
  • Added Turkish and Polish language packs
Download this release

Release Info

Developer eoigal
Plugin Icon 128x128 Crowdsignal Dashboard – Polls, Surveys & more
Version 1.8.10
Comparing to
See all releases

Code changes from version 1.8.9 to 1.8.10

Files changed (5) hide show
  1. polldaddy-client.php +11 -5
  2. polldaddy-org.php +331 -236
  3. polldaddy.php +1493 -1480
  4. rating.php +117 -106
  5. readme.txt +13 -3
polldaddy-client.php CHANGED
@@ -1118,10 +1118,15 @@ function &polldaddy_poll( $args = null, $id = null, $_require_data = true ) {
1118
  return $false;
1119
  }
1120
 
1121
- foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'makePublic', 'closePoll', 'closePollNow', 'sharing' ) as $bool ) {
1122
  if ( 'no' !== $args[$bool] && 'yes' !== $args[$bool] )
1123
  $args[$bool] = $defaults[$bool];
1124
  }
 
 
 
 
 
1125
 
1126
  foreach ( array( 'styleID', 'packID', 'folderID', 'languageID', 'choices', 'blockExpiration' ) as $int )
1127
  if ( !is_numeric( $args[$int] ) )
@@ -1238,10 +1243,11 @@ function _polldaddy_poll_default_language_id() {
1238
  endif;
1239
 
1240
  function &polldaddy_poll_answer( $args, $id = null ) {
1241
- if ( !is_string( $args['text'] ) || !$args['text'] )
1242
- return false;
1243
-
1244
- $answer = new PollDaddy_Poll_Answer( $args, compact( 'id' ) );
 
1245
 
1246
  return $answer;
1247
  }
1118
  return $false;
1119
  }
1120
 
1121
+ foreach ( array( 'multipleChoice', 'randomiseAnswers', 'makePublic', 'otherAnswer', 'closePoll', 'closePollNow', 'sharing' ) as $bool ) {
1122
  if ( 'no' !== $args[$bool] && 'yes' !== $args[$bool] )
1123
  $args[$bool] = $defaults[$bool];
1124
  }
1125
+
1126
+ global $wpdb;
1127
+ $public = (int) $wpdb->get_var( $wpdb->prepare( "SELECT public FROM wp_blogs WHERE blog_id = %d", $wpdb->blogid ) );
1128
+ if( $public == -1 )
1129
+ $args['makePublic'] = 'no';
1130
 
1131
  foreach ( array( 'styleID', 'packID', 'folderID', 'languageID', 'choices', 'blockExpiration' ) as $int )
1132
  if ( !is_numeric( $args[$int] ) )
1243
  endif;
1244
 
1245
  function &polldaddy_poll_answer( $args, $id = null ) {
1246
+ $answer = false;
1247
+
1248
+ if ( is_string( $args['text'] ) && strlen($args['text'] ) > 0 ){
1249
+ $answer = new PollDaddy_Poll_Answer( $args, compact( 'id' ) );
1250
+ }
1251
 
1252
  return $answer;
1253
  }
polldaddy-org.php CHANGED
@@ -2,107 +2,107 @@
2
 
3
  require_once dirname( __FILE__ ) . '/polldaddy-client.php';
4
 
5
- class WPORG_PollDaddy extends WP_PollDaddy {
6
  var $use_ssl;
7
-
8
- function WPORG_PollDaddy(){
9
- $this->__construct();
10
- }
11
-
12
- function __construct() {
13
- parent::__construct();
14
- $this->version = '1.8.9';
15
- $this->base_url = plugins_url() . '/' . dirname( plugin_basename( __FILE__ ) ) . '/';
16
- $this->polldaddy_client_class = 'WPORG_PollDaddy_Client';
17
  $this->use_ssl = (int) get_option( 'polldaddy_use_ssl' );
18
- $this->multiple_accounts = (bool) get_option( 'polldaddy_multiple_accounts' );
19
- $this->is_author = ( ( (bool) current_user_can('edit_others_posts')) or ( $this->multiple_accounts ) );
20
- return;
21
- }
22
-
23
- function set_api_user_code(){
24
- if ( empty( $this->rating_user_code ) ){
25
- $this->rating_user_code = get_option( 'pd-rating-usercode' );
26
-
27
- if ( empty( $this->rating_user_code ) ){
28
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
29
- $polldaddy->reset();
30
-
31
- if( $this->multiple_accounts ){
32
- //need to retrieve initial admin user code to use as ratings user code
33
- $polldaddy->update_partner_account( array( 'role' => 0 ) );
34
- update_option( 'polldaddy_multiple_accounts', 0 );
35
- }
36
-
37
- $this->rating_user_code = $polldaddy->get_usercode( $this->id );
38
- if ( !empty( $this->rating_user_code ) )
39
- update_option( 'pd-rating-usercode', $this->rating_user_code );
40
-
41
- if( $this->multiple_accounts ){
42
- $polldaddy->update_partner_account( array( 'role' => 1 ) );
43
- update_option( 'polldaddy_multiple_accounts', 1 );
44
- }
45
- }
46
- }
47
- parent::set_api_user_code();
48
- }
49
-
50
- function management_page_load() {
51
  require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
52
 
53
- $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
54
- wp_reset_vars( array( 'action', 'page' ) );
55
  global $action, $page;
56
-
57
  $this->set_api_user_code();
58
-
59
- if( $page == 'polls' ) {
60
  switch ( $action ) :
61
  case 'update-options' :
62
- if ( !$is_POST )
63
  return;
64
-
65
- if( $this->is_admin ){
66
- check_admin_referer( 'polldaddy-account' );
67
-
68
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
69
- $polldaddy->reset();
70
-
71
- $polldaddy_sync_account = 0;
72
- $polldaddy_multiple_accounts = 0;
73
-
74
- if( isset( $_POST['polldaddy-sync-account'] ) )
75
- $polldaddy_sync_account = (int) $_POST['polldaddy-sync-account'];
76
-
77
- if( $polldaddy_sync_account > 0 ){
78
- $this->rating_user_code = '';
79
- update_option( 'pd-rating-usercode', '' );
80
- $this->set_api_user_code();
81
- }
82
-
83
- if( isset( $_POST['polldaddy-multiple-accounts'] ) )
84
- $polldaddy_multiple_accounts = (int) $_POST['polldaddy-multiple-accounts'];
85
-
86
- $partner = array( 'role' => $polldaddy_multiple_accounts );
87
- $polldaddy->update_partner_account( $partner );
88
- update_option( 'polldaddy_multiple_accounts', $polldaddy_multiple_accounts );
89
- }
90
- break;
91
  endswitch;
92
- }
93
-
94
  parent::management_page_load();
95
- }
96
-
97
- function api_key_page_load() {
98
- if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
99
  return false;
100
 
101
  check_admin_referer( 'polldaddy-account' );
102
 
103
  $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
104
  $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
105
-
106
  if ( !$polldaddy_email )
107
  $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
108
 
@@ -122,7 +122,7 @@ class WPORG_PollDaddy extends WP_PollDaddy {
122
  update_option( 'polldaddy_use_ssl', $this->use_ssl );
123
  }
124
 
125
- $details = array(
126
  'uName' => get_bloginfo( 'name' ),
127
  'uEmail' => $polldaddy_email,
128
  'uPass' => $polldaddy_password,
@@ -131,8 +131,8 @@ class WPORG_PollDaddy extends WP_PollDaddy {
131
 
132
  if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
133
  $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
134
- 'body' => $details
135
- ) );
136
  if ( is_wp_error( $polldaddy_api_key ) ) {
137
  $this->errors = $polldaddy_api_key;
138
  return false;
@@ -177,12 +177,12 @@ class WPORG_PollDaddy extends WP_PollDaddy {
177
  $response .= fread( $fp, 4096 );
178
  fclose( $fp );
179
  list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
180
- }
181
 
182
- if( isset( $polldaddy_api_key ) && strlen( $polldaddy_api_key ) > 0 ){
183
  update_option( 'polldaddy_api_key', $polldaddy_api_key );
184
  }
185
- else{
186
  $this->errors->add( 'polldaddy_api_key', __( 'Login to PollDaddy failed. Double check your email address and password.', 'polldaddy' ) );
187
  if ( 1 !== $this->use_ssl ) {
188
  $this->errors->add( 'polldaddy_api_key', __( 'If your email address and password are correct, your host may not support secure logins.', 'polldaddy' ) );
@@ -200,11 +200,11 @@ class WPORG_PollDaddy extends WP_PollDaddy {
200
  $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
201
  return false;
202
  }
203
-
204
  wp_redirect( add_query_arg( array( 'page' => 'polls' ), wp_get_referer() ) );
205
  return true;
206
  }
207
-
208
  function api_key_page() {
209
  $this->print_errors();
210
  ?>
@@ -235,10 +235,10 @@ class WPORG_PollDaddy extends WP_PollDaddy {
235
  </td>
236
  </tr>
237
  <?php
238
- $checked = '';
239
- if ( $this->use_ssl == 0 )
240
- $checked = 'checked="checked"';
241
- ?>
242
  <tr class="form-field form-required">
243
  <th valign="top" scope="row">
244
  <label for="polldaddy-use-ssl"><?php _e( 'Use SSL to Log in', 'polldaddy' ); ?></label>
@@ -262,13 +262,13 @@ class WPORG_PollDaddy extends WP_PollDaddy {
262
 
263
  <?php
264
  }
265
-
266
- function plugin_options_add(){
267
- if( $this->is_admin ) {
268
- $checked = '';
269
- if ( $this->multiple_accounts )
270
- $checked = 'checked="checked"';
271
- ?><tr class="form-field form-required">
272
  <th valign="top" scope="row">
273
  <label for="polldaddy-multiple-accounts">
274
  <?php _e( 'Multiple PollDaddy Accounts', 'polldaddy' ); ?>
@@ -293,27 +293,31 @@ class WPORG_PollDaddy extends WP_PollDaddy {
293
  <label for="polldaddy-sync-account"><?php _e( 'This will synchronize your ratings PollDaddy account.', 'polldaddy' ); ?></label>
294
  </span>
295
  </td>
296
- </tr><?php }
297
- return parent::plugin_options_add();
298
- }
299
  }
300
 
301
- class WPORG_PollDaddy_Client extends api_client {
302
- /**
 
 
303
  * @return string|false PollDaddy partner account or false on failure
304
  */
305
- function get_partner_account() {
306
  $pos = $this->add_request( 'getpartneraccount' );
307
  $this->send_request();
308
  $r = $this->response_part( $pos );
309
  if ( isset( $r->partner ) && !is_null( $r->partner->_role ) )
310
  return $r->partner;
311
  return false;
312
- }
313
 
314
  /**
 
 
315
  * @see polldaddy_partner()
316
- * @param array $args polldaddy_partner() args
317
  * @return string|false PollDaddy partner account or false on failure
318
  */
319
  function update_partner_account( $args ) {
@@ -342,8 +346,8 @@ function &polldaddy_partner( $args = null ) {
342
  if ( !is_string( $args[$required] ) || !$args[$required] )
343
  return $false;
344
 
345
- $obj = new PollDaddy_Partner( $args, $args );
346
-
347
  return $obj;
348
  }
349
 
@@ -356,7 +360,7 @@ function _polldaddy_partner_defaults() {
356
 
357
  define( 'WP_POLLDADDY__CLASS', 'WPORG_PollDaddy' );
358
  define( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH', dirname( __FILE__ ) . '/polldaddy-client.php' );
359
-
360
  function polldaddy_loader() {
361
  global $polldaddy_object;
362
  $polldaddy_class = WP_POLLDADDY__CLASS;
@@ -365,80 +369,171 @@ function polldaddy_loader() {
365
  add_action( 'admin_menu', array( &$polldaddy_object, 'admin_menu' ) );
366
  }
367
 
368
- function polldaddy_shortcode_handler( $atts, $content=null ) {
369
- extract( shortcode_atts( array(
370
- 'survey' => null,
371
- 'link_text' => 'View Survey',
372
- 'poll' => 'empty',
373
- 'rating' => 'empty',
374
- 'unique_id' => null,
375
- 'title' => null,
376
- 'permalink' => null,
377
- 'cb' => 0 ), $atts ) );
378
-
379
- $survey = esc_attr( str_replace( "'", "", $survey ) );
380
- $link_text = esc_attr($link_text);
381
-
382
- if ( $survey != null ) {
383
- return "<script language='javascript' type='text/javascript'>
384
- var PDF_surveyID = '$survey';
385
- var PDF_openText = '$link_text';
386
- </script>
387
- <script type='text/javascript' language='javascript' src='http://www.polldaddy.com/s.js'></script>
388
- <noscript><a href='http://surveys.polldaddy.com/s/$survey/'>$link_text</a></noscript>";
389
- }
390
-
391
- $poll = (int) $poll;
392
- $rating = (int) $rating;
393
- $cb = (int) $cb;
394
-
395
- if ( $rating > 0 ) {
396
- if ( $unique_id != null ) {
397
- $unique_id = wp_specialchars( $unique_id );
398
- } else {
399
- if ( is_page() ) {
400
- $unique_id = 'wp-page-' . $post->ID;
401
- } else {
402
- $unique_id = 'wp-post-' . $post->ID;
403
- }
404
- }
405
-
406
- if ( $title != null ) {
407
- $title = wp_specialchars( $title );
408
- } else {
409
- $title = urlencode( $post->post_title );
410
- }
411
-
412
- if( $permalink != null ) {
413
- $permalink = clean_url( $permalink );
414
- } else {
415
- $permalink = urlencode( get_permalink( $post->ID ) );
416
- }
417
-
418
- wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
419
- add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
420
-
421
- return "<div id='pd_rating_holder_$rating'></div>
422
- <script language='javascript'>
423
- PDRTJS_settings_$rating = {
424
- 'id' : '$rating',
425
- 'unique_id' : '$unique_id',
426
- 'title' : '$title',
427
- 'permalink' : '$permalink'};
428
- </script>";
429
- }
430
- else if ( $poll > 0 ) {
431
- $cb = ( $cb == 1 ? '?cb=' . mktime() : '' );
432
- return "<script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/$poll.js$cb'></script><noscript> <a href='http://answers.polldaddy.com/poll/$poll/'>View Poll</a></noscript>";
433
- }
434
- }
435
-
436
- function polldaddy_add_rating_js() {
437
- wp_print_scripts( 'polldaddy-rating-js' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  }
439
 
440
  add_action( 'init', 'polldaddy_loader' );
441
- add_shortcode( 'polldaddy', 'polldaddy_shortcode_handler' );
442
  add_filter( 'widget_text', 'do_shortcode' );
443
 
444
  /**
@@ -447,85 +542,85 @@ add_filter( 'widget_text', 'do_shortcode' );
447
  * **/
448
  if ( class_exists( 'WP_Widget' ) ) {
449
  class PD_Top_Rated extends WP_Widget {
450
-
451
  function PD_Top_Rated() {
452
-
453
  $widget_ops = array( 'classname' => 'top_rated', 'description' => __( 'A list of your top rated posts, pages or comments.' ) );
454
  $this->WP_Widget( 'PD_Top_Rated', 'Top Rated', $widget_ops );
455
  }
456
-
457
  function widget($args, $instance) {
458
-
459
  extract($args, EXTR_SKIP);
460
-
461
  echo $before_widget;
462
  $title = empty( $instance['title'] ) ? __( 'Top Rated', 'polldaddy' ) : apply_filters( 'widget_title', $instance['title'] );
463
  $posts_rating_id = (int) get_option( 'pd-rating-posts-id' );
464
  $pages_rating_id = (int) get_option( 'pd-rating-pages-id' );
465
  $comments_rating_id = (int) get_option( 'pd-rating-comments-id' );
466
-
467
  echo $before_title . $title . $after_title;
468
  echo '<div id="pd_top_rated_holder"></div>';
469
  echo '<script language="javascript" src="http://i.polldaddy.com/ratings/rating-top.js"></script>';
470
  echo '<script language="javascript" type="text/javascript">';
471
  $rating_seq = $instance['show_posts'] . $instance['show_pages'] . $instance['show_comments'];
472
-
473
  echo ' PDRTJS_TOP = new PDRTJS_RATING_TOP( ' . $posts_rating_id . ', ' . $pages_rating_id . ', ' . $comments_rating_id . ", '" . $rating_seq . "', " . $instance['item_count'] . ' );';
474
  echo '</script>';
475
- echo $after_widget;
476
- }
477
-
478
- function update( $new_instance, $old_instance ) {
479
-
480
- $instance = $old_instance;
481
- $instance['title'] = strip_tags($new_instance['title']);
482
- $instance['show_posts'] = (int) $new_instance['show_posts'];
483
- $instance['show_pages'] = (int) $new_instance['show_pages'];
484
- $instance['show_comments'] = (int) $new_instance['show_comments'];
485
- $instance['item_count'] = (int) $new_instance['item_count'];
486
- return $instance;
487
- }
488
-
489
- function form( $instance ) {
490
-
491
- $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'show_posts' => '1', 'show_pages' => '1', 'show_comments' => '1', 'item_count' => '5' ) );
492
- $title = strip_tags( $instance['title'] );
493
- $show_posts = (int) $instance['show_posts'];
494
- $show_pages = (int) $instance['show_pages'];
495
- $show_comments = (int) $instance['show_comments'];
496
- $item_count = (int) $instance['item_count'];
497
- ?>
498
  <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title', 'polldaddy' ); ?>: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape( $title ); ?>" /></label></p>
499
  <p>
500
  <label for="<?php echo $this->get_field_id( 'show_posts' ); ?>">
501
  <?php
502
- $checked = '';
503
- if ( $show_posts == 1 )
504
- $checked = 'checked="checked"';
505
- ?>
506
- <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_posts' ); ?>" name="<?php echo $this->get_field_name( 'show_posts' ); ?>" value="1" <?php echo ( $checked ); ?> />
507
  <?php _e( 'Show for posts', 'polldaddy' ); ?>
508
  </label>
509
  </p>
510
  <p>
511
  <label for="<?php echo $this->get_field_id( 'show_pages' ); ?>">
512
  <?php
513
- $checked = '';
514
- if ( $show_pages == 1 )
515
- $checked = 'checked="checked"';
516
- ?>
517
- <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_pages' ); ?>" name="<?php echo $this->get_field_name( 'show_pages' ); ?>" value="1" <?php echo ( $checked ); ?> />
518
  <?php _e( 'Show for pages', 'polldaddy' ); ?>
519
  </label>
520
  </p>
521
  <p>
522
  <label for="<?php echo $this->get_field_id( 'show_comments' ); ?>">
523
  <?php
524
- $checked = '';
525
- if ( $show_comments == 1 )
526
- $checked = 'checked="checked"';
527
- ?>
528
- <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_comments' ); ?>" name="<?php echo $this->get_field_name( 'show_comments' ); ?>" value="1" <?php echo ( $checked ); ?>/>
529
  <?php _e( 'Show for comments', 'polldaddy' ); ?>
530
  </label>
531
  </p>
@@ -533,15 +628,15 @@ if ( class_exists( 'WP_Widget' ) ) {
533
  <label for="rss-items-<?php echo $number; ?>"><?php _e( 'How many items would you like to display?', 'polldaddy' ); ?>
534
  <select id="<?php echo $this->get_field_id( 'item_count' ); ?>" name="<?php echo $this->get_field_name( 'item_count' ); ?>">
535
  <?php
536
- for ( $i = 1; $i <= 20; ++$i )
537
- echo "<option value='$i' " . ( $item_count == $i ? "selected='selected'" : '' ) . ">$i</option>";
538
- ?>
539
  </select>
540
  </label>
541
  </p>
542
  <?php
543
- }
544
- }
545
- add_action('widgets_init', create_function('', 'return register_widget("PD_Top_Rated");'));
546
  }
547
  ?>
2
 
3
  require_once dirname( __FILE__ ) . '/polldaddy-client.php';
4
 
5
+ class WPORG_PollDaddy extends WP_PollDaddy {
6
  var $use_ssl;
7
+
8
+ function WPORG_PollDaddy() {
9
+ $this->__construct();
10
+ }
11
+
12
+ function __construct() {
13
+ parent::__construct();
14
+ $this->version = '1.8.9';
15
+ $this->base_url = plugins_url() . '/' . dirname( plugin_basename( __FILE__ ) ) . '/';
16
+ $this->polldaddy_client_class = 'WPORG_PollDaddy_Client';
17
  $this->use_ssl = (int) get_option( 'polldaddy_use_ssl' );
18
+ $this->multiple_accounts = (bool) get_option( 'polldaddy_multiple_accounts' );
19
+ $this->is_author = ( ( (bool) current_user_can('edit_others_posts')) or ( $this->multiple_accounts ) );
20
+ return;
21
+ }
22
+
23
+ function set_api_user_code() {
24
+ if ( empty( $this->rating_user_code ) ) {
25
+ $this->rating_user_code = get_option( 'pd-rating-usercode' );
26
+
27
+ if ( empty( $this->rating_user_code ) ) {
28
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
29
+ $polldaddy->reset();
30
+
31
+ if ( $this->multiple_accounts ) {
32
+ //need to retrieve initial admin user code to use as ratings user code
33
+ $polldaddy->update_partner_account( array( 'role' => 0 ) );
34
+ update_option( 'polldaddy_multiple_accounts', 0 );
35
+ }
36
+
37
+ $this->rating_user_code = $polldaddy->get_usercode( $this->id );
38
+ if ( !empty( $this->rating_user_code ) )
39
+ update_option( 'pd-rating-usercode', $this->rating_user_code );
40
+
41
+ if ( $this->multiple_accounts ) {
42
+ $polldaddy->update_partner_account( array( 'role' => 1 ) );
43
+ update_option( 'polldaddy_multiple_accounts', 1 );
44
+ }
45
+ }
46
+ }
47
+ parent::set_api_user_code();
48
+ }
49
+
50
+ function management_page_load() {
51
  require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
52
 
53
+ $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
54
+ wp_reset_vars( array( 'action', 'page' ) );
55
  global $action, $page;
56
+
57
  $this->set_api_user_code();
58
+
59
+ if ( $page == 'polls' ) {
60
  switch ( $action ) :
61
  case 'update-options' :
62
+ if ( !$is_POST )
63
  return;
64
+
65
+ if ( $this->is_admin ) {
66
+ check_admin_referer( 'polldaddy-account' );
67
+
68
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
69
+ $polldaddy->reset();
70
+
71
+ $polldaddy_sync_account = 0;
72
+ $polldaddy_multiple_accounts = 0;
73
+
74
+ if ( isset( $_POST['polldaddy-sync-account'] ) )
75
+ $polldaddy_sync_account = (int) $_POST['polldaddy-sync-account'];
76
+
77
+ if ( $polldaddy_sync_account > 0 ) {
78
+ $this->rating_user_code = '';
79
+ update_option( 'pd-rating-usercode', '' );
80
+ $this->set_api_user_code();
81
+ }
82
+
83
+ if ( isset( $_POST['polldaddy-multiple-accounts'] ) )
84
+ $polldaddy_multiple_accounts = (int) $_POST['polldaddy-multiple-accounts'];
85
+
86
+ $partner = array( 'role' => $polldaddy_multiple_accounts );
87
+ $polldaddy->update_partner_account( $partner );
88
+ update_option( 'polldaddy_multiple_accounts', $polldaddy_multiple_accounts );
89
+ }
90
+ break;
91
  endswitch;
92
+ }
93
+
94
  parent::management_page_load();
95
+ }
96
+
97
+ function api_key_page_load() {
98
+ if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
99
  return false;
100
 
101
  check_admin_referer( 'polldaddy-account' );
102
 
103
  $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
104
  $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
105
+
106
  if ( !$polldaddy_email )
107
  $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
108
 
122
  update_option( 'polldaddy_use_ssl', $this->use_ssl );
123
  }
124
 
125
+ $details = array(
126
  'uName' => get_bloginfo( 'name' ),
127
  'uEmail' => $polldaddy_email,
128
  'uPass' => $polldaddy_password,
131
 
132
  if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
133
  $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
134
+ 'body' => $details
135
+ ) );
136
  if ( is_wp_error( $polldaddy_api_key ) ) {
137
  $this->errors = $polldaddy_api_key;
138
  return false;
177
  $response .= fread( $fp, 4096 );
178
  fclose( $fp );
179
  list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
180
+ }
181
 
182
+ if ( isset( $polldaddy_api_key ) && strlen( $polldaddy_api_key ) > 0 ) {
183
  update_option( 'polldaddy_api_key', $polldaddy_api_key );
184
  }
185
+ else {
186
  $this->errors->add( 'polldaddy_api_key', __( 'Login to PollDaddy failed. Double check your email address and password.', 'polldaddy' ) );
187
  if ( 1 !== $this->use_ssl ) {
188
  $this->errors->add( 'polldaddy_api_key', __( 'If your email address and password are correct, your host may not support secure logins.', 'polldaddy' ) );
200
  $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?', 'polldaddy' ) );
201
  return false;
202
  }
203
+
204
  wp_redirect( add_query_arg( array( 'page' => 'polls' ), wp_get_referer() ) );
205
  return true;
206
  }
207
+
208
  function api_key_page() {
209
  $this->print_errors();
210
  ?>
235
  </td>
236
  </tr>
237
  <?php
238
+ $checked = '';
239
+ if ( $this->use_ssl == 0 )
240
+ $checked = 'checked="checked"';
241
+ ?>
242
  <tr class="form-field form-required">
243
  <th valign="top" scope="row">
244
  <label for="polldaddy-use-ssl"><?php _e( 'Use SSL to Log in', 'polldaddy' ); ?></label>
262
 
263
  <?php
264
  }
265
+
266
+ function plugin_options_add() {
267
+ if ( $this->is_admin ) {
268
+ $checked = '';
269
+ if ( $this->multiple_accounts )
270
+ $checked = 'checked="checked"';
271
+ ?><tr class="form-field form-required">
272
  <th valign="top" scope="row">
273
  <label for="polldaddy-multiple-accounts">
274
  <?php _e( 'Multiple PollDaddy Accounts', 'polldaddy' ); ?>
293
  <label for="polldaddy-sync-account"><?php _e( 'This will synchronize your ratings PollDaddy account.', 'polldaddy' ); ?></label>
294
  </span>
295
  </td>
296
+ </tr><?php }
297
+ return parent::plugin_options_add();
298
+ }
299
  }
300
 
301
+ class WPORG_PollDaddy_Client extends api_client {
302
+ /**
303
+ *
304
+ *
305
  * @return string|false PollDaddy partner account or false on failure
306
  */
307
+ function get_partner_account() {
308
  $pos = $this->add_request( 'getpartneraccount' );
309
  $this->send_request();
310
  $r = $this->response_part( $pos );
311
  if ( isset( $r->partner ) && !is_null( $r->partner->_role ) )
312
  return $r->partner;
313
  return false;
314
+ }
315
 
316
  /**
317
+ *
318
+ *
319
  * @see polldaddy_partner()
320
+ * @param array $args polldaddy_partner() args
321
  * @return string|false PollDaddy partner account or false on failure
322
  */
323
  function update_partner_account( $args ) {
346
  if ( !is_string( $args[$required] ) || !$args[$required] )
347
  return $false;
348
 
349
+ $obj = new PollDaddy_Partner( $args, $args );
350
+
351
  return $obj;
352
  }
353
 
360
 
361
  define( 'WP_POLLDADDY__CLASS', 'WPORG_PollDaddy' );
362
  define( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH', dirname( __FILE__ ) . '/polldaddy-client.php' );
363
+
364
  function polldaddy_loader() {
365
  global $polldaddy_object;
366
  $polldaddy_class = WP_POLLDADDY__CLASS;
369
  add_action( 'admin_menu', array( &$polldaddy_object, 'admin_menu' ) );
370
  }
371
 
372
+ if ( !function_exists( 'polldaddy_shortcode_handler' ) ) {
373
+ /*
374
+ polldaddy.com
375
+ [polldaddy poll="139742"]
376
+ */
377
+
378
+ function polldaddy_shortcode_handler_set_data() {
379
+ $resource = wp_remote_get( 'http://polldaddy.com/xml/keywords.xml' );
380
+ $body = wp_remote_retrieve_body( $resource );
381
+ $keywords_xml = simplexml_load_string ( $body );
382
+ $keywords = array();
383
+ $keywords['generated'] = time();
384
+
385
+ foreach ( $keywords_xml->keyword as $keyword_xml ){
386
+ $keywords[] = array( 'keyword' => (string) $keyword_xml, 'url' => (string) $keyword_xml['url'] );
387
+ }
388
+ wp_cache_set( 'pd-keywords', $keywords, 'site-options', 864000 );
389
+
390
+ return $keywords;
391
+ }
392
+
393
+ function polldaddy_add_rating_js() {
394
+ wp_print_scripts( 'polldaddy-rating-js' );
395
+ }
396
+
397
+ function polldaddy_shortcode_handler( $atts, $content = null ) {
398
+ global $post;
399
+
400
+ extract( shortcode_atts( array(
401
+ 'survey' => null,
402
+ 'link_text' => 'View Survey',
403
+ 'poll' => 'empty',
404
+ 'rating' => 'empty',
405
+ 'unique_id' => null,
406
+ 'title' => null,
407
+ 'permalink' => null,
408
+ 'cb' => 0,
409
+ 'type' => null,
410
+ 'body' => '',
411
+ 'button' => '',
412
+ 'text_color' => '000000',
413
+ 'back_color' => 'FFFFFF',
414
+ 'align' => '',
415
+ 'style' => ''
416
+ ), $atts ) );
417
+
418
+ $survey = esc_attr( str_replace( "'", "", $survey ) );
419
+ $link_text = esc_attr( $link_text );
420
+
421
+ if ( null != $survey ) {
422
+
423
+ // This is the new survey embed
424
+ if ( $type != null ) {
425
+ //need to use esc_js and esc_attr as the values will be inserted into javascript while being enclosed in single quotes.
426
+ $title = preg_replace( '/&amp;(\w*);/', '&$1;', esc_js( esc_attr( $title ) ) );
427
+ $type = preg_replace( '/&amp;(\w*);/', '&$1;', esc_js( esc_attr( $type ) ) );
428
+ $body = preg_replace( '/&amp;(\w*);/', '&$1;', esc_js( esc_attr( $body ) ) );
429
+ $button = preg_replace( '/&amp;(\w*);/', '&$1;', esc_js( esc_attr( $button ) ) );
430
+ $text_color = preg_replace( '/&amp;(\w*);/', '&$1;', esc_js( esc_attr( $text_color ) ) );
431
+ $back_color = preg_replace( '/&amp;(\w*);/', '&$1;', esc_js( esc_attr( $back_color ) ) );
432
+ $align = preg_replace( '/&amp;(\w*);/', '&$1;', esc_js( esc_attr( $align ) ) );
433
+ $style = preg_replace( '/&amp;(\w*);/', '&$1;', esc_js( esc_attr( $style ) ) );
434
+
435
+ return "
436
+ <script type='text/javascript' src='http://i0.poll.fm/survey.js' charset='UTF-8'></script>
437
+ <noscript><a href='http://polldaddy.com/s/$survey'>$title</a></noscript>
438
+ <script type='text/javascript'>
439
+ polldaddy.add( {
440
+ title: '$title',
441
+ type: '$type',
442
+ body: '$body',
443
+ button: '$button',
444
+ text_color: '$text_color',
445
+ back_color: '$back_color',
446
+ align: '$align',
447
+ style: '$style',
448
+ id: '$survey'
449
+ } );
450
+ </script>
451
+ ";
452
+
453
+ } else {
454
+ return "
455
+ <script language='javascript' type='text/javascript'>
456
+ var PDF_surveyID = '$survey';
457
+ var PDF_openText = '$link_text';
458
+ </script>
459
+ <script type='text/javascript' language='javascript' src='http://www.polldaddy.com/s.js'></script>
460
+ <noscript><a href='http://surveys.polldaddy.com/s/$survey/'>$link_text</a></noscript>
461
+ ";
462
+ }
463
+ }
464
+
465
+ $poll = (int) $poll;
466
+ $rating = (int) $rating;
467
+ $cb = (int) $cb;
468
+
469
+ if ( $rating > 0 ) {
470
+ if ( null != $unique_id ) {
471
+ $unique_id = wp_specialchars( $unique_id );
472
+ } else {
473
+ $unique_id = is_page() ? 'wp-page-' : 'wp-post-';
474
+ $unique_id .= $post->ID;
475
+ }
476
+
477
+ if ( null != $title )
478
+ $title = wp_specialchars( $title );
479
+ else
480
+ $title = urlencode( $post->post_title );
481
+
482
+ if ( null != $permalink )
483
+ $permalink = clean_url( $permalink );
484
+ else
485
+ $permalink = urlencode( get_permalink( $post->ID ) );
486
+
487
+ wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
488
+ add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
489
+
490
+ return '<div id="pd_rating_holder_' . $rating . '"></div>
491
+ <script language="javascript">
492
+ PDRTJS_settings_' . $rating . ' = {
493
+ "id" : "' . $rating . '",
494
+ "unique_id" : "' . $unique_id . '",
495
+ "title" : "' . $title . '",
496
+ "permalink" : "' . $permalink . '"
497
+ };
498
+ </script>';
499
+ } elseif ( $poll > 0 ) {
500
+ $cb = ( $cb == 1 ? '?cb=' . mktime() : '' );
501
+ $keywords = wp_cache_get( 'pd-keywords', 'site-options' );
502
+ if ( ! $keywords || $keywords['generated'] <= ( time() - 300 ) ) {
503
+ if ( ! wp_cache_get( 'pd-keywords-fetching', 'site-options' ) ) {
504
+ wp_cache_set( 'pd-keywords-fetching', 1, 'site-options', 30 );
505
+ $keywords = polldaddy_shortcode_handler_set_data();
506
+ }
507
+ }
508
+
509
+ if ( !$keywords )
510
+ $keywords = array();
511
+
512
+ $mod = ( $poll % ( count( $keywords ) - 1 ) );
513
+
514
+ return '<a name="pd_a_' . $poll . '"></a><div class="PDS_Poll" id="PDI_container' . $poll . '" style="display:inline-block;"></div><script type="text/javascript" language="javascript" charset="utf-8" src="http://static.polldaddy.com/p/' . $poll . '.js' . $cb . '"></script>
515
+ <noscript>
516
+ <a href="http://polldaddy.com/poll/' . $poll . '/">View This Poll</a><br/><span style="font-size:10px;"><a href="' . $keywords[ $mod ][ 'url' ] . '">' . $keywords[ $mod ][ 'keyword' ] . '</a></span>
517
+ </noscript>';
518
+ }
519
+
520
+ return '<!-- no polldaddy output -->';
521
+ }
522
+
523
+ // http://polldaddy.com/poll/1562975/?view=results&msg=voted
524
+ function polldaddy_link( $content ) {
525
+ return preg_replace( '!(?:\n|\A)http://polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n<script type='text/javascript' language='javascript' charset='utf-8' src='http://static.polldaddy.com/p/$1.js'></script><noscript> <a href='http://polldaddy.com/poll/$1/'>View Poll</a></noscript>\n", $content );
526
+ }
527
+
528
+ // higher priority because we need it before auto-link and autop get to it
529
+ add_filter( 'the_content', 'polldaddy_link', 1 );
530
+ add_filter( 'the_content_rss', 'polldaddy_link', 1 );
531
+ add_filter( 'comment_text', 'polldaddy_link', 1 );
532
+
533
+ add_shortcode( 'polldaddy', 'polldaddy_shortcode_handler' );
534
  }
535
 
536
  add_action( 'init', 'polldaddy_loader' );
 
537
  add_filter( 'widget_text', 'do_shortcode' );
538
 
539
  /**
542
  * **/
543
  if ( class_exists( 'WP_Widget' ) ) {
544
  class PD_Top_Rated extends WP_Widget {
545
+
546
  function PD_Top_Rated() {
547
+
548
  $widget_ops = array( 'classname' => 'top_rated', 'description' => __( 'A list of your top rated posts, pages or comments.' ) );
549
  $this->WP_Widget( 'PD_Top_Rated', 'Top Rated', $widget_ops );
550
  }
551
+
552
  function widget($args, $instance) {
553
+
554
  extract($args, EXTR_SKIP);
555
+
556
  echo $before_widget;
557
  $title = empty( $instance['title'] ) ? __( 'Top Rated', 'polldaddy' ) : apply_filters( 'widget_title', $instance['title'] );
558
  $posts_rating_id = (int) get_option( 'pd-rating-posts-id' );
559
  $pages_rating_id = (int) get_option( 'pd-rating-pages-id' );
560
  $comments_rating_id = (int) get_option( 'pd-rating-comments-id' );
561
+
562
  echo $before_title . $title . $after_title;
563
  echo '<div id="pd_top_rated_holder"></div>';
564
  echo '<script language="javascript" src="http://i.polldaddy.com/ratings/rating-top.js"></script>';
565
  echo '<script language="javascript" type="text/javascript">';
566
  $rating_seq = $instance['show_posts'] . $instance['show_pages'] . $instance['show_comments'];
567
+
568
  echo ' PDRTJS_TOP = new PDRTJS_RATING_TOP( ' . $posts_rating_id . ', ' . $pages_rating_id . ', ' . $comments_rating_id . ", '" . $rating_seq . "', " . $instance['item_count'] . ' );';
569
  echo '</script>';
570
+ echo $after_widget;
571
+ }
572
+
573
+ function update( $new_instance, $old_instance ) {
574
+
575
+ $instance = $old_instance;
576
+ $instance['title'] = strip_tags($new_instance['title']);
577
+ $instance['show_posts'] = (int) $new_instance['show_posts'];
578
+ $instance['show_pages'] = (int) $new_instance['show_pages'];
579
+ $instance['show_comments'] = (int) $new_instance['show_comments'];
580
+ $instance['item_count'] = (int) $new_instance['item_count'];
581
+ return $instance;
582
+ }
583
+
584
+ function form( $instance ) {
585
+
586
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'show_posts' => '1', 'show_pages' => '1', 'show_comments' => '1', 'item_count' => '5' ) );
587
+ $title = strip_tags( $instance['title'] );
588
+ $show_posts = (int) $instance['show_posts'];
589
+ $show_pages = (int) $instance['show_pages'];
590
+ $show_comments = (int) $instance['show_comments'];
591
+ $item_count = (int) $instance['item_count'];
592
+ ?>
593
  <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title', 'polldaddy' ); ?>: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape( $title ); ?>" /></label></p>
594
  <p>
595
  <label for="<?php echo $this->get_field_id( 'show_posts' ); ?>">
596
  <?php
597
+ $checked = '';
598
+ if ( $show_posts == 1 )
599
+ $checked = 'checked="checked"';
600
+ ?>
601
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_posts' ); ?>" name="<?php echo $this->get_field_name( 'show_posts' ); ?>" value="1" <?php echo $checked; ?> />
602
  <?php _e( 'Show for posts', 'polldaddy' ); ?>
603
  </label>
604
  </p>
605
  <p>
606
  <label for="<?php echo $this->get_field_id( 'show_pages' ); ?>">
607
  <?php
608
+ $checked = '';
609
+ if ( $show_pages == 1 )
610
+ $checked = 'checked="checked"';
611
+ ?>
612
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_pages' ); ?>" name="<?php echo $this->get_field_name( 'show_pages' ); ?>" value="1" <?php echo $checked; ?> />
613
  <?php _e( 'Show for pages', 'polldaddy' ); ?>
614
  </label>
615
  </p>
616
  <p>
617
  <label for="<?php echo $this->get_field_id( 'show_comments' ); ?>">
618
  <?php
619
+ $checked = '';
620
+ if ( $show_comments == 1 )
621
+ $checked = 'checked="checked"';
622
+ ?>
623
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'show_comments' ); ?>" name="<?php echo $this->get_field_name( 'show_comments' ); ?>" value="1" <?php echo $checked; ?>/>
624
  <?php _e( 'Show for comments', 'polldaddy' ); ?>
625
  </label>
626
  </p>
628
  <label for="rss-items-<?php echo $number; ?>"><?php _e( 'How many items would you like to display?', 'polldaddy' ); ?>
629
  <select id="<?php echo $this->get_field_id( 'item_count' ); ?>" name="<?php echo $this->get_field_name( 'item_count' ); ?>">
630
  <?php
631
+ for ( $i = 1; $i <= 20; ++$i )
632
+ echo "<option value='$i' " . ( $item_count == $i ? "selected='selected'" : '' ) . ">$i</option>";
633
+ ?>
634
  </select>
635
  </label>
636
  </p>
637
  <?php
638
+ }
639
+ }
640
+ add_action('widgets_init', create_function('', 'return register_widget("PD_Top_Rated");'));
641
  }
642
  ?>
polldaddy.php CHANGED
@@ -2,10 +2,11 @@
2
 
3
  /*
4
  Plugin Name: PollDaddy Polls
 
5
  Description: Create and manage PollDaddy polls and ratings in WordPress
6
  Author: Automattic, Inc.
7
  Author URL: http://automattic.com/
8
- Version: 1.8.9
9
  */
10
 
11
  // You can hardcode your PollDaddy PartnerGUID (API Key) here
@@ -17,36 +18,36 @@ class WP_PollDaddy {
17
  var $is_admin;
18
  var $is_author;
19
  var $scheme;
20
- var $version;
21
  var $polldaddy_client_class;
22
  var $polldaddy_clients;
23
  var $id;
24
  var $multiple_accounts;
25
  var $user_code;
26
  var $rating_user_code;
27
-
28
- function WP_PollDaddy(){
29
- $this ->__construct();
30
- }
31
-
32
- function __construct() {
33
- global $current_user;
34
- $this->errors = new WP_Error;
35
- $this->scheme = 'https';
36
- $this->version = '1.8.8';
37
- $this->multiple_accounts = true;
38
- $this->polldaddy_client_class = 'api_client';
39
- $this->polldaddy_clients = array();
40
- $this->is_admin = (bool) current_user_can('manage_options');
41
  $this->is_author = true;
42
- $this->id = (int) $current_user->ID;
43
- $this->user_code = null;
44
- $this->rating_user_code = null;
45
- }
46
-
47
  function &get_client( $api_key, $userCode = null ) {
48
  if ( isset( $this->polldaddy_clients[$api_key] ) ) {
49
- if ( !is_null( $userCode ) )
50
  $this->polldaddy_clients[$api_key]->userCode = $userCode;
51
  return $this->polldaddy_clients[$api_key];
52
  }
@@ -54,72 +55,72 @@ class WP_PollDaddy {
54
  $this->polldaddy_clients[$api_key] = $this->config_client( new $this->polldaddy_client_class( $api_key, $userCode ) );
55
  return $this->polldaddy_clients[$api_key];
56
  }
57
-
58
- function config_client( $client ){
59
- return $client;
60
- }
61
 
62
- function admin_menu() {
 
 
 
 
63
  if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
64
  $guid = get_option( 'polldaddy_api_key' );
65
  if ( !$guid || !is_string( $guid ) )
66
  $guid = false;
67
  define( 'WP_POLLDADDY__PARTNERGUID', $guid );
68
  }
69
-
70
- if ( !WP_POLLDADDY__PARTNERGUID ) {
71
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
72
- $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
73
- else
74
- $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ) );
75
-
76
- add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
77
-
78
- if ( function_exists( 'add_object_page' ) ) // WP 2.7+
79
- $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
80
- else
81
- $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
82
-
83
- add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
84
  if ( ( empty( $_GET['page'] ) || 'polls' != $_GET['page'] ) && ( empty( $_GET['page'] ) || 'ratings' != $_GET['page'] ) )
85
  add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "You need to <a href=\"%s\">input your PollDaddy.com account details</a>.", "edit.php?page=polls" ) . "</p></div>";' ) );
86
  return false;
87
- }
88
-
89
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
90
  $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
91
  else
92
  $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
93
-
94
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
95
 
96
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
97
  $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
98
  else
99
  $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
100
-
101
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
102
-
103
- if ( $this->is_admin ) {
104
- add_submenu_page( 'ratings', __( 'Ratings &ndash; Settings', 'polldaddy' ), __( 'Settings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
105
- add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings&amp;action=reports', array( &$this, 'management_page' ) );
106
  }
107
- else{
108
- add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
109
- }
110
-
111
  add_submenu_page( 'polls', __( 'Polls', 'polldaddy' ), __( 'Edit', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
112
-
113
- if ( $this->is_author ) {
114
- add_submenu_page( 'polls', __( 'Add New Poll', 'polldaddy' ), __( 'Add New', 'polldaddy' ), 'edit_posts', 'polls&amp;action=create-poll', array( &$this, 'management_page' ) );
115
- add_submenu_page( 'polls', __( 'Custom Styles', 'polldaddy' ), __( 'Custom Styles', 'polldaddy' ), 'edit_posts', 'polls&amp;action=list-styles', array( &$this, 'management_page' ) );
116
- add_submenu_page( 'polls', __( 'Options', 'polldaddy' ), __( 'Options', 'polldaddy' ), 'edit_posts', 'polls&amp;action=options', array( &$this, 'management_page' ) );
117
- }
118
 
119
  add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
120
  }
121
 
122
- function api_key_page_load() {
123
  if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
124
  return false;
125
 
@@ -137,7 +138,7 @@ class WP_PollDaddy {
137
  if ( $this->errors->get_error_codes() )
138
  return false;
139
 
140
- $details = array(
141
  'uName' => get_bloginfo( 'name' ),
142
  'uEmail' => $polldaddy_email,
143
  'uPass' => $polldaddy_password,
@@ -145,8 +146,8 @@ class WP_PollDaddy {
145
  );
146
  if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
147
  $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
148
- 'body' => $details
149
- ) );
150
  if ( is_wp_error( $polldaddy_api_key ) ) {
151
  $this->errors = $polldaddy_api_key;
152
  return false;
@@ -176,7 +177,7 @@ class WP_PollDaddy {
176
  $request = "POST /key.php HTTP/1.0\r\n";
177
  $request .= "Host: api.polldaddy.com\r\n";
178
  $request .= "User-agent: WordPress/$wp_version\r\n";
179
- $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
180
  $request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
181
 
182
  fwrite( $fp, "$request\r\n$request_body" );
@@ -185,7 +186,7 @@ class WP_PollDaddy {
185
  while ( !feof( $fp ) )
186
  $response .= fread( $fp, 4096 );
187
  fclose( $fp );
188
- list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
189
  }
190
 
191
  if ( !$polldaddy_api_key ) {
@@ -210,10 +211,10 @@ class WP_PollDaddy {
210
  if ( $polldaddy->errors )
211
  foreach ( $polldaddy->errors as $code => $error )
212
  $this->errors->add( $code, $error );
213
- if ( isset( $this->errors->errors[4] ) ) {
214
- $this->errors->errors[4] = array( sprintf( __( 'Obsolete PollDaddy User API Key: <a href="%s">Sign in again to re-authenticate</a>', 'polldaddy' ), add_query_arg( array( 'action' => 'signup', 'reaction' => empty( $_GET['action'] ) ? false : $_GET['action'] ) ) ) );
215
- $this->errors->add_data( true, 4 );
216
- }
217
  }
218
 
219
  function print_errors() {
@@ -234,7 +235,7 @@ class WP_PollDaddy {
234
  <?php
235
  endforeach;
236
  endforeach;
237
-
238
  $this->errors = new WP_Error;
239
  ?>
240
 
@@ -245,7 +246,7 @@ class WP_PollDaddy {
245
  }
246
 
247
  function api_key_page() {
248
- $this->print_errors();
249
  ?>
250
 
251
  <div class="wrap">
@@ -291,85 +292,85 @@ class WP_PollDaddy {
291
  $title = __( 'Add Poll', 'polldaddy' );
292
  echo "<a href='admin.php?page=polls&amp;iframe&amp;TB_iframe=true' onclick='return false;' id='add_poll' class='thickbox' title='$title'><img src='{$this->base_url}polldaddy.png' alt='$title' /></a>";
293
  }
294
-
295
- function set_api_user_code(){
296
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
297
  $polldaddy->reset();
298
-
299
- if ( empty( $this->user_code ) ){
300
- $this->user_code = $polldaddy->get_usercode( $this->id );
301
- }
302
- }
303
-
304
- function management_page_load() {
305
  wp_reset_vars( array( 'page', 'action', 'poll', 'style', 'rating', 'id' ) );
306
- global $plugin_page, $page, $action, $poll, $style, $rating, $id, $wp_locale;
307
-
308
- $this->set_api_user_code();
309
 
310
- if ( empty( $this->user_code ) && $page == 'polls' ){
311
- $action = 'signup';
312
- }
313
 
314
  require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
315
 
316
  wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version );
317
  wp_enqueue_script( 'polls-common', "{$this->base_url}common.js", array(), $this->version );
318
-
319
- if( $page == 'polls' ) {
320
- if ( !$this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles', 'options', 'update-options', 'import-account' ) ) ) {//check user privileges has access to action
321
- $action = '';
322
- }
323
-
324
- switch ( $action ) :
325
- case 'edit' :
326
- case 'edit-poll' :
327
- case 'create-poll' :
328
- wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/poll-style-picker.js", array(), $this->version );
329
-
330
- if ( $action == 'create-poll' )
331
- $plugin_page = 'polls&amp;action=create-poll';
332
-
333
- break;
334
- case 'edit-style' :
335
- case 'create-style' :
336
- wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/style-editor.js", array(), $this->version );
337
- wp_enqueue_script( 'polls-style-color', "http://i.polldaddy.com/js/jquery/jscolor.js", array(), $this->version );
338
- wp_enqueue_style( 'polls', "{$this->base_url}style-editor.css", array(), $this->version );
339
- $plugin_page = 'polls&amp;action=list-styles';
340
- break;
341
- case 'list-styles' :
342
- $plugin_page = 'polls&amp;action=list-styles';
343
- break;
344
- case 'options' :
345
- case 'update-options' :
346
- case 'import-account' :
347
- $plugin_page = 'polls&amp;action=options';
348
- break;
349
- endswitch;
350
- } elseif( $page == 'ratings' ) {
351
- if ( !$this->is_admin && !in_array( $action, array( 'reports', 'delete' ) ) ) {//check user privileges has access to action
352
- $action = 'reports';
353
- }
354
  switch ( $action ) :
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  case 'delete' :
356
  case 'reports' :
357
  $plugin_page = 'ratings&amp;action=reports';
358
- break;
359
- default :
360
- wp_enqueue_script( 'rating-text-color', "http://i.polldaddy.com/js/jquery/jscolor.js", array(), $this->version );
361
- wp_enqueue_script( 'ratings', 'http://i.polldaddy.com/ratings/rating.js', array(), $this->version );
362
- wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
363
  'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
364
- 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
365
  endswitch;
366
- }
367
-
368
  wp_enqueue_script( 'admin-forms' );
369
  add_thickbox();
370
 
371
  wp_enqueue_style( 'polls', "{$this->base_url}polldaddy.css", array( 'global', 'wp-admin' ), $this->version );
372
- if ( isset($wp_locale->text_direction) && 'rtl' == $wp_locale->text_direction )
373
  wp_enqueue_style( 'polls-rtl', "{$this->base_url}polldaddy-rtl.css", array( 'global', 'wp-admin' ), $this->version );
374
  add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
375
 
@@ -377,12 +378,12 @@ class WP_PollDaddy {
377
 
378
  $query_args = array();
379
  $args = array();
380
-
381
  $allowedtags = array(
382
  'a' => array(
383
  'href' => array (),
384
  'title' => array (),
385
- 'target' => array ()),
386
  'img' => array(
387
  'alt' => array (),
388
  'align' => array (),
@@ -393,32 +394,32 @@ class WP_PollDaddy {
393
  'longdesc' => array (),
394
  'vspace' => array (),
395
  'src' => array (),
396
- 'width' => array ()),
397
  'abbr' => array(
398
- 'title' => array ()),
399
  'acronym' => array(
400
- 'title' => array ()),
401
  'b' => array(),
402
  'blockquote' => array(
403
- 'cite' => array ()),
404
  'cite' => array (),
405
- 'em' => array (),
406
  'i' => array (),
407
- 'q' => array(
408
- 'cite' => array ()),
409
  'strike' => array(),
410
  'strong' => array()
411
  );
412
 
413
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
414
 
415
- if( $page == 'polls' ) {
416
  switch ( $action ) :
417
  case 'signup' : // sign up for first time
418
  case 'account' : // reauthenticate
419
  case 'import-account' : // reauthenticate
420
  if ( !$is_POST )
421
- return;
422
 
423
  check_admin_referer( 'polldaddy-account' );
424
 
@@ -426,9 +427,9 @@ class WP_PollDaddy {
426
  $query_args = array_merge( $query_args, $new_args );
427
  if ( $this->errors->get_error_codes() )
428
  return false;
429
-
430
  $query_args['message'] = 'imported-account';
431
-
432
  wp_reset_vars( array( 'action' ) );
433
  if ( !empty( $_GET['reaction'] ) )
434
  $query_args['action'] = $_GET['reaction'];
@@ -437,465 +438,471 @@ class WP_PollDaddy {
437
  else
438
  $query_args['action'] = false;
439
  break;
440
-
441
  case 'delete' :
442
  if ( empty( $poll ) )
443
  return;
444
-
445
  if ( is_array( $poll ) )
446
  check_admin_referer( 'action-poll_bulk' );
447
  else
448
  check_admin_referer( "delete-poll_$poll" );
449
-
450
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
451
-
452
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
453
  $polldaddy->reset();
454
  $poll_object = $polldaddy->get_poll( $poll );
455
-
456
  if ( !$this->can_edit( $poll_object ) ) {
457
  $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.', 'polldaddy' ) );
458
  return false;
459
  }
460
-
461
  // Send Poll Author credentials
462
  if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
463
  $polldaddy->reset();
464
- if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
465
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
466
  }
467
  $polldaddy->userCode = $userCode;
468
  }
469
-
470
  $polldaddy->reset();
471
  $polldaddy->delete_poll( $poll_id );
472
  }
473
-
474
  $query_args['message'] = 'deleted';
475
  $query_args['deleted'] = count( (array) $poll );
476
  break;
477
  case 'open' :
478
  if ( empty( $poll ) )
479
  return;
480
-
481
  if ( is_array( $poll ) )
482
  check_admin_referer( 'action-poll_bulk' );
483
  else
484
  check_admin_referer( "open-poll_$poll" );
485
-
486
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
487
-
488
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
489
  $polldaddy->reset();
490
  $poll_object = $polldaddy->get_poll( $poll );
491
-
492
  if ( !$this->can_edit( $poll_object ) ) {
493
  $this->errors->add( 'permission', __( 'You are not allowed to open this poll.', 'polldaddy' ) );
494
  return false;
495
  }
496
-
497
  // Send Poll Author credentials
498
  if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
499
  $polldaddy->reset();
500
- if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
501
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
502
  }
503
  $polldaddy->userCode = $userCode;
504
  }
505
-
506
  $polldaddy->reset();
507
  $polldaddy->open_poll( $poll_id );
508
  }
509
-
510
  $query_args['message'] = 'opened';
511
  $query_args['opened'] = count( (array) $poll );
512
  break;
513
  case 'close' :
514
  if ( empty( $poll ) )
515
  return;
516
-
517
  if ( is_array( $poll ) )
518
  check_admin_referer( 'action-poll_bulk' );
519
  else
520
  check_admin_referer( "close-poll_$poll" );
521
-
522
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
523
-
524
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
525
  $polldaddy->reset();
526
  $poll_object = $polldaddy->get_poll( $poll );
527
-
528
  if ( !$this->can_edit( $poll_object ) ) {
529
  $this->errors->add( 'permission', __( 'You are not allowed to close this poll.', 'polldaddy' ) );
530
  return false;
531
  }
532
-
533
  // Send Poll Author credentials
534
  if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
535
  $polldaddy->reset();
536
- if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
537
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
538
  }
539
  $polldaddy->userCode = $userCode;
540
  }
541
-
542
  $polldaddy->reset();
543
  $polldaddy->close_poll( $poll_id );
544
  }
545
-
546
  $query_args['message'] = 'closed';
547
  $query_args['closed'] = count( (array) $poll );
548
  break;
549
  case 'edit-poll' : // TODO: use polldaddy_poll
550
  if ( !$is_POST || !$poll = (int) $poll )
551
  return;
552
-
553
  check_admin_referer( "edit-poll_$poll" );
554
-
555
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
556
  $polldaddy->reset();
557
-
558
  $poll_object = $polldaddy->get_poll( $poll );
559
  $this->parse_errors( $polldaddy );
560
-
561
  if ( !$this->can_edit( $poll_object ) ) {
562
  $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
563
  return false;
564
  }
565
-
566
  // Send Poll Author credentials
567
-
568
  if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
569
  $polldaddy->reset();
570
- if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
571
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
572
  }
573
  $this->parse_errors( $polldaddy );
574
  $polldaddy->userCode = $userCode;
575
  }
576
-
577
- if ( !$poll_object )
578
  $this->errors->add( 'GetPoll', __( 'Poll not found', 'polldaddy' ) );
579
-
580
  if ( $this->errors->get_error_codes() )
581
  return false;
582
-
583
  $poll_data = get_object_vars( $poll_object );
584
  foreach ( $poll_data as $key => $value )
585
  if ( '_' === $key[0] )
586
  unset( $poll_data[$key] );
587
-
588
- foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
589
- if ( isset( $_POST[$option] ) && $_POST[$option] )
590
- $poll_data[$option] = 'yes';
591
- else
592
- $poll_data[$option] = 'no';
593
- }
594
-
595
  $blocks = array( 'off', 'cookie', 'cookieip' );
596
  if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
597
  $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
598
-
599
  $results = array( 'show', 'percent', 'hide' );
600
  if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
601
  $poll_data['resultsType'] = $_POST['resultsType'];
602
  $poll_data['question'] = stripslashes( $_POST['question'] );
603
-
604
  if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
605
  $this->errors->add( 'answer', __( 'Invalid answers', 'polldaddy' ) );
606
-
607
  $answers = array();
608
  foreach ( $_POST['answer'] as $answer_id => $answer ) {
609
- if ( !$answer = trim( stripslashes( $answer ) ) )
610
- continue;
611
-
612
- $args['text'] = wp_kses( $answer, $allowedtags );
613
-
614
- if ( is_numeric( $answer_id ) )
615
- $answers[] = polldaddy_poll_answer( $args, $answer_id );
616
- else
617
- $answers[] = polldaddy_poll_answer( $args );
 
 
 
618
  }
619
-
620
  if ( 2 > count( $answers ) )
621
  $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
622
-
623
  if ( $this->errors->get_error_codes() )
624
  return false;
625
-
626
  $poll_data['answers'] = $answers;
627
-
628
  $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
629
-
630
- if ( isset ( $_POST['styleID'] ) ){
631
- if ( $_POST['styleID'] == 'x' ){
632
  $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
633
  return false;
634
  }
635
  }
636
  $poll_data['styleID'] = (int) $_POST['styleID'];
637
  $poll_data['choices'] = (int) $_POST['choices'];
638
-
639
- if ( $poll_data['blockRepeatVotersType'] == 'cookie' ){
640
- if( isset( $_POST['cookieip_expiration'] ) )
641
- $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
642
- } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ){
643
- if( isset( $_POST['cookieip_expiration'] ) )
644
- $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
645
- }
646
-
647
  $polldaddy->reset();
648
-
649
  $update_response = $polldaddy->update_poll( $poll, $poll_data );
650
-
651
  $this->parse_errors( $polldaddy );
652
-
653
  if ( !$update_response )
654
  $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated', 'polldaddy' ) );
655
-
656
  if ( $this->errors->get_error_codes() )
657
  return false;
658
-
659
  $query_args['message'] = 'updated';
660
- if ( isset($_POST['iframe']) )
661
  $query_args['iframe'] = '';
662
  break;
663
  case 'create-poll' :
664
  if ( !$is_POST )
665
  return;
666
-
667
  check_admin_referer( 'create-poll' );
668
-
669
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
670
  $polldaddy->reset();
671
-
672
  $answers = array();
673
- foreach ( $_POST['answer'] as $answer ){
674
- if ( !$answer = trim( stripslashes( $answer ) ) )
675
- continue;
676
-
677
- $args['text'] = wp_kses( $answer, $allowedtags );
678
-
679
- $answers[] = polldaddy_poll_answer( $args );
 
 
 
680
  }
681
-
682
  if ( !$answers )
683
  return false;
684
-
685
  $poll_data = _polldaddy_poll_defaults();
686
-
687
  foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
688
  if ( isset( $_POST[$option] ) && $_POST[$option] )
689
  $poll_data[$option] = 'yes';
690
  else
691
  $poll_data[$option] = 'no';
692
  }
693
-
694
  $blocks = array( 'off', 'cookie', 'cookieip' );
695
  if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
696
  $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
697
-
698
  $results = array( 'show', 'percent', 'hide' );
699
  if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
700
  $poll_data['resultsType'] = $_POST['resultsType'];
701
-
702
  $poll_data['answers'] = $answers;
703
-
704
  $poll_data['question'] = stripslashes( $_POST['question'] );
705
  $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
706
-
707
- if ( isset ( $_POST['styleID'] ) ){
708
- if ( $_POST['styleID'] == 'x' ){
709
- $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
710
- return false;
711
  }
712
  }
713
  $poll_data['styleID'] = (int) $_POST['styleID'];
714
- $poll_data['choices'] = (int) $_POST['choices'];
715
-
716
- if ( $poll_data['blockRepeatVotersType'] == 'cookie' ){
717
- if( isset( $_POST['cookieip_expiration'] ) )
718
- $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
719
- } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ){
720
- if( isset( $_POST['cookieip_expiration'] ) )
721
- $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
722
- }
723
-
724
  $poll = $polldaddy->create_poll( $poll_data );
725
  $this->parse_errors( $polldaddy );
726
-
727
  if ( !$poll || empty( $poll->_id ) )
728
  $this->errors->add( 'CreatePoll', __( 'Poll could not be created', 'polldaddy' ) );
729
-
730
  if ( $this->errors->get_error_codes() )
731
  return false;
732
-
733
  $query_args['message'] = 'created';
734
  $query_args['action'] = 'edit-poll';
735
  $query_args['poll'] = $poll->_id;
736
- if ( isset($_POST['iframe']) )
737
  $query_args['iframe'] = '';
738
  break;
739
  case 'delete-style' :
740
  if ( empty( $style ) )
741
  return;
742
-
743
  if ( is_array( $style ) )
744
  check_admin_referer( 'action-style_bulk' );
745
  else
746
  check_admin_referer( "delete-style_$style" );
747
-
748
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
749
-
750
  foreach ( (array) $_REQUEST['style'] as $style_id ) {
751
  $polldaddy->reset();
752
  $polldaddy->delete_style( $style_id );
753
  }
754
-
755
  $query_args['message'] = 'deleted-style';
756
  $query_args['deleted'] = count( (array) $style );
757
  break;
758
  case 'edit-style' :
759
  if ( !$is_POST || !$style = (int) $style )
760
  return;
761
-
762
  check_admin_referer( "edit-style$style" );
763
-
764
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
765
  $polldaddy->reset();
766
-
767
  $style_data = _polldaddy_style_defaults();
768
-
769
- if ( isset($_POST['style-title'] ) )
770
- $style_data['title'] = stripslashes( trim ( (string) $_POST['style-title'] ) );
771
-
772
- if ( isset($_POST['CSSXML'] ) )
773
- $style_data['css'] = urlencode( stripslashes( trim ( (string) $_POST['CSSXML'] ) ) );
774
-
775
- if ( isset($_REQUEST['updatePollCheck'] ) && $_REQUEST['updatePollCheck'] == 'on' )
776
- $style_data['retro'] = 1;
777
-
778
  $update_response = $polldaddy->update_style( $style, $style_data );
779
-
780
  $this->parse_errors( $polldaddy );
781
-
782
  if ( !$update_response )
783
  $this->errors->add( 'UpdateStyle', __( 'Style could not be updated', 'polldaddy' ) );
784
-
785
  if ( $this->errors->get_error_codes() )
786
  return false;
787
-
788
  $query_args['message'] = 'updated-style';
789
- if ( isset($_POST['iframe']) )
790
  $query_args['iframe'] = '';
791
  break;
792
  case 'create-style' :
793
  if ( !$is_POST )
794
  return;
795
-
796
  check_admin_referer( 'create-style' );
797
-
798
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
799
  $polldaddy->reset();
800
-
801
  $style_data = _polldaddy_style_defaults();
802
-
803
- if ( isset($_POST['style-title'] ) )
804
- $style_data['title'] = stripslashes( strip_tags( trim ( (string) $_POST['style-title'] ) ) );
805
-
806
- if ( isset($_POST['CSSXML'] ) )
807
- $style_data['css'] = urlencode( stripslashes( trim ( (string) $_POST['CSSXML'] ) ) );
808
-
809
  $style = $polldaddy->create_style( $style_data );
810
  $this->parse_errors( $polldaddy );
811
-
812
  if ( !$style || empty( $style->_id ) )
813
  $this->errors->add( 'CreateStyle', __( 'Style could not be created', 'polldaddy' ) );
814
-
815
  if ( $this->errors->get_error_codes() )
816
  return false;
817
-
818
  $query_args['message'] = 'created-style';
819
  $query_args['action'] = 'edit-style';
820
  $query_args['style'] = $style->_id;
821
- if ( isset($_POST['iframe']) )
822
  $query_args['iframe'] = '';
823
  break;
824
  case 'update-options' :
825
- if ( !$is_POST )
826
  return;
827
-
828
  check_admin_referer( 'polldaddy-account' );
829
-
830
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
831
  $polldaddy->reset();
832
-
833
  $poll_defaults = _polldaddy_poll_defaults();
834
-
835
  $user_defaults = array();
836
-
837
- foreach( array( "multipleChoice", "randomiseAnswers", "otherAnswer", "sharing", "resultsType", "styleID", "blockRepeatVotersType", "blockExpiration" ) as $option ){
838
- if ( isset( $poll_defaults[$option] ) && $poll_defaults[$option] )
839
- $user_defaults[$option] = $poll_defaults[$option];
840
- }
841
-
842
  foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
843
  if ( isset( $_POST[$option] ) && $_POST[$option] )
844
  $user_defaults[$option] = 'yes';
845
  else
846
  $user_defaults[$option] = 'no';
847
  }
848
-
849
  $results = array( 'show', 'percent', 'hide' );
850
  if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
851
- $user_defaults['resultsType'] = $_POST['resultsType'];
852
-
853
- if ( isset ( $_POST['styleID'] ) ){
854
  $user_defaults['styleID'] = (int) $_POST['styleID'];
855
- }
856
-
857
  $blocks = array( 'off', 'cookie', 'cookieip' );
858
  if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
859
  $user_defaults['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
860
-
861
- if( isset( $_POST['blockExpiration'] ) )
862
- $user_defaults['blockExpiration'] = (int) $_POST['blockExpiration'];
863
-
864
- $polldaddy->update_poll_defaults( 0, $user_defaults );
865
-
866
- $this->parse_errors( $polldaddy );
867
  if ( $this->errors->get_error_codes() )
868
  return false;
869
-
870
- $query_args['message'] = 'updated-options';
871
- break;
872
  default :
873
  return;
874
  endswitch;
875
- } elseif( $page == 'ratings' ) {
876
-
877
  switch ( $action ) :
878
  case 'delete' :
879
  if ( empty( $id ) )
880
  return;
881
  if ( empty( $rating ) )
882
  return;
883
-
884
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
885
-
886
  if ( is_array( $rating ) ) {
887
  check_admin_referer( 'action-rating_bulk' );
888
-
889
- foreach( $rating as $key => $value ){
890
  $polldaddy->reset();
891
  $polldaddy->delete_rating_result( $id, $value );
892
  }
893
  } else {
894
  check_admin_referer( "delete-rating_$rating" );
895
-
896
  $polldaddy->delete_rating_result( $id, $rating );
897
  }
898
-
899
  if ( isset( $_REQUEST['filter'] ) )
900
  $query_args['filter'] = $_REQUEST['filter'];
901
  if ( isset( $_REQUEST['change-report-to'] ) )
@@ -903,11 +910,11 @@ class WP_PollDaddy {
903
  $query_args['message'] = 'deleted-rating';
904
  $query_args['deleted'] = count( (array) $rating );
905
  break;
906
- default :
907
  return;
908
  endswitch;
909
  }
910
-
911
  wp_redirect( add_query_arg( $query_args, wp_get_referer() ) );
912
  exit;
913
  }
@@ -915,20 +922,20 @@ class WP_PollDaddy {
915
  function management_page_load_signup() {
916
  switch ( $_POST['account'] ) :
917
  case 'import' :
918
- return $this->import_account();
919
  break;
920
  default :
921
  return;
922
  endswitch;
923
  }
924
-
925
- function import_account(){
926
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
927
  $polldaddy->reset();
928
  $email = trim( stripslashes( $_POST['polldaddy_email'] ) );
929
  $password = trim( stripslashes( $_POST['polldaddy_password'] ) );
930
-
931
- if ( !is_email( $email ) )
932
  $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
933
 
934
  if ( !$password )
@@ -938,13 +945,13 @@ class WP_PollDaddy {
938
  return false;
939
 
940
  if ( $usercode = $polldaddy->initiate( $email, $password, $this->id ) ) {
941
- $this->user_code = $usercode;
942
- } else {
943
  $this->parse_errors( $polldaddy );
944
- $this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?', 'polldaddy' ) );
945
  return false;
946
- }
947
- }
948
 
949
  function admin_body_class( $class ) {
950
  if ( isset( $_GET['iframe'] ) )
@@ -954,7 +961,7 @@ class WP_PollDaddy {
954
  return $class;
955
  }
956
 
957
- function management_page_notices( $message = false ) {
958
  switch ( (string) @$_GET['message'] ) :
959
  case 'deleted' :
960
  $deleted = (int) $_GET['deleted'];
@@ -1041,7 +1048,7 @@ class WP_PollDaddy {
1041
  }
1042
 
1043
  function management_page() {
1044
- global $page, $action, $poll, $style, $rating;
1045
  $poll = (int) $poll;
1046
  $style = (int) $style;
1047
  $rating = wp_specialchars( $rating );
@@ -1050,124 +1057,124 @@ class WP_PollDaddy {
1050
  <div class="wrap" id="manage-polls">
1051
 
1052
  <?php
1053
- if( $page == 'polls' ) {
1054
- if ( !$this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles', 'options', 'update-options', 'import-account' ) ) ) {//check user privileges has access to action
1055
- $action = '';
1056
- }
1057
- switch ( $action ) :
1058
- case 'signup' :
1059
- case 'account' :
1060
- $this->signup();
1061
- break;
1062
- case 'preview' :
1063
  ?>
1064
 
1065
  <h2 id="preview-header"><?php
1066
- if( $this->is_author )
1067
- printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)', 'polldaddy' ),
1068
- clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
1069
- clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ));
1070
- else
1071
- printf( __( 'Poll Preview (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1072
 
1073
  <?php
1074
- echo do_shortcode( "[polldaddy poll=$poll cb=1]" );
1075
- break;
1076
- case 'results' :
1077
  ?>
1078
 
1079
- <h2><?php
1080
- if( $this->is_author )
1081
- printf( __( 'Poll Results (<a href="%s">Edit Poll</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ) );
1082
- else
1083
- printf( __( 'Poll Results (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1084
 
1085
  <?php
1086
- $this->poll_results_page( $poll );
1087
- break;
1088
- case 'edit' :
1089
- case 'edit-poll' :
1090
  ?>
1091
 
1092
- <h2><?php printf( __('Edit Poll (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1093
 
1094
  <?php
1095
 
1096
- $this->poll_edit_form( $poll );
1097
- break;
1098
- case 'create-poll' :
1099
  ?>
1100
 
1101
- <h2><?php printf( __('Create Poll (<a href="%s">List Polls</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1102
 
1103
  <?php
1104
- $this->poll_edit_form();
1105
- break;
1106
- case 'list-styles' :
1107
  ?>
1108
 
1109
- <h2><?php
1110
- if( $this->is_author )
1111
- printf( __('Custom Styles (<a href="%s">Add New</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => 'create-style', 'poll' => false, 'message' => false ) ) ) );
1112
- else
1113
- _e('Custom Styles', 'polldaddy'); ?></h2>
1114
 
1115
  <?php
1116
- $this->styles_table();
1117
- break;
1118
- case 'edit-style' :
1119
  ?>
1120
 
1121
- <h2><?php printf( __('Edit Style (<a href="%s">List Styles</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?></h2>
1122
 
1123
  <?php
1124
 
1125
- $this->style_edit_form( $style );
1126
- break;
1127
- case 'create-style' :
1128
  ?>
1129
 
1130
- <h2><?php printf( __('Create Style (<a href="%s">List Styles</a>)', 'polldaddy'), clean_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?></h2>
1131
 
1132
  <?php
1133
- $this->style_edit_form();
1134
- break;
1135
- case 'options' :
1136
- case 'import-account' :
1137
- case 'update-options' :
1138
- $this->plugin_options();
1139
- break;
1140
- default :
1141
 
1142
  ?>
1143
 
1144
- <h2 id="poll-list-header"><?php
1145
- if( $this->is_author )
1146
- printf( __( 'Polls (<a href="%s">Add New</a>)', 'polldaddy' ), clean_url( add_query_arg( array('action' => 'create-poll','poll' => false,'message' => false) ) ) );
1147
- else
1148
- _e( 'Polls', 'polldaddy'); ?></h2>
1149
 
1150
- <?php
1151
- $this->polls_table( isset( $_GET['view'] ) && 'user' == $_GET['view'] ? 'user' : 'blog' );
1152
- endswitch;
1153
- } elseif( $page == 'ratings' ) {
1154
- if ( !$this->is_admin && !in_array( $action, array( 'delete', 'reports' ) ) ) {//check user privileges has access to action
1155
- $action = 'reports';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1156
  }
1157
-
1158
- switch ( $action ) :
1159
- case 'delete' :
1160
- case 'reports' :
1161
- $this->rating_reports();
1162
- break;
1163
- case 'update-rating' :
1164
- $this->update_rating();
1165
- $this->rating_settings( $action );
1166
- break;
1167
- default :
1168
- $this->rating_settings();
1169
- endswitch;
1170
- }
1171
  ?>
1172
 
1173
  </div>
@@ -1179,41 +1186,42 @@ class WP_PollDaddy {
1179
  function polls_table( $view = 'blog' ) {
1180
  $page = 1;
1181
  if ( isset( $_GET['paged'] ) )
1182
- $page = absint($_GET['paged']);
1183
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1184
  $polldaddy->reset();
1185
-
1186
- if( !$this->is_author )
1187
- $view = '';
1188
-
1189
  if ( 'user' == $view )
1190
  $polls_object = $polldaddy->get_polls( ( $page - 1 ) * 10 + 1, $page * 10 );
1191
  else
1192
  $polls_object = $polldaddy->get_polls_by_parent_id( ( $page - 1 ) * 10 + 1, $page * 10 );
 
1193
  $this->parse_errors( $polldaddy );
1194
  $this->print_errors();
1195
  $polls = & $polls_object->poll;
1196
- if( isset( $polls_object->_total ) )
1197
  $total_polls = $polls_object->_total;
1198
  else
1199
  $total_polls = count( $polls );
1200
  $class = '';
1201
 
1202
  $page_links = paginate_links( array(
1203
- 'base' => add_query_arg( 'paged', '%#%' ),
1204
- 'format' => '',
1205
- 'total' => ceil( $total_polls / 10 ),
1206
- 'current' => $page
1207
- ) );
1208
 
1209
- if( $this->is_author ){ ?>
1210
  <ul class="subsubsub">
1211
  <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => false, 'paged' => false ) ) ); ?>"<?php if ( 'blog' == $view ) echo ' class="current"'; ?>><?php _e( "All Blog's Polls", 'polldaddy' ); ?></a> | </li>
1212
  <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => 'user', 'paged' => false ) ) ); ?>"<?php if ( 'user' == $view ) echo ' class="current"'; ?>><?php _e( "All My Polls", 'polldaddy' ); ?></a></li>
1213
  </ul>
1214
  <?php } ?>
1215
  <form method="post" action="">
1216
- <?php if( $this->is_author ){ ?>
1217
  <div class="tablenav">
1218
  <div class="alignleft">
1219
  <select name="action">
@@ -1232,7 +1240,7 @@ class WP_PollDaddy {
1232
  <table class="widefat">
1233
  <thead>
1234
  <tr>
1235
- <th id="cb" class="manage-column column-cb check-column" scope="col" /><?php if( $this->is_author ){ ?><input type="checkbox" /><?php } ?></th>
1236
  <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Poll', 'polldaddy' ); ?></th>
1237
  <th id="votes" class="manage-column column-vote num" scope="col"><?php _e( 'Votes', 'polldaddy' ); ?></th>
1238
  <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Created', 'polldaddy' ); ?></th>
@@ -1241,56 +1249,56 @@ class WP_PollDaddy {
1241
  <tbody>
1242
 
1243
  <?php
1244
- if ( $polls ) :
1245
  foreach ( $polls as $poll ) :
1246
  $poll_id = (int) $poll->_id;
1247
-
1248
- $poll->___content = trim( strip_tags( $poll->___content ) );
1249
- if( strlen( $poll->___content ) == 0 ){
1250
- $poll->___content = '-- empty HTML tag --';
1251
- }
1252
-
1253
- $poll_closed = (int) $poll->_closed;
1254
-
1255
- if ( $this->is_author and $this->can_edit( $poll ) ) {
1256
- $edit_link = clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll_id, 'message' => false ) ) );
1257
- $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'poll' => $poll_id, 'message' => false ) ), "delete-poll_$poll_id" ) );
1258
- $open_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'open', 'poll' => $poll_id, 'message' => false ) ), "open-poll_$poll_id" ) );
1259
- $close_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'close', 'poll' => $poll_id, 'message' => false ) ), "close-poll_$poll_id" ) );
1260
- }
1261
- else {
1262
- $edit_link = false;
1263
- $delete_link = false;
1264
- $open_link = false;
1265
- $close_link = false;
1266
- }
1267
 
1268
- $class = $class ? '' : ' class="alternate"';
1269
- $results_link = clean_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll_id, 'message' => false ) ) );
1270
- $preview_link = clean_url( add_query_arg( array( 'action' => 'preview', 'poll' => $poll_id, 'message' => false ) ) ); //, 'iframe' => '', 'TB_iframe' => 'true' ) ) );
1271
- list($poll_time) = explode( '.', $poll->_created );
1272
- $poll_time = strtotime( $poll_time );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1273
  ?>
1274
  <tr<?php echo $class; ?>>
1275
- <th class="check-column" scope="row"><?php if( $this->is_author and $this->can_edit( $poll ) ){ ?><input type="checkbox" value="<?php echo (int) $poll_id; ?>" name="poll[]" /><?php } ?></th>
1276
  <td class="post-title column-title">
1277
- <?php if ( $edit_link ) { ?>
1278
  <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $poll->___content ); ?></a></strong>
1279
  <div class="row-actions">
1280
  <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
1281
- <?php } else { ?>
1282
  <strong><?php echo wp_specialchars( $poll->___content ); ?></strong>
1283
  <div class="row-actions">
1284
- <?php } ?>
1285
  <span class="results"><a href="<?php echo $results_link; ?>"><?php _e( 'Results', 'polldaddy' ); ?></a> | </span>
1286
- <?php if ( $delete_link ) { ?>
1287
  <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a> | </span>
1288
- <?php }
1289
- if ( $poll_closed == 2 ) {
1290
- if ( $open_link ) { ?>
1291
- <span class="open"><a class="open-poll" href="<?php echo $open_link; ?>"><?php _e( 'Open', 'polldaddy' ); ?></a> | </span>
1292
- <?php } } else {
1293
- if ( $close_link ) { ?>
1294
  <span class="close"><a class="close-poll" href="<?php echo $close_link; ?>"><?php _e( 'Close', 'polldaddy' ); ?></a> | </span>
1295
  <?php } } ?>
1296
  <?php if ( isset( $_GET['iframe'] ) ) { ?>
@@ -1307,7 +1315,7 @@ class WP_PollDaddy {
1307
  </div>
1308
  </td>
1309
  <td class="poll-votes column-vote num"><?php echo number_format_i18n( $poll->_responses ); ?></td>
1310
- <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A', 'polldaddy'), $poll_time ); ?>"><?php echo date( __('Y/m/d', 'polldaddy'), $poll_time ); ?></abbr></td>
1311
  </tr>
1312
  <tr class="polldaddy-shortcode-row" style="display: none;">
1313
  <td colspan="4">
@@ -1329,7 +1337,7 @@ class WP_PollDaddy {
1329
  </tr>
1330
 
1331
  <?php
1332
- endforeach;
1333
  elseif ( $total_polls ) : // $polls
1334
  ?>
1335
 
@@ -1342,13 +1350,13 @@ class WP_PollDaddy {
1342
  ?>
1343
 
1344
  <tr>
1345
- <td colspan="4"><?php
1346
- if( $this->is_author )
1347
- printf( __( 'No polls yet. <a href="%s">Create one</a>', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-poll' ) ) ) );
1348
- else
1349
- _e( 'No polls yet.', 'polldaddy' ); ?></td>
1350
  </tr>
1351
- <?php endif; // $polls ?>
1352
 
1353
  </tbody>
1354
  </table>
@@ -1359,24 +1367,24 @@ class WP_PollDaddy {
1359
  </div>
1360
  <br class="clear" />
1361
  <script language="javascript">
1362
- jQuery( document ).ready(function(){
1363
  plugin = new Plugin( {
1364
- delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
1365
- delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
1366
- delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
1367
- delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
1368
- standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
1369
- custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
1370
  } );
1371
  });
1372
  </script>
1373
 
1374
  <?php
1375
  }
1376
-
1377
- function poll_table_add_option(){}
1378
-
1379
- function poll_table_extra(){}
1380
 
1381
  function poll_edit_form( $poll_id = 1 ) {
1382
  $poll_id = (int) $poll_id;
@@ -1393,14 +1401,14 @@ class WP_PollDaddy {
1393
  if ( !$this->can_edit( $poll ) ) {
1394
  $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
1395
  }
1396
-
1397
- if( $poll_id == 1 ){
1398
- $poll->answers = array();
1399
- $poll_id = 0;
1400
- }
1401
-
1402
- } else {
1403
- $poll = polldaddy_poll( array(), null, false );
1404
  }
1405
 
1406
  $question = $is_POST ? attribute_escape( stripslashes( $_POST['question'] ) ) : attribute_escape( $poll->question );
@@ -1440,18 +1448,18 @@ class WP_PollDaddy {
1440
  <ul class="poll-options">
1441
 
1442
  <?php
1443
- foreach ( array( 'show' => __( 'Show results to voters', 'polldaddy' ), 'percent' => __( 'Only show percentages', 'polldaddy' ), 'hide' => __( 'Hide all results', 'polldaddy' ) ) as $value => $label ) :
1444
- if ( $is_POST )
1445
- $checked = $value === $_POST['resultsType'] ? ' checked="checked"' : '';
1446
- else
1447
- $checked = $value === $poll->resultsType ? ' checked="checked"' : '';
1448
  ?>
1449
 
1450
  <li>
1451
  <label for="resultsType-<?php echo $value; ?>"><input type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="resultsType" id="resultsType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1452
  </li>
1453
 
1454
- <?php endforeach; ?>
1455
 
1456
  </ul>
1457
  </div>
@@ -1463,33 +1471,33 @@ class WP_PollDaddy {
1463
  <ul class="poll-options">
1464
 
1465
  <?php
1466
- foreach ( array( 'off' => __( "Don't block repeat voters", 'polldaddy' ), 'cookie' => __( 'Block by cookie (recommended)', 'polldaddy' ), 'cookieip' => __( 'Block by cookie and by IP address', 'polldaddy' ) ) as $value => $label ) :
1467
- if ( $is_POST )
1468
- $checked = $value === $_POST['blockRepeatVotersType'] ? ' checked="checked"' : '';
1469
- else
1470
- $checked = $value === $poll->blockRepeatVotersType ? ' checked="checked"' : '';
1471
  ?>
1472
 
1473
  <li>
1474
  <label for="blockRepeatVotersType-<?php echo $value; ?>"><input class="block-repeat" type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="blockRepeatVotersType" id="blockRepeatVotersType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1475
  </li>
1476
 
1477
- <?php endforeach; ?>
1478
 
1479
  </ul>
1480
-
1481
  <span style="margin:6px 6px 8px;" id="cookieip_expiration_label"><label><?php _e( 'Expires: ', 'polldaddy' ); ?></label></span>
1482
  <select id="cookieip_expiration" name="cookieip_expiration" style="width: auto;<?php echo $poll->blockRepeatVotersType == 'off' ? 'display:none;' : ''; ?>">
1483
  <option value="0" <?php echo (int) $poll->blockExpiration == 0 ? 'selected' : ''; ?>><?php _e( 'Never', 'polldaddy' ); ?></option>
1484
- <option value="3600" <?php echo (int) $poll->blockExpiration == 3600 ? 'selected' : ''; ?>><?php printf( __('%d hour', 'polldaddy'), 1 ); ?></option>
1485
- <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 3 ); ?></option>
1486
- <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 6 ); ?></option>
1487
- <option value="43200" <?php echo (int) $poll->blockExpiration == 43200 ? 'selected' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 12 ); ?></option>
1488
- <option value="86400" <?php echo (int) $poll->blockExpiration == 86400 ? 'selected' : ''; ?>><?php printf( __('%d day', 'polldaddy'), 1 ); ?></option>
1489
- <option value="604800" <?php echo (int) $poll->blockExpiration == 604800 ? 'selected' : ''; ?>><?php printf( __('%d week', 'polldaddy'), 1 ); ?></option>
1490
- <option value="2419200" <?php echo (int) $poll->blockExpiration == 2419200 ? 'selected' : ''; ?>><?php printf( __('%d month', 'polldaddy'), 1 ); ?></option>
1491
  </select>
1492
- <p><?php _e( 'Note: Blocking by cookie and IP address can be problematic for some voters.', 'polldaddy'); ?></p>
1493
  </div>
1494
  </div>
1495
  </div>
@@ -1512,8 +1520,8 @@ class WP_PollDaddy {
1512
  $a = 0;
1513
  $answers = array();
1514
  if ( $is_POST && $_POST['answer'] ) {
1515
- foreach( $_POST['answer'] as $answer_id => $answer )
1516
- $answers[attribute_escape($answer_id)] = attribute_escape( stripslashes($answer) );
1517
  } elseif ( isset( $poll->answers->answer ) ) {
1518
  foreach ( $poll->answers->answer as $answer )
1519
  $answers[(int) $answer->_id] = attribute_escape( $answer->text );
@@ -1521,7 +1529,7 @@ class WP_PollDaddy {
1521
 
1522
  foreach ( $answers as $answer_id => $answer ) :
1523
  $a++;
1524
- $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-answer', 'poll' => $poll_id, 'answer' => $answer_id, 'message' => false ) ), "delete-answer_$answer_id" ) );
1525
  ?>
1526
 
1527
  <li>
@@ -1567,29 +1575,29 @@ class WP_PollDaddy {
1567
  <label for="<?php echo $option; ?>"><input type="checkbox"<?php echo $checked; ?> value="yes" id="<?php echo $option; ?>" name="<?php echo $option; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1568
  </li>
1569
 
1570
- <?php endforeach; ?>
1571
 
1572
  </ul>
1573
- <?php
1574
- if ( $is_POST )
1575
- $style = 'yes' === $_POST['multipleChoice'] ? 'display:block;' : 'display:none;';
1576
- else
1577
- $style = 'yes' === $poll->multipleChoice ? 'display:block;' : 'display:none;';
1578
- ?>
1579
  <div id="numberChoices" name="numberChoices" style="padding-left:15px;<?php echo $style; ?>">
1580
  <p>Number of choices: <select name="choices" id="choices"><option value="0">No Limit</option>
1581
- <?php
1582
- if ( $is_POST )
1583
- $choices = (int) $_POST['choices'];
1584
- else
1585
- $choices = (int) $poll->choices;
1586
-
1587
- if( $a > 1 ) :
1588
- for( $i=2; $i<=$a; $i++ ) :
1589
- $selected = $i == $choices ? 'selected="true"' : '';
1590
- echo "<option value='$i' $selected>$i</option>";
1591
- endfor;
1592
- endif; ?>
1593
  </select>
1594
  </p>
1595
  </div>
@@ -1598,97 +1606,97 @@ class WP_PollDaddy {
1598
 
1599
  <div id="design" class="postbox">
1600
 
1601
- <?php $style_ID = (int) ( $is_POST ? $_POST['styleID'] : $poll->styleID );
1602
 
1603
  $iframe_view = false;
1604
- if ( isset($_GET['iframe']) )
1605
  $iframe_view = true;
1606
-
1607
  $options = array(
1608
- 101 => __( 'Aluminum Narrow','polldaddy'),
1609
- 102 => __( 'Aluminum Medium','polldaddy'),
1610
- 103 => __( 'Aluminum Wide','polldaddy'),
1611
- 104 => __( 'Plain White Narrow','polldaddy'),
1612
- 105 => __( 'Plain White Medium','polldaddy'),
1613
- 106 => __( 'Plain White Wide','polldaddy'),
1614
- 107 => __( 'Plain Black Narrow','polldaddy'),
1615
- 108 => __( 'Plain Black Medium','polldaddy'),
1616
- 109 => __( 'Plain Black Wide','polldaddy'),
1617
- 110 => __( 'Paper Narrow','polldaddy'),
1618
- 111 => __( 'Paper Medium','polldaddy'),
1619
- 112 => __( 'Paper Wide','polldaddy'),
1620
- 113 => __( 'Skull Dark Narrow','polldaddy'),
1621
- 114 => __( 'Skull Dark Medium','polldaddy'),
1622
- 115 => __( 'Skull Dark Wide','polldaddy'),
1623
- 116 => __( 'Skull Light Narrow','polldaddy'),
1624
- 117 => __( 'Skull Light Medium','polldaddy'),
1625
- 118 => __( 'Skull Light Wide','polldaddy'),
1626
- 157 => __( 'Micro','polldaddy'),
1627
- 119 => __( 'Plastic White Narrow','polldaddy'),
1628
- 120 => __( 'Plastic White Medium','polldaddy'),
1629
- 121 => __( 'Plastic White Wide','polldaddy'),
1630
- 122 => __( 'Plastic Grey Narrow','polldaddy'),
1631
- 123 => __( 'Plastic Grey Medium','polldaddy'),
1632
- 124 => __( 'Plastic Grey Wide','polldaddy'),
1633
- 125 => __( 'Plastic Black Narrow','polldaddy'),
1634
- 126 => __( 'Plastic Black Medium','polldaddy'),
1635
- 127 => __( 'Plastic Black Wide','polldaddy'),
1636
- 128 => __( 'Manga Narrow','polldaddy'),
1637
- 129 => __( 'Manga Medium','polldaddy'),
1638
- 130 => __( 'Manga Wide','polldaddy'),
1639
- 131 => __( 'Tech Dark Narrow','polldaddy'),
1640
- 132 => __( 'Tech Dark Medium','polldaddy'),
1641
- 133 => __( 'Tech Dark Wide','polldaddy'),
1642
- 134 => __( 'Tech Grey Narrow','polldaddy'),
1643
- 135 => __( 'Tech Grey Medium','polldaddy'),
1644
- 136 => __( 'Tech Grey Wide','polldaddy'),
1645
- 137 => __( 'Tech Light Narrow','polldaddy'),
1646
- 138 => __( 'Tech Light Medium','polldaddy'),
1647
- 139 => __( 'Tech Light Wide','polldaddy'),
1648
- 140 => __( 'Working Male Narrow','polldaddy'),
1649
- 141 => __( 'Working Male Medium','polldaddy'),
1650
- 142 => __( 'Working Male Wide','polldaddy'),
1651
- 143 => __( 'Working Female Narrow','polldaddy'),
1652
- 144 => __( 'Working Female Medium','polldaddy'),
1653
- 145 => __( 'Working Female Wide','polldaddy'),
1654
- 146 => __( 'Thinking Male Narrow','polldaddy'),
1655
- 147 => __( 'Thinking Male Medium','polldaddy'),
1656
- 148 => __( 'Thinking Male Wide','polldaddy'),
1657
- 149 => __( 'Thinking Female Narrow','polldaddy'),
1658
- 150 => __( 'Thinking Female Medium','polldaddy'),
1659
- 151 => __( 'Thinking Female Wide','polldaddy'),
1660
- 152 => __( 'Sunset Narrow','polldaddy'),
1661
- 153 => __( 'Sunset Medium','polldaddy'),
1662
- 154 => __( 'Sunset Wide','polldaddy'),
1663
- 155 => __( 'Music Medium','polldaddy'),
1664
- 156 => __( 'Music Wide','polldaddy')
1665
  );
1666
-
1667
  $polldaddy->reset();
1668
  $styles = $polldaddy->get_styles();
1669
 
1670
  $show_custom = false;
1671
- if( !empty( $styles ) && !empty( $styles->style ) && count( $styles->style ) > 0 ){
1672
- foreach( (array) $styles->style as $style ){
1673
- $options[ (int) $style->_id ] = $style->title;
1674
  }
1675
  $show_custom = true;
1676
- }
1677
 
1678
- if ( $style_ID > 18 ){
1679
  $standard_style_ID = 0;
1680
  $custom_style_ID = $style_ID;
1681
  }
1682
- else{
1683
  $standard_style_ID = $style_ID;
1684
  $custom_style_ID = 0;
1685
- }
1686
  ?>
1687
 
1688
  <h3><?php _e( 'Design', 'polldaddy' ); ?></h3>
1689
  <input type="hidden" name="styleID" id="styleID" value="<?php echo $style_ID ?>">
1690
  <div class="inside">
1691
- <?php if ( $iframe_view ){ ?>
1692
  <div id="design_standard" style="padding:0px;">
1693
  <div class="hide-if-no-js">
1694
  <table class="pollStyle">
@@ -1748,15 +1756,15 @@ class WP_PollDaddy {
1748
  <p class="empty-if-js" id="no-js-styleID">
1749
  <select id="styleID" name="styleID">
1750
 
1751
- <?php foreach ( $options as $styleID => $label ) :
1752
- $selected = $styleID == $style_ID ? ' selected="selected"' : ''; ?>
1753
  <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option>
1754
- <?php endforeach; ?>
1755
 
1756
  </select>
1757
- </p>
1758
  </div>
1759
- <?php if ( $show_custom ){ ?>
1760
  <div id="design_custom">
1761
  <p class="hide-if-no-js">
1762
  <table class="pollStyle">
@@ -1778,17 +1786,17 @@ class WP_PollDaddy {
1778
  <tr>
1779
  <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1780
  <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1781
- <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1782
  <option value="x"<?php echo $selected; ?>><?php _e( 'Please choose a custom style...', 'polldaddy' ); ?></option>
1783
- <?php if( $show_custom) : foreach ( (array)$styles->style as $style ) :
1784
- $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1785
  <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1786
- <?php endforeach; endif; ?>
1787
  </select>
1788
  <div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy' ); ?></div></td>
1789
  </tr>
1790
  <tr>
1791
- <td><?php $extra = $show_custom == false ? __( 'You currently have no custom styles created.', 'polldaddy') : ''; ?>
1792
  <p><?php echo $extra ?></p>
1793
  <p><?php printf( __( 'Did you know we have a new editor for building your own custom poll styles? Find out more <a href="%s" target="_blank">here</a>.', 'polldaddy' ), 'http://support.polldaddy.com/custom-poll-styles/' ); ?></p>
1794
  </td>
@@ -1803,7 +1811,7 @@ class WP_PollDaddy {
1803
  <div id="design_options">
1804
  <a href="#" class="polldaddy-show-design-options"><?php _e( 'Custom Styles', 'polldaddy' ); ?></a>
1805
  </div>
1806
- <?php }}else{?>
1807
  <div class="design_standard">
1808
  <div class="hide-if-no-js">
1809
  <table class="pollStyle">
@@ -1874,14 +1882,14 @@ class WP_PollDaddy {
1874
  <tr>
1875
  <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1876
  <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1877
- <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1878
- <option value="x"<?php echo $selected; ?>><?php _e( 'Please choose a custom style...', 'polldaddy'); ?></option>
1879
- <?php if( $show_custom) : foreach ( (array)$styles->style as $style ) :
1880
- $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1881
  <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1882
- <?php endforeach; endif;?>
1883
  </select>
1884
- <div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy'); ?></div></td>
1885
  </tr>
1886
  <tr>
1887
  <td><?php $extra = $show_custom == false ? __( 'You currently have no custom styles created.', 'polldaddy' ) : ''; ?>
@@ -1898,115 +1906,115 @@ class WP_PollDaddy {
1898
  <p class="empty-if-js" id="no-js-styleID">
1899
  <select id="styleID" name="styleID">
1900
 
1901
- <?php foreach ( $options as $styleID => $label ) :
1902
- $selected = $styleID == $style_ID ? ' selected="selected"' : ''; ?>
1903
  <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option>
1904
- <?php endforeach; ?>
1905
 
1906
  </select>
1907
  </p>
1908
- </div>
1909
  <?php } ?>
1910
  <script language="javascript">
1911
- jQuery( document ).ready(function(){
1912
  plugin = new Plugin( {
1913
- delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
1914
- delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
1915
- delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
1916
- delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
1917
- standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
1918
- custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
1919
  } );
1920
  });
1921
  </script>
1922
  <script language="javascript">
1923
- current_pos = 0;
1924
-
1925
  for( var key in styles_array ) {
1926
  var name = styles_array[key].name;
1927
-
1928
  switch( name ){
1929
  case 'Aluminum':
1930
- styles_array[key].name = '<?php _e( 'Aluminum', 'polldaddy' ); ?>';
1931
  break;
1932
  case 'Plain White':
1933
- styles_array[key].name = '<?php _e( 'Plain White', 'polldaddy' ); ?>';
1934
  break;
1935
  case 'Plain Black':
1936
- styles_array[key].name = '<?php _e( 'Plain Black', 'polldaddy' ); ?>';
1937
  break;
1938
  case 'Paper':
1939
- styles_array[key].name = '<?php _e( 'Paper', 'polldaddy' ); ?>';
1940
  break;
1941
  case 'Skull Dark':
1942
- styles_array[key].name = '<?php _e( 'Skull Dark', 'polldaddy' ); ?>';
1943
  break;
1944
  case 'Skull Light':
1945
- styles_array[key].name = '<?php _e( 'Skull Light', 'polldaddy' ); ?>';
1946
  break;
1947
  case 'Micro':
1948
- styles_array[key].name = '<?php _e( 'Micro', 'polldaddy' ); ?>';
1949
- styles_array[key].n_desc = '<?php _e( 'Width 150px, the micro style is useful when space is tight.', 'polldaddy' ); ?>';
1950
  break;
1951
  case 'Plastic White':
1952
- styles_array[key].name = '<?php _e( 'Plastic White', 'polldaddy' ); ?>';
1953
  break;
1954
  case 'Plastic Grey':
1955
- styles_array[key].name = '<?php _e( 'Plastic Grey', 'polldaddy' ); ?>';
1956
  break;
1957
  case 'Plastic Black':
1958
- styles_array[key].name = '<?php _e( 'Plastic Black', 'polldaddy' ); ?>';
1959
  break;
1960
  case 'Manga':
1961
- styles_array[key].name = '<?php _e( 'Manga', 'polldaddy' ); ?>';
1962
  break;
1963
  case 'Tech Dark':
1964
- styles_array[key].name = '<?php _e( 'Tech Dark', 'polldaddy' ); ?>';
1965
  break;
1966
  case 'Tech Grey':
1967
- styles_array[key].name = '<?php _e( 'Tech Grey', 'polldaddy' ); ?>';
1968
  break;
1969
  case 'Tech Light':
1970
- styles_array[key].name = '<?php _e( 'Tech Light', 'polldaddy' ); ?>';
1971
  break;
1972
  case 'Working Male':
1973
- styles_array[key].name = '<?php _e( 'Working Male', 'polldaddy' ); ?>';
1974
  break;
1975
  case 'Working Female':
1976
- styles_array[key].name = '<?php _e( 'Working Female', 'polldaddy' ); ?>';
1977
  break;
1978
  case 'Thinking Male':
1979
- styles_array[key].name = '<?php _e( 'Thinking Male', 'polldaddy' ); ?>';
1980
  break;
1981
  case 'Thinking Female':
1982
- styles_array[key].name = '<?php _e( 'Thinking Female', 'polldaddy' ); ?>';
1983
  break;
1984
  case 'Sunset':
1985
- styles_array[key].name = '<?php _e( 'Sunset', 'polldaddy' ); ?>';
1986
  break;
1987
  case 'Music':
1988
- styles_array[key].name = '<?php _e( 'Music', 'polldaddy' ); ?>';
1989
  break;
1990
  }
1991
  }
1992
  pd_map = {
1993
- wide : '<?php _e( 'Wide', 'polldaddy' ); ?>',
1994
- medium : '<?php _e( 'Medium', 'polldaddy' ); ?>',
1995
- narrow : '<?php _e( 'Narrow', 'polldaddy' ); ?>',
1996
- style_desc_wide : '<?php _e( 'Width: 630px, the wide style is good for blog posts.', 'polldaddy' ); ?>',
1997
- style_desc_medium : '<?php _e( 'Width: 300px, the medium style is good for general use.', 'polldaddy' ); ?>',
1998
- style_desc_narrow : '<?php _e( 'Width 150px, the narrow style is good for sidebars etc.', 'polldaddy' ); ?>',
1999
- style_desc_micro : '<?php _e( 'Width 150px, the micro style is useful when space is tight.', 'polldaddy' ); ?>'
2000
  }
2001
  pd_build_styles( current_pos );
2002
- <?php if( $style_ID > 0 && $style_ID <= 1000 ){ ?>
2003
  pd_pick_style( <?php echo $style_ID ?> );
2004
- <?php }else{ ?>
2005
  pd_change_style( <?php echo $style_ID ?> );
2006
  <?php } ?>
2007
  </script>
2008
  </div>
2009
-
2010
  </div>
2011
 
2012
  </div>
@@ -2037,12 +2045,12 @@ class WP_PollDaddy {
2037
  $class = '';
2038
  foreach ( $results->answers as $answer ) :
2039
  $answer->text = trim( strip_tags( $answer->text ) );
2040
- if( strlen( $answer->text ) == 0 ){
2041
- $answer->text = '-- empty HTML tag --';
2042
- }
2043
-
2044
- $class = $class ? '' : ' class="alternate"';
2045
- $content = $results->others && 'Other answer...' === $answer->text ? sprintf( __( 'Other (<a href="%s">see below</a>)', 'polldaddy' ), '#other-answers-results' ) : wp_specialchars( $answer->text );
2046
 
2047
  ?>
2048
 
@@ -2099,24 +2107,24 @@ class WP_PollDaddy {
2099
 
2100
  <?php
2101
  }
2102
-
2103
  function styles_table() {
2104
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2105
  $polldaddy->reset();
2106
-
2107
  $styles_object = $polldaddy->get_styles();
2108
-
2109
  $this->parse_errors( $polldaddy );
2110
  $this->print_errors();
2111
  $styles = & $styles_object->style;
2112
  $class = '';
2113
  $styles_exist = false;
2114
-
2115
  foreach ( (array)$styles as $style ) :
2116
- if( (int) $style->_type == 1 ):
2117
  $styles_exist = true;
2118
- break;
2119
- endif;
2120
  endforeach;
2121
  ?>
2122
 
@@ -2146,41 +2154,41 @@ class WP_PollDaddy {
2146
  <?php
2147
  if ( $styles_exist ) :
2148
  foreach ( $styles as $style ) :
2149
- if( (int) $style->_type == 1 ):
2150
- $style_id = (int) $style->_id;
2151
 
2152
- $class = $class ? '' : ' class="alternate"';
2153
- $edit_link = clean_url( add_query_arg( array( 'action' => 'edit-style', 'style' => $style_id, 'message' => false ) ) );
2154
- $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-style', 'style' => $style_id, 'message' => false ) ), "delete-style_$style_id" ) );
2155
- list($style_time) = explode( '.', $style->date );
2156
- $style_time = strtotime( $style_time );
2157
- ?>
2158
 
2159
  <tr<?php echo $class; ?>>
2160
  <th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $style_id; ?>" name="style[]" /></th>
2161
  <td class="post-title column-title">
2162
- <?php if ( $edit_link ) : ?>
2163
  <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $style->title ); ?></a></strong>
2164
  <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
2165
- <?php else : ?>
2166
  <strong><?php echo wp_specialchars( $style->title ); ?></strong>
2167
- <?php endif; ?>
2168
 
2169
  <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a></span>
2170
  </td>
2171
- <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>
2172
  </tr>
2173
 
2174
  <?php
2175
- endif;
2176
- endforeach;
2177
  else : // $styles
2178
  ?>
2179
 
2180
  <tr>
2181
  <td colspan="4"><?php printf( __( 'No custom styles yet. <a href="%s">Create one</a>', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-style' ) ) ) ); ?></td>
2182
  </tr>
2183
- <?php endif; // $styles ?>
2184
 
2185
  </tbody>
2186
  </table>
@@ -2192,15 +2200,15 @@ class WP_PollDaddy {
2192
 
2193
  <?php
2194
  }
2195
-
2196
- function style_edit_form( $style_id = 105 ) {
2197
  $style_id = (int) $style_id;
2198
 
2199
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2200
  $polldaddy->reset();
2201
 
2202
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
2203
-
2204
  if ( $style_id ) {
2205
  $style = $polldaddy->get_style( $style_id );
2206
  $this->parse_errors( $polldaddy );
@@ -2218,19 +2226,18 @@ class WP_PollDaddy {
2218
  $preload_style_id = 0;
2219
  $preload_style = null;
2220
 
2221
- if ( isset ( $_REQUEST['preload'] ) )
2222
- {
2223
  $preload_style_id = (int) $_REQUEST['preload'];
2224
 
2225
  if ( $preload_style_id > 1000 || $preload_style_id < 100 )
2226
  $preload_style_id = 0;
2227
-
2228
  if ( $preload_style_id > 0 ) {
2229
  $polldaddy->reset();
2230
  $preload_style = $polldaddy->get_style( $preload_style_id );
2231
  $this->parse_errors( $polldaddy );
2232
  }
2233
-
2234
  $preload_style->css = trim( urldecode( $preload_style->css ) );
2235
 
2236
  if ( $start = stripos( $preload_style->css, '<data>' ) )
@@ -2238,11 +2245,11 @@ class WP_PollDaddy {
2238
 
2239
  $style->css = addslashes( $preload_style->css );
2240
  }
2241
-
2242
  $this->print_errors();
2243
-
2244
  echo '<script language="javascript">var CSSXMLString = "' . $style->css .'";</script>';
2245
- ?>
2246
 
2247
  <form action="" method="post">
2248
  <div id="poststuff">
@@ -2272,7 +2279,7 @@ class WP_PollDaddy {
2272
  <label class="CSSE_title_label"><?php _e( 'Preload Basic Style', 'polldaddy' ); ?></label>
2273
  </td>
2274
  <td>
2275
- <div class="CSSE_preload">
2276
  <select id="preload_value">
2277
  <option value="0"></option>
2278
  <option value="102"><?php _e( 'Aluminum', 'polldaddy' ); ?></option>
@@ -2300,7 +2307,7 @@ class WP_PollDaddy {
2300
  <option value="pds-answer"><?php _e( 'Answers', 'polldaddy' ); ?></option>
2301
  <option value="pds-textfield"><?php _e( 'Other Input', 'polldaddy' ); ?></option>
2302
  <option value="pds-vote-button"><?php _e( 'Vote Button', 'polldaddy' ); ?></option>
2303
- <option value="pds-link"><?php _e( 'Links', 'polldaddy' ); ?></option>
2304
  <option value="pds-answer-feedback"><?php _e( 'Result Background', 'polldaddy' ); ?></option>
2305
  <option value="pds-answer-feedback-bar"><?php _e( 'Result Bar', 'polldaddy' ); ?></option>
2306
  <option value="pds-totalvotes-inner"><?php _e( 'Total Votes', 'polldaddy' ); ?></option>
@@ -3050,7 +3057,7 @@ class WP_PollDaddy {
3050
  <div class="pds-totalvotes-outer">
3051
  <span class="pds-links-back">
3052
  <br/>
3053
- <a href="javascript:" class="pds-link" id="pds-link1"><?php _e( 'Comments', 'polldaddy' ); ?> <strong>(19)</strong></a>
3054
  <xsl:text> </xsl:text>
3055
  <a href="javascript:renderStyleEdit('pds-box');" class="pds-link" id="pds-link2"><?php _e( 'Return To Poll', 'polldaddy' ); ?></a>
3056
  <span class="pds-clear"></span>
@@ -3067,35 +3074,35 @@ class WP_PollDaddy {
3067
  </td>
3068
  </tr>
3069
  </table>
3070
- <div id="editBox"></div>
3071
- <p class="pds-clear"></p>
3072
  <p>
3073
  <?php wp_nonce_field( $style_id > 1000 ? "edit-style$style_id" : 'create-style' ); ?>
3074
  <input type="hidden" name="action" value="<?php echo $style_id > 1000 ? 'edit-style' : 'create-style'; ?>" />
3075
  <input type="hidden" class="polldaddy-style-id" name="style" value="<?php echo $style_id; ?>" />
3076
- <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Style', 'polldaddy' ) ); ?>" />
3077
  <?php if ( $style_id > 1000 ) { ?>
3078
  <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.' ); ?></label>
3079
  <?php } ?>
3080
  </p>
3081
  </div>
3082
- </div>
3083
  <textarea id="S_www" name="CSSXML" style="display:none;width: 1000px; height: 500px;" rows="10" cols="10"> </textarea>
3084
  </form>
3085
  <script language="javascript">
3086
- jQuery( document ).ready(function(){
3087
  plugin = new Plugin( {
3088
- delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
3089
- delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
3090
- delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
3091
- delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
3092
- standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
3093
- custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
3094
  } );
3095
  });
3096
  pd_map = {
3097
- thankyou : '<?php _e( 'Thank you for voting!', 'polldaddy' ); ?>',
3098
- question : '<?php _e( 'Do you mostly use the internet at work, in school or at home?', 'polldaddy' ); ?>'
3099
  }
3100
  </script>
3101
  <script type="text/javascript" language="javascript">window.onload = function() {
@@ -3108,51 +3115,51 @@ class WP_PollDaddy {
3108
 
3109
  <?php
3110
  }
3111
-
3112
- function rating_settings(){
3113
  global $action, $rating;
3114
  $show_posts = $show_posts_index = $show_pages = $show_comments = $pos_posts = $pos_posts_index = $pos_pages = $pos_comments = 0;
3115
  $show_settings = $rating_updated = ( $action == 'update-rating' ? true : false );
3116
  $error = false;
3117
-
3118
  $settings_style = 'display: none;';
3119
- if( $show_settings )
3120
  $settings_style = 'display: block;';
3121
-
3122
  $rating_id = get_option( 'pd-rating-posts-id' );
3123
  $report_type = 'posts';
3124
  $updated = false;
3125
-
3126
  if ( isset( $rating ) ) {
3127
  switch ( $rating ) :
3128
- case 'pages':
3129
- $report_type = 'pages';
3130
- $rating_id = (int) get_option( 'pd-rating-pages-id' );
3131
- break;
3132
- case 'comments':
3133
- $report_type = 'comments';
3134
- $rating_id = (int) get_option( 'pd-rating-comments-id' );
3135
- break;
3136
- case 'posts':
3137
- $report_type = 'posts';
3138
- $rating_id = (int) get_option( 'pd-rating-posts-id' );
3139
- break;
3140
  endswitch;
3141
  }
3142
-
3143
  $new_type = 0;
3144
  if ( $report_type == 'comments' )
3145
  $new_type = 1;
3146
-
3147
  $blog_name = get_option( 'blogname' );
3148
-
3149
  if ( empty( $blog_name ) )
3150
- $blog_name = 'WordPress Blog';
3151
- $blog_name .= ' - ' . $report_type;
3152
-
3153
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
3154
- $polldaddy->reset();
3155
-
3156
  if ( empty( $rating_id ) ) {
3157
  $pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
3158
  if ( !empty( $pd_rating ) ) {
@@ -3160,402 +3167,402 @@ class WP_PollDaddy {
3160
  update_option ( 'pd-rating-' . $report_type . '-id', $rating_id );
3161
  update_option ( 'pd-rating-' . $report_type, 0 );
3162
  }
3163
- } else
3164
  $pd_rating = $polldaddy->get_rating( $rating_id );
3165
-
3166
  if ( empty( $pd_rating ) || (int) $pd_rating->_id == 0 ) {
3167
-
3168
  if ( $polldaddy->errors ) {
3169
- if( array_key_exists( 4, $polldaddy->errors ) ) { //Obsolete key
3170
  $this->rating_user_code = '';
3171
- update_option( 'pd-rating-usercode', '' );
3172
  $this->set_api_user_code(); // get latest key
3173
-
3174
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
3175
  $polldaddy->reset();
3176
  $pd_rating = $polldaddy->get_rating( $rating_id ); //see it exists
3177
-
3178
- if ( empty( $pd_rating ) || (int) $pd_rating->_id == 0 ) { //if not then create a rating for blog
3179
- $polldaddy->reset();
3180
  $pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
3181
  }
3182
- }
3183
- }
3184
-
3185
- if( empty( $pd_rating ) ) { //something's up!
3186
- echo '<div class="error"><p>'.sprintf(__('Sorry! There was an error creating your rating widget. Please contact <a href="%1$s" %2$s>PollDaddy support</a> to fix this.', 'polldaddy'), 'http://polldaddy.com/feedback/', 'target="_blank"') . '</p></div>';
3187
  $error = true;
3188
  } else {
3189
  $rating_id = (int) $pd_rating->_id;
3190
  update_option ( 'pd-rating-' . $report_type . '-id', $rating_id );
3191
  update_option ( 'pd-rating-' . $report_type, 0 );
3192
-
3193
  switch ( $report_type ) :
3194
- case 'posts':
3195
- $show_posts = 0;
3196
- break;
3197
- case 'pages':
3198
- $show_pages = 0;
3199
- break;
3200
- case 'comments':
3201
- $show_comments = 0;
3202
- break;
3203
- endswitch;
3204
- }
3205
- }
3206
-
3207
- if ( isset( $_POST[ 'pd_rating_action_type' ] ) ) {
3208
-
3209
- switch ( $_POST[ 'pd_rating_action_type' ] ) :
3210
- case 'posts' :
3211
- if ( isset( $_POST[ 'pd_show_posts' ] ) && (int) $_POST[ 'pd_show_posts' ] == 1 )
3212
- $show_posts = get_option( 'pd-rating-posts-id' );
3213
-
3214
- update_option( 'pd-rating-posts', $show_posts );
3215
-
3216
- if ( isset( $_POST[ 'pd_show_posts_index' ] ) && (int) $_POST[ 'pd_show_posts_index' ] == 1 )
3217
- $show_posts_index = get_option( 'pd-rating-posts-id' );
3218
-
3219
- update_option( 'pd-rating-posts-index', $show_posts_index );
3220
-
3221
- if ( isset( $_POST[ 'posts_pos' ] ) && (int) $_POST[ 'posts_pos' ] == 1 )
3222
- $pos_posts = 1;
3223
-
3224
- update_option( 'pd-rating-posts-pos', $pos_posts );
3225
-
3226
- if ( isset( $_POST[ 'posts_index_pos' ] ) && (int) $_POST[ 'posts_index_pos' ] == 1 )
3227
- $pos_posts_index = 1;
3228
-
3229
- update_option( 'pd-rating-posts-index-pos', $pos_posts_index );
3230
- $rating_updated = true;
3231
  break;
3232
-
3233
- case 'pages';
3234
- if ( isset( $_POST[ 'pd_show_pages' ] ) && (int) $_POST[ 'pd_show_pages' ] == 1 )
3235
- $show_pages = get_option( 'pd-rating-pages-id' );
3236
-
3237
- update_option( 'pd-rating-pages', $show_pages );
3238
-
3239
- if ( isset( $_POST[ 'pages_pos' ] ) && (int) $_POST[ 'pages_pos' ] == 1 )
3240
- $pos_pages = 1;
3241
-
3242
- update_option( 'pd-rating-pages-pos', $pos_pages );
3243
- $rating_updated = true;
3244
  break;
3245
-
3246
  case 'comments':
3247
- if ( isset( $_POST[ 'pd_show_comments' ] ) && (int) $_POST[ 'pd_show_comments' ] == 1 )
3248
- $show_comments = get_option( 'pd-rating-comments-id' );
3249
-
3250
- update_option( 'pd-rating-comments', $show_comments );
3251
-
3252
- if ( isset( $_POST[ 'comments_pos' ] ) && (int) $_POST[ 'comments_pos' ] == 1 )
3253
- $pos_comments = 1;
3254
-
3255
- update_option( 'pd-rating-comments-pos', $pos_comments );
3256
-
3257
- $rating_updated = true;
3258
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3259
  endswitch;
3260
  }
3261
-
3262
  $show_posts = (int) get_option( 'pd-rating-posts' );
3263
  $show_pages = (int) get_option( 'pd-rating-pages' );
3264
  $show_comments = (int) get_option( 'pd-rating-comments' );
3265
  $show_posts_index = (int) get_option( 'pd-rating-posts-index' );
3266
-
3267
  $pos_posts = (int) get_option( 'pd-rating-posts-pos' );
3268
  $pos_pages = (int) get_option( 'pd-rating-pages-pos' );
3269
  $pos_comments = (int) get_option( 'pd-rating-comments-pos' );
3270
  $pos_posts_index = (int) get_option( 'pd-rating-posts-index-pos' );
3271
-
3272
  if ( !empty( $pd_rating ) ) {
3273
  $settings_text = $pd_rating->settings;
3274
- $settings = json_decode( $settings_text );
3275
-
3276
  $popup_disabled = ( isset( $settings->popup ) && $settings->popup == 'off' );
3277
-
3278
  $rating_type = 0;
3279
-
3280
- if( $settings->type == 'stars' )
3281
  $rating_type = 0;
3282
  else
3283
  $rating_type = 1;
3284
-
3285
- if( empty( $settings->font_color ) )
3286
- $settings->font_color = '#000000';
3287
- }?>
3288
  <div class="wrap">
3289
- <h2><?php _e('Rating Settings', 'polldaddy'); ?></h2><?php
3290
- if ( $rating_updated )
3291
- echo( '<div class="updated"><p>'.__('Rating updated', 'polldaddy').'</p></div>' );
3292
 
3293
- if ( !$error ) { ?>
3294
- <div id="side-sortables">
3295
  <div id="categorydiv" class="categorydiv">
3296
- <ul id="category-tabs" class="category-tabs"><?php
3297
- $this_class = '';
3298
- $posts_link = clean_url( add_query_arg( array( 'rating' => 'posts', 'message' => false ) ) );
3299
- $pages_link = clean_url( add_query_arg( array( 'rating' => 'pages', 'message' => false ) ) );
3300
- $comments_link = clean_url( add_query_arg( array( 'rating' => 'comments', 'message' => false ) ) );
3301
- if ( $report_type == 'posts' )
3302
- $this_class = ' class="tabs"';?>
3303
- <li <?php echo( $this_class ); ?>><a tabindex="3" href="<?php echo $posts_link; ?>"><?php _e('Posts', 'polldaddy');?></a></li><?php
3304
- $this_class = '';
3305
- if ( $report_type == 'pages' )
3306
- $this_class = ' class="tabs"'; ?>
3307
- <li <?php echo( $this_class ); ?>><a tabindex="3" href="<?php echo $pages_link; ?>"><?php _e('Pages', 'polldaddy');?></a></li><?php
3308
- $this_class = '';
3309
- if ( $report_type == 'comments' )
3310
- $this_class = ' class="tabs"'; ?>
3311
- <li <?php echo( $this_class ); ?>><a href="<?php echo $comments_link; ?>"><?php _e('Comments', 'polldaddy');?></a></li>
3312
  </ul>
3313
  <div class="tabs-panel" id="categories-all" style="background: #FFFFFF;height: auto; overflow: visible;">
3314
  <form action="" method="post">
3315
- <input type="hidden" name="pd_rating_action_type" value="<?php echo ( $report_type ); ?>" />
3316
  <table class="form-table" style="width: normal;">
3317
  <tbody><?php
3318
- if ( $report_type == 'posts' ) { ?>
3319
  <tr valign="top">
3320
  <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
3321
  <label for="pd_show_posts">
3322
- <input type="checkbox" name="pd_show_posts" id="pd_show_posts" <?php if( $show_posts > 0 ) echo( ' checked="checked" ' ); ?> value="1" /> <?php _e('Enable for blog posts', 'polldaddy');?>
3323
  </label>
3324
  <span id="span_posts">
3325
  <select name="posts_pos"><?php
3326
- $select = array( __('Above each blog post', 'polldaddy') => '0', __('Below each blog post', 'polldaddy') => '1' );
3327
- foreach( $select as $option => $value ) :
3328
- $selected = '';
3329
- if ( $value == $pos_posts )
3330
- $selected = ' selected="selected"';
3331
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
3332
- endforeach;?>
3333
  </select>
3334
  </span>
3335
  </td>
3336
- </tr>
3337
  <tr valign="top">
3338
  <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
3339
  <label for="pd_show_posts_index">
3340
- <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('Enable for front page', 'polldaddy');?>
3341
  </label>
3342
  <span id="span_posts">
3343
  <select name="posts_index_pos"><?php
3344
- $select = array( __('Above each blog post', 'polldaddy') => '0', __('Below each blog post', 'polldaddy') => '1' );
3345
- foreach( $select as $option => $value ) :
3346
- $selected = '';
3347
- if ( $value == $pos_posts_index )
3348
- $selected = ' selected="selected"';
3349
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
3350
- endforeach;?>
3351
  </select>
3352
  </span>
3353
  </td>
3354
  </tr><?php
3355
- }
3356
- if ( $report_type == 'pages' ) {?>
3357
  <tr valign="top">
3358
  <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
3359
  <label for="pd_show_pages">
3360
- <input type="checkbox" name="pd_show_pages" id="pd_show_pages" <?php if( $show_pages > 0 ) echo( ' checked="checked" ' ); ?> value="1" /> <?php _e('Enable for pages', 'polldaddy');?>
3361
- </label>
3362
  <span id="span_pages">
3363
  <select name="pages_pos"><?php
3364
- $select = array( __('Above each page', 'polldaddy') => '0', __('Below each page', 'polldaddy') => '1' );
3365
- foreach( $select as $option => $value ) :
3366
- $selected = '';
3367
- if ( $value == $pos_pages )
3368
- $selected = ' selected="selected"';
3369
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
3370
- endforeach; ?>
3371
  </select>
3372
  </span>
3373
  </td>
3374
  </tr><?php
3375
- }
3376
- if ( $report_type == 'comments' ) {?>
3377
  <tr valign="top">
3378
  <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
3379
  <label for="pd_show_comments">
3380
- <input type="checkbox" name="pd_show_comments" id="pd_show_comments" <?php if( $show_comments > 0 ) echo( ' checked="checked" ' ); ?> value="1" /> <?php _e('Enable for comments', 'polldaddy');?>
3381
- </label>
3382
  <span id="span_comments">
3383
  <select name="comments_pos"><?php
3384
- $select = array( __('Above each comment', 'polldaddy') => '0', __('Below each comment', 'polldaddy') => '1' );
3385
- foreach( $select as $option => $value ) :
3386
- $selected = '';
3387
- if ( $value == $pos_comments )
3388
- $selected = ' selected="selected"';
3389
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
3390
- endforeach; ?>
3391
  </select>
3392
  </span>
3393
  </td>
3394
- </tr><?php
3395
- } ?>
3396
  </tbody>
3397
  </table>
3398
  <p class="submit">
3399
- <input class="button-primary" type="submit" value="<?php esc_attr_e('Save Changes', 'polldaddy');?>" name="Submit" />
3400
  </p><?php
3401
- if ( $report_type == 'posts' ) {
3402
- if( $show_posts > 0 || $show_posts_index > 0 )
3403
- $show_settings = true;
3404
- }
3405
- if ( $report_type == 'pages' && $show_pages > 0 )
3406
- $show_settings = true;
3407
- if ( $report_type == 'comments' && $show_comments > 0 )
3408
- $show_settings = true;
3409
- if ( $show_settings == true )
3410
- echo ( '<a href="javascript:" onclick="show_settings();">'.__('Advanced Settings', 'polldaddy').'</a>' );?>
3411
  </form>
3412
  </div>
3413
  </div>
3414
  </div>
3415
 
3416
- <?php if ( $show_settings == true ){ ?>
3417
  <br />
3418
  <form method="post" action="">
3419
- <div id="poststuff" style="<?php echo( $settings_style ); ?>">
3420
  <div class="has-sidebar has-right-sidebar">
3421
  <div class="inner-sidebar-ratings">
3422
  <div class="postbox" id="submitdiv">
3423
- <h3><?php _e('Save', 'polldaddy');?></h3>
3424
  <div class="inside">
3425
  <div id="major-publishing-actions">
3426
- <input type="hidden" name="type" value="<?php echo( $report_type ); ?>" />
3427
- <input type="hidden" name="rating_id" value="<?php echo( $rating_id ); ?>" />
3428
  <input type="hidden" name="action" value="update-rating" />
3429
  <p id="publishing-action">
3430
- <input type="submit" value="<?php _e('Save Changes', 'polldaddy');?>" class="button-primary"/>
3431
  </p>
3432
  <br class="clear"/>
3433
  </div>
3434
  </div>
3435
  </div>
3436
  <div class="postbox">
3437
- <h3><?php _e('Preview', 'polldaddy');?></h3>
3438
  <div class="inside">
3439
- <p><?php _e('This is a demo of what your rating widget will look like', 'polldaddy'); ?>.</p>
3440
  <p>
3441
  <div id="pd_rating_holder_1"></div>
3442
  </p>
3443
  </div>
3444
  </div>
3445
  <div class="postbox">
3446
- <h3><?php _e('Customize Labels', 'polldaddy');?></h3>
3447
  <div class="inside">
3448
  <table width="99.5%">
3449
  <tr>
3450
- <td><p style="margin-bottom: 0px;"><?php _e('Vote', 'polldaddy');?></p></td>
3451
  </tr>
3452
  <tr>
3453
  <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' : wp_specialchars( $settings->text_vote ); ?>" maxlength="20" />
3454
  </tr>
3455
  <tr>
3456
- <td><p style="margin-bottom: 0px;"><?php _e('Votes', 'polldaddy');?></p></td>
3457
  </tr>
3458
  <tr>
3459
  <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' : wp_specialchars( $settings->text_votes ); ?>" maxlength="20" />
3460
  </tr>
3461
  <tr>
3462
- <td><p style="margin-bottom: 0px;"><?php _e('Rate This', 'polldaddy');?></p></td>
3463
  </tr>
3464
  <tr>
3465
  <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' : wp_specialchars( $settings->text_rate_this ); ?>" maxlength="20" />
3466
  </tr>
3467
  <tr>
3468
- <td><p style="margin-bottom: 0px;"><?php printf(__( '%d star', 'polldaddy' ), 1);?></p></td>
3469
  </tr>
3470
  <tr>
3471
  <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' : wp_specialchars( $settings->text_1_star ); ?>" maxlength="20" />
3472
  </tr>
3473
  <tr>
3474
- <td><p style="margin-bottom: 0px;"><?php printf(__( '%d stars', 'polldaddy' ), 2);?></p></td>
3475
  </tr>
3476
  <tr>
3477
  <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' : wp_specialchars( $settings->text_2_star ); ?>" maxlength="20" />
3478
  </tr>
3479
  <tr>
3480
- <td><p style="margin-bottom: 0px;"><?php printf(__( '%d stars', 'polldaddy' ), 3);?></p></td>
3481
  </tr>
3482
  <tr>
3483
  <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' : wp_specialchars( $settings->text_3_star ); ?>" maxlength="20" />
3484
  </tr>
3485
  <tr>
3486
- <td><p style="margin-bottom: 0px;"><?php printf(__( '%d stars', 'polldaddy' ), 4);?></p></td>
3487
  </tr>
3488
  <tr>
3489
  <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' : wp_specialchars( $settings->text_4_star ); ?>" maxlength="20" />
3490
  </tr>
3491
  <tr>
3492
- <td><p style="margin-bottom: 0px;"><?php printf(__( '%d stars', 'polldaddy' ), 5);?></p></td>
3493
  </tr>
3494
  <tr>
3495
  <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' : wp_specialchars( $settings->text_5_star ); ?>" maxlength="20" />
3496
  </tr>
3497
  <tr>
3498
- <td><p style="margin-bottom: 0px;"><?php _e('Thank You', 'polldaddy');?></p></td>
3499
  </tr>
3500
  <tr>
3501
  <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' : wp_specialchars( $settings->text_thank_you ); ?>" maxlength="20" />
3502
  </tr>
3503
  <tr>
3504
- <td><p style="margin-bottom: 0px;"><?php _e('Rate Up', 'polldaddy');?></p></td>
3505
  </tr>
3506
  <tr>
3507
  <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' : wp_specialchars( $settings->text_rate_up ); ?>" maxlength="20" />
3508
  </tr>
3509
  <tr>
3510
- <td><p style="margin-bottom: 0px;"><?php _e('Rate Down', 'polldaddy');?></p></td>
3511
  </tr>
3512
  <tr>
3513
  <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' : wp_specialchars( $settings->text_rate_down ); ?>" maxlength="20" />
3514
  </tr>
3515
  <tr>
3516
- <td><p style="margin-bottom: 0px;"><?php _e('Most Popular Content', 'polldaddy');?></p></td>
3517
  </tr>
3518
  <tr>
3519
  <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' : wp_specialchars( $settings->text_popcontent ); ?>" maxlength="20" />
3520
  </tr>
3521
  <tr>
3522
- <td><p style="margin-bottom: 0px;"><?php _e('Close', 'polldaddy');?></p></td>
3523
  </tr>
3524
  <tr>
3525
  <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' : wp_specialchars( $settings->text_close ); ?>" maxlength="20" />
3526
  </tr>
3527
  <tr>
3528
- <td><p style="margin-bottom: 0px;"><?php _e('All', 'polldaddy');?></p></td>
3529
  </tr>
3530
  <tr>
3531
  <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' : wp_specialchars( $settings->text_all ); ?>" maxlength="20" />
3532
  </tr>
3533
  <tr>
3534
- <td><p style="margin-bottom: 0px;"><?php _e('Today', 'polldaddy');?></p></td>
3535
  </tr>
3536
  <tr>
3537
  <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' : wp_specialchars( $settings->text_today ); ?>" maxlength="20" />
3538
  </tr>
3539
  <tr>
3540
- <td><p style="margin-bottom: 0px;"><?php _e('This Week', 'polldaddy');?></p></td>
3541
  </tr>
3542
  <tr>
3543
  <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' : wp_specialchars( $settings->text_thisweek ); ?>" maxlength="20" />
3544
  </tr>
3545
  <tr>
3546
- <td><p style="margin-bottom: 0px;"><?php _e('This Month', 'polldaddy');?></p></td>
3547
  </tr>
3548
  <tr>
3549
  <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' : wp_specialchars( $settings->text_thismonth ); ?>" maxlength="20" />
3550
  </tr>
3551
  <tr>
3552
- <td><p style="margin-bottom: 0px;"><?php _e('Rated', 'polldaddy');?></p></td>
3553
  </tr>
3554
  <tr>
3555
  <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' : wp_specialchars( $settings->text_rated ); ?>" maxlength="20" />
3556
  </tr>
3557
  <tr>
3558
- <td><p style="margin-bottom: 0px;"><?php _e('There are no rated items for this period', 'polldaddy');?></p></td>
3559
  </tr>
3560
  <tr>
3561
  <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' : wp_specialchars( $settings->text_noratings ); ?>" maxlength="50" />
@@ -3564,187 +3571,187 @@ class WP_PollDaddy {
3564
  </div>
3565
  </div>
3566
  </div>
3567
- <div id="post-body-content" class="has-sidebar-content">
3568
  <div class="postbox">
3569
- <h3><?php _e('Rating Type', 'polldaddy');?></h3>
3570
- <div class="inside">
3571
- <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>
3572
  <ul>
3573
  <li style="display: inline;margin-right: 10px;">
3574
  <label for="stars"><?php
3575
- $checked = '';
3576
- if ( $settings->type == 'stars' )
3577
- $checked = ' checked="checked"';?>
3578
- <input type="radio" onchange="pd_change_type( 0 );" <?php echo ( $checked ); ?> value="stars" id="stars" name="rating_type" />
3579
- <?php printf(__( '%d Star Rating', 'polldaddy' ), 5);?>
3580
  </label>
3581
  </li>
3582
  <li style="display: inline;">
3583
  <label><?php
3584
- $checked = '';
3585
- if ( $settings->type == 'nero' )
3586
- $checked = ' checked="checked"';?>
3587
- <input type="radio" onchange="pd_change_type( 1 );" <?php echo( $checked ); ?> value="nero" id="nero" name="rating_type" />
3588
- <?php _e('Nero Rating', 'polldaddy' );?>
3589
- </label>
3590
  </li>
3591
  </ul>
3592
  </div>
3593
  </div>
3594
  <div class="postbox">
3595
- <h3><?php _e('Rating Style', 'polldaddy');?></h3>
3596
  <div class="inside">
3597
  <table>
3598
  <tr>
3599
- <td height="30" width="100" id="editor_star_size_text"><?php _e('Star Size', 'polldaddy');?></td>
3600
  <td>
3601
  <select name="size" id="size" onchange="pd_bind(this);"><?php
3602
- $select = array( __('Small', 'polldaddy')." (16px)" => "sml", __('Medium', 'polldaddy')." (20px)" => "med", __('Large', 'polldaddy')." (24px)" => "lrg" );
3603
- foreach ( $select as $option => $value ) :
3604
- $selected = '';
3605
- if ( $settings->size == $value )
3606
- $selected = ' selected="selected"';
3607
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
3608
- endforeach;?>
3609
  </select>
3610
  </td>
3611
  </tr>
3612
  <tr>
3613
- <td height="30" id="editor_star_color_text"><?php echo 'bubu'; _e('Star Color', 'polldaddy');?></td>
3614
  <td>
3615
  <select name="star_color" id="star_color" onchange="pd_bind(this);" style="display: none;"><?php
3616
- $select = array( __('Yellow', 'polldaddy') => "yellow", __('Red', 'polldaddy') => "red", __('Blue', 'polldaddy') => "blue", __('Green', 'polldaddy') => "green", __('Grey', 'polldaddy') => "grey" );
3617
- foreach ( $select as $option => $value ) :
3618
- $selected = '';
3619
- if ( $settings->star_color == $value )
3620
- $selected = ' selected="selected"';
3621
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
3622
- endforeach;?>
3623
  </select>
3624
  <select name="nero_style" id="nero_style" onchange="pd_bind(this);" style="display: none;"><?php
3625
- $select = array( __('Hand', 'polldaddy') => "hand" );
3626
- foreach ( $select as $option => $value ) :
3627
- $selected = '';
3628
- if ( $settings->star_color == $value )
3629
- $selected = ' selected="selected"';
3630
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
3631
- endforeach;?>
3632
  </select>
3633
  </td>
3634
  </tr>
3635
  <tr>
3636
- <td height="30"><?php _e('Custom Image', 'polldaddy');?></td>
3637
- <td><input type="text" onblur="pd_bind(this);" name="custom_star" id="custom_star" value="<?php echo( clean_url( $settings->custom_star ) ); ?>" maxlength="200" />
3638
  </tr>
3639
  </table>
3640
  </div>
3641
  </div>
3642
  <div class="postbox">
3643
- <h3><?php _e('Text Layout & Font', 'polldaddy');?></h3>
3644
  <div class="inside">
3645
  <table>
3646
  <tr>
3647
- <td width="100" height="30"><?php _e('Align', 'polldaddy');?></td>
3648
  <td>
3649
  <select id="font_align" onchange="pd_bind(this);" name="font_align"><?php
3650
- $select = array( __('Left', 'polldaddy') => "left", __('Center', 'polldaddy') => "center", __('Right', 'polldaddy') => "right" );
3651
- foreach( $select as $option => $value ):
3652
- $selected = '';
3653
- if ( $settings->font_align == $value )
3654
- $selected = ' selected="selected"';
3655
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>');
3656
- endforeach;?>
3657
  </select>
3658
  </td>
3659
  </tr>
3660
  <tr>
3661
- <td height="30"><?php _e('Position', 'polldaddy');?></td>
3662
  <td>
3663
  <select name="font_position" onchange="pd_bind(this);" id="font_position"><?php
3664
- $select = array( __('Top', 'polldaddy') => "top", __('Right', 'polldaddy') => "right", __('Bottom', 'polldaddy') => "bottom" );
3665
- foreach( $select as $option => $value ) :
3666
- $selected = '';
3667
- if ( $settings->font_position == $value )
3668
- $selected = ' selected="selected"';
3669
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>');
3670
- endforeach;?>
3671
  </select>
3672
  </td>
3673
  </tr>
3674
  <tr>
3675
- <td height="30"><?php _e('Font', 'polldaddy');?></td>
3676
  <td>
3677
  <select name="font_family" id="font_family" onchange="pd_bind(this);"><?php
3678
- $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" );
3679
- foreach( $select as $option => $value ) :
3680
- $selected = '';
3681
- if ( $settings->font_family == $value )
3682
- $selected = ' selected="selected"';
3683
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' );
3684
- endforeach;?>
3685
  </select>
3686
  </td>
3687
  </tr>
3688
  <tr>
3689
- <td height="30"><?php _e('Color', 'polldaddy');?></td>
3690
- <td><input type="text" onblur="pd_bind(this);" class="elmColor jscolor-picker" name="font_color" id="font_color" value="<?php echo( wp_specialchars( $settings->font_color ) ); ?>" maxlength="11" autocomplete="off"/>
3691
  </td>
3692
  </tr>
3693
  <tr>
3694
- <td><?php _e('Size', 'polldaddy');?></td>
3695
  <td>
3696
  <select name="font_size" id="font_size" onchange="pd_bind(this);"><?php
3697
- $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", );
3698
- foreach ( $select as $option => $value ) :
3699
- $selected = '';
3700
- if ( $settings->font_size == $value )
3701
- $selected = ' selected="selected"';
3702
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
3703
- endforeach;?>
3704
  </select>
3705
  </td>
3706
  </tr>
3707
  <tr>
3708
- <td height="30"><?php _e('Line Height', 'polldaddy');?></td>
3709
  <td>
3710
  <select name="font_line_height" id="font_line_height" onchange="pd_bind(this);"><?php
3711
- $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", );
3712
- foreach ( $select as $option => $value ) :
3713
- $selected = '';
3714
- if ( $settings->font_line_height == $value )
3715
- $selected = ' selected="selected"';
3716
- echo ( '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n" );
3717
- endforeach; ?>
3718
  </select>
3719
  </td>
3720
  </tr>
3721
  <tr>
3722
- <td height="30"><?php _e('Bold', 'polldaddy');?></td>
3723
- <td><?php
3724
- $checked = '';
3725
- if ( $settings->font_bold == 'bold' )
3726
- $checked = ' checked="checked"';?>
3727
- <input type="checkbox" name="font_bold" onclick="pd_bind(this);" id="font_bold" value="bold" <?php echo( $checked ); ?> />
3728
  </td>
3729
  </tr>
3730
  <tr>
3731
- <td height="30"><?php _e('Italic', 'polldaddy');?></td><?php
3732
- $checked = '';
3733
- if( $settings->font_italic == 'italic' )
3734
- $checked = ' checked="checked"';?>
3735
- <td><input type="checkbox" name="font_italic" onclick="pd_bind(this);" id="font_italic" value="italic" <?php echo( $checked ); ?>/></td>
3736
  </tr>
3737
  </table>
3738
  </div>
3739
  </div>
3740
- <?php
3741
- if ( $this->is_admin ) { ?>
3742
  <div class="postbox">
3743
- <h3><?php _e('Extra Settings', 'polldaddy');?></h3>
3744
  <div class="inside">
3745
- <table>
3746
  <tr>
3747
- <td width="100" height="30"><?php _e('Results Popup', 'polldaddy');?></td>
3748
  <td>
3749
  <input type="checkbox" onchange="pd_bind(this);" value="on" name="polldaddy-rating-popup" id="polldaddy-rating-popup" <?php echo !$popup_disabled ? 'checked="checked"' : ''; ?> />
3750
  </td>
@@ -3754,10 +3761,10 @@ class WP_PollDaddy {
3754
  </span>
3755
  </td>
3756
  </tr><?php
3757
- if ( $report_type == 'posts' ) {
3758
- $exclude_post_ids = wp_specialchars( get_option( 'pd-rating-exclude-post-ids' ) ); ?>
3759
  <tr>
3760
- <td width="100" height="30"><?php _e('Rating ID', 'polldaddy');?></td>
3761
  <td>
3762
  <input type="text" name="polldaddy-post-rating-id" id="polldaddy-post-rating-id" value="<?php echo $rating_id; ?>" />
3763
  </td>
@@ -3768,7 +3775,7 @@ class WP_PollDaddy {
3768
  </td>
3769
  </tr>
3770
  <tr>
3771
- <td width="100" height="30"><?php _e('Exclude Posts', 'polldaddy');?></td>
3772
  <td>
3773
  <input type="text" name="exclude-post-ids" id="exclude-post-ids" value="<?php echo $exclude_post_ids; ?>" />
3774
  </td>
@@ -3778,10 +3785,10 @@ class WP_PollDaddy {
3778
  </span>
3779
  </td>
3780
  </tr><?php
3781
- } else if ( $report_type == 'pages' ) {
3782
- $exclude_page_ids = wp_specialchars( get_option( 'pd-rating-exclude-page-ids' ) ); ?>
3783
  <tr>
3784
- <td width="100" height="30"><?php _e('Rating ID', 'polldaddy');?></td>
3785
  <td>
3786
  <input type="text" name="polldaddy-page-rating-id" id="polldaddy-page-rating-id" value="<?php echo $rating_id; ?>" />
3787
  </td>
@@ -3792,7 +3799,7 @@ class WP_PollDaddy {
3792
  </td>
3793
  </tr>
3794
  <tr>
3795
- <td width="100" height="30"><?php _e('Exclude Pages', 'polldaddy');?></td>
3796
  <td>
3797
  <input type="text" name="exclude-page-ids" id="exclude-page-ids" value="<?php echo $exclude_page_ids; ?>" />
3798
  </td>
@@ -3801,10 +3808,10 @@ class WP_PollDaddy {
3801
  <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>
3802
  </span>
3803
  </td>
3804
- </tr><?php
3805
- } else if ( $report_type == 'comments' ) { ?>
3806
  <tr>
3807
- <td width="100" height="30"><?php _e('Rating ID', 'polldaddy');?></td>
3808
  <td>
3809
  <input type="text" name="polldaddy-comment-rating-id" id="polldaddy-comment-rating-id" value="<?php echo $rating_id; ?>" />
3810
  </td>
@@ -3814,7 +3821,7 @@ class WP_PollDaddy {
3814
  </span>
3815
  </td>
3816
  </tr><?php
3817
- } ?>
3818
  </table>
3819
  </div>
3820
  </div>
@@ -3823,242 +3830,242 @@ class WP_PollDaddy {
3823
  </div>
3824
  </form>
3825
  <script language="javascript">
3826
- jQuery( document ).ready(function(){
3827
  plugin = new Plugin( {
3828
- delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
3829
- delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
3830
- delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
3831
- delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
3832
- standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
3833
- custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
3834
  } );
3835
  });
3836
  </script>
3837
  <script type="text/javascript">
3838
- PDRTJS_settings = <?php echo ( $settings_text ); ?>;
3839
- PDRTJS_settings.id = "1";
3840
  PDRTJS_settings.unique_id = "xxx";
3841
  PDRTJS_settings.title = "";
3842
- PDRTJS_settings.override = "<?php echo( $rating_id ); ?>";
3843
  PDRTJS_settings.permalink = "";
3844
  PDRTJS_1 = new PDRTJS_RATING( PDRTJS_settings );
3845
- pd_change_type( <?php echo ( $rating_type ) ?> );
3846
- </script><?php
3847
- } ?>
3848
- </div><?php
3849
- } // from if !error ?>
3850
  </div><?php
3851
- }
3852
-
3853
- function update_rating(){
3854
- $rating_type = 0;
3855
- $rating_id = 0;
3856
- $new_rating_id = 0;
3857
- $type = 'post';
3858
- $set = null;
3859
-
3860
- if( isset( $_REQUEST['rating_id'] ) )
3861
- $rating_id = (int) $_REQUEST['rating_id'];
3862
-
3863
- if( isset( $_REQUEST['polldaddy-post-rating-id'] ) ) {
3864
- $new_rating_id = (int) $_REQUEST['polldaddy-post-rating-id'];
3865
- $type = 'posts';
3866
- }
3867
- else if( isset( $_REQUEST['polldaddy-page-rating-id'] ) ) {
3868
- $new_rating_id = (int) $_REQUEST['polldaddy-page-rating-id'];
3869
- $type = 'pages';
3870
- }
3871
- else if( isset( $_REQUEST['polldaddy-comment-rating-id'] ) ) {
3872
- $new_rating_id = (int) $_REQUEST['polldaddy-comment-rating-id'];
3873
- $type = 'comments';
3874
- } else{
3875
- $new_rating_id = $rating_id;
3876
- }
3877
-
3878
- if( $rating_id > 0 && $rating_id == $new_rating_id ) {
3879
- if( isset( $_REQUEST['rating_type'] ) && $_REQUEST['rating_type'] == 'stars' ) {
3880
- $set->type = 'stars';
3881
- $rating_type = 0;
3882
- if( isset( $_REQUEST['star_color'] ) )
3883
- $set->star_color = attribute_escape( $_REQUEST['star_color'] );
3884
- } else {
3885
- $set->type = 'nero';
3886
- $rating_type = 1;
3887
- if( isset( $_REQUEST['nero_style'] ) )
3888
- $set->star_color = attribute_escape( $_REQUEST['nero_style'] );
3889
- }
3890
-
3891
- $set->size = wp_specialchars( $_REQUEST['size'], 1 );
3892
- $set->custom_star = wp_specialchars( clean_url( $_REQUEST['custom_star'] ) , 1 );
3893
- $set->font_align = wp_specialchars( $_REQUEST['font_align'], 1 );
3894
- $set->font_position = wp_specialchars( $_REQUEST['font_position'], 1 );
3895
- $set->font_family = wp_specialchars( $_REQUEST['font_family'], 1);
3896
- $set->font_size = wp_specialchars( $_REQUEST['font_size'], 1 );
3897
- $set->font_line_height = wp_specialchars( $_REQUEST['font_line_height'], 1 );
3898
-
3899
- if ( isset( $_REQUEST['font_bold'] ) && $_REQUEST['font_bold'] == 'bold' )
3900
- $set->font_bold = 'bold';
3901
- else
3902
- $set->font_bold = 'normal';
3903
-
3904
- if ( isset( $_REQUEST['font_italic'] ) && $_REQUEST['font_italic'] == 'italic' )
3905
- $set->font_italic = 'italic';
3906
- else
3907
- $set->font_italic = 'normal';
3908
-
3909
- $set->text_vote = wp_specialchars( $_REQUEST['text_vote'], 1 );
3910
- $set->text_votes = wp_specialchars( $_REQUEST['text_votes'], 1 );
3911
- $set->text_rate_this = wp_specialchars( $_REQUEST['text_rate_this'], 1 );
3912
- $set->text_1_star = wp_specialchars( $_REQUEST['text_1_star'], 1 );
3913
- $set->text_2_star = wp_specialchars( $_REQUEST['text_2_star'], 1 );
3914
- $set->text_3_star = wp_specialchars( $_REQUEST['text_3_star'], 1 );
3915
- $set->text_4_star = wp_specialchars( $_REQUEST['text_4_star'], 1 );
3916
- $set->text_5_star = wp_specialchars( $_REQUEST['text_5_star'], 1 );
3917
- $set->text_thank_you = wp_specialchars( $_REQUEST['text_thank_you'], 1 );
3918
- $set->text_rate_up = wp_specialchars( $_REQUEST['text_rate_up'], 1 );
3919
- $set->text_rate_down = wp_specialchars( $_REQUEST['text_rate_down'], 1 );
3920
- $set->font_color = wp_specialchars( $_REQUEST['font_color'], 1 );
3921
-
3922
- $set->text_popcontent= wp_specialchars( $_REQUEST['text_popcontent'], 1 );
3923
- $set->text_close = wp_specialchars( $_REQUEST['text_close'], 1 );
3924
- $set->text_all = wp_specialchars( $_REQUEST['text_all'], 1 );
3925
- $set->text_today = wp_specialchars( $_REQUEST['text_today'], 1 );
3926
- $set->text_thisweek = wp_specialchars( $_REQUEST['text_thisweek'], 1 );
3927
- $set->text_thismonth = wp_specialchars( $_REQUEST['text_thismonth'], 1 );
3928
- $set->text_rated = wp_specialchars( $_REQUEST['text_rated'], 1 );
3929
- $set->text_noratings = wp_specialchars( $_REQUEST['text_noratings'], 1 );
3930
-
3931
-
3932
- $set->popup = 'off';
3933
- if( isset( $_REQUEST['polldaddy-rating-popup'] ) )
3934
- $set->popup = ( $_REQUEST['polldaddy-rating-popup'] == 'on' ? 'on' : 'off' );
3935
-
3936
- $settings_text = json_encode( $set );
3937
-
3938
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
3939
- $polldaddy->reset();
3940
- $rating = $polldaddy->update_rating( $rating_id, $settings_text, $rating_type );
3941
- }
3942
- else if( $this->is_admin && $new_rating_id > 0 ){
3943
- switch( $type ){
3944
- case 'pages':
3945
- update_option( 'pd-rating-pages-id', $new_rating_id );
3946
- if( (int) get_option( 'pd-rating-pages' ) > 0 )
3947
- update_option( 'pd-rating-pages', $new_rating_id );
3948
- break;
3949
- case 'comments':
3950
- update_option( 'pd-rating-comments-id', $new_rating_id );
3951
- if( (int) get_option( 'pd-rating-comments' ) > 0 )
3952
- update_option( 'pd-rating-comments', $new_rating_id );
3953
- break;
3954
- case 'posts':
3955
- update_option( 'pd-rating-posts-id', $new_rating_id );
3956
- if( (int) get_option( 'pd-rating-posts' ) > 0 )
3957
- update_option( 'pd-rating-posts', $new_rating_id );
3958
- }
3959
- }
3960
-
3961
- if( $this->is_admin ) {
3962
- if( $type=='posts' && isset( $_REQUEST['exclude-post-ids'] ) ) {
3963
- $exclude_post_ids = $_REQUEST['exclude-post-ids'];
3964
- if( empty( $exclude_post_ids ) ){
3965
- update_option( 'pd-rating-exclude-post-ids', '' );
3966
- } else{
3967
- $post_ids = array();
3968
- $ids = explode( ',', $exclude_post_ids );
3969
- if( !empty( $ids ) ){
3970
- foreach( (array) $ids as $id ){
3971
- if( (int) $id > 0 )
3972
- $post_ids[] = (int) $id;
3973
- }
3974
- }
3975
- if( !empty( $post_ids ) ){
3976
- $exclude_post_ids = implode( ',', $post_ids );
3977
- update_option( 'pd-rating-exclude-post-ids', $exclude_post_ids );
3978
- }
3979
- }
3980
- }
3981
-
3982
- if( $type=='pages' && isset( $_REQUEST['exclude-page-ids'] ) ) {
3983
- $exclude_page_ids = $_REQUEST['exclude-page-ids'];
3984
- if( empty( $exclude_page_ids ) ){
3985
- update_option( 'pd-rating-exclude-page-ids', '' );
3986
- } else{
3987
- $page_ids = array();
3988
- $ids = explode( ',', $exclude_page_ids );
3989
- if( !empty( $ids ) ){
3990
- foreach( (array) $ids as $id ){
3991
- if( (int) $id > 0 )
3992
- $page_ids[] = (int) $id;
3993
- }
3994
- }
3995
- if( !empty( $page_ids ) ){
3996
- $exclude_page_ids = implode( ',', $page_ids );
3997
- update_option( 'pd-rating-exclude-page-ids', $exclude_page_ids );
3998
- }
3999
- }
4000
- }
4001
- }
4002
- }
4003
- function rating_reports() {
4004
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
4005
- $rating_id = get_option( 'pd-rating-posts-id' );
4006
-
4007
- $report_type = 'posts';
4008
- $period = '7';
4009
- $show_rating = 0;
4010
-
4011
- if ( isset( $_REQUEST['change-report-to'] ) ){
4012
- switch ( $_REQUEST['change-report-to'] ) :
4013
- case 'pages':
4014
- $report_type = 'pages';
4015
- $rating_id = (int) get_option( 'pd-rating-pages-id' );
4016
- break;
4017
-
4018
- case 'comments':
4019
- $report_type = 'comments';
4020
- $rating_id = get_option( 'pd-rating-comments-id' );
4021
- break;
4022
-
4023
- case 'posts':
4024
- $report_type = 'posts';
4025
- $rating_id = get_option( 'pd-rating-posts-id' );
4026
- break;
4027
- endswitch;
4028
- }
4029
-
4030
- if ( isset( $_REQUEST['filter'] ) && $_REQUEST['filter'] ){
4031
- switch ( $_REQUEST['filter'] ) :
4032
- case '1':
4033
- $period = '1';
4034
- break;
4035
 
4036
- case '7':
4037
- $period = '7';
4038
- break;
 
 
 
4039
 
4040
- case '31':
4041
- $period = '31';
4042
- break;
4043
 
4044
- case '90':
4045
- $period = '90';
4046
- break;
 
 
 
 
 
 
 
 
 
 
 
4047
 
4048
- case '365':
4049
- $period = '365';
4050
- break;
 
 
 
 
 
 
 
 
 
4051
 
4052
- case 'all':
4053
- $period = 'all';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4054
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4055
  endswitch;
4056
  }
4057
 
4058
- $page_size = 15;
4059
  $current_page = 1;
4060
 
4061
- if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'change-report' ){
4062
  $current_page = 1;
4063
  } else {
4064
  if ( isset( $_REQUEST['paged'] ) ) {
@@ -4071,28 +4078,28 @@ class WP_PollDaddy {
4071
  $start = ( $current_page * $page_size ) - $page_size;
4072
  $end = $page_size;
4073
 
4074
- $response = $polldaddy->get_rating_results( $rating_id, $period, $start, $end );
4075
-
4076
- $total = $total_pages = 0;
4077
- $ratings = null;
4078
-
4079
- if( !empty($response) ){
4080
- $ratings = $response->rating;
4081
- $total = (int) $response->_total;
4082
- $total_pages = ceil( $total / $page_size );
4083
- }
4084
-
4085
  $page_links = paginate_links( array(
4086
- 'base' => add_query_arg( array ('paged' => '%#%', 'change-report-to' => $report_type, 'filter' => $period ) ),
4087
- 'format' => '',
4088
- 'prev_text' => __('&laquo;', 'polldaddy'),
4089
- 'next_text' => __('&raquo;', 'polldaddy'),
4090
- 'total' => $total_pages,
4091
- 'current' => $current_page
4092
- ));
4093
- ?>
4094
  <div class="wrap">
4095
- <h2><?php _e('Rating Reports', 'polldaddy');?> <span style="font-size: 16px;">(<?php echo ( $report_type ); ?>)</span></h2>
4096
  <div class="clear"></div>
4097
  <form method="post" action="admin.php?page=ratings&action=reports">
4098
  <div class="tablenav">
@@ -4105,57 +4112,57 @@ class WP_PollDaddy {
4105
  <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
4106
  <?php wp_nonce_field( 'action-rating_bulk' ); ?>
4107
  <select name="change-report-to"><?php
4108
- $select = array( __('Posts', 'polldaddy') => "posts", __('Pages', 'polldaddy') => "pages", __('Comments', 'polldaddy') => "comments" );
4109
- foreach ( $select as $option => $value ) :
4110
- $selected = '';
4111
- if ( $value == $report_type )
4112
- $selected = ' selected="selected"';?>
4113
  <option value="<?php echo $value; ?>" <?php echo $selected; ?>><?php echo $option; ?></option>
4114
  <?php endforeach; ?>
4115
  </select>
4116
  <select name="filter"><?php
4117
- $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" );
4118
  foreach ( $select as $option => $value ) :
4119
  $selected = '';
4120
- if ( $value == $period )
4121
- $selected = ' selected="selected"';?>
4122
  <option value="<?php echo $value; ?>" <?php echo $selected; ?>><?php echo $option; ?></option>
4123
  <?php endforeach; ?>
4124
  </select>
4125
- <input class="button-secondary action" type="submit" value="<?php _e('Filter', 'polldaddy');?>" />
4126
  </div>
4127
  <div class="alignright">
4128
  <div class="tablenav-pages">
4129
- <?php echo( $page_links ); ?>
4130
- </div>
4131
  </div>
4132
  </div>
4133
 
4134
  <table class="widefat"><?php
4135
- if ( empty( $ratings ) ) { ?>
4136
  <tbody>
4137
  <tr>
4138
- <td colspan="4"><?php printf(__('No ratings have been collected for your %s yet.', 'polldaddy'), $report_type); ?></td>
4139
  </tr>
4140
  </tbody><?php
4141
- } else { ?>
4142
  <thead>
4143
  <tr>
4144
  <th scope="col" class="manage-column column-cb check-column" id="cb"><input type="checkbox"></th>
4145
- <th scope="col" class="manage-column column-title" id="title"><?php _e('Title', 'polldaddy');?></th>
4146
- <th scope="col" class="manage-column column-id" id="id"><?php _e('Unique ID', 'polldaddy');?></th>
4147
- <th scope="col" class="manage-column column-date" id="date"><?php _e('Start Date', 'polldaddy');?></th>
4148
- <th scope="col" class="manage-column column-vote num" id="votes"><?php _e('Votes', 'polldaddy');?></th>
4149
- <th scope="col" class="manage-column column-rating num" id="rating"><?php _e('Average Rating', 'polldaddy');?></th>
4150
  </tr>
4151
  </thead>
4152
  <tbody><?php
4153
- $alt_counter = 0;
4154
- $alt = '';
4155
 
4156
- foreach ( $ratings as $rating ) :
4157
- $delete_link = clean_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" ) );
4158
- $alt_counter++;?>
4159
  <tr <?php echo ( $alt_counter & 1 ) ? ' class="alternate"' : ''; ?>>
4160
  <th class="check-column" scope="row"><input type="checkbox" value="<?php echo wp_specialchars( $rating->uid ); ?>" name="rating[]" /></th>
4161
  <td class="post-title column-title">
@@ -4170,42 +4177,42 @@ class WP_PollDaddy {
4170
  <?php echo wp_specialchars( $rating->uid ); ?>
4171
  </td>
4172
  <td class="date column-date">
4173
- <abbr title="<?php echo date( __('Y/m/d g:i:s A', 'polldaddy'), $rating->date ); ?>"><?php echo str_replace( '-', '/', substr( wp_specialchars( $rating->date ), 0, 10 ) ); ?></abbr>
4174
  </td>
4175
  <td class="column-vote num"><?php echo number_format( $rating->_votes ); ?></td>
4176
  <td class="column-rating num"><table width="100%"><tr align="center"><td style="border:none;"><?php
4177
- if ( $rating->_type == 0 ) {
4178
- $avg_rating = $this->round( $rating->average_rating, 0.5 );?>
4179
  <div style="width:100px"><?php
4180
- $image_pos = '';
4181
-
4182
- for ( $c = 1; $c <= 5; $c++ ) :
4183
- if ( $avg_rating > 0 ) {
4184
- if ( $avg_rating < $c )
4185
- $image_pos = 'bottom left';
4186
- if ( $avg_rating == ( $c - 1 + 0.5 ) )
4187
- $image_pos = 'center left';
4188
- } ?>
4189
- <div style="width: 20px; height: 20px; background: url(http://i.polldaddy.com/ratings/images/star-yellow-med.png) <?php echo $image_pos; ?>; float: left;"></div><?php
4190
- endfor; ?>
4191
  <br class="clear" />
4192
- </div><?php
4193
- } else { ?>
4194
  <div>
4195
  <div style="margin: 0px 0px 0px 20px; background: transparent url(http://i.polldaddy.com/images/rate-graph-up.png); width: 20px; height: 20px; float: left;"></div>
4196
- <div style="float:left; line-height: 20px; padding: 0px 10px 0px 5px;"><?php echo number_format ( $rating->total1 );?></div>
4197
  <div style="margin: 0px; background: transparent url(http://i.polldaddy.com/images/rate-graph-dn.png); width: 20px; height: 20px; float: left;"></div>
4198
  <div style="float:left; line-height: 20px; padding: 0px 10px 0px 5px;"><?php echo number_format( $rating->total2 );?></div>
4199
  <br class="clear" />
4200
- </div><?php
4201
- } ?>
4202
  </td></tr></table>
4203
  </td>
4204
- </tr><?php
4205
- endforeach;
4206
- ?>
4207
- </tbody><?php
4208
- } ?>
4209
  </table>
4210
  <div class="tablenav">
4211
  <div class="alignright">
@@ -4214,114 +4221,114 @@ class WP_PollDaddy {
4214
  </div>
4215
  </div>
4216
  </div>
4217
- </form>
4218
  </div>
4219
  <p></p>
4220
  <script language="javascript">
4221
- jQuery( document ).ready(function(){
4222
  plugin = new Plugin( {
4223
- delete_rating: '<?php _e( 'Are you sure you want to delete the rating for "%s"?','polldaddy'); ?>',
4224
- delete_poll: '<?php _e( 'Are you sure you want to delete "%s"?','polldaddy'); ?>',
4225
- delete_answer: '<?php _e( 'Are you sure you want to delete this answer?','polldaddy'); ?>',
4226
- delete_answer_title: '<?php _e( 'delete this answer','polldaddy'); ?>',
4227
- standard_styles: '<?php _e( 'Standard Styles','polldaddy'); ?>',
4228
- custom_styles: '<?php _e( 'Custom Styles','polldaddy'); ?>'
4229
  } );
4230
  });
4231
  </script><?php
4232
  }
4233
-
4234
  function plugin_options() {
4235
- if ( isset( $_POST['polldaddy_email'] ) ){
4236
- $account_email = attribute_escape( $_POST['polldaddy_email'] );
4237
- }
4238
- else{
4239
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
4240
- $account = $polldaddy->get_account();
4241
-
4242
- if( !empty($account) )
4243
- $account_email = attribute_escape( $account->email );
4244
-
4245
- $polldaddy->reset();
4246
- $poll = $polldaddy->get_poll( 1 );
4247
-
4248
- $options = array(
4249
- 101 => __( 'Aluminum Narrow','polldaddy'),
4250
- 102 => __( 'Aluminum Medium','polldaddy'),
4251
- 103 => __( 'Aluminum Wide','polldaddy'),
4252
- 104 => __( 'Plain White Narrow','polldaddy'),
4253
- 105 => __( 'Plain White Medium','polldaddy'),
4254
- 106 => __( 'Plain White Wide','polldaddy'),
4255
- 107 => __( 'Plain Black Narrow','polldaddy'),
4256
- 108 => __( 'Plain Black Medium','polldaddy'),
4257
- 109 => __( 'Plain Black Wide','polldaddy'),
4258
- 110 => __( 'Paper Narrow','polldaddy'),
4259
- 111 => __( 'Paper Medium','polldaddy'),
4260
- 112 => __( 'Paper Wide','polldaddy'),
4261
- 113 => __( 'Skull Dark Narrow','polldaddy'),
4262
- 114 => __( 'Skull Dark Medium','polldaddy'),
4263
- 115 => __( 'Skull Dark Wide','polldaddy'),
4264
- 116 => __( 'Skull Light Narrow','polldaddy'),
4265
- 117 => __( 'Skull Light Medium','polldaddy'),
4266
- 118 => __( 'Skull Light Wide','polldaddy'),
4267
- 157 => __( 'Micro','polldaddy'),
4268
- 119 => __( 'Plastic White Narrow','polldaddy'),
4269
- 120 => __( 'Plastic White Medium','polldaddy'),
4270
- 121 => __( 'Plastic White Wide','polldaddy'),
4271
- 122 => __( 'Plastic Grey Narrow','polldaddy'),
4272
- 123 => __( 'Plastic Grey Medium','polldaddy'),
4273
- 124 => __( 'Plastic Grey Wide','polldaddy'),
4274
- 125 => __( 'Plastic Black Narrow','polldaddy'),
4275
- 126 => __( 'Plastic Black Medium','polldaddy'),
4276
- 127 => __( 'Plastic Black Wide','polldaddy'),
4277
- 128 => __( 'Manga Narrow','polldaddy'),
4278
- 129 => __( 'Manga Medium','polldaddy'),
4279
- 130 => __( 'Manga Wide','polldaddy'),
4280
- 131 => __( 'Tech Dark Narrow','polldaddy'),
4281
- 132 => __( 'Tech Dark Medium','polldaddy'),
4282
- 133 => __( 'Tech Dark Wide','polldaddy'),
4283
- 134 => __( 'Tech Grey Narrow','polldaddy'),
4284
- 135 => __( 'Tech Grey Medium','polldaddy'),
4285
- 136 => __( 'Tech Grey Wide','polldaddy'),
4286
- 137 => __( 'Tech Light Narrow','polldaddy'),
4287
- 138 => __( 'Tech Light Medium','polldaddy'),
4288
- 139 => __( 'Tech Light Wide','polldaddy'),
4289
- 140 => __( 'Working Male Narrow','polldaddy'),
4290
- 141 => __( 'Working Male Medium','polldaddy'),
4291
- 142 => __( 'Working Male Wide','polldaddy'),
4292
- 143 => __( 'Working Female Narrow','polldaddy'),
4293
- 144 => __( 'Working Female Medium','polldaddy'),
4294
- 145 => __( 'Working Female Wide','polldaddy'),
4295
- 146 => __( 'Thinking Male Narrow','polldaddy'),
4296
- 147 => __( 'Thinking Male Medium','polldaddy'),
4297
- 148 => __( 'Thinking Male Wide','polldaddy'),
4298
- 149 => __( 'Thinking Female Narrow','polldaddy'),
4299
- 150 => __( 'Thinking Female Medium','polldaddy'),
4300
- 151 => __( 'Thinking Female Wide','polldaddy'),
4301
- 152 => __( 'Sunset Narrow','polldaddy'),
4302
- 153 => __( 'Sunset Medium','polldaddy'),
4303
- 154 => __( 'Sunset Wide','polldaddy'),
4304
- 155 => __( 'Music Medium','polldaddy'),
4305
- 156 => __( 'Music Wide','polldaddy')
4306
- );
4307
-
4308
- $polldaddy->reset();
4309
- $styles = $polldaddy->get_styles();
4310
-
4311
- if( !empty( $styles ) && !empty( $styles->style ) && count( $styles->style ) > 0 ){
4312
- foreach( (array) $styles->style as $style ){
4313
- $options[ (int) $style->_id ] = $style->title;
4314
- }
4315
- }
4316
- }
4317
- $this->print_errors();
4318
- ?>
4319
  <div id="options-page" class="wrap">
4320
  <div class="icon32" id="icon-options-general"><br/></div>
4321
  <h2>
4322
  <?php _e( 'Options', 'polldaddy' ); ?>
4323
  </h2>
4324
- <?php if( $this->is_admin || $this->multiple_accounts ) {?>
4325
  <h3>
4326
  <?php _e( 'PollDaddy Account Info', 'polldaddy' ); ?>
4327
  </h3>
@@ -4377,61 +4384,61 @@ class WP_PollDaddy {
4377
  <td>
4378
  <fieldset>
4379
  <legend class="screen-reader-text"><span>poll-defaults</span></legend><?php
4380
- $selected = '';
4381
- if ( $poll->multipleChoice == 'yes' )
4382
- $selected = 'checked="checked"';?>
4383
  <label for="multipleChoice"><input type="checkbox" <?php echo $selected; ?> value="1" id="multipleChoice" name="multipleChoice"> <?php _e( 'Multiple Choice', 'polldaddy' ); ?></label>
4384
  <br /><?php
4385
- $selected = '';
4386
- if ( $poll->randomiseAnswers == 'yes' )
4387
- $selected = 'checked="checked"';?>
4388
  <label for="randomiseAnswers"><input type="checkbox" <?php echo $selected; ?> value="1" id="randomiseAnswers" name="randomiseAnswers"> <?php _e( 'Randomise Answers', 'polldaddy' ); ?></label>
4389
  <br /><?php
4390
- $selected = '';
4391
- if ( $poll->otherAnswer == 'yes' )
4392
- $selected = 'checked="checked"';?>
4393
  <label for="otherAnswer"><input type="checkbox" <?php echo $selected; ?> value="1" id="otherAnswer" name="otherAnswer"> <?php _e( 'Other Answer', 'polldaddy' ); ?></label>
4394
  <br /><?php
4395
- $selected = '';
4396
- if ( $poll->sharing == 'yes' )
4397
- $selected = 'checked="checked"';?>
4398
  <label for="sharing"><input type="checkbox" <?php echo $selected; ?> value="1" id="sharing" name="sharing"> <?php _e( 'Sharing', 'polldaddy' ); ?></label>
4399
  <br />
4400
  <label for="resultsType">
4401
  <select id="resultsType" name="resultsType">
4402
- <option <?php echo $poll->resultsType == 'show' ? 'selected="selected"':''; ?> value="show"><?php _e('Show', 'polldaddy'); ?></option>
4403
- <option <?php echo $poll->resultsType == 'hide' ? 'selected="selected"':''; ?> value="hide"><?php _e('Hide', 'polldaddy'); ?></option>
4404
- <option <?php echo $poll->resultsType == 'percent' ? 'selected="selected"':''; ?> value="percent"><?php _e('Percentages', 'polldaddy'); ?></option>
4405
  </select> <?php _e( 'Poll results', 'polldaddy' ); ?>
4406
  </label>
4407
  <br />
4408
  <label for="styleID">
4409
- <select id="styleID" name="styleID"><?php
4410
- foreach ( (array) $options as $styleID => $label ) :
4411
- $selected = $styleID == $poll->styleID ? ' selected="selected"' : ''; ?>
4412
- <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option><?php
4413
- endforeach;?>
4414
  </select> <?php _e( 'Poll style', 'polldaddy' ); ?>
4415
  </label>
4416
  <br />
4417
  <label for="blockRepeatVotersType">
4418
  <select id="poll-block-repeat" name="blockRepeatVotersType">
4419
- <option <?php echo $poll->blockRepeatVotersType == 'off' ? 'selected="selected"':''; ?> value="off"><?php _e('Off', 'polldaddy'); ?></option>
4420
- <option <?php echo $poll->blockRepeatVotersType == 'cookie' ? 'selected="selected"':''; ?> value="cookie"><?php _e('Cookie', 'polldaddy'); ?></option>
4421
- <option <?php echo $poll->blockRepeatVotersType == 'cookieip' ? 'selected="selected"':''; ?> value="cookieip"><?php _e('Cookie & IP address', 'polldaddy'); ?></option>
4422
  </select> <?php _e( 'Block repeat voters', 'polldaddy' ); ?>
4423
  </label>
4424
  <br />
4425
  <label for="blockExpiration">
4426
  <select id="blockExpiration" name="blockExpiration">
4427
- <option value="0" <?php echo $poll->blockExpiration == 0 ? 'selected="selected"':''; ?>><?php _e('Never', 'polldaddy'); ?></option>
4428
- <option value="3600" <?php echo $poll->blockExpiration == 3600 ? 'selected="selected"':''; ?>><?php printf( __('%d hour', 'polldaddy'), 1 ); ?></option>
4429
- <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 3 ); ?></option>
4430
- <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 6 ); ?></option>
4431
- <option value="43200" <?php echo (int) $poll->blockExpiration == 43200 ? 'selected="selected"' : ''; ?>><?php printf( __('%d hours', 'polldaddy'), 12 ); ?></option>
4432
- <option value="86400" <?php echo (int) $poll->blockExpiration == 86400 ? 'selected="selected"' : ''; ?>><?php printf( __('%d day', 'polldaddy'), 1 ); ?></option>
4433
- <option value="604800" <?php echo (int) $poll->blockExpiration == 604800 ? 'selected="selected"' : ''; ?>><?php printf( __('%d week', 'polldaddy'), 1 ); ?></option>
4434
- <option value="2419200" <?php echo (int) $poll->blockExpiration == 2419200 ? 'selected="selected"' : ''; ?>><?php printf( __('%d month', 'polldaddy'), 1 ); ?></option>
4435
  </select> <?php _e( 'Block expiration limit', 'polldaddy' ); ?>
4436
  </label>
4437
  <br />
@@ -4449,26 +4456,32 @@ class WP_PollDaddy {
4449
  </form>
4450
  </div>
4451
  <?php
4452
- }
4453
-
4454
- function plugin_options_add(){}
4455
 
4456
- function round($number, $increments) {
4457
  $increments = 1 / $increments;
4458
- return ( round ( $number * $increments ) / $increments );
4459
- }
4460
 
4461
  function signup() {
4462
  return $this->api_key_page();
4463
  }
4464
 
4465
- function can_edit( &$poll ) {
4466
- if ( empty( $poll->_owner ) )
4467
  return true;
4468
-
4469
  if ( $this->id == $poll->_owner )
4470
  return true;
4471
 
 
 
 
 
 
 
4472
  return (bool) current_user_can( 'edit_others_posts' );
4473
  }
4474
  }
2
 
3
  /*
4
  Plugin Name: PollDaddy Polls
5
+ Plugin URI: http://wordpress.org/extend/plugins/polldaddy/
6
  Description: Create and manage PollDaddy polls and ratings in WordPress
7
  Author: Automattic, Inc.
8
  Author URL: http://automattic.com/
9
+ Version: 1.8.10
10
  */
11
 
12
  // You can hardcode your PollDaddy PartnerGUID (API Key) here
18
  var $is_admin;
19
  var $is_author;
20
  var $scheme;
21
+ var $version;
22
  var $polldaddy_client_class;
23
  var $polldaddy_clients;
24
  var $id;
25
  var $multiple_accounts;
26
  var $user_code;
27
  var $rating_user_code;
28
+
29
+ function WP_PollDaddy() {
30
+ $this ->__construct();
31
+ }
32
+
33
+ function __construct() {
34
+ global $current_user;
35
+ $this->errors = new WP_Error;
36
+ $this->scheme = 'https';
37
+ $this->version = '1.8.10';
38
+ $this->multiple_accounts = true;
39
+ $this->polldaddy_client_class = 'api_client';
40
+ $this->polldaddy_clients = array();
41
+ $this->is_admin = (bool) current_user_can( 'manage_options' );
42
  $this->is_author = true;
43
+ $this->id = (int) $current_user->ID;
44
+ $this->user_code = null;
45
+ $this->rating_user_code = null;
46
+ }
47
+
48
  function &get_client( $api_key, $userCode = null ) {
49
  if ( isset( $this->polldaddy_clients[$api_key] ) ) {
50
+ if ( !is_null( $userCode ) )
51
  $this->polldaddy_clients[$api_key]->userCode = $userCode;
52
  return $this->polldaddy_clients[$api_key];
53
  }
55
  $this->polldaddy_clients[$api_key] = $this->config_client( new $this->polldaddy_client_class( $api_key, $userCode ) );
56
  return $this->polldaddy_clients[$api_key];
57
  }
 
 
 
 
58
 
59
+ function config_client( $client ) {
60
+ return $client;
61
+ }
62
+
63
+ function admin_menu() {
64
  if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
65
  $guid = get_option( 'polldaddy_api_key' );
66
  if ( !$guid || !is_string( $guid ) )
67
  $guid = false;
68
  define( 'WP_POLLDADDY__PARTNERGUID', $guid );
69
  }
70
+
71
+ if ( !WP_POLLDADDY__PARTNERGUID ) {
72
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
73
+ $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
74
+ else
75
+ $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'api_key_page' ) );
76
+
77
+ add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
78
+
79
+ if ( function_exists( 'add_object_page' ) ) // WP 2.7+
80
+ $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
81
+ else
82
+ $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
83
+
84
+ add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
85
  if ( ( empty( $_GET['page'] ) || 'polls' != $_GET['page'] ) && ( empty( $_GET['page'] ) || 'ratings' != $_GET['page'] ) )
86
  add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "You need to <a href=\"%s\">input your PollDaddy.com account details</a>.", "edit.php?page=polls" ) . "</p></div>";' ) );
87
  return false;
88
+ }
89
+
90
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
91
  $hook = add_object_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
92
  else
93
  $hook = add_management_page( __( 'Ratings', 'polldaddy' ), __( 'Ratings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
94
+
95
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
96
 
97
  if ( function_exists( 'add_object_page' ) ) // WP 2.7+
98
  $hook = add_object_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
99
  else
100
  $hook = add_management_page( __( 'Polls', 'polldaddy' ), __( 'Polls', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
101
+
102
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
103
+
104
+ if ( $this->is_admin ) {
105
+ add_submenu_page( 'ratings', __( 'Ratings &ndash; Settings', 'polldaddy' ), __( 'Settings', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
106
+ add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings&amp;action=reports', array( &$this, 'management_page' ) );
107
  }
108
+ else {
109
+ add_submenu_page( 'ratings', __( 'Ratings &ndash; Reports', 'polldaddy' ), __( 'Reports', 'polldaddy' ), 'edit_posts', 'ratings', array( &$this, 'management_page' ) );
110
+ }
111
+
112
  add_submenu_page( 'polls', __( 'Polls', 'polldaddy' ), __( 'Edit', 'polldaddy' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
113
+
114
+ if ( $this->is_author ) {
115
+ add_submenu_page( 'polls', __( 'Add New Poll', 'polldaddy' ), __( 'Add New', 'polldaddy' ), 'edit_posts', 'polls&amp;action=create-poll', array( &$this, 'management_page' ) );
116
+ add_submenu_page( 'polls', __( 'Custom Styles', 'polldaddy' ), __( 'Custom Styles', 'polldaddy' ), 'edit_posts', 'polls&amp;action=list-styles', array( &$this, 'management_page' ) );
117
+ add_submenu_page( 'polls', __( 'Options', 'polldaddy' ), __( 'Options', 'polldaddy' ), 'edit_posts', 'polls&amp;action=options', array( &$this, 'management_page' ) );
118
+ }
119
 
120
  add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
121
  }
122
 
123
+ function api_key_page_load() {
124
  if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
125
  return false;
126
 
138
  if ( $this->errors->get_error_codes() )
139
  return false;
140
 
141
+ $details = array(
142
  'uName' => get_bloginfo( 'name' ),
143
  'uEmail' => $polldaddy_email,
144
  'uPass' => $polldaddy_password,
146
  );
147
  if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
148
  $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
149
+ 'body' => $details
150
+ ) );
151
  if ( is_wp_error( $polldaddy_api_key ) ) {
152
  $this->errors = $polldaddy_api_key;
153
  return false;
177
  $request = "POST /key.php HTTP/1.0\r\n";
178
  $request .= "Host: api.polldaddy.com\r\n";
179
  $request .= "User-agent: WordPress/$wp_version\r\n";
180
+ $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ) . "\r\n";
181
  $request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
182
 
183
  fwrite( $fp, "$request\r\n$request_body" );
186
  while ( !feof( $fp ) )
187
  $response .= fread( $fp, 4096 );
188
  fclose( $fp );
189
+ list( $headers, $polldaddy_api_key ) = explode( "\r\n\r\n", $response, 2 );
190
  }
191
 
192
  if ( !$polldaddy_api_key ) {
211
  if ( $polldaddy->errors )
212
  foreach ( $polldaddy->errors as $code => $error )
213
  $this->errors->add( $code, $error );
214
+ if ( isset( $this->errors->errors[4] ) ) {
215
+ $this->errors->errors[4] = array( sprintf( __( 'Obsolete PollDaddy User API Key: <a href="%s">Sign in again to re-authenticate</a>', 'polldaddy' ), add_query_arg( array( 'action' => 'signup', 'reaction' => empty( $_GET['action'] ) ? false : $_GET['action'] ) ) ) );
216
+ $this->errors->add_data( true, 4 );
217
+ }
218
  }
219
 
220
  function print_errors() {
235
  <?php
236
  endforeach;
237
  endforeach;
238
+
239
  $this->errors = new WP_Error;
240
  ?>
241
 
246
  }
247
 
248
  function api_key_page() {
249
+ $this->print_errors();
250
  ?>
251
 
252
  <div class="wrap">
292
  $title = __( 'Add Poll', 'polldaddy' );
293
  echo "<a href='admin.php?page=polls&amp;iframe&amp;TB_iframe=true' onclick='return false;' id='add_poll' class='thickbox' title='$title'><img src='{$this->base_url}polldaddy.png' alt='$title' /></a>";
294
  }
295
+
296
+ function set_api_user_code() {
297
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
298
  $polldaddy->reset();
299
+
300
+ if ( empty( $this->user_code ) ) {
301
+ $this->user_code = $polldaddy->get_usercode( $this->id );
302
+ }
303
+ }
304
+
305
+ function management_page_load() {
306
  wp_reset_vars( array( 'page', 'action', 'poll', 'style', 'rating', 'id' ) );
307
+ global $plugin_page, $page, $action, $poll, $style, $rating, $id, $wp_locale;
308
+
309
+ $this->set_api_user_code();
310
 
311
+ if ( empty( $this->user_code ) && $page == 'polls' ) {
312
+ $action = 'signup';
313
+ }
314
 
315
  require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
316
 
317
  wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version );
318
  wp_enqueue_script( 'polls-common', "{$this->base_url}common.js", array(), $this->version );
319
+
320
+ if ( $page == 'polls' ) {
321
+ if ( !$this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles', 'options', 'update-options', 'import-account' ) ) ) {//check user privileges has access to action
322
+ $action = '';
323
+ }
324
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  switch ( $action ) :
326
+ case 'edit' :
327
+ case 'edit-poll' :
328
+ case 'create-poll' :
329
+ wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/poll-style-picker.js", array(), $this->version );
330
+
331
+ if ( $action == 'create-poll' )
332
+ $plugin_page = 'polls&amp;action=create-poll';
333
+
334
+ break;
335
+ case 'edit-style' :
336
+ case 'create-style' :
337
+ wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/style-editor.js", array(), $this->version );
338
+ wp_enqueue_script( 'polls-style-color', "http://i.polldaddy.com/js/jquery/jscolor.js", array(), $this->version );
339
+ wp_enqueue_style( 'polls', "{$this->base_url}style-editor.css", array(), $this->version );
340
+ $plugin_page = 'polls&amp;action=list-styles';
341
+ break;
342
+ case 'list-styles' :
343
+ $plugin_page = 'polls&amp;action=list-styles';
344
+ break;
345
+ case 'options' :
346
+ case 'update-options' :
347
+ case 'import-account' :
348
+ $plugin_page = 'polls&amp;action=options';
349
+ break;
350
+ endswitch;
351
+ } elseif ( $page == 'ratings' ) {
352
+ if ( !$this->is_admin && !in_array( $action, array( 'reports', 'delete' ) ) ) {//check user privileges has access to action
353
+ $action = 'reports';
354
+ }
355
+ switch ( $action ) :
356
  case 'delete' :
357
  case 'reports' :
358
  $plugin_page = 'ratings&amp;action=reports';
359
+ break;
360
+ default :
361
+ wp_enqueue_script( 'rating-text-color', "http://i.polldaddy.com/js/jquery/jscolor.js", array(), $this->version );
362
+ wp_enqueue_script( 'ratings', 'http://i.polldaddy.com/ratings/rating.js', array(), $this->version );
363
+ wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
364
  'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
365
+ 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
366
  endswitch;
367
+ }
368
+
369
  wp_enqueue_script( 'admin-forms' );
370
  add_thickbox();
371
 
372
  wp_enqueue_style( 'polls', "{$this->base_url}polldaddy.css", array( 'global', 'wp-admin' ), $this->version );
373
+ if ( isset( $wp_locale->text_direction ) && 'rtl' == $wp_locale->text_direction )
374
  wp_enqueue_style( 'polls-rtl', "{$this->base_url}polldaddy-rtl.css", array( 'global', 'wp-admin' ), $this->version );
375
  add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
376
 
378
 
379
  $query_args = array();
380
  $args = array();
381
+
382
  $allowedtags = array(
383
  'a' => array(
384
  'href' => array (),
385
  'title' => array (),
386
+ 'target' => array () ),
387
  'img' => array(
388
  'alt' => array (),
389
  'align' => array (),
394
  'longdesc' => array (),
395
  'vspace' => array (),
396
  'src' => array (),
397
+ 'width' => array () ),
398
  'abbr' => array(
399
+ 'title' => array () ),
400
  'acronym' => array(
401
+ 'title' => array () ),
402
  'b' => array(),
403
  'blockquote' => array(
404
+ 'cite' => array () ),
405
  'cite' => array (),
406
+ 'em' => array (),
407
  'i' => array (),
408
+ 'q' => array(
409
+ 'cite' => array () ),
410
  'strike' => array(),
411
  'strong' => array()
412
  );
413
 
414
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
415
 
416
+ if ( $page == 'polls' ) {
417
  switch ( $action ) :
418
  case 'signup' : // sign up for first time
419
  case 'account' : // reauthenticate
420
  case 'import-account' : // reauthenticate
421
  if ( !$is_POST )
422
+ return;
423
 
424
  check_admin_referer( 'polldaddy-account' );
425
 
427
  $query_args = array_merge( $query_args, $new_args );
428
  if ( $this->errors->get_error_codes() )
429
  return false;
430
+
431
  $query_args['message'] = 'imported-account';
432
+
433
  wp_reset_vars( array( 'action' ) );
434
  if ( !empty( $_GET['reaction'] ) )
435
  $query_args['action'] = $_GET['reaction'];
438
  else
439
  $query_args['action'] = false;
440
  break;
441
+
442
  case 'delete' :
443
  if ( empty( $poll ) )
444
  return;
445
+
446
  if ( is_array( $poll ) )
447
  check_admin_referer( 'action-poll_bulk' );
448
  else
449
  check_admin_referer( "delete-poll_$poll" );
450
+
451
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
452
+
453
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
454
  $polldaddy->reset();
455
  $poll_object = $polldaddy->get_poll( $poll );
456
+
457
  if ( !$this->can_edit( $poll_object ) ) {
458
  $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.', 'polldaddy' ) );
459
  return false;
460
  }
461
+
462
  // Send Poll Author credentials
463
  if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
464
  $polldaddy->reset();
465
+ if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
466
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
467
  }
468
  $polldaddy->userCode = $userCode;
469
  }
470
+
471
  $polldaddy->reset();
472
  $polldaddy->delete_poll( $poll_id );
473
  }
474
+
475
  $query_args['message'] = 'deleted';
476
  $query_args['deleted'] = count( (array) $poll );
477
  break;
478
  case 'open' :
479
  if ( empty( $poll ) )
480
  return;
481
+
482
  if ( is_array( $poll ) )
483
  check_admin_referer( 'action-poll_bulk' );
484
  else
485
  check_admin_referer( "open-poll_$poll" );
486
+
487
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
488
+
489
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
490
  $polldaddy->reset();
491
  $poll_object = $polldaddy->get_poll( $poll );
492
+
493
  if ( !$this->can_edit( $poll_object ) ) {
494
  $this->errors->add( 'permission', __( 'You are not allowed to open this poll.', 'polldaddy' ) );
495
  return false;
496
  }
497
+
498
  // Send Poll Author credentials
499
  if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
500
  $polldaddy->reset();
501
+ if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
502
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
503
  }
504
  $polldaddy->userCode = $userCode;
505
  }
506
+
507
  $polldaddy->reset();
508
  $polldaddy->open_poll( $poll_id );
509
  }
510
+
511
  $query_args['message'] = 'opened';
512
  $query_args['opened'] = count( (array) $poll );
513
  break;
514
  case 'close' :
515
  if ( empty( $poll ) )
516
  return;
517
+
518
  if ( is_array( $poll ) )
519
  check_admin_referer( 'action-poll_bulk' );
520
  else
521
  check_admin_referer( "close-poll_$poll" );
522
+
523
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
524
+
525
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
526
  $polldaddy->reset();
527
  $poll_object = $polldaddy->get_poll( $poll );
528
+
529
  if ( !$this->can_edit( $poll_object ) ) {
530
  $this->errors->add( 'permission', __( 'You are not allowed to close this poll.', 'polldaddy' ) );
531
  return false;
532
  }
533
+
534
  // Send Poll Author credentials
535
  if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
536
  $polldaddy->reset();
537
+ if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
538
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
539
  }
540
  $polldaddy->userCode = $userCode;
541
  }
542
+
543
  $polldaddy->reset();
544
  $polldaddy->close_poll( $poll_id );
545
  }
546
+
547
  $query_args['message'] = 'closed';
548
  $query_args['closed'] = count( (array) $poll );
549
  break;
550
  case 'edit-poll' : // TODO: use polldaddy_poll
551
  if ( !$is_POST || !$poll = (int) $poll )
552
  return;
553
+
554
  check_admin_referer( "edit-poll_$poll" );
555
+
556
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
557
  $polldaddy->reset();
558
+
559
  $poll_object = $polldaddy->get_poll( $poll );
560
  $this->parse_errors( $polldaddy );
561
+
562
  if ( !$this->can_edit( $poll_object ) ) {
563
  $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
564
  return false;
565
  }
566
+
567
  // Send Poll Author credentials
568
+
569
  if ( !empty( $poll_object->_owner ) && $this->id != $poll_object->_owner ) {
570
  $polldaddy->reset();
571
+ if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
572
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author', 'polldaddy' ) );
573
  }
574
  $this->parse_errors( $polldaddy );
575
  $polldaddy->userCode = $userCode;
576
  }
577
+
578
+ if ( !$poll_object )
579
  $this->errors->add( 'GetPoll', __( 'Poll not found', 'polldaddy' ) );
580
+
581
  if ( $this->errors->get_error_codes() )
582
  return false;
583
+
584
  $poll_data = get_object_vars( $poll_object );
585
  foreach ( $poll_data as $key => $value )
586
  if ( '_' === $key[0] )
587
  unset( $poll_data[$key] );
588
+
589
+ foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
590
+ if ( isset( $_POST[$option] ) && $_POST[$option] )
591
+ $poll_data[$option] = 'yes';
592
+ else
593
+ $poll_data[$option] = 'no';
594
+ }
595
+
596
  $blocks = array( 'off', 'cookie', 'cookieip' );
597
  if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
598
  $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
599
+
600
  $results = array( 'show', 'percent', 'hide' );
601
  if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
602
  $poll_data['resultsType'] = $_POST['resultsType'];
603
  $poll_data['question'] = stripslashes( $_POST['question'] );
604
+
605
  if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
606
  $this->errors->add( 'answer', __( 'Invalid answers', 'polldaddy' ) );
607
+
608
  $answers = array();
609
  foreach ( $_POST['answer'] as $answer_id => $answer ) {
610
+ $answer = stripslashes( trim( $answer ) );
611
+
612
+ if ( strlen( $answer ) > 0 ) {
613
+ $answer = wp_kses( $answer, $allowedtags );
614
+
615
+ $args['text'] = (string) $answer;
616
+
617
+ if ( is_numeric( $answer_id ) )
618
+ $answers[] = polldaddy_poll_answer( $args, $answer_id );
619
+ else
620
+ $answers[] = polldaddy_poll_answer( $args );
621
+ }
622
  }
623
+
624
  if ( 2 > count( $answers ) )
625
  $this->errors->add( 'answer', __( 'You must include at least 2 answers', 'polldaddy' ) );
626
+
627
  if ( $this->errors->get_error_codes() )
628
  return false;
629
+
630
  $poll_data['answers'] = $answers;
631
+
632
  $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
633
+
634
+ if ( isset ( $_POST['styleID'] ) ) {
635
+ if ( $_POST['styleID'] == 'x' ) {
636
  $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
637
  return false;
638
  }
639
  }
640
  $poll_data['styleID'] = (int) $_POST['styleID'];
641
  $poll_data['choices'] = (int) $_POST['choices'];
642
+
643
+ if ( $poll_data['blockRepeatVotersType'] == 'cookie' ) {
644
+ if ( isset( $_POST['cookieip_expiration'] ) )
645
+ $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
646
+ } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ) {
647
+ if ( isset( $_POST['cookieip_expiration'] ) )
648
+ $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
649
+ }
650
+
651
  $polldaddy->reset();
652
+
653
  $update_response = $polldaddy->update_poll( $poll, $poll_data );
654
+
655
  $this->parse_errors( $polldaddy );
656
+
657
  if ( !$update_response )
658
  $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated', 'polldaddy' ) );
659
+
660
  if ( $this->errors->get_error_codes() )
661
  return false;
662
+
663
  $query_args['message'] = 'updated';
664
+ if ( isset( $_POST['iframe'] ) )
665
  $query_args['iframe'] = '';
666
  break;
667
  case 'create-poll' :
668
  if ( !$is_POST )
669
  return;
670
+
671
  check_admin_referer( 'create-poll' );
672
+
673
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
674
  $polldaddy->reset();
675
+
676
  $answers = array();
677
+ foreach ( $_POST['answer'] as $answer ) {
678
+ $answer = stripslashes( trim( $answer ) );
679
+
680
+ if ( strlen( $answer ) > 0 ) {
681
+ $answer = wp_kses( $answer, $allowedtags );
682
+
683
+ $args['text'] = (string) $answer;
684
+
685
+ $answers[] = polldaddy_poll_answer( $args );
686
+ }
687
  }
688
+
689
  if ( !$answers )
690
  return false;
691
+
692
  $poll_data = _polldaddy_poll_defaults();
693
+
694
  foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
695
  if ( isset( $_POST[$option] ) && $_POST[$option] )
696
  $poll_data[$option] = 'yes';
697
  else
698
  $poll_data[$option] = 'no';
699
  }
700
+
701
  $blocks = array( 'off', 'cookie', 'cookieip' );
702
  if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
703
  $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
704
+
705
  $results = array( 'show', 'percent', 'hide' );
706
  if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
707
  $poll_data['resultsType'] = $_POST['resultsType'];
708
+
709
  $poll_data['answers'] = $answers;
710
+
711
  $poll_data['question'] = stripslashes( $_POST['question'] );
712
  $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
713
+
714
+ if ( isset ( $_POST['styleID'] ) ) {
715
+ if ( $_POST['styleID'] == 'x' ) {
716
+ $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style', 'polldaddy' ) );
717
+ return false;
718
  }
719
  }
720
  $poll_data['styleID'] = (int) $_POST['styleID'];
721
+ $poll_data['choices'] = (int) $_POST['choices'];
722
+
723
+ if ( $poll_data['blockRepeatVotersType'] == 'cookie' ) {
724
+ if ( isset( $_POST['cookieip_expiration'] ) )
725
+ $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
726
+ } elseif ( $poll_data['blockRepeatVotersType'] == 'cookieip' ) {
727
+ if ( isset( $_POST['cookieip_expiration'] ) )
728
+ $poll_data['blockExpiration'] = (int) $_POST['cookieip_expiration'];
729
+ }
730
+
731
  $poll = $polldaddy->create_poll( $poll_data );
732
  $this->parse_errors( $polldaddy );
733
+
734
  if ( !$poll || empty( $poll->_id ) )
735
  $this->errors->add( 'CreatePoll', __( 'Poll could not be created', 'polldaddy' ) );
736
+
737
  if ( $this->errors->get_error_codes() )
738
  return false;
739
+
740
  $query_args['message'] = 'created';
741
  $query_args['action'] = 'edit-poll';
742
  $query_args['poll'] = $poll->_id;
743
+ if ( isset( $_POST['iframe'] ) )
744
  $query_args['iframe'] = '';
745
  break;
746
  case 'delete-style' :
747
  if ( empty( $style ) )
748
  return;
749
+
750
  if ( is_array( $style ) )
751
  check_admin_referer( 'action-style_bulk' );
752
  else
753
  check_admin_referer( "delete-style_$style" );
754
+
755
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
756
+
757
  foreach ( (array) $_REQUEST['style'] as $style_id ) {
758
  $polldaddy->reset();
759
  $polldaddy->delete_style( $style_id );
760
  }
761
+
762
  $query_args['message'] = 'deleted-style';
763
  $query_args['deleted'] = count( (array) $style );
764
  break;
765
  case 'edit-style' :
766
  if ( !$is_POST || !$style = (int) $style )
767
  return;
768
+
769
  check_admin_referer( "edit-style$style" );
770
+
771
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
772
  $polldaddy->reset();
773
+
774
  $style_data = _polldaddy_style_defaults();
775
+
776
+ if ( isset( $_POST['style-title'] ) )
777
+ $style_data['title'] = stripslashes( trim( (string) $_POST['style-title'] ) );
778
+
779
+ if ( isset( $_POST['CSSXML'] ) )
780
+ $style_data['css'] = urlencode( stripslashes( trim( (string) $_POST['CSSXML'] ) ) );
781
+
782
+ if ( isset( $_REQUEST['updatePollCheck'] ) && $_REQUEST['updatePollCheck'] == 'on' )
783
+ $style_data['retro'] = 1;
784
+
785
  $update_response = $polldaddy->update_style( $style, $style_data );
786
+
787
  $this->parse_errors( $polldaddy );
788
+
789
  if ( !$update_response )
790
  $this->errors->add( 'UpdateStyle', __( 'Style could not be updated', 'polldaddy' ) );
791
+
792
  if ( $this->errors->get_error_codes() )
793
  return false;
794
+
795
  $query_args['message'] = 'updated-style';
796
+ if ( isset( $_POST['iframe'] ) )
797
  $query_args['iframe'] = '';
798
  break;
799
  case 'create-style' :
800
  if ( !$is_POST )
801
  return;
802
+
803
  check_admin_referer( 'create-style' );
804
+
805
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
806
  $polldaddy->reset();
807
+
808
  $style_data = _polldaddy_style_defaults();
809
+
810
+ if ( isset( $_POST['style-title'] ) )
811
+ $style_data['title'] = stripslashes( strip_tags( trim( (string) $_POST['style-title'] ) ) );
812
+
813
+ if ( isset( $_POST['CSSXML'] ) )
814
+ $style_data['css'] = urlencode( stripslashes( trim( (string) $_POST['CSSXML'] ) ) );
815
+
816
  $style = $polldaddy->create_style( $style_data );
817
  $this->parse_errors( $polldaddy );
818
+
819
  if ( !$style || empty( $style->_id ) )
820
  $this->errors->add( 'CreateStyle', __( 'Style could not be created', 'polldaddy' ) );
821
+
822
  if ( $this->errors->get_error_codes() )
823
  return false;
824
+
825
  $query_args['message'] = 'created-style';
826
  $query_args['action'] = 'edit-style';
827
  $query_args['style'] = $style->_id;
828
+ if ( isset( $_POST['iframe'] ) )
829
  $query_args['iframe'] = '';
830
  break;
831
  case 'update-options' :
832
+ if ( !$is_POST )
833
  return;
834
+
835
  check_admin_referer( 'polldaddy-account' );
836
+
837
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
838
  $polldaddy->reset();
839
+
840
  $poll_defaults = _polldaddy_poll_defaults();
841
+
842
  $user_defaults = array();
843
+
844
+ foreach ( array( "multipleChoice", "randomiseAnswers", "otherAnswer", "sharing", "resultsType", "styleID", "blockRepeatVotersType", "blockExpiration" ) as $option ) {
845
+ if ( isset( $poll_defaults[$option] ) && $poll_defaults[$option] )
846
+ $user_defaults[$option] = $poll_defaults[$option];
847
+ }
848
+
849
  foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
850
  if ( isset( $_POST[$option] ) && $_POST[$option] )
851
  $user_defaults[$option] = 'yes';
852
  else
853
  $user_defaults[$option] = 'no';
854
  }
855
+
856
  $results = array( 'show', 'percent', 'hide' );
857
  if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
858
+ $user_defaults['resultsType'] = $_POST['resultsType'];
859
+
860
+ if ( isset ( $_POST['styleID'] ) ) {
861
  $user_defaults['styleID'] = (int) $_POST['styleID'];
862
+ }
863
+
864
  $blocks = array( 'off', 'cookie', 'cookieip' );
865
  if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
866
  $user_defaults['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
867
+
868
+ if ( isset( $_POST['blockExpiration'] ) )
869
+ $user_defaults['blockExpiration'] = (int) $_POST['blockExpiration'];
870
+
871
+ $polldaddy->update_poll_defaults( 0, $user_defaults );
872
+
873
+ $this->parse_errors( $polldaddy );
874
  if ( $this->errors->get_error_codes() )
875
  return false;
876
+
877
+ $query_args['message'] = 'updated-options';
878
+ break;
879
  default :
880
  return;
881
  endswitch;
882
+ } elseif ( $page == 'ratings' ) {
883
+
884
  switch ( $action ) :
885
  case 'delete' :
886
  if ( empty( $id ) )
887
  return;
888
  if ( empty( $rating ) )
889
  return;
890
+
891
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
892
+
893
  if ( is_array( $rating ) ) {
894
  check_admin_referer( 'action-rating_bulk' );
895
+
896
+ foreach ( $rating as $key => $value ) {
897
  $polldaddy->reset();
898
  $polldaddy->delete_rating_result( $id, $value );
899
  }
900
  } else {
901
  check_admin_referer( "delete-rating_$rating" );
902
+
903
  $polldaddy->delete_rating_result( $id, $rating );
904
  }
905
+
906
  if ( isset( $_REQUEST['filter'] ) )
907
  $query_args['filter'] = $_REQUEST['filter'];
908
  if ( isset( $_REQUEST['change-report-to'] ) )
910
  $query_args['message'] = 'deleted-rating';
911
  $query_args['deleted'] = count( (array) $rating );
912
  break;
913
+ default :
914
  return;
915
  endswitch;
916
  }
917
+
918
  wp_redirect( add_query_arg( $query_args, wp_get_referer() ) );
919
  exit;
920
  }
922
  function management_page_load_signup() {
923
  switch ( $_POST['account'] ) :
924
  case 'import' :
925
+ return $this->import_account();
926
  break;
927
  default :
928
  return;
929
  endswitch;
930
  }
931
+
932
+ function import_account() {
933
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
934
  $polldaddy->reset();
935
  $email = trim( stripslashes( $_POST['polldaddy_email'] ) );
936
  $password = trim( stripslashes( $_POST['polldaddy_password'] ) );
937
+
938
+ if ( !is_email( $email ) )
939
  $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) );
940
 
941
  if ( !$password )
945
  return false;
946
 
947
  if ( $usercode = $polldaddy->initiate( $email, $password, $this->id ) ) {
948
+ $this->user_code = $usercode;
949
+ } else {
950
  $this->parse_errors( $polldaddy );
951
+ $this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?', 'polldaddy' ) );
952
  return false;
953
+ }
954
+ }
955
 
956
  function admin_body_class( $class ) {
957
  if ( isset( $_GET['iframe'] ) )
961
  return $class;
962
  }
963
 
964
+ function management_page_notices( $message = false ) {
965
  switch ( (string) @$_GET['message'] ) :
966
  case 'deleted' :
967
  $deleted = (int) $_GET['deleted'];
1048
  }
1049
 
1050
  function management_page() {
1051
+ global $page, $action, $poll, $style, $rating;
1052
  $poll = (int) $poll;
1053
  $style = (int) $style;
1054
  $rating = wp_specialchars( $rating );
1057
  <div class="wrap" id="manage-polls">
1058
 
1059
  <?php
1060
+ if ( $page == 'polls' ) {
1061
+ if ( !$this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles', 'options', 'update-options', 'import-account' ) ) ) {//check user privileges has access to action
1062
+ $action = '';
1063
+ }
1064
+ switch ( $action ) :
1065
+ case 'signup' :
1066
+ case 'account' :
1067
+ $this->signup();
1068
+ break;
1069
+ case 'preview' :
1070
  ?>
1071
 
1072
  <h2 id="preview-header"><?php
1073
+ if ( $this->is_author )
1074
+ printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)', 'polldaddy' ),
1075
+ clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
1076
+ clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) );
1077
+ else
1078
+ printf( __( 'Poll Preview (<a href="%s">List Polls</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1079
 
1080
  <?php
1081
+ echo do_shortcode( "[polldaddy poll=$poll cb=1]" );
1082
+ break;
1083
+ case 'results' :
1084
  ?>
1085
 
1086
+ <h2><?php
1087
+ if ( $this->is_author )
1088
+ printf( __( 'Poll Results (<a href="%s">Edit Poll</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ) );
1089
+ else
1090
+ printf( __( 'Poll Results (<a href="%s">List Polls</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1091
 
1092
  <?php
1093
+ $this->poll_results_page( $poll );
1094
+ break;
1095
+ case 'edit' :
1096
+ case 'edit-poll' :
1097
  ?>
1098
 
1099
+ <h2><?php printf( __( 'Edit Poll (<a href="%s">List Polls</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1100
 
1101
  <?php
1102
 
1103
+ $this->poll_edit_form( $poll );
1104
+ break;
1105
+ case 'create-poll' :
1106
  ?>
1107
 
1108
+ <h2><?php printf( __( 'Create Poll (<a href="%s">List Polls</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
1109
 
1110
  <?php
1111
+ $this->poll_edit_form();
1112
+ break;
1113
+ case 'list-styles' :
1114
  ?>
1115
 
1116
+ <h2><?php
1117
+ if ( $this->is_author )
1118
+ printf( __( 'Custom Styles (<a href="%s">Add New</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-style', 'poll' => false, 'message' => false ) ) ) );
1119
+ else
1120
+ _e( 'Custom Styles', 'polldaddy' ); ?></h2>
1121
 
1122
  <?php
1123
+ $this->styles_table();
1124
+ break;
1125
+ case 'edit-style' :
1126
  ?>
1127
 
1128
+ <h2><?php printf( __( 'Edit Style (<a href="%s">List Styles</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?></h2>
1129
 
1130
  <?php
1131
 
1132
+ $this->style_edit_form( $style );
1133
+ break;
1134
+ case 'create-style' :
1135
  ?>
1136
 
1137
+ <h2><?php printf( __( 'Create Style (<a href="%s">List Styles</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?></h2>
1138
 
1139
  <?php
1140
+ $this->style_edit_form();
1141
+ break;
1142
+ case 'options' :
1143
+ case 'import-account' :
1144
+ case 'update-options' :
1145
+ $this->plugin_options();
1146
+ break;
1147
+ default :
1148
 
1149
  ?>
1150
 
1151
+ <h2 id="poll-list-header"><?php
1152
+ if ( $this->is_author )
1153
+ printf( __( 'Polls (<a href="%s">Add New</a>)', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-poll', 'poll' => false, 'message' => false ) ) ) );
1154
+ else
1155
+ _e( 'Polls', 'polldaddy' ); ?></h2>
1156
 
1157
+ <?php
1158
+ $this->polls_table( isset( $_GET['view'] ) && 'user' == $_GET['view'] ? 'user' : 'blog' );
1159
+ endswitch;
1160
+ } elseif ( $page == 'ratings' ) {
1161
+ if ( !$this->is_admin && !in_array( $action, array( 'delete', 'reports' ) ) ) {//check user privileges has access to action
1162
+ $action = 'reports';
1163
+ }
1164
+
1165
+ switch ( $action ) :
1166
+ case 'delete' :
1167
+ case 'reports' :
1168
+ $this->rating_reports();
1169
+ break;
1170
+ case 'update-rating' :
1171
+ $this->update_rating();
1172
+ $this->rating_settings( $action );
1173
+ break;
1174
+ default :
1175
+ $this->rating_settings();
1176
+ endswitch;
1177
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1178
  ?>
1179
 
1180
  </div>
1186
  function polls_table( $view = 'blog' ) {
1187
  $page = 1;
1188
  if ( isset( $_GET['paged'] ) )
1189
+ $page = absint( $_GET['paged'] );
1190
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
1191
  $polldaddy->reset();
1192
+
1193
+ if ( !$this->is_author )
1194
+ $view = '';
1195
+
1196
  if ( 'user' == $view )
1197
  $polls_object = $polldaddy->get_polls( ( $page - 1 ) * 10 + 1, $page * 10 );
1198
  else
1199
  $polls_object = $polldaddy->get_polls_by_parent_id( ( $page - 1 ) * 10 + 1, $page * 10 );
1200
+
1201
  $this->parse_errors( $polldaddy );
1202
  $this->print_errors();
1203
  $polls = & $polls_object->poll;
1204
+ if ( isset( $polls_object->_total ) )
1205
  $total_polls = $polls_object->_total;
1206
  else
1207
  $total_polls = count( $polls );
1208
  $class = '';
1209
 
1210
  $page_links = paginate_links( array(
1211
+ 'base' => add_query_arg( 'paged', '%#%' ),
1212
+ 'format' => '',
1213
+ 'total' => ceil( $total_polls / 10 ),
1214
+ 'current' => $page
1215
+ ) );
1216
 
1217
+ if ( $this->is_author ) { ?>
1218
  <ul class="subsubsub">
1219
  <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => false, 'paged' => false ) ) ); ?>"<?php if ( 'blog' == $view ) echo ' class="current"'; ?>><?php _e( "All Blog's Polls", 'polldaddy' ); ?></a> | </li>
1220
  <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => 'user', 'paged' => false ) ) ); ?>"<?php if ( 'user' == $view ) echo ' class="current"'; ?>><?php _e( "All My Polls", 'polldaddy' ); ?></a></li>
1221
  </ul>
1222
  <?php } ?>
1223
  <form method="post" action="">
1224
+ <?php if ( $this->is_author ) { ?>
1225
  <div class="tablenav">
1226
  <div class="alignleft">
1227
  <select name="action">
1240
  <table class="widefat">
1241
  <thead>
1242
  <tr>
1243
+ <th id="cb" class="manage-column column-cb check-column" scope="col" /><?php if ( $this->is_author ) { ?><input type="checkbox" /><?php } ?></th>
1244
  <th id="title" class="manage-column column-title" scope="col"><?php _e( 'Poll', 'polldaddy' ); ?></th>
1245
  <th id="votes" class="manage-column column-vote num" scope="col"><?php _e( 'Votes', 'polldaddy' ); ?></th>
1246
  <th id="date" class="manage-column column-date" scope="col"><?php _e( 'Created', 'polldaddy' ); ?></th>
1249
  <tbody>
1250
 
1251
  <?php
1252
+ if ( $polls ) :
1253
  foreach ( $polls as $poll ) :
1254
  $poll_id = (int) $poll->_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1255
 
1256
+ $poll->___content = trim( strip_tags( $poll->___content ) );
1257
+ if ( strlen( $poll->___content ) == 0 ) {
1258
+ $poll->___content = '-- empty HTML tag --';
1259
+ }
1260
+
1261
+ $poll_closed = (int) $poll->_closed;
1262
+
1263
+ if ( $this->is_author and $this->can_edit( $poll ) ) {
1264
+ $edit_link = clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll_id, 'message' => false ) ) );
1265
+ $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'poll' => $poll_id, 'message' => false ) ), "delete-poll_$poll_id" ) );
1266
+ $open_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'open', 'poll' => $poll_id, 'message' => false ) ), "open-poll_$poll_id" ) );
1267
+ $close_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'close', 'poll' => $poll_id, 'message' => false ) ), "close-poll_$poll_id" ) );
1268
+ }
1269
+ else {
1270
+ $edit_link = false;
1271
+ $delete_link = false;
1272
+ $open_link = false;
1273
+ $close_link = false;
1274
+ }
1275
+
1276
+ $class = $class ? '' : ' class="alternate"';
1277
+ $results_link = clean_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll_id, 'message' => false ) ) );
1278
+ $preview_link = clean_url( add_query_arg( array( 'action' => 'preview', 'poll' => $poll_id, 'message' => false ) ) ); //, 'iframe' => '', 'TB_iframe' => 'true' ) ) );
1279
+ list( $poll_time ) = explode( '.', $poll->_created );
1280
+ $poll_time = strtotime( $poll_time );
1281
  ?>
1282
  <tr<?php echo $class; ?>>
1283
+ <th class="check-column" scope="row"><?php if ( $this->is_author and $this->can_edit( $poll ) ) { ?><input type="checkbox" value="<?php echo (int) $poll_id; ?>" name="poll[]" /><?php } ?></th>
1284
  <td class="post-title column-title">
1285
+ <?php if ( $edit_link ) { ?>
1286
  <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $poll->___content ); ?></a></strong>
1287
  <div class="row-actions">
1288
  <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
1289
+ <?php } else { ?>
1290
  <strong><?php echo wp_specialchars( $poll->___content ); ?></strong>
1291
  <div class="row-actions">
1292
+ <?php } ?>
1293
  <span class="results"><a href="<?php echo $results_link; ?>"><?php _e( 'Results', 'polldaddy' ); ?></a> | </span>
1294
+ <?php if ( $delete_link ) { ?>
1295
  <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a> | </span>
1296
+ <?php }
1297
+ if ( $poll_closed == 2 ) {
1298
+ if ( $open_link ) { ?>
1299
+ <span class="open"><a class="open-poll" href="<?php echo $open_link; ?>"><?php _e( 'Open', 'polldaddy' ); ?></a> | </span>
1300
+ <?php } } else {
1301
+ if ( $close_link ) { ?>
1302
  <span class="close"><a class="close-poll" href="<?php echo $close_link; ?>"><?php _e( 'Close', 'polldaddy' ); ?></a> | </span>
1303
  <?php } } ?>
1304
  <?php if ( isset( $_GET['iframe'] ) ) { ?>
1315
  </div>
1316
  </td>
1317
  <td class="poll-votes column-vote num"><?php echo number_format_i18n( $poll->_responses ); ?></td>
1318
+ <td class="date column-date"><abbr title="<?php echo date( __( 'Y/m/d g:i:s A', 'polldaddy' ), $poll_time ); ?>"><?php echo date( __( 'Y/m/d', 'polldaddy' ), $poll_time ); ?></abbr></td>
1319
  </tr>
1320
  <tr class="polldaddy-shortcode-row" style="display: none;">
1321
  <td colspan="4">
1337
  </tr>
1338
 
1339
  <?php
1340
+ endforeach;
1341
  elseif ( $total_polls ) : // $polls
1342
  ?>
1343
 
1350
  ?>
1351
 
1352
  <tr>
1353
+ <td colspan="4"><?php
1354
+ if ( $this->is_author )
1355
+ printf( __( 'No polls yet. <a href="%s">Create one</a>', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-poll' ) ) ) );
1356
+ else
1357
+ _e( 'No polls yet.', 'polldaddy' ); ?></td>
1358
  </tr>
1359
+ <?php endif; // $polls ?>
1360
 
1361
  </tbody>
1362
  </table>
1367
  </div>
1368
  <br class="clear" />
1369
  <script language="javascript">
1370
+ jQuery( document ).ready(function(){
1371
  plugin = new Plugin( {
1372
+ delete_rating: '<?php echo esc_attr( __( 'Are you sure you want to delete the rating for "%s"?', 'polldaddy' ) ); ?>',
1373
+ delete_poll: '<?php echo esc_attr( __( 'Are you sure you want to delete "%s"?', 'polldaddy' ) ); ?>',
1374
+ delete_answer: '<?php echo esc_attr( __( 'Are you sure you want to delete this answer?', 'polldaddy' ) ); ?>',
1375
+ delete_answer_title: '<?php echo esc_attr( __( 'delete this answer', 'polldaddy' ) ); ?>',
1376
+ standard_styles: '<?php echo esc_attr( __( 'Standard Styles', 'polldaddy' ) ); ?>',
1377
+ custom_styles: '<?php echo esc_attr( __( 'Custom Styles', 'polldaddy' ) ); ?>'
1378
  } );
1379
  });
1380
  </script>
1381
 
1382
  <?php
1383
  }
1384
+
1385
+ function poll_table_add_option() {}
1386
+
1387
+ function poll_table_extra() {}
1388
 
1389
  function poll_edit_form( $poll_id = 1 ) {
1390
  $poll_id = (int) $poll_id;
1401
  if ( !$this->can_edit( $poll ) ) {
1402
  $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.', 'polldaddy' ) );
1403
  }
1404
+
1405
+ if ( $poll_id == 1 ) {
1406
+ $poll->answers = array();
1407
+ $poll_id = 0;
1408
+ }
1409
+
1410
+ } else {
1411
+ $poll = polldaddy_poll( array(), null, false );
1412
  }
1413
 
1414
  $question = $is_POST ? attribute_escape( stripslashes( $_POST['question'] ) ) : attribute_escape( $poll->question );
1448
  <ul class="poll-options">
1449
 
1450
  <?php
1451
+ foreach ( array( 'show' => __( 'Show results to voters', 'polldaddy' ), 'percent' => __( 'Only show percentages', 'polldaddy' ), 'hide' => __( 'Hide all results', 'polldaddy' ) ) as $value => $label ) :
1452
+ if ( $is_POST )
1453
+ $checked = $value === $_POST['resultsType'] ? ' checked="checked"' : '';
1454
+ else
1455
+ $checked = $value === $poll->resultsType ? ' checked="checked"' : '';
1456
  ?>
1457
 
1458
  <li>
1459
  <label for="resultsType-<?php echo $value; ?>"><input type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="resultsType" id="resultsType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1460
  </li>
1461
 
1462
+ <?php endforeach; ?>
1463
 
1464
  </ul>
1465
  </div>
1471
  <ul class="poll-options">
1472
 
1473
  <?php
1474
+ foreach ( array( 'off' => __( "Don't block repeat voters", 'polldaddy' ), 'cookie' => __( 'Block by cookie (recommended)', 'polldaddy' ), 'cookieip' => __( 'Block by cookie and by IP address', 'polldaddy' ) ) as $value => $label ) :
1475
+ if ( $is_POST )
1476
+ $checked = $value === $_POST['blockRepeatVotersType'] ? ' checked="checked"' : '';
1477
+ else
1478
+ $checked = $value === $poll->blockRepeatVotersType ? ' checked="checked"' : '';
1479
  ?>
1480
 
1481
  <li>
1482
  <label for="blockRepeatVotersType-<?php echo $value; ?>"><input class="block-repeat" type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="blockRepeatVotersType" id="blockRepeatVotersType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1483
  </li>
1484
 
1485
+ <?php endforeach; ?>
1486
 
1487
  </ul>
1488
+
1489
  <span style="margin:6px 6px 8px;" id="cookieip_expiration_label"><label><?php _e( 'Expires: ', 'polldaddy' ); ?></label></span>
1490
  <select id="cookieip_expiration" name="cookieip_expiration" style="width: auto;<?php echo $poll->blockRepeatVotersType == 'off' ? 'display:none;' : ''; ?>">
1491
  <option value="0" <?php echo (int) $poll->blockExpiration == 0 ? 'selected' : ''; ?>><?php _e( 'Never', 'polldaddy' ); ?></option>
1492
+ <option value="3600" <?php echo (int) $poll->blockExpiration == 3600 ? 'selected' : ''; ?>><?php printf( __( '%d hour', 'polldaddy' ), 1 ); ?></option>
1493
+ <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected' : ''; ?>><?php printf( __( '%d hours', 'polldaddy' ), 3 ); ?></option>
1494
+ <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected' : ''; ?>><?php printf( __( '%d hours', 'polldaddy' ), 6 ); ?></option>
1495
+ <option value="43200" <?php echo (int) $poll->blockExpiration == 43200 ? 'selected' : ''; ?>><?php printf( __( '%d hours', 'polldaddy' ), 12 ); ?></option>
1496
+ <option value="86400" <?php echo (int) $poll->blockExpiration == 86400 ? 'selected' : ''; ?>><?php printf( __( '%d day', 'polldaddy' ), 1 ); ?></option>
1497
+ <option value="604800" <?php echo (int) $poll->blockExpiration == 604800 ? 'selected' : ''; ?>><?php printf( __( '%d week', 'polldaddy' ), 1 ); ?></option>
1498
+ <option value="2419200" <?php echo (int) $poll->blockExpiration == 2419200 ? 'selected' : ''; ?>><?php printf( __( '%d month', 'polldaddy' ), 1 ); ?></option>
1499
  </select>
1500
+ <p><?php _e( 'Note: Blocking by cookie and IP address can be problematic for some voters.', 'polldaddy' ); ?></p>
1501
  </div>
1502
  </div>
1503
  </div>
1520
  $a = 0;
1521
  $answers = array();
1522
  if ( $is_POST && $_POST['answer'] ) {
1523
+ foreach ( $_POST['answer'] as $answer_id => $answer )
1524
+ $answers[attribute_escape( $answer_id )] = attribute_escape( stripslashes( $answer ) );
1525
  } elseif ( isset( $poll->answers->answer ) ) {
1526
  foreach ( $poll->answers->answer as $answer )
1527
  $answers[(int) $answer->_id] = attribute_escape( $answer->text );
1529
 
1530
  foreach ( $answers as $answer_id => $answer ) :
1531
  $a++;
1532
+ $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-answer', 'poll' => $poll_id, 'answer' => $answer_id, 'message' => false ) ), "delete-answer_$answer_id" ) );
1533
  ?>
1534
 
1535
  <li>
1575
  <label for="<?php echo $option; ?>"><input type="checkbox"<?php echo $checked; ?> value="yes" id="<?php echo $option; ?>" name="<?php echo $option; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1576
  </li>
1577
 
1578
+ <?php endforeach; ?>
1579
 
1580
  </ul>
1581
+ <?php
1582
+ if ( $is_POST )
1583
+ $style = 'yes' === $_POST['multipleChoice'] ? 'display:block;' : 'display:none;';
1584
+ else
1585
+ $style = 'yes' === $poll->multipleChoice ? 'display:block;' : 'display:none;';
1586
+ ?>
1587
  <div id="numberChoices" name="numberChoices" style="padding-left:15px;<?php echo $style; ?>">
1588
  <p>Number of choices: <select name="choices" id="choices"><option value="0">No Limit</option>
1589
+ <?php
1590
+ if ( $is_POST )
1591
+ $choices = (int) $_POST['choices'];
1592
+ else
1593
+ $choices = (int) $poll->choices;
1594
+
1595
+ if ( $a > 1 ) :
1596
+ for ( $i=2; $i<=$a; $i++ ) :
1597
+ $selected = $i == $choices ? 'selected="true"' : '';
1598
+ echo "<option value='$i' $selected>$i</option>";
1599
+ endfor;
1600
+ endif; ?>
1601
  </select>
1602
  </p>
1603
  </div>
1606
 
1607
  <div id="design" class="postbox">
1608
 
1609
+ <?php $style_ID = (int) ( $is_POST ? $_POST['styleID'] : $poll->styleID );
1610
 
1611
  $iframe_view = false;
1612
+ if ( isset( $_GET['iframe'] ) )
1613
  $iframe_view = true;
1614
+
1615
  $options = array(
1616
+ 101 => __( 'Aluminum Narrow', 'polldaddy' ),
1617
+ 102 => __( 'Aluminum Medium', 'polldaddy' ),
1618
+ 103 => __( 'Aluminum Wide', 'polldaddy' ),
1619
+ 104 => __( 'Plain White Narrow', 'polldaddy' ),
1620
+ 105 => __( 'Plain White Medium', 'polldaddy' ),
1621
+ 106 => __( 'Plain White Wide', 'polldaddy' ),
1622
+ 107 => __( 'Plain Black Narrow', 'polldaddy' ),
1623
+ 108 => __( 'Plain Black Medium', 'polldaddy' ),
1624
+ 109 => __( 'Plain Black Wide', 'polldaddy' ),
1625
+ 110 => __( 'Paper Narrow', 'polldaddy' ),
1626
+ 111 => __( 'Paper Medium', 'polldaddy' ),
1627
+ 112 => __( 'Paper Wide', 'polldaddy' ),
1628
+ 113 => __( 'Skull Dark Narrow', 'polldaddy' ),
1629
+ 114 => __( 'Skull Dark Medium', 'polldaddy' ),
1630
+ 115 => __( 'Skull Dark Wide', 'polldaddy' ),
1631
+ 116 => __( 'Skull Light Narrow', 'polldaddy' ),
1632
+ 117 => __( 'Skull Light Medium', 'polldaddy' ),
1633
+ 118 => __( 'Skull Light Wide', 'polldaddy' ),
1634
+ 157 => __( 'Micro', 'polldaddy' ),
1635
+ 119 => __( 'Plastic White Narrow', 'polldaddy' ),
1636
+ 120 => __( 'Plastic White Medium', 'polldaddy' ),
1637
+ 121 => __( 'Plastic White Wide', 'polldaddy' ),
1638
+ 122 => __( 'Plastic Grey Narrow', 'polldaddy' ),
1639
+ 123 => __( 'Plastic Grey Medium', 'polldaddy' ),
1640
+ 124 => __( 'Plastic Grey Wide', 'polldaddy' ),
1641
+ 125 => __( 'Plastic Black Narrow', 'polldaddy' ),
1642
+ 126 => __( 'Plastic Black Medium', 'polldaddy' ),
1643
+ 127 => __( 'Plastic Black Wide', 'polldaddy' ),
1644
+ 128 => __( 'Manga Narrow', 'polldaddy' ),
1645
+ 129 => __( 'Manga Medium', 'polldaddy' ),
1646
+ 130 => __( 'Manga Wide', 'polldaddy' ),
1647
+ 131 => __( 'Tech Dark Narrow', 'polldaddy' ),
1648
+ 132 => __( 'Tech Dark Medium', 'polldaddy' ),
1649
+ 133 => __( 'Tech Dark Wide', 'polldaddy' ),
1650
+ 134 => __( 'Tech Grey Narrow', 'polldaddy' ),
1651
+ 135 => __( 'Tech Grey Medium', 'polldaddy' ),
1652
+ 136 => __( 'Tech Grey Wide', 'polldaddy' ),
1653
+ 137 => __( 'Tech Light Narrow', 'polldaddy' ),
1654
+ 138 => __( 'Tech Light Medium', 'polldaddy' ),
1655
+ 139 => __( 'Tech Light Wide', 'polldaddy' ),
1656
+ 140 => __( 'Working Male Narrow', 'polldaddy' ),
1657
+ 141 => __( 'Working Male Medium', 'polldaddy' ),
1658
+ 142 => __( 'Working Male Wide', 'polldaddy' ),
1659
+ 143 => __( 'Working Female Narrow', 'polldaddy' ),
1660
+ 144 => __( 'Working Female Medium', 'polldaddy' ),
1661
+ 145 => __( 'Working Female Wide', 'polldaddy' ),
1662
+ 146 => __( 'Thinking Male Narrow', 'polldaddy' ),
1663
+ 147 => __( 'Thinking Male Medium', 'polldaddy' ),
1664
+ 148 => __( 'Thinking Male Wide', 'polldaddy' ),
1665
+ 149 => __( 'Thinking Female Narrow', 'polldaddy' ),
1666
+ 150 => __( 'Thinking Female Medium', 'polldaddy' ),
1667
+ 151 => __( 'Thinking Female Wide', 'polldaddy' ),
1668
+ 152 => __( 'Sunset Narrow', 'polldaddy' ),
1669
+ 153 => __( 'Sunset Medium', 'polldaddy' ),
1670
+ 154 => __( 'Sunset Wide', 'polldaddy' ),
1671
+ 155 => __( 'Music Medium', 'polldaddy' ),
1672
+ 156 => __( 'Music Wide', 'polldaddy' )
1673
  );
1674
+
1675
  $polldaddy->reset();
1676
  $styles = $polldaddy->get_styles();
1677
 
1678
  $show_custom = false;
1679
+ if ( !empty( $styles ) && !empty( $styles->style ) && count( $styles->style ) > 0 ) {
1680
+ foreach ( (array) $styles->style as $style ) {
1681
+ $options[ (int) $style->_id ] = $style->title;
1682
  }
1683
  $show_custom = true;
1684
+ }
1685
 
1686
+ if ( $style_ID > 18 ) {
1687
  $standard_style_ID = 0;
1688
  $custom_style_ID = $style_ID;
1689
  }
1690
+ else {
1691
  $standard_style_ID = $style_ID;
1692
  $custom_style_ID = 0;
1693
+ }
1694
  ?>
1695
 
1696
  <h3><?php _e( 'Design', 'polldaddy' ); ?></h3>
1697
  <input type="hidden" name="styleID" id="styleID" value="<?php echo $style_ID ?>">
1698
  <div class="inside">
1699
+ <?php if ( $iframe_view ) { ?>
1700
  <div id="design_standard" style="padding:0px;">
1701
  <div class="hide-if-no-js">
1702
  <table class="pollStyle">
1756
  <p class="empty-if-js" id="no-js-styleID">
1757
  <select id="styleID" name="styleID">
1758
 
1759
+ <?php foreach ( $options as $styleID => $label ) :
1760
+ $selected = $styleID == $style_ID ? ' selected="selected"' : ''; ?>
1761
  <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option>
1762
+ <?php endforeach; ?>
1763
 
1764
  </select>
1765
+ </p>
1766
  </div>
1767
+ <?php if ( $show_custom ) { ?>
1768
  <div id="design_custom">
1769
  <p class="hide-if-no-js">
1770
  <table class="pollStyle">
1786
  <tr>
1787
  <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1788
  <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1789
+ <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1790
  <option value="x"<?php echo $selected; ?>><?php _e( 'Please choose a custom style...', 'polldaddy' ); ?></option>
1791
+ <?php if ( $show_custom ) : foreach ( (array)$styles->style as $style ) :
1792
+ $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1793
  <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1794
+ <?php endforeach; endif; ?>
1795
  </select>
1796
  <div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy' ); ?></div></td>
1797
  </tr>
1798
  <tr>
1799
+ <td><?php $extra = $show_custom == false ? __( 'You currently have no custom styles created.', 'polldaddy' ) : ''; ?>
1800
  <p><?php echo $extra ?></p>
1801
  <p><?php printf( __( 'Did you know we have a new editor for building your own custom poll styles? Find out more <a href="%s" target="_blank">here</a>.', 'polldaddy' ), 'http://support.polldaddy.com/custom-poll-styles/' ); ?></p>
1802
  </td>
1811
  <div id="design_options">
1812
  <a href="#" class="polldaddy-show-design-options"><?php _e( 'Custom Styles', 'polldaddy' ); ?></a>
1813
  </div>
1814
+ <?php }}else {?>
1815
  <div class="design_standard">
1816
  <div class="hide-if-no-js">
1817
  <table class="pollStyle">
1882
  <tr>
1883
  <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1884
  <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1885
+ <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1886
+ <option value="x"<?php echo $selected; ?>><?php _e( 'Please choose a custom style...', 'polldaddy' ); ?></option>
1887
+ <?php if ( $show_custom ) : foreach ( (array)$styles->style as $style ) :
1888
+ $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1889
  <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1890
+ <?php endforeach; endif;?>
1891
  </select>
1892
+ <div id="styleIDErr" class="formErr" style="display:none;"><?php _e( 'Please choose a style.', 'polldaddy' ); ?></div></td>
1893
  </tr>
1894
  <tr>
1895
  <td><?php $extra = $show_custom == false ? __( 'You currently have no custom styles created.', 'polldaddy' ) : ''; ?>
1906
  <p class="empty-if-js" id="no-js-styleID">
1907
  <select id="styleID" name="styleID">
1908
 
1909
+ <?php foreach ( $options as $styleID => $label ) :
1910
+ $selected = $styleID == $style_ID ? ' selected="selected"' : ''; ?>
1911
  <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option>
1912
+ <?php endforeach; ?>
1913
 
1914
  </select>
1915
  </p>
1916
+ </div>
1917
  <?php } ?>
1918
  <script language="javascript">
1919
+ jQuery( document ).ready(function(){
1920
  plugin = new Plugin( {
1921
+ delete_rating: '<?php echo esc_attr( __( 'Are you sure you want to delete the rating for "%s"?', 'polldaddy' ) ); ?>',
1922
+ delete_poll: '<?php echo esc_attr( __( 'Are you sure you want to delete "%s"?', 'polldaddy' ) ); ?>',
1923
+ delete_answer: '<?php echo esc_attr( __( 'Are you sure you want to delete this answer?', 'polldaddy' ) ); ?>',
1924
+ delete_answer_title: '<?php echo esc_attr( __( 'delete this answer', 'polldaddy' ) ); ?>',
1925
+ standard_styles: '<?php echo esc_attr( __( 'Standard Styles', 'polldaddy' ) ); ?>',
1926
+ custom_styles: '<?php echo esc_attr( __( 'Custom Styles', 'polldaddy' ) ); ?>'
1927
  } );
1928
  });
1929
  </script>
1930
  <script language="javascript">
1931
+ current_pos = 0;
1932
+
1933
  for( var key in styles_array ) {
1934
  var name = styles_array[key].name;
1935
+
1936
  switch( name ){
1937
  case 'Aluminum':
1938
+ styles_array[key].name = '<?php echo esc_attr( __( 'Aluminum', 'polldaddy' ) ); ?>';
1939
  break;
1940
  case 'Plain White':
1941
+ styles_array[key].name = '<?php echo esc_attr( __( 'Plain White', 'polldaddy' ) ); ?>';
1942
  break;
1943
  case 'Plain Black':
1944
+ styles_array[key].name = '<?php echo esc_attr( __( 'Plain Black', 'polldaddy' ) ); ?>';
1945
  break;
1946
  case 'Paper':
1947
+ styles_array[key].name = '<?php echo esc_attr( __( 'Paper', 'polldaddy' ) ); ?>';
1948
  break;
1949
  case 'Skull Dark':
1950
+ styles_array[key].name = '<?php echo esc_attr( __( 'Skull Dark', 'polldaddy' ) ); ?>';
1951
  break;
1952
  case 'Skull Light':
1953
+ styles_array[key].name = '<?php echo esc_attr( __( 'Skull Light', 'polldaddy' ) ); ?>';
1954
  break;
1955
  case 'Micro':
1956
+ styles_array[key].name = '<?php echo esc_attr( __( 'Micro', 'polldaddy' ) ); ?>';
1957
+ styles_array[key].n_desc = '<?php echo esc_attr( __( 'Width 150px, the micro style is useful when space is tight.', 'polldaddy' ) ); ?>';
1958
  break;
1959
  case 'Plastic White':
1960
+ styles_array[key].name = '<?php echo esc_attr( __( 'Plastic White', 'polldaddy' ) ); ?>';
1961
  break;
1962
  case 'Plastic Grey':
1963
+ styles_array[key].name = '<?php echo esc_attr( __( 'Plastic Grey', 'polldaddy' ) ); ?>';
1964
  break;
1965
  case 'Plastic Black':
1966
+ styles_array[key].name = '<?php echo esc_attr( __( 'Plastic Black', 'polldaddy' ) ); ?>';
1967
  break;
1968
  case 'Manga':
1969
+ styles_array[key].name = '<?php echo esc_attr( __( 'Manga', 'polldaddy' ) ); ?>';
1970
  break;
1971
  case 'Tech Dark':
1972
+ styles_array[key].name = '<?php echo esc_attr( __( 'Tech Dark', 'polldaddy' ) ); ?>';
1973
  break;
1974
  case 'Tech Grey':
1975
+ styles_array[key].name = '<?php echo esc_attr( __( 'Tech Grey', 'polldaddy' ) ); ?>';
1976
  break;
1977
  case 'Tech Light':
1978
+ styles_array[key].name = '<?php echo esc_attr( __( 'Tech Light', 'polldaddy' ) ); ?>';
1979
  break;
1980
  case 'Working Male':
1981
+ styles_array[key].name = '<?php echo esc_attr( __( 'Working Male', 'polldaddy' ) ); ?>';
1982
  break;
1983
  case 'Working Female':
1984
+ styles_array[key].name = '<?php echo esc_attr( __( 'Working Female', 'polldaddy' ) ); ?>';
1985
  break;
1986
  case 'Thinking Male':
1987
+ styles_array[key].name = '<?php echo esc_attr( __( 'Thinking Male', 'polldaddy' ) ); ?>';
1988
  break;
1989
  case 'Thinking Female':
1990
+ styles_array[key].name = '<?php echo esc_attr( __( 'Thinking Female', 'polldaddy' ) ); ?>';
1991
  break;
1992
  case 'Sunset':
1993
+ styles_array[key].name = '<?php echo esc_attr( __( 'Sunset', 'polldaddy' ) ); ?>';
1994
  break;
1995
  case 'Music':
1996
+ styles_array[key].name = '<?php echo esc_attr( __( 'Music', 'polldaddy' ) ); ?>';
1997
  break;
1998
  }
1999
  }
2000
  pd_map = {
2001
+ wide : '<?php echo esc_attr( __( 'Wide', 'polldaddy' ) ); ?>',
2002
+ medium : '<?php echo esc_attr( __( 'Medium', 'polldaddy' ) ); ?>',
2003
+ narrow : '<?php echo esc_attr( __( 'Narrow', 'polldaddy' ) ); ?>',
2004
+ style_desc_wide : '<?php echo esc_attr( __( 'Width: 630px, the wide style is good for blog posts.', 'polldaddy' ) ); ?>',
2005
+ style_desc_medium : '<?php echo esc_attr( __( 'Width: 300px, the medium style is good for general use.', 'polldaddy' ) ); ?>',
2006
+ style_desc_narrow : '<?php echo esc_attr( __( 'Width 150px, the narrow style is good for sidebars etc.', 'polldaddy' ) ); ?>',
2007
+ style_desc_micro : '<?php echo esc_attr( __( 'Width 150px, the micro style is useful when space is tight.', 'polldaddy' ) ); ?>'
2008
  }
2009
  pd_build_styles( current_pos );
2010
+ <?php if ( $style_ID > 0 && $style_ID <= 1000 ) { ?>
2011
  pd_pick_style( <?php echo $style_ID ?> );
2012
+ <?php }else { ?>
2013
  pd_change_style( <?php echo $style_ID ?> );
2014
  <?php } ?>
2015
  </script>
2016
  </div>
2017
+
2018
  </div>
2019
 
2020
  </div>
2045
  $class = '';
2046
  foreach ( $results->answers as $answer ) :
2047
  $answer->text = trim( strip_tags( $answer->text ) );
2048
+ if ( strlen( $answer->text ) == 0 ) {
2049
+ $answer->text = '-- empty HTML tag --';
2050
+ }
2051
+
2052
+ $class = $class ? '' : ' class="alternate"';
2053
+ $content = $results->others && 'Other answer...' === $answer->text ? sprintf( __( 'Other (<a href="%s">see below</a>)', 'polldaddy' ), '#other-answers-results' ) : wp_specialchars( $answer->text );
2054
 
2055
  ?>
2056
 
2107
 
2108
  <?php
2109
  }
2110
+
2111
  function styles_table() {
2112
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2113
  $polldaddy->reset();
2114
+
2115
  $styles_object = $polldaddy->get_styles();
2116
+
2117
  $this->parse_errors( $polldaddy );
2118
  $this->print_errors();
2119
  $styles = & $styles_object->style;
2120
  $class = '';
2121
  $styles_exist = false;
2122
+
2123
  foreach ( (array)$styles as $style ) :
2124
+ if ( (int) $style->_type == 1 ):
2125
  $styles_exist = true;
2126
+ break;
2127
+ endif;
2128
  endforeach;
2129
  ?>
2130
 
2154
  <?php
2155
  if ( $styles_exist ) :
2156
  foreach ( $styles as $style ) :
2157
+ if ( (int) $style->_type == 1 ):
2158
+ $style_id = (int) $style->_id;
2159
 
2160
+ $class = $class ? '' : ' class="alternate"';
2161
+ $edit_link = clean_url( add_query_arg( array( 'action' => 'edit-style', 'style' => $style_id, 'message' => false ) ) );
2162
+ $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-style', 'style' => $style_id, 'message' => false ) ), "delete-style_$style_id" ) );
2163
+ list( $style_time ) = explode( '.', $style->date );
2164
+ $style_time = strtotime( $style_time );
2165
+ ?>
2166
 
2167
  <tr<?php echo $class; ?>>
2168
  <th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $style_id; ?>" name="style[]" /></th>
2169
  <td class="post-title column-title">
2170
+ <?php if ( $edit_link ) : ?>
2171
  <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $style->title ); ?></a></strong>
2172
  <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit', 'polldaddy' ); ?></a> | </span>
2173
+ <?php else : ?>
2174
  <strong><?php echo wp_specialchars( $style->title ); ?></strong>
2175
+ <?php endif; ?>
2176
 
2177
  <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete', 'polldaddy' ); ?></a></span>
2178
  </td>
2179
+ <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>
2180
  </tr>
2181
 
2182
  <?php
2183
+ endif;
2184
+ endforeach;
2185
  else : // $styles
2186
  ?>
2187
 
2188
  <tr>
2189
  <td colspan="4"><?php printf( __( 'No custom styles yet. <a href="%s">Create one</a>', 'polldaddy' ), clean_url( add_query_arg( array( 'action' => 'create-style' ) ) ) ); ?></td>
2190
  </tr>
2191
+ <?php endif; // $styles ?>
2192
 
2193
  </tbody>
2194
  </table>
2200
 
2201
  <?php
2202
  }
2203
+
2204
+ function style_edit_form( $style_id = 105 ) {
2205
  $style_id = (int) $style_id;
2206
 
2207
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
2208
  $polldaddy->reset();
2209
 
2210
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
2211
+
2212
  if ( $style_id ) {
2213
  $style = $polldaddy->get_style( $style_id );
2214
  $this->parse_errors( $polldaddy );
2226
  $preload_style_id = 0;
2227
  $preload_style = null;
2228
 
2229
+ if ( isset ( $_REQUEST['preload'] ) ) {
 
2230
  $preload_style_id = (int) $_REQUEST['preload'];
2231
 
2232
  if ( $preload_style_id > 1000 || $preload_style_id < 100 )
2233
  $preload_style_id = 0;
2234
+
2235
  if ( $preload_style_id > 0 ) {
2236
  $polldaddy->reset();
2237
  $preload_style = $polldaddy->get_style( $preload_style_id );
2238
  $this->parse_errors( $polldaddy );
2239
  }
2240
+
2241
  $preload_style->css = trim( urldecode( $preload_style->css ) );
2242
 
2243
  if ( $start = stripos( $preload_style->css, '<data>' ) )
2245
 
2246
  $style->css = addslashes( $preload_style->css );
2247
  }
2248
+
2249
  $this->print_errors();
2250
+
2251
  echo '<script language="javascript">var CSSXMLString = "' . $style->css .'";</script>';
2252
+ ?>
2253
 
2254
  <form action="" method="post">
2255
  <div id="poststuff">
2279
  <label class="CSSE_title_label"><?php _e( 'Preload Basic Style', 'polldaddy' ); ?></label>
2280
  </td>
2281
  <td>
2282
+ <div class="CSSE_preload">
2283
  <select id="preload_value">
2284
  <option value="0"></option>
2285
  <option value="102"><?php _e( 'Aluminum', 'polldaddy' ); ?></option>
2307
  <option value="pds-answer"><?php _e( 'Answers', 'polldaddy' ); ?></option>
2308
  <option value="pds-textfield"><?php _e( 'Other Input', 'polldaddy' ); ?></option>
2309
  <option value="pds-vote-button"><?php _e( 'Vote Button', 'polldaddy' ); ?></option>
2310
+ <option value="pds-link"><?php _e( 'Links', 'polldaddy' ); ?></option>
2311
  <option value="pds-answer-feedback"><?php _e( 'Result Background', 'polldaddy' ); ?></option>
2312
  <option value="pds-answer-feedback-bar"><?php _e( 'Result Bar', 'polldaddy' ); ?></option>
2313
  <option value="pds-totalvotes-inner"><?php _e( 'Total Votes', 'polldaddy' ); ?></option>
3057
  <div class="pds-totalvotes-outer">
3058
  <span class="pds-links-back">
3059
  <br/>
3060
+ <a href="javascript:" class="pds-link" id="pds-link1"><?php _e( 'Comments', 'polldaddy' ); ?> <strong>(19)</strong></a>
3061
  <xsl:text> </xsl:text>
3062
  <a href="javascript:renderStyleEdit('pds-box');" class="pds-link" id="pds-link2"><?php _e( 'Return To Poll', 'polldaddy' ); ?></a>
3063
  <span class="pds-clear"></span>
3074
  </td>
3075
  </tr>
3076
  </table>
3077
+ <div id="editBox"></div>
3078
+ <p class="pds-clear"></p>
3079
  <p>
3080
  <?php wp_nonce_field( $style_id > 1000 ? "edit-style$style_id" : 'create-style' ); ?>
3081
  <input type="hidden" name="action" value="<?php echo $style_id > 1000 ? 'edit-style' : 'create-style'; ?>" />
3082
  <input type="hidden" class="polldaddy-style-id" name="style" value="<?php echo $style_id; ?>" />
3083
+ <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Style', 'polldaddy' ) ); ?>" />
3084
  <?php if ( $style_id > 1000 ) { ?>
3085
  <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.' ); ?></label>
3086
  <?php } ?>
3087
  </p>
3088
  </div>
3089
+ </div>
3090
  <textarea id="S_www" name="CSSXML" style="display:none;width: 1000px; height: 500px;" rows="10" cols="10"> </textarea>
3091
  </form>
3092
  <script language="javascript">
3093
+ jQuery( document ).ready(function(){
3094
  plugin = new Plugin( {
3095
+ delete_rating: '<?php echo esc_attr( __( 'Are you sure you want to delete the rating for "%s"?', 'polldaddy' ) ); ?>',
3096
+ delete_poll: '<?php echo esc_attr( __( 'Are you sure you want to delete "%s"?', 'polldaddy' ) ); ?>',
3097
+ delete_answer: '<?php echo esc_attr( __( 'Are you sure you want to delete this answer?', 'polldaddy' ) ); ?>',
3098
+ delete_answer_title: '<?php echo esc_attr( __( 'delete this answer', 'polldaddy' ) ); ?>',
3099
+ standard_styles: '<?php echo esc_attr( __( 'Standard Styles', 'polldaddy' ) ); ?>',
3100
+ custom_styles: '<?php echo esc_attr( __( 'Custom Styles', 'polldaddy' ) ); ?>'
3101
  } );
3102
  });
3103
  pd_map = {
3104
+ thankyou : '<?php echo esc_attr( __( 'Thank you for voting!', 'polldaddy' ) ); ?>',
3105
+ question : '<?php echo esc_attr( __( 'Do you mostly use the internet at work, in school or at home?', 'polldaddy' ) ); ?>'
3106
  }
3107
  </script>
3108
  <script type="text/javascript" language="javascript">window.onload = function() {
3115
 
3116
  <?php
3117
  }
3118
+
3119
+ function rating_settings() {
3120
  global $action, $rating;
3121
  $show_posts = $show_posts_index = $show_pages = $show_comments = $pos_posts = $pos_posts_index = $pos_pages = $pos_comments = 0;
3122
  $show_settings = $rating_updated = ( $action == 'update-rating' ? true : false );
3123
  $error = false;
3124
+
3125
  $settings_style = 'display: none;';
3126
+ if ( $show_settings )
3127
  $settings_style = 'display: block;';
3128
+
3129
  $rating_id = get_option( 'pd-rating-posts-id' );
3130
  $report_type = 'posts';
3131
  $updated = false;
3132
+
3133
  if ( isset( $rating ) ) {
3134
  switch ( $rating ) :
3135
+ case 'pages':
3136
+ $report_type = 'pages';
3137
+ $rating_id = (int) get_option( 'pd-rating-pages-id' );
3138
+ break;
3139
+ case 'comments':
3140
+ $report_type = 'comments';
3141
+ $rating_id = (int) get_option( 'pd-rating-comments-id' );
3142
+ break;
3143
+ case 'posts':
3144
+ $report_type = 'posts';
3145
+ $rating_id = (int) get_option( 'pd-rating-posts-id' );
3146
+ break;
3147
  endswitch;
3148
  }
3149
+
3150
  $new_type = 0;
3151
  if ( $report_type == 'comments' )
3152
  $new_type = 1;
3153
+
3154
  $blog_name = get_option( 'blogname' );
3155
+
3156
  if ( empty( $blog_name ) )
3157
+ $blog_name = 'WordPress Blog';
3158
+ $blog_name .= ' - ' . $report_type;
3159
+
3160
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
3161
+ $polldaddy->reset();
3162
+
3163
  if ( empty( $rating_id ) ) {
3164
  $pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
3165
  if ( !empty( $pd_rating ) ) {
3167
  update_option ( 'pd-rating-' . $report_type . '-id', $rating_id );
3168
  update_option ( 'pd-rating-' . $report_type, 0 );
3169
  }
3170
+ } else
3171
  $pd_rating = $polldaddy->get_rating( $rating_id );
3172
+
3173
  if ( empty( $pd_rating ) || (int) $pd_rating->_id == 0 ) {
3174
+
3175
  if ( $polldaddy->errors ) {
3176
+ if ( array_key_exists( 4, $polldaddy->errors ) ) { //Obsolete key
3177
  $this->rating_user_code = '';
3178
+ update_option( 'pd-rating-usercode', '' );
3179
  $this->set_api_user_code(); // get latest key
3180
+
3181
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
3182
  $polldaddy->reset();
3183
  $pd_rating = $polldaddy->get_rating( $rating_id ); //see it exists
3184
+
3185
+ if ( empty( $pd_rating ) || (int) $pd_rating->_id == 0 ) { //if not then create a rating for blog
3186
+ $polldaddy->reset();
3187
  $pd_rating = $polldaddy->create_rating( $blog_name , $new_type );
3188
  }
3189
+ }
3190
+ }
3191
+
3192
+ if ( empty( $pd_rating ) ) { //something's up!
3193
+ echo '<div class="error"><p>'.sprintf( __( 'Sorry! There was an error creating your rating widget. Please contact <a href="%1$s" %2$s>PollDaddy support</a> to fix this.', 'polldaddy' ), 'http://polldaddy.com/feedback/', 'target="_blank"' ) . '</p></div>';
3194
  $error = true;
3195
  } else {
3196
  $rating_id = (int) $pd_rating->_id;
3197
  update_option ( 'pd-rating-' . $report_type . '-id', $rating_id );
3198
  update_option ( 'pd-rating-' . $report_type, 0 );
3199
+
3200
  switch ( $report_type ) :
3201
+ case 'posts':
3202
+ $show_posts = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3203
  break;
3204
+ case 'pages':
3205
+ $show_pages = 0;
 
 
 
 
 
 
 
 
 
 
3206
  break;
 
3207
  case 'comments':
3208
+ $show_comments = 0;
3209
+ break;
3210
+ endswitch;
3211
+ }
3212
+ }
3213
+
3214
+ if ( isset( $_POST[ 'pd_rating_action_type' ] ) ) {
3215
+
3216
+ switch ( $_POST[ 'pd_rating_action_type' ] ) :
3217
+ case 'posts' :
3218
+ if ( isset( $_POST[ 'pd_show_posts' ] ) && (int) $_POST[ 'pd_show_posts' ] == 1 )
3219
+ $show_posts = get_option( 'pd-rating-posts-id' );
3220
+
3221
+ update_option( 'pd-rating-posts', $show_posts );
3222
+
3223
+ if ( isset( $_POST[ 'pd_show_posts_index' ] ) && (int) $_POST[ 'pd_show_posts_index' ] == 1 )
3224
+ $show_posts_index = get_option( 'pd-rating-posts-id' );
3225
+
3226
+ update_option( 'pd-rating-posts-index', $show_posts_index );
3227
+
3228
+ if ( isset( $_POST[ 'posts_pos' ] ) && (int) $_POST[ 'posts_pos' ] == 1 )
3229
+ $pos_posts = 1;
3230
+
3231
+ update_option( 'pd-rating-posts-pos', $pos_posts );
3232
+
3233
+ if ( isset( $_POST[ 'posts_index_pos' ] ) && (int) $_POST[ 'posts_index_pos' ] == 1 )
3234
+ $pos_posts_index = 1;
3235
+
3236
+ update_option( 'pd-rating-posts-index-pos', $pos_posts_index );
3237
+ $rating_updated = true;
3238
+ break;
3239
+
3240
+ case 'pages';
3241
+ if ( isset( $_POST[ 'pd_show_pages' ] ) && (int) $_POST[ 'pd_show_pages' ] == 1 )
3242
+ $show_pages = get_option( 'pd-rating-pages-id' );
3243
+
3244
+ update_option( 'pd-rating-pages', $show_pages );
3245
+
3246
+ if ( isset( $_POST[ 'pages_pos' ] ) && (int) $_POST[ 'pages_pos' ] == 1 )
3247
+ $pos_pages = 1;
3248
+
3249
+ update_option( 'pd-rating-pages-pos', $pos_pages );
3250
+ $rating_updated = true;
3251
+ break;
3252
+
3253
+ case 'comments':
3254
+ if ( isset( $_POST[ 'pd_show_comments' ] ) && (int) $_POST[ 'pd_show_comments' ] == 1 )
3255
+ $show_comments = get_option( 'pd-rating-comments-id' );
3256
+
3257
+ update_option( 'pd-rating-comments', $show_comments );
3258
+
3259
+ if ( isset( $_POST[ 'comments_pos' ] ) && (int) $_POST[ 'comments_pos' ] == 1 )
3260
+ $pos_comments = 1;
3261
+
3262
+ update_option( 'pd-rating-comments-pos', $pos_comments );
3263
+
3264
+ $rating_updated = true;
3265
+ break;
3266
  endswitch;
3267
  }
3268
+
3269
  $show_posts = (int) get_option( 'pd-rating-posts' );
3270
  $show_pages = (int) get_option( 'pd-rating-pages' );
3271
  $show_comments = (int) get_option( 'pd-rating-comments' );
3272
  $show_posts_index = (int) get_option( 'pd-rating-posts-index' );
3273
+
3274
  $pos_posts = (int) get_option( 'pd-rating-posts-pos' );
3275
  $pos_pages = (int) get_option( 'pd-rating-pages-pos' );
3276
  $pos_comments = (int) get_option( 'pd-rating-comments-pos' );
3277
  $pos_posts_index = (int) get_option( 'pd-rating-posts-index-pos' );
3278
+
3279
  if ( !empty( $pd_rating ) ) {
3280
  $settings_text = $pd_rating->settings;
3281
+ $settings = json_decode( $settings_text );
3282
+
3283
  $popup_disabled = ( isset( $settings->popup ) && $settings->popup == 'off' );
3284
+
3285
  $rating_type = 0;
3286
+
3287
+ if ( $settings->type == 'stars' )
3288
  $rating_type = 0;
3289
  else
3290
  $rating_type = 1;
3291
+
3292
+ if ( empty( $settings->font_color ) )
3293
+ $settings->font_color = '#000000';
3294
+ }?>
3295
  <div class="wrap">
3296
+ <h2><?php _e( 'Rating Settings', 'polldaddy' ); ?></h2><?php
3297
+ if ( $rating_updated )
3298
+ echo '<div class="updated"><p>'.__( 'Rating updated', 'polldaddy' ).'</p></div>';
3299
 
3300
+ if ( !$error ) { ?>
3301
+ <div id="side-sortables">
3302
  <div id="categorydiv" class="categorydiv">
3303
+ <ul id="category-tabs" class="category-tabs"><?php
3304
+ $this_class = '';
3305
+ $posts_link = clean_url( add_query_arg( array( 'rating' => 'posts', 'message' => false ) ) );
3306
+ $pages_link = clean_url( add_query_arg( array( 'rating' => 'pages', 'message' => false ) ) );
3307
+ $comments_link = clean_url( add_query_arg( array( 'rating' => 'comments', 'message' => false ) ) );
3308
+ if ( $report_type == 'posts' )
3309
+ $this_class = ' class="tabs"';?>
3310
+ <li <?php echo $this_class; ?>><a tabindex="3" href="<?php echo $posts_link; ?>"><?php _e( 'Posts', 'polldaddy' );?></a></li><?php
3311
+ $this_class = '';
3312
+ if ( $report_type == 'pages' )
3313
+ $this_class = ' class="tabs"'; ?>
3314
+ <li <?php echo $this_class; ?>><a tabindex="3" href="<?php echo $pages_link; ?>"><?php _e( 'Pages', 'polldaddy' );?></a></li><?php
3315
+ $this_class = '';
3316
+ if ( $report_type == 'comments' )
3317
+ $this_class = ' class="tabs"'; ?>
3318
+ <li <?php echo $this_class; ?>><a href="<?php echo $comments_link; ?>"><?php _e( 'Comments', 'polldaddy' );?></a></li>
3319
  </ul>
3320
  <div class="tabs-panel" id="categories-all" style="background: #FFFFFF;height: auto; overflow: visible;">
3321
  <form action="" method="post">
3322
+ <input type="hidden" name="pd_rating_action_type" value="<?php echo $report_type; ?>" />
3323
  <table class="form-table" style="width: normal;">
3324
  <tbody><?php
3325
+ if ( $report_type == 'posts' ) { ?>
3326
  <tr valign="top">
3327
  <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
3328
  <label for="pd_show_posts">
3329
+ <input type="checkbox" name="pd_show_posts" id="pd_show_posts" <?php if ( $show_posts > 0 ) echo ' checked="checked" '; ?> value="1" /> <?php _e( 'Enable for blog posts', 'polldaddy' );?>
3330
  </label>
3331
  <span id="span_posts">
3332
  <select name="posts_pos"><?php
3333
+ $select = array( __( 'Above each blog post', 'polldaddy' ) => '0', __( 'Below each blog post', 'polldaddy' ) => '1' );
3334
+ foreach ( $select as $option => $value ) :
3335
+ $selected = '';
3336
+ if ( $value == $pos_posts )
3337
+ $selected = ' selected="selected"';
3338
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3339
+ endforeach;?>
3340
  </select>
3341
  </span>
3342
  </td>
3343
+ </tr>
3344
  <tr valign="top">
3345
  <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
3346
  <label for="pd_show_posts_index">
3347
+ <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( 'Enable for front page', 'polldaddy' );?>
3348
  </label>
3349
  <span id="span_posts">
3350
  <select name="posts_index_pos"><?php
3351
+ $select = array( __( 'Above each blog post', 'polldaddy' ) => '0', __( 'Below each blog post', 'polldaddy' ) => '1' );
3352
+ foreach ( $select as $option => $value ) :
3353
+ $selected = '';
3354
+ if ( $value == $pos_posts_index )
3355
+ $selected = ' selected="selected"';
3356
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3357
+ endforeach;?>
3358
  </select>
3359
  </span>
3360
  </td>
3361
  </tr><?php
3362
+ }
3363
+ if ( $report_type == 'pages' ) {?>
3364
  <tr valign="top">
3365
  <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
3366
  <label for="pd_show_pages">
3367
+ <input type="checkbox" name="pd_show_pages" id="pd_show_pages" <?php if ( $show_pages > 0 ) echo ' checked="checked" '; ?> value="1" /> <?php _e( 'Enable for pages', 'polldaddy' );?>
3368
+ </label>
3369
  <span id="span_pages">
3370
  <select name="pages_pos"><?php
3371
+ $select = array( __( 'Above each page', 'polldaddy' ) => '0', __( 'Below each page', 'polldaddy' ) => '1' );
3372
+ foreach ( $select as $option => $value ) :
3373
+ $selected = '';
3374
+ if ( $value == $pos_pages )
3375
+ $selected = ' selected="selected"';
3376
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3377
+ endforeach; ?>
3378
  </select>
3379
  </span>
3380
  </td>
3381
  </tr><?php
3382
+ }
3383
+ if ( $report_type == 'comments' ) {?>
3384
  <tr valign="top">
3385
  <td style="padding-left: 0px; padding-right: 0px; padding-top: 7px;">
3386
  <label for="pd_show_comments">
3387
+ <input type="checkbox" name="pd_show_comments" id="pd_show_comments" <?php if ( $show_comments > 0 ) echo ' checked="checked" '; ?> value="1" /> <?php _e( 'Enable for comments', 'polldaddy' );?>
3388
+ </label>
3389
  <span id="span_comments">
3390
  <select name="comments_pos"><?php
3391
+ $select = array( __( 'Above each comment', 'polldaddy' ) => '0', __( 'Below each comment', 'polldaddy' ) => '1' );
3392
+ foreach ( $select as $option => $value ) :
3393
+ $selected = '';
3394
+ if ( $value == $pos_comments )
3395
+ $selected = ' selected="selected"';
3396
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3397
+ endforeach; ?>
3398
  </select>
3399
  </span>
3400
  </td>
3401
+ </tr><?php
3402
+ } ?>
3403
  </tbody>
3404
  </table>
3405
  <p class="submit">
3406
+ <input class="button-primary" type="submit" value="<?php esc_attr_e( 'Save Changes', 'polldaddy' );?>" name="Submit" />
3407
  </p><?php
3408
+ if ( $report_type == 'posts' ) {
3409
+ if ( $show_posts > 0 || $show_posts_index > 0 )
3410
+ $show_settings = true;
3411
+ }
3412
+ if ( $report_type == 'pages' && $show_pages > 0 )
3413
+ $show_settings = true;
3414
+ if ( $report_type == 'comments' && $show_comments > 0 )
3415
+ $show_settings = true;
3416
+ if ( $show_settings == true )
3417
+ echo '<a href="javascript:" onclick="show_settings();">'.__( 'Advanced Settings', 'polldaddy' ).'</a>';?>
3418
  </form>
3419
  </div>
3420
  </div>
3421
  </div>
3422
 
3423
+ <?php if ( $show_settings == true ) { ?>
3424
  <br />
3425
  <form method="post" action="">
3426
+ <div id="poststuff" style="<?php echo $settings_style; ?>">
3427
  <div class="has-sidebar has-right-sidebar">
3428
  <div class="inner-sidebar-ratings">
3429
  <div class="postbox" id="submitdiv">
3430
+ <h3><?php _e( 'Save', 'polldaddy' );?></h3>
3431
  <div class="inside">
3432
  <div id="major-publishing-actions">
3433
+ <input type="hidden" name="type" value="<?php echo $report_type; ?>" />
3434
+ <input type="hidden" name="rating_id" value="<?php echo $rating_id; ?>" />
3435
  <input type="hidden" name="action" value="update-rating" />
3436
  <p id="publishing-action">
3437
+ <input type="submit" value="<?php _e( 'Save Changes', 'polldaddy' );?>" class="button-primary"/>
3438
  </p>
3439
  <br class="clear"/>
3440
  </div>
3441
  </div>
3442
  </div>
3443
  <div class="postbox">
3444
+ <h3><?php _e( 'Preview', 'polldaddy' );?></h3>
3445
  <div class="inside">
3446
+ <p><?php _e( 'This is a demo of what your rating widget will look like', 'polldaddy' ); ?>.</p>
3447
  <p>
3448
  <div id="pd_rating_holder_1"></div>
3449
  </p>
3450
  </div>
3451
  </div>
3452
  <div class="postbox">
3453
+ <h3><?php _e( 'Customize Labels', 'polldaddy' );?></h3>
3454
  <div class="inside">
3455
  <table width="99.5%">
3456
  <tr>
3457
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Vote', 'polldaddy' );?></p></td>
3458
  </tr>
3459
  <tr>
3460
  <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' : wp_specialchars( $settings->text_vote ); ?>" maxlength="20" />
3461
  </tr>
3462
  <tr>
3463
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Votes', 'polldaddy' );?></p></td>
3464
  </tr>
3465
  <tr>
3466
  <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' : wp_specialchars( $settings->text_votes ); ?>" maxlength="20" />
3467
  </tr>
3468
  <tr>
3469
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Rate This', 'polldaddy' );?></p></td>
3470
  </tr>
3471
  <tr>
3472
  <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' : wp_specialchars( $settings->text_rate_this ); ?>" maxlength="20" />
3473
  </tr>
3474
  <tr>
3475
+ <td><p style="margin-bottom: 0px;"><?php printf( __( '%d star', 'polldaddy' ), 1 );?></p></td>
3476
  </tr>
3477
  <tr>
3478
  <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' : wp_specialchars( $settings->text_1_star ); ?>" maxlength="20" />
3479
  </tr>
3480
  <tr>
3481
+ <td><p style="margin-bottom: 0px;"><?php printf( __( '%d stars', 'polldaddy' ), 2 );?></p></td>
3482
  </tr>
3483
  <tr>
3484
  <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' : wp_specialchars( $settings->text_2_star ); ?>" maxlength="20" />
3485
  </tr>
3486
  <tr>
3487
+ <td><p style="margin-bottom: 0px;"><?php printf( __( '%d stars', 'polldaddy' ), 3 );?></p></td>
3488
  </tr>
3489
  <tr>
3490
  <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' : wp_specialchars( $settings->text_3_star ); ?>" maxlength="20" />
3491
  </tr>
3492
  <tr>
3493
+ <td><p style="margin-bottom: 0px;"><?php printf( __( '%d stars', 'polldaddy' ), 4 );?></p></td>
3494
  </tr>
3495
  <tr>
3496
  <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' : wp_specialchars( $settings->text_4_star ); ?>" maxlength="20" />
3497
  </tr>
3498
  <tr>
3499
+ <td><p style="margin-bottom: 0px;"><?php printf( __( '%d stars', 'polldaddy' ), 5 );?></p></td>
3500
  </tr>
3501
  <tr>
3502
  <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' : wp_specialchars( $settings->text_5_star ); ?>" maxlength="20" />
3503
  </tr>
3504
  <tr>
3505
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Thank You', 'polldaddy' );?></p></td>
3506
  </tr>
3507
  <tr>
3508
  <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' : wp_specialchars( $settings->text_thank_you ); ?>" maxlength="20" />
3509
  </tr>
3510
  <tr>
3511
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Rate Up', 'polldaddy' );?></p></td>
3512
  </tr>
3513
  <tr>
3514
  <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' : wp_specialchars( $settings->text_rate_up ); ?>" maxlength="20" />
3515
  </tr>
3516
  <tr>
3517
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Rate Down', 'polldaddy' );?></p></td>
3518
  </tr>
3519
  <tr>
3520
  <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' : wp_specialchars( $settings->text_rate_down ); ?>" maxlength="20" />
3521
  </tr>
3522
  <tr>
3523
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Most Popular Content', 'polldaddy' );?></p></td>
3524
  </tr>
3525
  <tr>
3526
  <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' : wp_specialchars( $settings->text_popcontent ); ?>" maxlength="20" />
3527
  </tr>
3528
  <tr>
3529
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Close', 'polldaddy' );?></p></td>
3530
  </tr>
3531
  <tr>
3532
  <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' : wp_specialchars( $settings->text_close ); ?>" maxlength="20" />
3533
  </tr>
3534
  <tr>
3535
+ <td><p style="margin-bottom: 0px;"><?php _e( 'All', 'polldaddy' );?></p></td>
3536
  </tr>
3537
  <tr>
3538
  <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' : wp_specialchars( $settings->text_all ); ?>" maxlength="20" />
3539
  </tr>
3540
  <tr>
3541
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Today', 'polldaddy' );?></p></td>
3542
  </tr>
3543
  <tr>
3544
  <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' : wp_specialchars( $settings->text_today ); ?>" maxlength="20" />
3545
  </tr>
3546
  <tr>
3547
+ <td><p style="margin-bottom: 0px;"><?php _e( 'This Week', 'polldaddy' );?></p></td>
3548
  </tr>
3549
  <tr>
3550
  <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' : wp_specialchars( $settings->text_thisweek ); ?>" maxlength="20" />
3551
  </tr>
3552
  <tr>
3553
+ <td><p style="margin-bottom: 0px;"><?php _e( 'This Month', 'polldaddy' );?></p></td>
3554
  </tr>
3555
  <tr>
3556
  <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' : wp_specialchars( $settings->text_thismonth ); ?>" maxlength="20" />
3557
  </tr>
3558
  <tr>
3559
+ <td><p style="margin-bottom: 0px;"><?php _e( 'Rated', 'polldaddy' );?></p></td>
3560
  </tr>
3561
  <tr>
3562
  <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' : wp_specialchars( $settings->text_rated ); ?>" maxlength="20" />
3563
  </tr>
3564
  <tr>
3565
+ <td><p style="margin-bottom: 0px;"><?php _e( 'There are no rated items for this period', 'polldaddy' );?></p></td>
3566
  </tr>
3567
  <tr>
3568
  <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' : wp_specialchars( $settings->text_noratings ); ?>" maxlength="50" />
3571
  </div>
3572
  </div>
3573
  </div>
3574
+ <div id="post-body-content" class="has-sidebar-content">
3575
  <div class="postbox">
3576
+ <h3><?php _e( 'Rating Type', 'polldaddy' );?></h3>
3577
+ <div class="inside">
3578
+ <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>
3579
  <ul>
3580
  <li style="display: inline;margin-right: 10px;">
3581
  <label for="stars"><?php
3582
+ $checked = '';
3583
+ if ( $settings->type == 'stars' )
3584
+ $checked = ' checked="checked"';?>
3585
+ <input type="radio" onchange="pd_change_type( 0 );" <?php echo $checked; ?> value="stars" id="stars" name="rating_type" />
3586
+ <?php printf( __( '%d Star Rating', 'polldaddy' ), 5 );?>
3587
  </label>
3588
  </li>
3589
  <li style="display: inline;">
3590
  <label><?php
3591
+ $checked = '';
3592
+ if ( $settings->type == 'nero' )
3593
+ $checked = ' checked="checked"';?>
3594
+ <input type="radio" onchange="pd_change_type( 1 );" <?php echo $checked; ?> value="nero" id="nero" name="rating_type" />
3595
+ <?php _e( 'Nero Rating', 'polldaddy' );?>
3596
+ </label>
3597
  </li>
3598
  </ul>
3599
  </div>
3600
  </div>
3601
  <div class="postbox">
3602
+ <h3><?php _e( 'Rating Style', 'polldaddy' );?></h3>
3603
  <div class="inside">
3604
  <table>
3605
  <tr>
3606
+ <td height="30" width="100" id="editor_star_size_text"><?php _e( 'Star Size', 'polldaddy' );?></td>
3607
  <td>
3608
  <select name="size" id="size" onchange="pd_bind(this);"><?php
3609
+ $select = array( __( 'Small', 'polldaddy' )." (16px)" => "sml", __( 'Medium', 'polldaddy' )." (20px)" => "med", __( 'Large', 'polldaddy' )." (24px)" => "lrg" );
3610
+ foreach ( $select as $option => $value ) :
3611
+ $selected = '';
3612
+ if ( $settings->size == $value )
3613
+ $selected = ' selected="selected"';
3614
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3615
+ endforeach;?>
3616
  </select>
3617
  </td>
3618
  </tr>
3619
  <tr>
3620
+ <td height="30" id="editor_star_color_text"><?php echo 'bubu'; _e( 'Star Color', 'polldaddy' );?></td>
3621
  <td>
3622
  <select name="star_color" id="star_color" onchange="pd_bind(this);" style="display: none;"><?php
3623
+ $select = array( __( 'Yellow', 'polldaddy' ) => "yellow", __( 'Red', 'polldaddy' ) => "red", __( 'Blue', 'polldaddy' ) => "blue", __( 'Green', 'polldaddy' ) => "green", __( 'Grey', 'polldaddy' ) => "grey" );
3624
+ foreach ( $select as $option => $value ) :
3625
+ $selected = '';
3626
+ if ( $settings->star_color == $value )
3627
+ $selected = ' selected="selected"';
3628
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3629
+ endforeach;?>
3630
  </select>
3631
  <select name="nero_style" id="nero_style" onchange="pd_bind(this);" style="display: none;"><?php
3632
+ $select = array( __( 'Hand', 'polldaddy' ) => "hand" );
3633
+ foreach ( $select as $option => $value ) :
3634
+ $selected = '';
3635
+ if ( $settings->star_color == $value )
3636
+ $selected = ' selected="selected"';
3637
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3638
+ endforeach;?>
3639
  </select>
3640
  </td>
3641
  </tr>
3642
  <tr>
3643
+ <td height="30"><?php _e( 'Custom Image', 'polldaddy' );?></td>
3644
+ <td><input type="text" onblur="pd_bind(this);" name="custom_star" id="custom_star" value="<?php echo clean_url( $settings->custom_star ); ?>" maxlength="200" />
3645
  </tr>
3646
  </table>
3647
  </div>
3648
  </div>
3649
  <div class="postbox">
3650
+ <h3><?php _e( 'Text Layout & Font', 'polldaddy' );?></h3>
3651
  <div class="inside">
3652
  <table>
3653
  <tr>
3654
+ <td width="100" height="30"><?php _e( 'Align', 'polldaddy' );?></td>
3655
  <td>
3656
  <select id="font_align" onchange="pd_bind(this);" name="font_align"><?php
3657
+ $select = array( __( 'Left', 'polldaddy' ) => "left", __( 'Center', 'polldaddy' ) => "center", __( 'Right', 'polldaddy' ) => "right" );
3658
+ foreach ( $select as $option => $value ):
3659
+ $selected = '';
3660
+ if ( $settings->font_align == $value )
3661
+ $selected = ' selected="selected"';
3662
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3663
+ endforeach;?>
3664
  </select>
3665
  </td>
3666
  </tr>
3667
  <tr>
3668
+ <td height="30"><?php _e( 'Position', 'polldaddy' );?></td>
3669
  <td>
3670
  <select name="font_position" onchange="pd_bind(this);" id="font_position"><?php
3671
+ $select = array( __( 'Top', 'polldaddy' ) => "top", __( 'Right', 'polldaddy' ) => "right", __( 'Bottom', 'polldaddy' ) => "bottom" );
3672
+ foreach ( $select as $option => $value ) :
3673
+ $selected = '';
3674
+ if ( $settings->font_position == $value )
3675
+ $selected = ' selected="selected"';
3676
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3677
+ endforeach;?>
3678
  </select>
3679
  </td>
3680
  </tr>
3681
  <tr>
3682
+ <td height="30"><?php _e( 'Font', 'polldaddy' );?></td>
3683
  <td>
3684
  <select name="font_family" id="font_family" onchange="pd_bind(this);"><?php
3685
+ $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" );
3686
+ foreach ( $select as $option => $value ) :
3687
+ $selected = '';
3688
+ if ( $settings->font_family == $value )
3689
+ $selected = ' selected="selected"';
3690
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>';
3691
+ endforeach;?>
3692
  </select>
3693
  </td>
3694
  </tr>
3695
  <tr>
3696
+ <td height="30"><?php _e( 'Color', 'polldaddy' );?></td>
3697
+ <td><input type="text" onblur="pd_bind(this);" class="elmColor jscolor-picker" name="font_color" id="font_color" value="<?php echo wp_specialchars( $settings->font_color ); ?>" maxlength="11" autocomplete="off"/>
3698
  </td>
3699
  </tr>
3700
  <tr>
3701
+ <td><?php _e( 'Size', 'polldaddy' );?></td>
3702
  <td>
3703
  <select name="font_size" id="font_size" onchange="pd_bind(this);"><?php
3704
+ $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", );
3705
+ foreach ( $select as $option => $value ) :
3706
+ $selected = '';
3707
+ if ( $settings->font_size == $value )
3708
+ $selected = ' selected="selected"';
3709
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3710
+ endforeach;?>
3711
  </select>
3712
  </td>
3713
  </tr>
3714
  <tr>
3715
+ <td height="30"><?php _e( 'Line Height', 'polldaddy' );?></td>
3716
  <td>
3717
  <select name="font_line_height" id="font_line_height" onchange="pd_bind(this);"><?php
3718
+ $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", );
3719
+ foreach ( $select as $option => $value ) :
3720
+ $selected = '';
3721
+ if ( $settings->font_line_height == $value )
3722
+ $selected = ' selected="selected"';
3723
+ echo '<option value="' . $value . '" ' . $selected . '>' . $option . '</option>' . "\n";
3724
+ endforeach; ?>
3725
  </select>
3726
  </td>
3727
  </tr>
3728
  <tr>
3729
+ <td height="30"><?php _e( 'Bold', 'polldaddy' );?></td>
3730
+ <td><?php
3731
+ $checked = '';
3732
+ if ( $settings->font_bold == 'bold' )
3733
+ $checked = ' checked="checked"';?>
3734
+ <input type="checkbox" name="font_bold" onclick="pd_bind(this);" id="font_bold" value="bold" <?php echo $checked; ?> />
3735
  </td>
3736
  </tr>
3737
  <tr>
3738
+ <td height="30"><?php _e( 'Italic', 'polldaddy' );?></td><?php
3739
+ $checked = '';
3740
+ if ( $settings->font_italic == 'italic' )
3741
+ $checked = ' checked="checked"';?>
3742
+ <td><input type="checkbox" name="font_italic" onclick="pd_bind(this);" id="font_italic" value="italic" <?php echo $checked; ?>/></td>
3743
  </tr>
3744
  </table>
3745
  </div>
3746
  </div>
3747
+ <?php
3748
+ if ( $this->is_admin ) { ?>
3749
  <div class="postbox">
3750
+ <h3><?php _e( 'Extra Settings', 'polldaddy' );?></h3>
3751
  <div class="inside">
3752
+ <table>
3753
  <tr>
3754
+ <td width="100" height="30"><?php _e( 'Results Popup', 'polldaddy' );?></td>
3755
  <td>
3756
  <input type="checkbox" onchange="pd_bind(this);" value="on" name="polldaddy-rating-popup" id="polldaddy-rating-popup" <?php echo !$popup_disabled ? 'checked="checked"' : ''; ?> />
3757
  </td>
3761
  </span>
3762
  </td>
3763
  </tr><?php
3764
+ if ( $report_type == 'posts' ) {
3765
+ $exclude_post_ids = wp_specialchars( get_option( 'pd-rating-exclude-post-ids' ) ); ?>
3766
  <tr>
3767
+ <td width="100" height="30"><?php _e( 'Rating ID', 'polldaddy' );?></td>
3768
  <td>
3769
  <input type="text" name="polldaddy-post-rating-id" id="polldaddy-post-rating-id" value="<?php echo $rating_id; ?>" />
3770
  </td>
3775
  </td>
3776
  </tr>
3777
  <tr>
3778
+ <td width="100" height="30"><?php _e( 'Exclude Posts', 'polldaddy' );?></td>
3779
  <td>
3780
  <input type="text" name="exclude-post-ids" id="exclude-post-ids" value="<?php echo $exclude_post_ids; ?>" />
3781
  </td>
3785
  </span>
3786
  </td>
3787
  </tr><?php
3788
+ } else if ( $report_type == 'pages' ) {
3789
+ $exclude_page_ids = wp_specialchars( get_option( 'pd-rating-exclude-page-ids' ) ); ?>
3790
  <tr>
3791
+ <td width="100" height="30"><?php _e( 'Rating ID', 'polldaddy' );?></td>
3792
  <td>
3793
  <input type="text" name="polldaddy-page-rating-id" id="polldaddy-page-rating-id" value="<?php echo $rating_id; ?>" />
3794
  </td>
3799
  </td>
3800
  </tr>
3801
  <tr>
3802
+ <td width="100" height="30"><?php _e( 'Exclude Pages', 'polldaddy' );?></td>
3803
  <td>
3804
  <input type="text" name="exclude-page-ids" id="exclude-page-ids" value="<?php echo $exclude_page_ids; ?>" />
3805
  </td>
3808
  <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>
3809
  </span>
3810
  </td>
3811
+ </tr><?php
3812
+ } else if ( $report_type == 'comments' ) { ?>
3813
  <tr>
3814
+ <td width="100" height="30"><?php _e( 'Rating ID', 'polldaddy' );?></td>
3815
  <td>
3816
  <input type="text" name="polldaddy-comment-rating-id" id="polldaddy-comment-rating-id" value="<?php echo $rating_id; ?>" />
3817
  </td>
3821
  </span>
3822
  </td>
3823
  </tr><?php
3824
+ } ?>
3825
  </table>
3826
  </div>
3827
  </div>
3830
  </div>
3831
  </form>
3832
  <script language="javascript">
3833
+ jQuery( document ).ready(function(){
3834
  plugin = new Plugin( {
3835
+ delete_rating: '<?php echo esc_attr( __( 'Are you sure you want to delete the rating for "%s"?', 'polldaddy' ) ); ?>',
3836
+ delete_poll: '<?php echo esc_attr( __( 'Are you sure you want to delete "%s"?', 'polldaddy' ) ); ?>',
3837
+ delete_answer: '<?php echo esc_attr( __( 'Are you sure you want to delete this answer?', 'polldaddy' ) ); ?>',
3838
+ delete_answer_title: '<?php echo esc_attr( __( 'delete this answer', 'polldaddy' ) ); ?>',
3839
+ standard_styles: '<?php echo esc_attr( __( 'Standard Styles', 'polldaddy' ) ); ?>',
3840
+ custom_styles: '<?php echo esc_attr( __( 'Custom Styles', 'polldaddy' ) ); ?>'
3841
  } );
3842
  });
3843
  </script>
3844
  <script type="text/javascript">
3845
+ PDRTJS_settings = <?php echo $settings_text; ?>;
3846
+ PDRTJS_settings.id = "1";
3847
  PDRTJS_settings.unique_id = "xxx";
3848
  PDRTJS_settings.title = "";
3849
+ PDRTJS_settings.override = "<?php echo esc_attr( $rating_id ); ?>";
3850
  PDRTJS_settings.permalink = "";
3851
  PDRTJS_1 = new PDRTJS_RATING( PDRTJS_settings );
3852
+ pd_change_type( <?php echo $rating_type?> );
3853
+ </script><?php
3854
+ } ?>
 
 
3855
  </div><?php
3856
+ } // from if !error ?>
3857
+ </div><?php
3858
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3859
 
3860
+ function update_rating() {
3861
+ $rating_type = 0;
3862
+ $rating_id = 0;
3863
+ $new_rating_id = 0;
3864
+ $type = 'post';
3865
+ $set = null;
3866
 
3867
+ if ( isset( $_REQUEST['rating_id'] ) )
3868
+ $rating_id = (int) $_REQUEST['rating_id'];
 
3869
 
3870
+ if ( isset( $_REQUEST['polldaddy-post-rating-id'] ) ) {
3871
+ $new_rating_id = (int) $_REQUEST['polldaddy-post-rating-id'];
3872
+ $type = 'posts';
3873
+ }
3874
+ else if ( isset( $_REQUEST['polldaddy-page-rating-id'] ) ) {
3875
+ $new_rating_id = (int) $_REQUEST['polldaddy-page-rating-id'];
3876
+ $type = 'pages';
3877
+ }
3878
+ else if ( isset( $_REQUEST['polldaddy-comment-rating-id'] ) ) {
3879
+ $new_rating_id = (int) $_REQUEST['polldaddy-comment-rating-id'];
3880
+ $type = 'comments';
3881
+ } else {
3882
+ $new_rating_id = $rating_id;
3883
+ }
3884
 
3885
+ if ( $rating_id > 0 && $rating_id == $new_rating_id ) {
3886
+ if ( isset( $_REQUEST['rating_type'] ) && $_REQUEST['rating_type'] == 'stars' ) {
3887
+ $set->type = 'stars';
3888
+ $rating_type = 0;
3889
+ if ( isset( $_REQUEST['star_color'] ) )
3890
+ $set->star_color = attribute_escape( $_REQUEST['star_color'] );
3891
+ } else {
3892
+ $set->type = 'nero';
3893
+ $rating_type = 1;
3894
+ if ( isset( $_REQUEST['nero_style'] ) )
3895
+ $set->star_color = attribute_escape( $_REQUEST['nero_style'] );
3896
+ }
3897
 
3898
+ $set->size = wp_specialchars( $_REQUEST['size'], 1 );
3899
+ $set->custom_star = wp_specialchars( clean_url( $_REQUEST['custom_star'] ) , 1 );
3900
+ $set->font_align = wp_specialchars( $_REQUEST['font_align'], 1 );
3901
+ $set->font_position = wp_specialchars( $_REQUEST['font_position'], 1 );
3902
+ $set->font_family = wp_specialchars( $_REQUEST['font_family'], 1 );
3903
+ $set->font_size = wp_specialchars( $_REQUEST['font_size'], 1 );
3904
+ $set->font_line_height = wp_specialchars( $_REQUEST['font_line_height'], 1 );
3905
+
3906
+ if ( isset( $_REQUEST['font_bold'] ) && $_REQUEST['font_bold'] == 'bold' )
3907
+ $set->font_bold = 'bold';
3908
+ else
3909
+ $set->font_bold = 'normal';
3910
+
3911
+ if ( isset( $_REQUEST['font_italic'] ) && $_REQUEST['font_italic'] == 'italic' )
3912
+ $set->font_italic = 'italic';
3913
+ else
3914
+ $set->font_italic = 'normal';
3915
+
3916
+ $set->text_vote = stripslashes( wp_specialchars( $_REQUEST['text_vote'], 1 ) );
3917
+ $set->text_votes = stripslashes( wp_specialchars( $_REQUEST['text_votes'], 1 ) );
3918
+ $set->text_rate_this = stripslashes( wp_specialchars( $_REQUEST['text_rate_this'], 1 ) );
3919
+ $set->text_1_star = stripslashes( wp_specialchars( $_REQUEST['text_1_star'], 1 ) );
3920
+ $set->text_2_star = stripslashes( wp_specialchars( $_REQUEST['text_2_star'], 1 ) );
3921
+ $set->text_3_star = stripslashes( wp_specialchars( $_REQUEST['text_3_star'], 1 ) );
3922
+ $set->text_4_star = stripslashes( wp_specialchars( $_REQUEST['text_4_star'], 1 ) );
3923
+ $set->text_5_star = stripslashes( wp_specialchars( $_REQUEST['text_5_star'], 1 ) );
3924
+ $set->text_thank_you = stripslashes( wp_specialchars( $_REQUEST['text_thank_you'], 1 ) );
3925
+ $set->text_rate_up = stripslashes( wp_specialchars( $_REQUEST['text_rate_up'], 1 ) );
3926
+ $set->text_rate_down = stripslashes( wp_specialchars( $_REQUEST['text_rate_down'], 1 ) );
3927
+ $set->font_color = stripslashes( wp_specialchars( $_REQUEST['font_color'], 1 ) );
3928
+
3929
+ $set->text_popcontent= stripslashes( wp_specialchars( $_REQUEST['text_popcontent'], 1 ) );
3930
+ $set->text_close = stripslashes( wp_specialchars( $_REQUEST['text_close'], 1 ) );
3931
+ $set->text_all = stripslashes( wp_specialchars( $_REQUEST['text_all'], 1 ) );
3932
+ $set->text_today = stripslashes( wp_specialchars( $_REQUEST['text_today'], 1 ) );
3933
+ $set->text_thisweek = stripslashes( wp_specialchars( $_REQUEST['text_thisweek'], 1 ) );
3934
+ $set->text_thismonth = stripslashes( wp_specialchars( $_REQUEST['text_thismonth'], 1 ) );
3935
+ $set->text_rated = stripslashes( wp_specialchars( $_REQUEST['text_rated'], 1 ) );
3936
+ $set->text_noratings = stripslashes( wp_specialchars( $_REQUEST['text_noratings'], 1 ) );
3937
+
3938
+
3939
+ $set->popup = 'off';
3940
+ if ( isset( $_REQUEST['polldaddy-rating-popup'] ) )
3941
+ $set->popup = ( $_REQUEST['polldaddy-rating-popup'] == 'on' ? 'on' : 'off' );
3942
+
3943
+ $settings_text = json_encode( $set );
3944
+
3945
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
3946
+ $polldaddy->reset();
3947
+ $rating = $polldaddy->update_rating( $rating_id, $settings_text, $rating_type );
3948
+ }
3949
+ else if ( $this->is_admin && $new_rating_id > 0 ) {
3950
+ switch ( $type ) {
3951
+ case 'pages':
3952
+ update_option( 'pd-rating-pages-id', $new_rating_id );
3953
+ if ( (int) get_option( 'pd-rating-pages' ) > 0 )
3954
+ update_option( 'pd-rating-pages', $new_rating_id );
3955
+ break;
3956
+ case 'comments':
3957
+ update_option( 'pd-rating-comments-id', $new_rating_id );
3958
+ if ( (int) get_option( 'pd-rating-comments' ) > 0 )
3959
+ update_option( 'pd-rating-comments', $new_rating_id );
3960
  break;
3961
+ case 'posts':
3962
+ update_option( 'pd-rating-posts-id', $new_rating_id );
3963
+ if ( (int) get_option( 'pd-rating-posts' ) > 0 )
3964
+ update_option( 'pd-rating-posts', $new_rating_id );
3965
+ }
3966
+ }
3967
+
3968
+ if ( $this->is_admin ) {
3969
+ if ( $type=='posts' && isset( $_REQUEST['exclude-post-ids'] ) ) {
3970
+ $exclude_post_ids = $_REQUEST['exclude-post-ids'];
3971
+ if ( empty( $exclude_post_ids ) ) {
3972
+ update_option( 'pd-rating-exclude-post-ids', '' );
3973
+ } else {
3974
+ $post_ids = array();
3975
+ $ids = explode( ',', $exclude_post_ids );
3976
+ if ( !empty( $ids ) ) {
3977
+ foreach ( (array) $ids as $id ) {
3978
+ if ( (int) $id > 0 )
3979
+ $post_ids[] = (int) $id;
3980
+ }
3981
+ }
3982
+ if ( !empty( $post_ids ) ) {
3983
+ $exclude_post_ids = implode( ',', $post_ids );
3984
+ update_option( 'pd-rating-exclude-post-ids', $exclude_post_ids );
3985
+ }
3986
+ }
3987
+ }
3988
+
3989
+ if ( $type=='pages' && isset( $_REQUEST['exclude-page-ids'] ) ) {
3990
+ $exclude_page_ids = $_REQUEST['exclude-page-ids'];
3991
+ if ( empty( $exclude_page_ids ) ) {
3992
+ update_option( 'pd-rating-exclude-page-ids', '' );
3993
+ } else {
3994
+ $page_ids = array();
3995
+ $ids = explode( ',', $exclude_page_ids );
3996
+ if ( !empty( $ids ) ) {
3997
+ foreach ( (array) $ids as $id ) {
3998
+ if ( (int) $id > 0 )
3999
+ $page_ids[] = (int) $id;
4000
+ }
4001
+ }
4002
+ if ( !empty( $page_ids ) ) {
4003
+ $exclude_page_ids = implode( ',', $page_ids );
4004
+ update_option( 'pd-rating-exclude-page-ids', $exclude_page_ids );
4005
+ }
4006
+ }
4007
+ }
4008
+ }
4009
+ }
4010
+ function rating_reports() {
4011
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->rating_user_code );
4012
+ $rating_id = get_option( 'pd-rating-posts-id' );
4013
+
4014
+ $report_type = 'posts';
4015
+ $period = '7';
4016
+ $show_rating = 0;
4017
+
4018
+ if ( isset( $_REQUEST['change-report-to'] ) ) {
4019
+ switch ( $_REQUEST['change-report-to'] ) :
4020
+ case 'pages':
4021
+ $report_type = 'pages';
4022
+ $rating_id = (int) get_option( 'pd-rating-pages-id' );
4023
+ break;
4024
+
4025
+ case 'comments':
4026
+ $report_type = 'comments';
4027
+ $rating_id = get_option( 'pd-rating-comments-id' );
4028
+ break;
4029
+
4030
+ case 'posts':
4031
+ $report_type = 'posts';
4032
+ $rating_id = get_option( 'pd-rating-posts-id' );
4033
+ break;
4034
+ endswitch;
4035
+ }
4036
+
4037
+ if ( isset( $_REQUEST['filter'] ) && $_REQUEST['filter'] ) {
4038
+ switch ( $_REQUEST['filter'] ) :
4039
+ case '1':
4040
+ $period = '1';
4041
+ break;
4042
+
4043
+ case '7':
4044
+ $period = '7';
4045
+ break;
4046
+
4047
+ case '31':
4048
+ $period = '31';
4049
+ break;
4050
+
4051
+ case '90':
4052
+ $period = '90';
4053
+ break;
4054
+
4055
+ case '365':
4056
+ $period = '365';
4057
+ break;
4058
+
4059
+ case 'all':
4060
+ $period = 'all';
4061
+ break;
4062
  endswitch;
4063
  }
4064
 
4065
+ $page_size = 15;
4066
  $current_page = 1;
4067
 
4068
+ if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'change-report' ) {
4069
  $current_page = 1;
4070
  } else {
4071
  if ( isset( $_REQUEST['paged'] ) ) {
4078
  $start = ( $current_page * $page_size ) - $page_size;
4079
  $end = $page_size;
4080
 
4081
+ $response = $polldaddy->get_rating_results( $rating_id, $period, $start, $end );
4082
+
4083
+ $total = $total_pages = 0;
4084
+ $ratings = null;
4085
+
4086
+ if ( !empty( $response ) ) {
4087
+ $ratings = $response->rating;
4088
+ $total = (int) $response->_total;
4089
+ $total_pages = ceil( $total / $page_size );
4090
+ }
4091
+
4092
  $page_links = paginate_links( array(
4093
+ 'base' => add_query_arg( array ( 'paged' => '%#%', 'change-report-to' => $report_type, 'filter' => $period ) ),
4094
+ 'format' => '',
4095
+ 'prev_text' => __( '&laquo;', 'polldaddy' ),
4096
+ 'next_text' => __( '&raquo;', 'polldaddy' ),
4097
+ 'total' => $total_pages,
4098
+ 'current' => $current_page
4099
+ ) );
4100
+ ?>
4101
  <div class="wrap">
4102
+ <h2><?php _e( 'Rating Reports', 'polldaddy' );?> <span style="font-size: 16px;">(<?php echo $report_type; ?>)</span></h2>
4103
  <div class="clear"></div>
4104
  <form method="post" action="admin.php?page=ratings&action=reports">
4105
  <div class="tablenav">
4112
  <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply', 'polldaddy' ); ?>" />
4113
  <?php wp_nonce_field( 'action-rating_bulk' ); ?>
4114
  <select name="change-report-to"><?php
4115
+ $select = array( __( 'Posts', 'polldaddy' ) => "posts", __( 'Pages', 'polldaddy' ) => "pages", __( 'Comments', 'polldaddy' ) => "comments" );
4116
+ foreach ( $select as $option => $value ) :
4117
+ $selected = '';
4118
+ if ( $value == $report_type )
4119
+ $selected = ' selected="selected"';?>
4120
  <option value="<?php echo $value; ?>" <?php echo $selected; ?>><?php echo $option; ?></option>
4121
  <?php endforeach; ?>
4122
  </select>
4123
  <select name="filter"><?php
4124
+ $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" );
4125
  foreach ( $select as $option => $value ) :
4126
  $selected = '';
4127
+ if ( $value == $period )
4128
+ $selected = ' selected="selected"';?>
4129
  <option value="<?php echo $value; ?>" <?php echo $selected; ?>><?php echo $option; ?></option>
4130
  <?php endforeach; ?>
4131
  </select>
4132
+ <input class="button-secondary action" type="submit" value="<?php _e( 'Filter', 'polldaddy' );?>" />
4133
  </div>
4134
  <div class="alignright">
4135
  <div class="tablenav-pages">
4136
+ <?php echo $page_links; ?>
4137
+ </div>
4138
  </div>
4139
  </div>
4140
 
4141
  <table class="widefat"><?php
4142
+ if ( empty( $ratings ) ) { ?>
4143
  <tbody>
4144
  <tr>
4145
+ <td colspan="4"><?php printf( __( 'No ratings have been collected for your %s yet.', 'polldaddy' ), $report_type ); ?></td>
4146
  </tr>
4147
  </tbody><?php
4148
+ } else { ?>
4149
  <thead>
4150
  <tr>
4151
  <th scope="col" class="manage-column column-cb check-column" id="cb"><input type="checkbox"></th>
4152
+ <th scope="col" class="manage-column column-title" id="title"><?php _e( 'Title', 'polldaddy' );?></th>
4153
+ <th scope="col" class="manage-column column-id" id="id"><?php _e( 'Unique ID', 'polldaddy' );?></th>
4154
+ <th scope="col" class="manage-column column-date" id="date"><?php _e( 'Start Date', 'polldaddy' );?></th>
4155
+ <th scope="col" class="manage-column column-vote num" id="votes"><?php _e( 'Votes', 'polldaddy' );?></th>
4156
+ <th scope="col" class="manage-column column-rating num" id="rating"><?php _e( 'Average Rating', 'polldaddy' );?></th>
4157
  </tr>
4158
  </thead>
4159
  <tbody><?php
4160
+ $alt_counter = 0;
4161
+ $alt = '';
4162
 
4163
+ foreach ( $ratings as $rating ) :
4164
+ $delete_link = clean_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" ) );
4165
+ $alt_counter++;?>
4166
  <tr <?php echo ( $alt_counter & 1 ) ? ' class="alternate"' : ''; ?>>
4167
  <th class="check-column" scope="row"><input type="checkbox" value="<?php echo wp_specialchars( $rating->uid ); ?>" name="rating[]" /></th>
4168
  <td class="post-title column-title">
4177
  <?php echo wp_specialchars( $rating->uid ); ?>
4178
  </td>
4179
  <td class="date column-date">
4180
+ <abbr title="<?php echo date( __( 'Y/m/d g:i:s A', 'polldaddy' ), $rating->date ); ?>"><?php echo str_replace( '-', '/', substr( wp_specialchars( $rating->date ), 0, 10 ) ); ?></abbr>
4181
  </td>
4182
  <td class="column-vote num"><?php echo number_format( $rating->_votes ); ?></td>
4183
  <td class="column-rating num"><table width="100%"><tr align="center"><td style="border:none;"><?php
4184
+ if ( $rating->_type == 0 ) {
4185
+ $avg_rating = $this->round( $rating->average_rating, 0.5 );?>
4186
  <div style="width:100px"><?php
4187
+ $image_pos = '';
4188
+
4189
+ for ( $c = 1; $c <= 5; $c++ ) :
4190
+ if ( $avg_rating > 0 ) {
4191
+ if ( $avg_rating < $c )
4192
+ $image_pos = 'bottom left';
4193
+ if ( $avg_rating == ( $c - 1 + 0.5 ) )
4194
+ $image_pos = 'center left';
4195
+ } ?>
4196
+ <div style="width: 20px; height: 20px; background: url(http://i.polldaddy.com/ratings/images/star-yellow-med.png) <?php echo $image_pos; ?>; float: left;"></div><?php
4197
+ endfor; ?>
4198
  <br class="clear" />
4199
+ </div><?php
4200
+ } else { ?>
4201
  <div>
4202
  <div style="margin: 0px 0px 0px 20px; background: transparent url(http://i.polldaddy.com/images/rate-graph-up.png); width: 20px; height: 20px; float: left;"></div>
4203
+ <div style="float:left; line-height: 20px; padding: 0px 10px 0px 5px;"><?php echo number_format( $rating->total1 );?></div>
4204
  <div style="margin: 0px; background: transparent url(http://i.polldaddy.com/images/rate-graph-dn.png); width: 20px; height: 20px; float: left;"></div>
4205
  <div style="float:left; line-height: 20px; padding: 0px 10px 0px 5px;"><?php echo number_format( $rating->total2 );?></div>
4206
  <br class="clear" />
4207
+ </div><?php
4208
+ } ?>
4209
  </td></tr></table>
4210
  </td>
4211
+ </tr><?php
4212
+ endforeach;
4213
+ ?>
4214
+ </tbody><?php
4215
+ } ?>
4216
  </table>
4217
  <div class="tablenav">
4218
  <div class="alignright">
4221
  </div>
4222
  </div>
4223
  </div>
4224
+ </form>
4225
  </div>
4226
  <p></p>
4227
  <script language="javascript">
4228
+ jQuery( document ).ready(function(){
4229
  plugin = new Plugin( {
4230
+ delete_rating: '<?php echo esc_attr( __( 'Are you sure you want to delete the rating for "%s"?', 'polldaddy' ) ); ?>',
4231
+ delete_poll: '<?php echo esc_attr( __( 'Are you sure you want to delete "%s"?', 'polldaddy' ) ); ?>',
4232
+ delete_answer: '<?php echo esc_attr( __( 'Are you sure you want to delete this answer?', 'polldaddy' ) ); ?>',
4233
+ delete_answer_title: '<?php echo esc_attr( __( 'delete this answer', 'polldaddy' ) ); ?>',
4234
+ standard_styles: '<?php echo esc_attr( __( 'Standard Styles', 'polldaddy' ) ); ?>',
4235
+ custom_styles: '<?php echo esc_attr( __( 'Custom Styles', 'polldaddy' ) ); ?>'
4236
  } );
4237
  });
4238
  </script><?php
4239
  }
4240
+
4241
  function plugin_options() {
4242
+ if ( isset( $_POST['polldaddy_email'] ) ) {
4243
+ $account_email = attribute_escape( $_POST['polldaddy_email'] );
4244
+ }
4245
+ else {
4246
+ $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, $this->user_code );
4247
+ $account = $polldaddy->get_account();
4248
+
4249
+ if ( !empty( $account ) )
4250
+ $account_email = attribute_escape( $account->email );
4251
+
4252
+ $polldaddy->reset();
4253
+ $poll = $polldaddy->get_poll( 1 );
4254
+
4255
+ $options = array(
4256
+ 101 => __( 'Aluminum Narrow', 'polldaddy' ),
4257
+ 102 => __( 'Aluminum Medium', 'polldaddy' ),
4258
+ 103 => __( 'Aluminum Wide', 'polldaddy' ),
4259
+ 104 => __( 'Plain White Narrow', 'polldaddy' ),
4260
+ 105 => __( 'Plain White Medium', 'polldaddy' ),
4261
+ 106 => __( 'Plain White Wide', 'polldaddy' ),
4262
+ 107 => __( 'Plain Black Narrow', 'polldaddy' ),
4263
+ 108 => __( 'Plain Black Medium', 'polldaddy' ),
4264
+ 109 => __( 'Plain Black Wide', 'polldaddy' ),
4265
+ 110 => __( 'Paper Narrow', 'polldaddy' ),
4266
+ 111 => __( 'Paper Medium', 'polldaddy' ),
4267
+ 112 => __( 'Paper Wide', 'polldaddy' ),
4268
+ 113 => __( 'Skull Dark Narrow', 'polldaddy' ),
4269
+ 114 => __( 'Skull Dark Medium', 'polldaddy' ),
4270
+ 115 => __( 'Skull Dark Wide', 'polldaddy' ),
4271
+ 116 => __( 'Skull Light Narrow', 'polldaddy' ),
4272
+ 117 => __( 'Skull Light Medium', 'polldaddy' ),
4273
+ 118 => __( 'Skull Light Wide', 'polldaddy' ),
4274
+ 157 => __( 'Micro', 'polldaddy' ),
4275
+ 119 => __( 'Plastic White Narrow', 'polldaddy' ),
4276
+ 120 => __( 'Plastic White Medium', 'polldaddy' ),
4277
+ 121 => __( 'Plastic White Wide', 'polldaddy' ),
4278
+ 122 => __( 'Plastic Grey Narrow', 'polldaddy' ),
4279
+ 123 => __( 'Plastic Grey Medium', 'polldaddy' ),
4280
+ 124 => __( 'Plastic Grey Wide', 'polldaddy' ),
4281
+ 125 => __( 'Plastic Black Narrow', 'polldaddy' ),
4282
+ 126 => __( 'Plastic Black Medium', 'polldaddy' ),
4283
+ 127 => __( 'Plastic Black Wide', 'polldaddy' ),
4284
+ 128 => __( 'Manga Narrow', 'polldaddy' ),
4285
+ 129 => __( 'Manga Medium', 'polldaddy' ),
4286
+ 130 => __( 'Manga Wide', 'polldaddy' ),
4287
+ 131 => __( 'Tech Dark Narrow', 'polldaddy' ),
4288
+ 132 => __( 'Tech Dark Medium', 'polldaddy' ),
4289
+ 133 => __( 'Tech Dark Wide', 'polldaddy' ),
4290
+ 134 => __( 'Tech Grey Narrow', 'polldaddy' ),
4291
+ 135 => __( 'Tech Grey Medium', 'polldaddy' ),
4292
+ 136 => __( 'Tech Grey Wide', 'polldaddy' ),
4293
+ 137 => __( 'Tech Light Narrow', 'polldaddy' ),
4294
+ 138 => __( 'Tech Light Medium', 'polldaddy' ),
4295
+ 139 => __( 'Tech Light Wide', 'polldaddy' ),
4296
+ 140 => __( 'Working Male Narrow', 'polldaddy' ),
4297
+ 141 => __( 'Working Male Medium', 'polldaddy' ),
4298
+ 142 => __( 'Working Male Wide', 'polldaddy' ),
4299
+ 143 => __( 'Working Female Narrow', 'polldaddy' ),
4300
+ 144 => __( 'Working Female Medium', 'polldaddy' ),
4301
+ 145 => __( 'Working Female Wide', 'polldaddy' ),
4302
+ 146 => __( 'Thinking Male Narrow', 'polldaddy' ),
4303
+ 147 => __( 'Thinking Male Medium', 'polldaddy' ),
4304
+ 148 => __( 'Thinking Male Wide', 'polldaddy' ),
4305
+ 149 => __( 'Thinking Female Narrow', 'polldaddy' ),
4306
+ 150 => __( 'Thinking Female Medium', 'polldaddy' ),
4307
+ 151 => __( 'Thinking Female Wide', 'polldaddy' ),
4308
+ 152 => __( 'Sunset Narrow', 'polldaddy' ),
4309
+ 153 => __( 'Sunset Medium', 'polldaddy' ),
4310
+ 154 => __( 'Sunset Wide', 'polldaddy' ),
4311
+ 155 => __( 'Music Medium', 'polldaddy' ),
4312
+ 156 => __( 'Music Wide', 'polldaddy' )
4313
+ );
4314
+
4315
+ $polldaddy->reset();
4316
+ $styles = $polldaddy->get_styles();
4317
+
4318
+ if ( !empty( $styles ) && !empty( $styles->style ) && count( $styles->style ) > 0 ) {
4319
+ foreach ( (array) $styles->style as $style ) {
4320
+ $options[ (int) $style->_id ] = $style->title;
4321
+ }
4322
+ }
4323
+ }
4324
+ $this->print_errors();
4325
+ ?>
4326
  <div id="options-page" class="wrap">
4327
  <div class="icon32" id="icon-options-general"><br/></div>
4328
  <h2>
4329
  <?php _e( 'Options', 'polldaddy' ); ?>
4330
  </h2>
4331
+ <?php if ( $this->is_admin || $this->multiple_accounts ) {?>
4332
  <h3>
4333
  <?php _e( 'PollDaddy Account Info', 'polldaddy' ); ?>
4334
  </h3>
4384
  <td>
4385
  <fieldset>
4386
  <legend class="screen-reader-text"><span>poll-defaults</span></legend><?php
4387
+ $selected = '';
4388
+ if ( $poll->multipleChoice == 'yes' )
4389
+ $selected = 'checked="checked"';?>
4390
  <label for="multipleChoice"><input type="checkbox" <?php echo $selected; ?> value="1" id="multipleChoice" name="multipleChoice"> <?php _e( 'Multiple Choice', 'polldaddy' ); ?></label>
4391
  <br /><?php
4392
+ $selected = '';
4393
+ if ( $poll->randomiseAnswers == 'yes' )
4394
+ $selected = 'checked="checked"';?>
4395
  <label for="randomiseAnswers"><input type="checkbox" <?php echo $selected; ?> value="1" id="randomiseAnswers" name="randomiseAnswers"> <?php _e( 'Randomise Answers', 'polldaddy' ); ?></label>
4396
  <br /><?php
4397
+ $selected = '';
4398
+ if ( $poll->otherAnswer == 'yes' )
4399
+ $selected = 'checked="checked"';?>
4400
  <label for="otherAnswer"><input type="checkbox" <?php echo $selected; ?> value="1" id="otherAnswer" name="otherAnswer"> <?php _e( 'Other Answer', 'polldaddy' ); ?></label>
4401
  <br /><?php
4402
+ $selected = '';
4403
+ if ( $poll->sharing == 'yes' )
4404
+ $selected = 'checked="checked"';?>
4405
  <label for="sharing"><input type="checkbox" <?php echo $selected; ?> value="1" id="sharing" name="sharing"> <?php _e( 'Sharing', 'polldaddy' ); ?></label>
4406
  <br />
4407
  <label for="resultsType">
4408
  <select id="resultsType" name="resultsType">
4409
+ <option <?php echo $poll->resultsType == 'show' ? 'selected="selected"':''; ?> value="show"><?php _e( 'Show', 'polldaddy' ); ?></option>
4410
+ <option <?php echo $poll->resultsType == 'hide' ? 'selected="selected"':''; ?> value="hide"><?php _e( 'Hide', 'polldaddy' ); ?></option>
4411
+ <option <?php echo $poll->resultsType == 'percent' ? 'selected="selected"':''; ?> value="percent"><?php _e( 'Percentages', 'polldaddy' ); ?></option>
4412
  </select> <?php _e( 'Poll results', 'polldaddy' ); ?>
4413
  </label>
4414
  <br />
4415
  <label for="styleID">
4416
+ <select id="styleID" name="styleID"><?php
4417
+ foreach ( (array) $options as $styleID => $label ) :
4418
+ $selected = $styleID == $poll->styleID ? ' selected="selected"' : ''; ?>
4419
+ <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option><?php
4420
+ endforeach;?>
4421
  </select> <?php _e( 'Poll style', 'polldaddy' ); ?>
4422
  </label>
4423
  <br />
4424
  <label for="blockRepeatVotersType">
4425
  <select id="poll-block-repeat" name="blockRepeatVotersType">
4426
+ <option <?php echo $poll->blockRepeatVotersType == 'off' ? 'selected="selected"':''; ?> value="off"><?php _e( 'Off', 'polldaddy' ); ?></option>
4427
+ <option <?php echo $poll->blockRepeatVotersType == 'cookie' ? 'selected="selected"':''; ?> value="cookie"><?php _e( 'Cookie', 'polldaddy' ); ?></option>
4428
+ <option <?php echo $poll->blockRepeatVotersType == 'cookieip' ? 'selected="selected"':''; ?> value="cookieip"><?php _e( 'Cookie & IP address', 'polldaddy' ); ?></option>
4429
  </select> <?php _e( 'Block repeat voters', 'polldaddy' ); ?>
4430
  </label>
4431
  <br />
4432
  <label for="blockExpiration">
4433
  <select id="blockExpiration" name="blockExpiration">
4434
+ <option value="0" <?php echo $poll->blockExpiration == 0 ? 'selected="selected"':''; ?>><?php _e( 'Never', 'polldaddy' ); ?></option>
4435
+ <option value="3600" <?php echo $poll->blockExpiration == 3600 ? 'selected="selected"':''; ?>><?php printf( __( '%d hour', 'polldaddy' ), 1 ); ?></option>
4436
+ <option value="10800" <?php echo (int) $poll->blockExpiration == 10800 ? 'selected="selected"' : ''; ?>><?php printf( __( '%d hours', 'polldaddy' ), 3 ); ?></option>
4437
+ <option value="21600" <?php echo (int) $poll->blockExpiration == 21600 ? 'selected="selected"' : ''; ?>><?php printf( __( '%d hours', 'polldaddy' ), 6 ); ?></option>
4438
+ <option value="43200" <?php echo (int) $poll->blockExpiration == 43200 ? 'selected="selected"' : ''; ?>><?php printf( __( '%d hours', 'polldaddy' ), 12 ); ?></option>
4439
+ <option value="86400" <?php echo (int) $poll->blockExpiration == 86400 ? 'selected="selected"' : ''; ?>><?php printf( __( '%d day', 'polldaddy' ), 1 ); ?></option>
4440
+ <option value="604800" <?php echo (int) $poll->blockExpiration == 604800 ? 'selected="selected"' : ''; ?>><?php printf( __( '%d week', 'polldaddy' ), 1 ); ?></option>
4441
+ <option value="2419200" <?php echo (int) $poll->blockExpiration == 2419200 ? 'selected="selected"' : ''; ?>><?php printf( __( '%d month', 'polldaddy' ), 1 ); ?></option>
4442
  </select> <?php _e( 'Block expiration limit', 'polldaddy' ); ?>
4443
  </label>
4444
  <br />
4456
  </form>
4457
  </div>
4458
  <?php
4459
+ }
4460
+
4461
+ function plugin_options_add() {}
4462
 
4463
+ function round( $number, $increments ) {
4464
  $increments = 1 / $increments;
4465
+ return round( $number * $increments ) / $increments;
4466
+ }
4467
 
4468
  function signup() {
4469
  return $this->api_key_page();
4470
  }
4471
 
4472
+ function can_edit( &$poll ) {
4473
+ if ( empty( $poll->_owner ) )
4474
  return true;
4475
+
4476
  if ( $this->id == $poll->_owner )
4477
  return true;
4478
 
4479
+ //check to see if poll owner is a member of this blog
4480
+ if ( function_exists( 'get_users_of_blog' ) ) { //WP 2.2 +
4481
+ if ( !array_key_exists( $poll->_owner, get_users_of_blog() ) )
4482
+ return false;
4483
+ }
4484
+
4485
  return (bool) current_user_can( 'edit_others_posts' );
4486
  }
4487
  }
rating.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
- function polldaddy_show_rating_comments( $content ){
3
- if ( !is_feed() ) {
4
  global $comment;
5
  global $post;
6
 
@@ -10,143 +10,154 @@ function polldaddy_show_rating_comments( $content ){
10
  $permalink = '';
11
  $html = '';
12
  $rating_pos = 0;
13
-
14
  if ( (int) get_option( 'pd-rating-comments' ) > 0 ) {
15
  $rating_id = (int) get_option( 'pd-rating-comments' );
16
  $unique_id = 'wp-comment-' . $comment->comment_ID;
17
- $rating_pos = (int) get_option( 'pd-rating-comments-pos' );
18
- $title = mb_substr( $comment->comment_content, 0, 195 ) . '...';
19
- $permalink = get_permalink( $post->ID ) . '#comment-' . $comment->comment_ID;
20
  $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, '_comm_' . $comment->comment_ID );
21
 
22
  wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
23
  add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
24
  }
25
 
26
- if ( $rating_pos == 0 )
27
- $content = $html . $content;
28
- else
29
- $content .= $html;
30
- }
31
  }
32
  return $content;
33
  }
34
 
35
  function polldaddy_show_rating( $content ) {
36
  if ( !is_feed() && !is_attachment() ) {
37
- if ( is_single() || is_page() || is_home() ) {
38
- $html = polldaddy_get_rating_html( 'check-options' );
39
-
40
- if( !empty( $html ) ) {
41
- $rating_pos = 0;
42
-
43
- if ( is_page() ) {
44
- $rating_pos = (int) get_option( 'pd-rating-pages-pos' );
45
- } else if( is_home() ) {
46
- $rating_pos = (int) get_option( 'pd-rating-posts-index-pos' );
47
- } else {
48
- $rating_pos = (int) get_option( 'pd-rating-posts-pos' );
49
- }
50
-
51
- if ( $rating_pos == 0 )
52
- $content = $html . $content;
53
- else
54
- $content .= $html;
55
- }
56
  }
57
  }
58
- return $content;
59
  }
60
 
61
- function polldaddy_get_rating_html( $condition = '' ){
62
- global $post;
63
- $html = '';
64
-
65
- if ( $post->ID > 0 ) {
66
- $unique_id = '';
67
- $title = '';
68
- $permalink = '';
69
- $rating_id = 0;
70
- $item_id = '';
71
- $exclude_posts = explode( ',', get_option( 'pd-rating-exclude-post-ids' ) );
72
- $exclude_pages = explode( ',', get_option( 'pd-rating-exclude-page-ids' ) );
73
-
74
- if ( is_page() ) {
75
- if( !in_array( $post->ID, $exclude_pages ) ){
76
- $unique_id = 'wp-page-' . $post->ID;
77
- $item_id = '_page_' . $post->ID;
78
- if ( $condition == 'check-options' ){
79
- if( (int) get_option( 'pd-rating-pages' ) > 0 ){
80
- $rating_id = (int) get_option( 'pd-rating-pages-id' );
81
- }
82
- } else {
83
- $rating_id = (int) get_option( 'pd-rating-pages-id' );
84
- }
85
- }
86
- } else if ( !in_array( $post->ID, $exclude_posts ) ) {
87
- $unique_id = 'wp-post-' . $post->ID;
88
- $item_id = '_post_' . $post->ID;
89
- if ( is_home() ){
90
- if ( $condition == 'check-options' ){
91
- if( (int) get_option( 'pd-rating-posts-index' ) > 0 ){
92
- $rating_id = (int) get_option( 'pd-rating-posts-id' );
93
- }
94
- } else {
95
- $rating_id = (int) get_option( 'pd-rating-posts-id' );
96
- }
97
- } else {
98
- if ( $condition == 'check-options' ){
99
- if( (int) get_option( 'pd-rating-posts' ) > 0 ){
100
- $rating_id = (int) get_option( 'pd-rating-posts-id' );
101
- }
102
- } else {
103
- $rating_id = (int) get_option( 'pd-rating-posts-id' );
104
- }
105
- }
106
- }
107
-
108
- if ( $rating_id > 0 ) {
109
- $title = $post->post_title;
110
- $permalink = get_permalink( $post->ID );
111
- $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id );
112
- wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
113
  add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
114
- }
115
- }
116
- return $html;
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
119
  function polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id = '' ) {
120
- $html = "\n".'<div class="pd-rating" id="pd_rating_holder_' . $rating_id . $item_id . '"></div>
121
- <script type="text/javascript" charset="utf-8">
122
- PDRTJS_settings_' . (int)$rating_id . $item_id . ' = {
123
- "id" : "' . (int)$rating_id . '",
124
- "unique_id" : "' . urlencode( $unique_id ) . '",
125
- "title" : "' . urlencode( $title ) . '",' . "\n";
126
-
127
- if ( $item_id != '' )
128
- $html .= ( ' "item_id" : "' . $item_id . '",' . "\n" );
129
-
130
- $html .= ' "permalink" : "' . urlencode( clean_url( $permalink ) ) . '"';
131
- $html .= "\n }\n";
132
- $html .= "</script>\n";
133
 
134
  return $html;
135
  }
136
 
137
  function polldaddy_show_rating_excerpt( $content ) {
138
- remove_filter( 'the_content', 'polldaddy_show_rating', 5 );
139
- return $content;
140
  }
141
 
142
  function polldaddy_show_rating_excerpt_for_real( $content ) {
143
- return polldaddy_show_rating( $content );
144
  }
145
 
146
- if ( (int) get_option( 'pd-rating-pages' ) > 0 || (int) get_option( 'pd-rating-posts-index' ) > 0 || (int) get_option( 'pd-rating-posts' ) > 0 ) {
147
- add_filter( 'the_content', 'polldaddy_show_rating', 5 );
148
- add_filter( 'get_the_excerpt', 'polldaddy_show_rating_excerpt', 5 );
149
- add_filter( 'the_excerpt', 'polldaddy_show_rating_excerpt_for_real' );
150
  }
151
 
152
  add_filter( 'comment_text', 'polldaddy_show_rating_comments', 50 );
1
  <?php
2
+ function polldaddy_show_rating_comments( $content ) {
3
+ if ( !is_feed() && !defined( 'DOING_AJAX' ) ) {
4
  global $comment;
5
  global $post;
6
 
10
  $permalink = '';
11
  $html = '';
12
  $rating_pos = 0;
13
+
14
  if ( (int) get_option( 'pd-rating-comments' ) > 0 ) {
15
  $rating_id = (int) get_option( 'pd-rating-comments' );
16
  $unique_id = 'wp-comment-' . $comment->comment_ID;
17
+ $rating_pos = (int) get_option( 'pd-rating-comments-pos' );
18
+ $title = mb_substr( preg_replace( '/[\x00-\x1F\x80-\xFF]/', '', $comment->comment_content ), 0, 195 ) . '...';
19
+ $permalink = get_permalink( $post->ID ) . '#comment-' . $comment->comment_ID;
20
  $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, '_comm_' . $comment->comment_ID );
21
 
22
  wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
23
  add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
24
  }
25
 
26
+ if ( $rating_pos == 0 )
27
+ $content = $html . $content;
28
+ else
29
+ $content .= $html;
30
+ }
31
  }
32
  return $content;
33
  }
34
 
35
  function polldaddy_show_rating( $content ) {
36
  if ( !is_feed() && !is_attachment() ) {
37
+ if ( is_single() || is_page() || is_home() ) {
38
+ $html = polldaddy_get_rating_html( 'check-options' );
39
+
40
+ if ( !empty( $html ) ) {
41
+ $rating_pos = 0;
42
+
43
+ if ( is_page() ) {
44
+ $rating_pos = (int) get_option( 'pd-rating-pages-pos' );
45
+ } else if ( is_home() ) {
46
+ $rating_pos = (int) get_option( 'pd-rating-posts-index-pos' );
47
+ } else {
48
+ $rating_pos = (int) get_option( 'pd-rating-posts-pos' );
49
+ }
50
+
51
+ if ( $rating_pos == 0 )
52
+ $content = $html . $content;
53
+ else
54
+ $content .= $html;
55
+ }
56
  }
57
  }
58
+ return $content;
59
  }
60
 
61
+ function polldaddy_get_rating_html( $condition = '' ) {
62
+ global $post;
63
+ $html = '';
64
+
65
+ if ( $post->ID > 0 ) {
66
+ $unique_id = '';
67
+ $title = '';
68
+ $permalink = '';
69
+ $rating_id = 0;
70
+ $item_id = '';
71
+ $exclude_posts = explode( ',', get_option( 'pd-rating-exclude-post-ids' ) );
72
+ $exclude_pages = explode( ',', get_option( 'pd-rating-exclude-page-ids' ) );
73
+
74
+ if ( is_page() ) {
75
+ if ( !in_array( $post->ID, $exclude_pages ) ) {
76
+ $unique_id = 'wp-page-' . $post->ID;
77
+ $item_id = '_page_' . $post->ID;
78
+ if ( $condition == 'check-options' ) {
79
+ if ( (int) get_option( 'pd-rating-pages' ) > 0 ) {
80
+ $rating_id = (int) get_option( 'pd-rating-pages-id' );
81
+ }
82
+ } else {
83
+ $rating_id = (int) get_option( 'pd-rating-pages-id' );
84
+ }
85
+ }
86
+ } else if ( !in_array( $post->ID, $exclude_posts ) ) {
87
+ $unique_id = 'wp-post-' . $post->ID;
88
+ $item_id = '_post_' . $post->ID;
89
+ if ( is_home() ) {
90
+ if ( $condition == 'check-options' ) {
91
+ if ( (int) get_option( 'pd-rating-posts-index' ) > 0 ) {
92
+ $rating_id = (int) get_option( 'pd-rating-posts-id' );
93
+ }
94
+ } else {
95
+ $rating_id = (int) get_option( 'pd-rating-posts-id' );
96
+ }
97
+ } else {
98
+ if ( $condition == 'check-options' ) {
99
+ if ( (int) get_option( 'pd-rating-posts' ) > 0 ) {
100
+ $rating_id = (int) get_option( 'pd-rating-posts-id' );
101
+ }
102
+ } else {
103
+ $rating_id = (int) get_option( 'pd-rating-posts-id' );
104
+ }
105
+ }
106
+ }
107
+
108
+ if ( $rating_id > 0 ) {
109
+ $title = apply_filters( 'wp_title', $post->post_title );
110
+ $permalink = get_permalink( $post->ID );
111
+ $html = polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id );
112
+ wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' );
113
  add_filter( 'wp_footer', 'polldaddy_add_rating_js' );
114
+ }
115
+ }
116
+ return $html;
117
  }
118
 
119
+ /**
120
+ * Construct a PollDaddy target div for a given rating_id and optional item_id
121
+ * Define a PollDaddy ratings variable for a given rating_id and optional item_id
122
+ *
123
+ * @param int $rating_id
124
+ * @param string $unique_id
125
+ * @param string $title Post title
126
+ * @param string $permalink Post permalink
127
+ * @param string $item_id
128
+ * @return HTML snippet with a ratings container and a related JS block defining a new variable
129
+ */
130
  function polldaddy_get_rating_code( $rating_id, $unique_id, $title, $permalink, $item_id = '' ) {
131
+ $rating_id = absint( $rating_id );
132
+ $html = "\n".'<div class="pd-rating" id="pd_rating_holder_' . $rating_id . $item_id . '"></div>';
133
+ $settings = array(
134
+ 'id'=>$rating_id,
135
+ 'unique_id'=>$unique_id,
136
+ 'title'=>trim( $title ),
137
+ 'permalink'=>esc_url_raw( $permalink )
138
+ );
139
+ if ( !empty( $item_id ) )
140
+ $settings['item_id'] = $item_id;
141
+ $html .= '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . "\n";
142
+ $html .= "PDRTJS_settings_{$rating_id}{$item_id}=" . json_encode( $settings ) . "\n";
143
+ $html .= "//--><!]]></script>\n";
144
 
145
  return $html;
146
  }
147
 
148
  function polldaddy_show_rating_excerpt( $content ) {
149
+ remove_filter( 'the_content', 'polldaddy_show_rating', 5 );
150
+ return $content;
151
  }
152
 
153
  function polldaddy_show_rating_excerpt_for_real( $content ) {
154
+ return polldaddy_show_rating( $content );
155
  }
156
 
157
+ if ( (int) get_option( 'pd-rating-pages' ) > 0 || (int) get_option( 'pd-rating-posts-index' ) > 0 || (int) get_option( 'pd-rating-posts' ) > 0 ) {
158
+ add_filter( 'the_content', 'polldaddy_show_rating', 5 );
159
+ add_filter( 'get_the_excerpt', 'polldaddy_show_rating_excerpt', 5 );
160
+ add_filter( 'the_excerpt', 'polldaddy_show_rating_excerpt_for_real' );
161
  }
162
 
163
  add_filter( 'comment_text', 'polldaddy_show_rating_comments', 50 );
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: mdawaffe, eoigal
3
  Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
4
  Requires at least: 2.6
5
- Tested up to: 3.0.1
6
- Stable tag: 1.8.9
7
 
8
  Create and manage PollDaddy polls and ratings from within WordPress.
9
 
@@ -14,13 +14,15 @@ The PollDaddy Polls and Ratings plugin allows you to create and manage polls and
14
  PollDaddy Polls is localizable and currently available in:
15
 
16
  * English
17
- * Arabic (thanks <a href="http://www.Ghorab.ws" target="_blank">Ghorab.ws</a>)
18
  * French
19
  * Spanish
20
  * Czech
21
  * Danish
22
  * Khmer
23
  * Tegulu
 
 
24
 
25
  A messages.pot file is included in the plugin - please do send us any language files!
26
 
@@ -64,9 +66,17 @@ More info here - http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks
64
  You need to select the synchronize ratings account in the Options menu to make sure the ratings API key is valid.
65
 
66
  == Change Log ==
 
 
 
 
 
 
 
67
  = 1.8.9 =
68
  * Added option to rating settings to disable ratings results popup
69
  * Fixed bug in choosing rating text color
 
70
  = 1.8.8 =
71
  * Updated style editor to catch some missing strings so they can be now be localised
72
  * Added string maps to javascript files to allow them to be localised
2
  Contributors: mdawaffe, eoigal
3
  Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
4
  Requires at least: 2.6
5
+ Tested up to: 3.1
6
+ Stable tag: 1.8.10
7
 
8
  Create and manage PollDaddy polls and ratings from within WordPress.
9
 
14
  PollDaddy Polls is localizable and currently available in:
15
 
16
  * English
17
+ * Arabic (thanks to <a href="http://www.Ghorab.ws" target="_blank">Ghorab.ws</a>)
18
  * French
19
  * Spanish
20
  * Czech
21
  * Danish
22
  * Khmer
23
  * Tegulu
24
+ * Polish (thanks to <a href="http://mkopec.eu" target="_blank">Maciej Kopeć</a>)
25
+ * Turkish (thanks to Gürol Barın)
26
 
27
  A messages.pot file is included in the plugin - please do send us any language files!
28
 
66
  You need to select the synchronize ratings account in the Options menu to make sure the ratings API key is valid.
67
 
68
  == Change Log ==
69
+ = 1.8.10 =
70
+ * Updated shortcodes to use latest Polldaddy code
71
+ * Fixed minor bug in rating results
72
+ * Fixed minor bug in poll editor to allow use of 0 as poll answer
73
+ * Added extra check to edit permissions on whether user is a blog member
74
+ * Added Turkish and Polish language packs
75
+
76
  = 1.8.9 =
77
  * Added option to rating settings to disable ratings results popup
78
  * Fixed bug in choosing rating text color
79
+
80
  = 1.8.8 =
81
  * Updated style editor to catch some missing strings so they can be now be localised
82
  * Added string maps to javascript files to allow them to be localised