Crowdsignal Dashboard – Polls, Surveys & more - Version 2.2.3

Version Description

  • Remove the "is poll owner part of blog" check on poll listings page as it caused problems for those with multiple sites. #50
  • Add a message to the poll listing page linking to the Crowdsignal Forms plugin. #51
  • Update grunt version dependency #52
  • Remove rich snippet support. It hasn't worked in years.
  • Rearrange the menus. Polls and ratings go in Feedback, Settings go Settings.
Download this release

Release Info

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

Code changes from version 2.2.2 to 2.2.3

Files changed (3) hide show
  1. polldaddy-org.php +1 -76
  2. polldaddy.php +124 -88
  3. readme.txt +13 -3
polldaddy-org.php CHANGED
@@ -82,7 +82,7 @@ class WPORG_Polldaddy extends WP_Polldaddy {
82
 
83
  $this->set_api_user_code();
84
 
85
- if ( $page == 'polls' ) {
86
  switch ( $action ) {
87
  case 'update-options' :
88
  if ( !$is_POST )
@@ -651,16 +651,6 @@ function polldaddy_login_warning() {
651
  }
652
  add_action( 'admin_notices', 'polldaddy_login_warning' );
653
 
654
- /**
655
- * check if the hook is scheduled - if not, schedule it.
656
- */
657
- function polldaddy_setup_schedule() {
658
- if ( false == wp_next_scheduled( 'polldaddy_rating_update_job' ) ) {
659
- wp_schedule_event( time(), 'twicedaily', 'polldaddy_rating_update_job');
660
- }
661
- }
662
- add_action( 'init', 'polldaddy_setup_schedule' );
663
-
664
  /**
665
  * On deactivation, remove all functions from the scheduled action hook.
666
  */
@@ -669,69 +659,4 @@ function polldaddy_deactivation() {
669
  }
670
  register_deactivation_hook( __FILE__, 'polldaddy_deactivation' );
671
 
672
- /**
673
- * On the scheduled action hook, run a function.
674
- */
675
- function polldaddy_rating_update() {
676
- if ( false == get_option( 'pd-rich-snippets', 1 ) )
677
- return false;
678
-
679
- global $polldaddy_object;
680
- $polldaddy = $polldaddy_object->get_client( WP_POLLDADDY__PARTNERGUID, get_option( 'pd-rating-usercode' ) );
681
- $rating_id = get_option( 'pd-rating-posts-id' );
682
- $finished = false;
683
- $c = 0;
684
- while ( !$finished ) {
685
- $response = $polldaddy->get_rating_results( $rating_id, 2, $c, 50 );
686
- $ratings = $response->rating;
687
- if ( false == is_array( $ratings ) )
688
- $finished = true;
689
- else
690
- polldaddy_update_ratings_cache( $ratings );
691
- $c += 50;
692
- if ( $c > 1000 ) // gotta stop somewhere
693
- $finished = true;
694
- }
695
- return true;
696
- }
697
-
698
- add_action( 'polldaddy_rating_update_job', 'polldaddy_rating_update' );
699
-
700
- function polldaddy_update_ratings_cache( $ratings ) {
701
- foreach( $ratings as $rating ) {
702
- $post_id = str_replace( 'wp-post-', '', $rating->uid );
703
- update_post_meta( $post_id, 'pd_rating', array( 'type' => $rating->_type, 'votes' => $rating->_votes,
704
- 'total1' => $rating->total1,
705
- 'total2' => $rating->total2,
706
- 'total3' => $rating->total3,
707
- 'total4' => $rating->total4,
708
- 'total5' => $rating->total5,
709
- 'average' => $rating->average_rating ) );
710
- }
711
- }
712
-
713
- function polldaddy_post_rating( $content ) {
714
- if ( false == get_option( 'pd-rich-snippets', 1 ) )
715
- return $content;
716
- if ( false == is_singular() )
717
- return $content;
718
- if ( false == get_option( 'pd-rating-usercode' ) )
719
- return $content;
720
- $rating = get_post_meta( $GLOBALS[ 'post' ]->ID, 'pd_rating' );
721
- if ( false == $rating )
722
- return $content;
723
- // convert to 5 star rating
724
- if ( $rating[0][ 'type' ] == 1 ) {
725
- $average = ceil( ( $rating[0][ 'average' ] / $rating[0][ 'votes' ] ) * 5 );
726
- } elseif ( isset( $rating[ 'average' ] ) ) {
727
- $average = $rating[ 'average' ];
728
- } else {
729
- $average = 0;
730
- }
731
- if ( $average < 0 || $average == '' )
732
- return $content;
733
- global $post;
734
- return $content . '<span class="hreview-aggregate"><span class="item"><span class="fn">"' . $post->post_title . '"</span></span>, <span class="rating"><span class="average">' . $average . '</span> out of <span class="best">5</span> based on <span class="votes">' . $rating[0][ 'votes' ] . '</span> ratings.</span></span>';
735
- }
736
- add_filter( 'the_content', 'polldaddy_post_rating' );
737
  ?>
82
 
83
  $this->set_api_user_code();
84
 
85
+ if ( 'polls' === $page || 'pollsettings' === $page ) {
86
  switch ( $action ) {
87
  case 'update-options' :
88
  if ( !$is_POST )
651
  }
652
  add_action( 'admin_notices', 'polldaddy_login_warning' );
653
 
 
 
 
 
 
 
 
 
 
 
654
  /**
655
  * On deactivation, remove all functions from the scheduled action hook.
656
  */
659
  }
660
  register_deactivation_hook( __FILE__, 'polldaddy_deactivation' );
661
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  ?>
polldaddy.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Create and manage Crowdsignal polls and ratings in WordPress
6
  * Author: Automattic, Inc.
7
  * Author URL: https://crowdsignal.com/
8
- * Version: 2.2.2
9
  */
10
 
11
  // To hardcode your Polldaddy PartnerGUID (API Key), add the (uncommented) line below with the PartnerGUID to your `wp-config.php`
@@ -84,6 +84,46 @@ class WP_Polldaddy {
84
 
85
  add_filter( 'jetpack_options_whitelist', array( $this, 'add_to_jetpack_options_whitelist' ) );
86
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
 
89
  /**
@@ -130,39 +170,33 @@ class WP_Polldaddy {
130
 
131
  $icon_encoded = 'PHN2ZyBpZD0iY29udGVudCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMjg4IDIyMCI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNGRkZGRkY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5pY29uLWJsdWU8L3RpdGxlPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTI2Mi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M0LTFsLTcuOTQtMTguNzNBMTAuMiwxMC4yLDAsMCwwLDYsMTg1LjI2WiIvPjwvc3ZnPgo=';
132
 
133
- $hook = add_menu_page(
134
- __( 'Crowdsignal', 'polldaddy' ),
135
- __( 'Crowdsignal', 'polldaddy' ),
136
- $capability,
137
- 'feedback',
138
- $function,
139
- 'data:image/svg+xml;base64,' . $icon_encoded
140
- );
141
- add_action( "load-$hook", array( &$this, 'management_page_load' ) );
 
 
 
 
142
 
143
  foreach( array( 'polls' => __( 'Polls', 'polldaddy' ), 'ratings' => __( 'Ratings', 'polldaddy' ) ) as $menu_slug => $page_title ) {
144
  $menu_title = $page_title;
145
 
146
- $hook = add_menu_page( $menu_title, $menu_title, $capability, $menu_slug, $function, 'div' );
147
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
148
-
149
- add_submenu_page( 'feedback', $page_title, $page_title, $capability, $menu_slug, $function );
150
  }
151
 
152
  // Add settings pages.
153
- foreach( array( 'polls' => __( 'Poll', 'polldaddy' ), 'ratings' => __( 'Rating', 'polldaddy' ) ) as $menu_slug => $page_title ) {
154
  // translators: %s placeholder is the setting page type (Poll or Rating).
155
  $settings_page_title = sprintf( esc_html__( '%s Settings', 'polldaddy' ), $page_title );
156
- add_submenu_page( 'feedback', $settings_page_title, $settings_page_title, $menu_slug == 'ratings' ? 'manage_options' : $capability, $menu_slug.'&action=options', $function );
157
- }
158
-
159
- remove_submenu_page( 'feedback', 'feedback' );
160
- remove_menu_page( 'polls' );
161
- remove_menu_page( 'ratings' );
162
-
163
- if ( $this->has_feedback_menu ) {
164
- add_submenu_page( 'feedback', __( 'Feedback', 'polldaddy' ), __( 'Feedback', 'polldaddy' ), 'edit_posts', 'edit.php?post_type=feedback' );
165
- remove_menu_page( 'edit.php?post_type=feedback' );
166
  }
167
 
168
  add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
@@ -407,7 +441,7 @@ class WP_Polldaddy {
407
 
408
  $this->set_api_user_code();
409
 
410
- if ( empty( $this->user_code ) && $page == 'polls' && $action !== 'options' ) {
411
  // one last try to get the user code automatically if possible
412
  $this->user_code = apply_filters_ref_array( 'polldaddy_get_user_code', array( $this->user_code, &$this ) );
413
  if ( false == $this->user_code && $action != 'restore-account' )
@@ -446,30 +480,21 @@ class WP_Polldaddy {
446
  case 'list-styles' :
447
  $plugin_page = 'polls&action=list-styles';
448
  break;
449
- case 'options' :
450
- case 'update-options' :
451
- case 'import-account' :
452
- case 'reset-account' :
453
- case 'restore-account' :
454
- $plugin_page = 'polls&action=options';
455
- break;
456
  }//end switch
 
 
457
  } elseif ( $page == 'ratings' ) {
458
- switch ( $action ) {
459
- case 'update-rating' :
460
- case 'options':
461
- $plugin_page = 'ratings&action=options';
462
- wp_enqueue_script( 'rating-text-color', "{$this->base_url}js/jscolor.js", array(), $this->version );
463
- wp_enqueue_script( 'ratings', "{$this->base_url}js/rating.js", array(), $this->version );
464
- wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
465
- 'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
466
- 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
467
- break;
468
- default :
469
- if ( empty( $action ) )
470
- $action = 'reports';
471
- $plugin_page = 'ratings&action=reports';
472
- }//end switch
473
  }
474
 
475
  wp_enqueue_style( 'polldaddy', "{$this->base_url}css/polldaddy.css", array(), $this->version );
@@ -519,7 +544,7 @@ class WP_Polldaddy {
519
 
520
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
521
 
522
- if ( $page == 'polls' ) {
523
  switch ( $action ) {
524
  case 'reset-account' : // reset everything
525
  global $current_user;
@@ -1128,7 +1153,7 @@ class WP_Polldaddy {
1128
  default :
1129
  return;
1130
  }//end switch
1131
- } elseif ( $page == 'ratings' ) {
1132
 
1133
  switch ( $action ) {
1134
  case 'delete' :
@@ -1304,6 +1329,33 @@ class WP_Polldaddy {
1304
  $this->print_errors();
1305
  }
1306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1307
  function management_page() {
1308
 
1309
  global $page, $action, $poll, $style, $rating;
@@ -1316,7 +1368,7 @@ class WP_Polldaddy {
1316
 
1317
  <?php
1318
  if ( $page == 'polls' ) {
1319
- 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
1320
  $action = '';
1321
  }
1322
  switch ( $action ) {
@@ -1387,11 +1439,6 @@ class WP_Polldaddy {
1387
  <?php
1388
  $this->style_edit_form();
1389
  break;
1390
- case 'options' :
1391
- case 'import-account' :
1392
- case 'update-options' :
1393
- $this->plugin_options();
1394
- break;
1395
  default :
1396
 
1397
  ?>
@@ -1407,7 +1454,20 @@ class WP_Polldaddy {
1407
  if ( !empty( $account ) )
1408
  $account_email = esc_attr( $account->email );
1409
  if ( isset( $account_email ) && current_user_can( 'manage_options' ) ) {
1410
- echo "<p>" . sprintf( __( 'Linked to WordPress.com Account: <strong>%s</strong> (<a target="_blank" href="admin.php?page=polls&action=options">Settings</a> / <a target="_blank" href="https://app.crowdsignal.com/">Crowdsignal.com</a>)', 'polldaddy' ), $account_email ) . "</p>";
 
 
 
 
 
 
 
 
 
 
 
 
 
1411
  }
1412
 
1413
  if ( !isset( $_GET['view'] ) )
@@ -1426,12 +1486,6 @@ class WP_Polldaddy {
1426
  case 'reports' :
1427
  $this->rating_reports();
1428
  break;
1429
- case 'update-rating' :
1430
- $this->update_rating();
1431
- $this->rating_settings();
1432
- break;
1433
- default :
1434
- $this->rating_settings();
1435
  }//end switch
1436
  }
1437
  ?>
@@ -3822,10 +3876,10 @@ src="https://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/sc
3822
 
3823
  switch ( $_POST[ 'pd_rating_action_type' ] ) {
3824
  case 'posts' :
3825
- if ( isset( $_POST[ 'pd_rich_snippets' ] ) && (int) $_POST[ 'pd_rich_snippets' ] == 1 )
3826
- $rich_snippets = 1;
3827
-
3828
- update_option( 'pd-rich-snippets', $rich_snippets );
3829
 
3830
  if ( isset( $_POST[ 'pd_show_posts' ] ) && (int) $_POST[ 'pd_show_posts' ] == 1 )
3831
  $show_posts = get_option( 'pd-rating-posts-id' );
@@ -3878,7 +3932,6 @@ src="https://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/sc
3878
  }//end switch
3879
  }
3880
 
3881
- $rich_snippets = (int) get_option( 'pd-rich-snippets', 1 );
3882
  $show_posts = (int) get_option( 'pd-rating-posts' );
3883
  $show_pages = (int) get_option( 'pd-rating-pages' );
3884
  $show_comments = (int) get_option( 'pd-rating-comments' );
@@ -3940,13 +3993,6 @@ src="https://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/sc
3940
  <table class="form-table" style="width: normal;">
3941
  <tbody>
3942
  <?php if ( $report_type == 'posts' ) { ?>
3943
- <tr valign="top">
3944
- <th scope="row"><label><?php _e( 'Rich Snippets in Search Results', 'polldaddy' );?></label></th>
3945
- <td>
3946
- <label><input type="checkbox" name="pd_rich_snippets" id="pd_rich_snippets" <?php if ( $rich_snippets == 1 ) echo ' checked="checked" '; ?> value="1" /> <?php printf( __( 'Display rich snippets in search results using post and page ratings (<a href="%s">documentation</a> and <a href="">page tester</a>)', 'polldaddy' ), 'https://support.google.com/webmasters/answer/99170', 'http://www.google.com/webmasters/tools/richsnippets' );?></label>
3947
- <p><?php _e( 'Once activated, it may take several weeks before the snippets show up in Google search results.', 'polldaddy' );?></p>
3948
- </td>
3949
- </tr>
3950
  <tr valign="top">
3951
  <th scope="row"><label><?php _e( 'Show Ratings on', 'polldaddy' );?></label></th>
3952
  <td>
@@ -4037,7 +4083,7 @@ src="https://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/sc
4037
  $previous_settings = get_option( 'polldaddy_settings' );
4038
  $current_setting = get_option( 'pd-rating-posts-id' );
4039
  if ( $current_setting && isset( $previous_settings[ 'pd-rating-posts-id' ] ) && $current_setting != $previous_settings[ 'pd-rating-posts-id' ] ) {
4040
- echo "<p>" . sprintf( __( "Previous settings for ratings on this site discovered. You can restore them on the <a href='%s'>poll settings page</a> if your site is missing ratings after resetting your connection settings.", 'polldaddy' ), "admin.php?page=polls&action=options" ) . "</p>";
4041
  }
4042
  ?>
4043
  </div>
@@ -4068,7 +4114,7 @@ src="https://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/sc
4068
  <div class="inside">
4069
  <div class="submitbox" id="submitpost">
4070
  <div id="minor-publishing" style="padding:10px;">
4071
- <input type="submit" name="save_menu" id="save_menu_header" class="button button-primary menu-save" value="<?php echo esc_attr( __( 'Save Changes', 'polldaddy' ) );?>">
4072
  <input type="hidden" name="type" value="<?php echo $report_type; ?>" />
4073
  <input type="hidden" name="rating_id" value="<?php echo $rating_id; ?>" />
4074
  <input type="hidden" name="action" value="update-rating" />
@@ -4744,7 +4790,7 @@ src="https://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/sc
4744
  ?>
4745
  <div class="wrap">
4746
  <?php if ( $this->is_admin ) : ?>
4747
- <h2 id="polldaddy-header"><?php printf( __( 'Rating Results <a href="%s" class="add-new-h2">Settings</a>', 'polldaddy' ), esc_url( 'admin.php?page=ratings&action=options' ) ); ?></h2>
4748
  <?php else : ?>
4749
  <h2 id="polldaddy-header"><?php _e( 'Rating Results', 'polldaddy' ); ?></h2>
4750
  <?php endif; ?>
@@ -4803,7 +4849,6 @@ src="https://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/sc
4803
  </tr>
4804
  </tbody><?php
4805
  } else {
4806
- polldaddy_update_ratings_cache( $ratings );
4807
  ?>
4808
  <thead>
4809
  <tr>
@@ -5237,15 +5282,6 @@ if ( false == is_object( $poll ) ) {
5237
  return true;
5238
  }
5239
 
5240
- //check to see if poll owner is a member of this blog
5241
- if ( function_exists( 'get_users' ) ) {
5242
- $user = get_users( array( 'include' => $poll->_owner ) );
5243
- if ( empty( $user ) ) {
5244
- $this->log( 'can_edit: poll owner is not a member of this blog.' );
5245
- return false;
5246
- }
5247
- }
5248
-
5249
  if ( false == (bool) current_user_can( 'edit_others_posts' ) )
5250
  $this->log( 'can_edit: current user cannot edit_others_posts.' );
5251
 
@@ -5260,7 +5296,7 @@ if ( false == is_object( $poll ) ) {
5260
  echo '<h1>' . $message . '</h1>';
5261
  echo '<p>' . __( "There are a few things you can do:" );
5262
  echo "<ul><ol>" . __( "Press reload on your browser and reload this page. There may have been a temporary problem communicating with Crowdsignal.com", "polldaddy" ) . "</ol>";
5263
- echo "<ol>" . sprintf( __( "Go to the <a href='%s'>poll settings page</a>, scroll to the end of the page and reset your connection settings. Link your account again with the same API key.", "polldaddy" ), 'admin.php?page=polls&action=options' ) . "</ol>";
5264
  echo "<ol>" . sprintf( __( 'Contact <a href="%1$s" %2$s>Crowdsignal support</a> and tell them your rating usercode is %3$s', 'polldaddy' ), 'https://crowdsignal.com/feedback/', 'target="_blank"', $this->rating_user_code ) . '<br />' . __( 'Also include the following information when contacting support to help us resolve your problem as quickly as possible:', 'polldaddy' ) . '';
5265
  echo "<ul><li> API Key: " . get_option( 'polldaddy_api_key' ) . "</li>";
5266
  echo "<li> ID Usercode: " . get_option( 'pd-usercode-' . $current_user->ID ) . "</li>";
5
  * Description: Create and manage Crowdsignal polls and ratings in WordPress
6
  * Author: Automattic, Inc.
7
  * Author URL: https://crowdsignal.com/
8
+ * Version: 2.2.3
9
  */
10
 
11
  // To hardcode your Polldaddy PartnerGUID (API Key), add the (uncommented) line below with the PartnerGUID to your `wp-config.php`
84
 
85
  add_filter( 'jetpack_options_whitelist', array( $this, 'add_to_jetpack_options_whitelist' ) );
86
  }
87
+
88
+ if ( ! post_type_exists( 'feedback' ) ) {
89
+ register_post_type(
90
+ 'feedback', array(
91
+ 'labels' => array(
92
+ ),
93
+ 'menu_icon' => 'dashicons-feedback',
94
+ 'show_ui' => true,
95
+ 'show_in_menu' => 'edit.php?post_type=feedback',
96
+ 'show_in_admin_bar' => false,
97
+ 'public' => false,
98
+ 'rewrite' => false,
99
+ 'query_var' => false,
100
+ 'capability_type' => 'page',
101
+ 'show_in_rest' => true,
102
+ 'rest_controller_class' => 'Grunion_Contact_Form_Endpoint',
103
+ 'capabilities' => array(
104
+ 'create_posts' => 'do_not_allow',
105
+ 'publish_posts' => 'publish_pages',
106
+ 'edit_posts' => 'edit_pages',
107
+ 'edit_others_posts' => 'edit_others_pages',
108
+ 'delete_posts' => 'delete_pages',
109
+ 'delete_others_posts' => 'delete_others_pages',
110
+ 'read_private_posts' => 'read_private_pages',
111
+ 'edit_post' => 'edit_page',
112
+ 'delete_post' => 'delete_page',
113
+ 'read_post' => 'read_page',
114
+ ),
115
+ 'map_meta_cap' => true,
116
+ )
117
+ );
118
+ add_action( 'admin_menu', array( $this, 'remove_feedback_menu' ) );
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Remove the feedback "All Posts" submenu if not needed.
124
+ */
125
+ public function remove_feedback_menu() {
126
+ remove_submenu_page( 'edit.php?post_type=feedback', 'edit.php?post_type=feedback' );
127
  }
128
 
129
  /**
170
 
171
  $icon_encoded = 'PHN2ZyBpZD0iY29udGVudCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMjg4IDIyMCI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNGRkZGRkY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5pY29uLWJsdWU8L3RpdGxlPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTI2Mi40MSw4MC4xYy04LjQ3LTIyLjU1LTE5LjA1LTQyLjgzLTI5Ljc5LTU3LjFDMjIwLjc0LDcuMjQsMjEwLC41NywyMDEuNDcsMy43OWExMi4zMiwxMi4zMiwwLDAsMC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back_menu ) {
176
+ $hook = add_menu_page(
177
+ __( 'Feedback', 'polldaddy' ),
178
+ __( 'Feedback', 'polldaddy' ),
179
+ $capability,
180
+ $slug,
181
+ $function,
182
+ 'data:image/svg+xml;base64,' . $icon_encoded
183
+ );
184
+ add_action( "load-$hook", array( &$this, 'management_page_load' ) );
185
+ }
186
 
187
  foreach( array( 'polls' => __( 'Polls', 'polldaddy' ), 'ratings' => __( 'Ratings', 'polldaddy' ) ) as $menu_slug => $page_title ) {
188
  $menu_title = $page_title;
189
 
190
+ $hook = add_submenu_page( $slug, $menu_title, $menu_title, $capability, $menu_slug, $function, 'div' );
191
  add_action( "load-$hook", array( &$this, 'management_page_load' ) );
 
 
192
  }
193
 
194
  // Add settings pages.
195
+ foreach( array( 'pollsettings' => __( 'Poll', 'polldaddy' ), 'ratingsettings' => __( 'Rating', 'polldaddy' ) ) as $menu_slug => $page_title ) {
196
  // translators: %s placeholder is the setting page type (Poll or Rating).
197
  $settings_page_title = sprintf( esc_html__( '%s Settings', 'polldaddy' ), $page_title );
198
+ $hook = add_options_page( $settings_page_title, $settings_page_title, $menu_slug == 'ratings' ? 'manage_options' : $capability, $menu_slug, array( $this, 'settings_page' ) );
199
+ add_action( "load-$hook", array( $this, 'management_page_load' ) );
 
 
 
 
 
 
 
 
200
  }
201
 
202
  add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
441
 
442
  $this->set_api_user_code();
443
 
444
+ if ( empty( $this->user_code ) && 'pollsettings' === $page && 'options' !== $action ) {
445
  // one last try to get the user code automatically if possible
446
  $this->user_code = apply_filters_ref_array( 'polldaddy_get_user_code', array( $this->user_code, &$this ) );
447
  if ( false == $this->user_code && $action != 'restore-account' )
480
  case 'list-styles' :
481
  $plugin_page = 'polls&action=list-styles';
482
  break;
 
 
 
 
 
 
 
483
  }//end switch
484
+ } elseif ( $page == 'pollsettings' ) {
485
+ $plugin_page = 'pollsettings';
486
  } elseif ( $page == 'ratings' ) {
487
+ if ( empty( $action ) ) {
488
+ $action = 'reports';
489
+ }
490
+ $plugin_page = 'ratings&action=reports';
491
+ } elseif ( $page == 'ratingsettings' ) {
492
+ $plugin_page = 'ratingsettings';
493
+ wp_enqueue_script( 'rating-text-color', "{$this->base_url}js/jscolor.js", array(), $this->version );
494
+ wp_enqueue_script( 'ratings', "{$this->base_url}js/rating.js", array(), $this->version );
495
+ wp_localize_script( 'polls-common', 'adminRatingsL10n', array(
496
+ 'star_colors' => __( 'Star Colors', 'polldaddy' ), 'star_size' => __( 'Star Size', 'polldaddy' ),
497
+ 'nero_type' => __( 'Nero Type', 'polldaddy' ), 'nero_size' => __( 'Nero Size', 'polldaddy' ), ) );
 
 
 
 
498
  }
499
 
500
  wp_enqueue_style( 'polldaddy', "{$this->base_url}css/polldaddy.css", array(), $this->version );
544
 
545
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
546
 
547
+ if ( 'polls' === $page || 'pollsettings' === $page ) {
548
  switch ( $action ) {
549
  case 'reset-account' : // reset everything
550
  global $current_user;
1153
  default :
1154
  return;
1155
  }//end switch
1156
+ } elseif ( 'ratings' === $page || 'ratingsettings' === $page ) {
1157
 
1158
  switch ( $action ) {
1159
  case 'delete' :
1329
  $this->print_errors();
1330
  }
1331
 
1332
+ function settings_page() {
1333
+ global $page, $action;
1334
+ ?>
1335
+ <div class="wrap" id="manage-polls">
1336
+ <?php
1337
+ $this->set_api_user_code();
1338
+
1339
+ if ( isset( $_GET['page'] ) ) {
1340
+ $page = $_GET['page'];
1341
+ }
1342
+ if ( 'pollsettings' === $page ) {
1343
+ if ( ! $this->is_author ) { //check user privileges has access to action
1344
+ return;
1345
+ }
1346
+ $this->plugin_options();
1347
+ } elseif ( 'ratingsettings' === $page ) {
1348
+ if ( 'update-rating' === $action ) {
1349
+ $this->update_rating();
1350
+ }
1351
+
1352
+ $this->rating_settings();
1353
+ }
1354
+ ?>
1355
+ </div>
1356
+ <?php
1357
+ }
1358
+
1359
  function management_page() {
1360
 
1361
  global $page, $action, $poll, $style, $rating;
1368
 
1369
  <?php
1370
  if ( $page == 'polls' ) {
1371
+ if ( ! $this->is_author && in_array( $action, array( 'edit', 'edit-poll', 'create-poll', 'edit-style', 'create-style', 'list-styles' ) ) ) {//check user privileges has access to action
1372
  $action = '';
1373
  }
1374
  switch ( $action ) {
1439
  <?php
1440
  $this->style_edit_form();
1441
  break;
 
 
 
 
 
1442
  default :
1443
 
1444
  ?>
1454
  if ( !empty( $account ) )
1455
  $account_email = esc_attr( $account->email );
1456
  if ( isset( $account_email ) && current_user_can( 'manage_options' ) ) {
1457
+ echo "<p>" . sprintf( __( 'Linked to WordPress.com Account: <strong>%1$s</strong> (<a target="_blank" href="%2$s">Settings</a> / <a target="_blank" href="%3$s">Crowdsignal.com</a>)', 'polldaddy' ), $account_email, admin_url( 'options-general.php?page=pollsettings' ), 'https://app.crowdsignal.com/' ) . "</p>";
1458
+ }
1459
+
1460
+ if ( ! is_plugin_active( 'crowdsignal-forms/crowdsignal-forms.php' ) ) {
1461
+ echo "<p>" . sprintf(
1462
+ esc_html__(
1463
+ 'Did you know we have another plugin with new blocks? Poll, Applause, NPS and more. Look for the Crowdsignal Forms plugin or download it %s.',
1464
+ 'polldaddy'
1465
+ ),
1466
+ sprintf( '<a href="%s">%s</a>',
1467
+ 'https://wordpress.org/plugins/crowdsignal-forms/',
1468
+ esc_html__( 'here', 'polldaddy' )
1469
+ )
1470
+ ) . "</p>";
1471
  }
1472
 
1473
  if ( !isset( $_GET['view'] ) )
1486
  case 'reports' :
1487
  $this->rating_reports();
1488
  break;
 
 
 
 
 
 
1489
  }//end switch
1490
  }
1491
  ?>
3876
 
3877
  switch ( $_POST[ 'pd_rating_action_type' ] ) {
3878
  case 'posts' :
3879
+ delete_option( 'pd-rich-snippets' );
3880
+ if ( wp_next_scheduled( 'polldaddy_rating_update_job' ) ) {
3881
+ wp_clear_scheduled_hook( 'polldaddy_rating_update_job' );
3882
+ }
3883
 
3884
  if ( isset( $_POST[ 'pd_show_posts' ] ) && (int) $_POST[ 'pd_show_posts' ] == 1 )
3885
  $show_posts = get_option( 'pd-rating-posts-id' );
3932
  }//end switch
3933
  }
3934
 
 
3935
  $show_posts = (int) get_option( 'pd-rating-posts' );
3936
  $show_pages = (int) get_option( 'pd-rating-pages' );
3937
  $show_comments = (int) get_option( 'pd-rating-comments' );
3993
  <table class="form-table" style="width: normal;">
3994
  <tbody>
3995
  <?php if ( $report_type == 'posts' ) { ?>
 
 
 
 
 
 
 
3996
  <tr valign="top">
3997
  <th scope="row"><label><?php _e( 'Show Ratings on', 'polldaddy' );?></label></th>
3998
  <td>
4083
  $previous_settings = get_option( 'polldaddy_settings' );
4084
  $current_setting = get_option( 'pd-rating-posts-id' );
4085
  if ( $current_setting && isset( $previous_settings[ 'pd-rating-posts-id' ] ) && $current_setting != $previous_settings[ 'pd-rating-posts-id' ] ) {
4086
+ echo "<p>" . sprintf( __( "Previous settings for ratings on this site discovered. You can restore them on the <a href='%s'>poll settings page</a> if your site is missing ratings after resetting your connection settings.", 'polldaddy' ), "options-general.php?page=pollsettings" ) . "</p>";
4087
  }
4088
  ?>
4089
  </div>
4114
  <div class="inside">
4115
  <div class="submitbox" id="submitpost">
4116
  <div id="minor-publishing" style="padding:10px;">
4117
+ <input type="submit" name="save_menu" class="button button-primary menu-save" value="<?php echo esc_attr( __( 'Save Changes', 'polldaddy' ) );?>">
4118
  <input type="hidden" name="type" value="<?php echo $report_type; ?>" />
4119
  <input type="hidden" name="rating_id" value="<?php echo $rating_id; ?>" />
4120
  <input type="hidden" name="action" value="update-rating" />
4790
  ?>
4791
  <div class="wrap">
4792
  <?php if ( $this->is_admin ) : ?>
4793
+ <h2 id="polldaddy-header"><?php printf( __( 'Rating Results <a href="%s" class="add-new-h2">Settings</a>', 'polldaddy' ), esc_url( 'options-general.php?page=ratingsettings' ) ); ?></h2>
4794
  <?php else : ?>
4795
  <h2 id="polldaddy-header"><?php _e( 'Rating Results', 'polldaddy' ); ?></h2>
4796
  <?php endif; ?>
4849
  </tr>
4850
  </tbody><?php
4851
  } else {
 
4852
  ?>
4853
  <thead>
4854
  <tr>
5282
  return true;
5283
  }
5284
 
 
 
 
 
 
 
 
 
 
5285
  if ( false == (bool) current_user_can( 'edit_others_posts' ) )
5286
  $this->log( 'can_edit: current user cannot edit_others_posts.' );
5287
 
5296
  echo '<h1>' . $message . '</h1>';
5297
  echo '<p>' . __( "There are a few things you can do:" );
5298
  echo "<ul><ol>" . __( "Press reload on your browser and reload this page. There may have been a temporary problem communicating with Crowdsignal.com", "polldaddy" ) . "</ol>";
5299
+ echo "<ol>" . sprintf( __( "Go to the <a href='%s'>poll settings page</a>, scroll to the end of the page and reset your connection settings. Link your account again with the same API key.", "polldaddy" ), 'options-general.php?page=pollsettings' ) . "</ol>";
5300
  echo "<ol>" . sprintf( __( 'Contact <a href="%1$s" %2$s>Crowdsignal support</a> and tell them your rating usercode is %3$s', 'polldaddy' ), 'https://crowdsignal.com/feedback/', 'target="_blank"', $this->rating_user_code ) . '<br />' . __( 'Also include the following information when contacting support to help us resolve your problem as quickly as possible:', 'polldaddy' ) . '';
5301
  echo "<ul><li> API Key: " . get_option( 'polldaddy_api_key' ) . "</li>";
5302
  echo "<li> ID Usercode: " . get_option( 'pd-usercode-' . $current_user->ID ) . "</li>";
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: eoigal, mdawaffe, donncha, johnny5, panosktn, ice9js
3
  Tags: crowdsignal, polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
4
  Requires at least: 4.6
5
  Requires PHP: 5.6
6
- Tested up to: 5.6
7
- Stable tag: 2.2.2
8
 
9
  Create and manage Crowdsignal polls and ratings from within WordPress.
10
 
@@ -12,6 +12,9 @@ Create and manage Crowdsignal polls and ratings from within WordPress.
12
 
13
  The Crowdsignal Polls and Ratings plugin allows you to create and manage polls and ratings from within your WordPress dashboard. You can create polls, choose from 20 different styles for your polls, and view all results for your polls as they come in. All Crowdsignal polls are fully customizable, you can set a close date for your poll, create multiple choice polls, choose whether to display the results or keep them private. You can also create your own custom style for your poll. You can even embed the polls you create on other websites. You can collect unlimited votes and create unlimited polls. The new ratings menu allows you to embed ratings into your posts, pages or comments. The rating editor allows you to fully customize your rating. You can also avail of the 'Top Rated' widget that will allow you to place the widget in your sidebar. This widget will show you the top rated posts, pages and comments today, this week and this month.
14
 
 
 
 
15
  Crowdsignal Polls is currently available in the following languages:
16
 
17
  * Arabic
@@ -120,10 +123,17 @@ This is possible if your server or network is blocking outgoing calls to Crowdsi
120
  Make sure to whitelist `api.crowdsignal.com` in your firewall to fix this.
121
 
122
  == Upgrade Notice ==
123
- Security and bug fix release.
124
 
125
  == Changelog ==
126
 
 
 
 
 
 
 
 
127
  = 2.2.2 =
128
  * Fixed XSS in the style title. #46
129
  * Fixed wp_parse_str #40
3
  Tags: crowdsignal, polls, poll, polldaddy, wppolls, vote, polling, surveys, rate, rating, ratings
4
  Requires at least: 4.6
5
  Requires PHP: 5.6
6
+ Tested up to: 5.7.1
7
+ Stable tag: 2.2.3
8
 
9
  Create and manage Crowdsignal polls and ratings from within WordPress.
10
 
12
 
13
  The Crowdsignal Polls and Ratings plugin allows you to create and manage polls and ratings from within your WordPress dashboard. You can create polls, choose from 20 different styles for your polls, and view all results for your polls as they come in. All Crowdsignal polls are fully customizable, you can set a close date for your poll, create multiple choice polls, choose whether to display the results or keep them private. You can also create your own custom style for your poll. You can even embed the polls you create on other websites. You can collect unlimited votes and create unlimited polls. The new ratings menu allows you to embed ratings into your posts, pages or comments. The rating editor allows you to fully customize your rating. You can also avail of the 'Top Rated' widget that will allow you to place the widget in your sidebar. This widget will show you the top rated posts, pages and comments today, this week and this month.
14
 
15
+ === And there's another plugin! ===
16
+ Are you a fan of the new block editor for WordPress? Our other plugin, [Crowdsignal Forms](https://wordpress.org/plugins/crowdsignal-forms/) provides a number of good looking blocks for your site. Of course there is a poll block and it's even easier to use than the poll embed here. Collect the positive vibes of a round of applause through our applause block, or see who will give your blog post a thumbs up with the vote block. There are even some blocks like the NPS block that are only available in this plugin. To get the most out of Crowdsignal you should install the Crowdsignal Forms plugin and this plugin because they do different jobs.
17
+
18
  Crowdsignal Polls is currently available in the following languages:
19
 
20
  * Arabic
123
  Make sure to whitelist `api.crowdsignal.com` in your firewall to fix this.
124
 
125
  == Upgrade Notice ==
126
+ Bugfix release.
127
 
128
  == Changelog ==
129
 
130
+ = 2.2.3 =
131
+ * Remove the "is poll owner part of blog" check on poll listings page as it caused problems for those with multiple sites. #50
132
+ * Add a message to the poll listing page linking to the Crowdsignal Forms plugin. #51
133
+ * Update grunt version dependency #52
134
+ * Remove rich snippet support. It hasn't worked in years.
135
+ * Rearrange the menus. Polls and ratings go in Feedback, Settings go Settings.
136
+
137
  = 2.2.2 =
138
  * Fixed XSS in the style title. #46
139
  * Fixed wp_parse_str #40