WP-Polls - Version 2.73.6

Version Description

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-Polls
Version 2.73.6
Comparing to
See all releases

Code changes from version 2.73.5 to 2.73.6

Files changed (3) hide show
  1. polls-templates.php +14 -20
  2. readme.txt +5 -2
  3. wp-polls.php +12 -13
polls-templates.php CHANGED
@@ -1,27 +1,21 @@
1
  <?php
2
- /*
3
- +----------------------------------------------------------------+
4
- | |
5
- | WordPress Plugin: WP-Polls |
6
- | Copyright (c) 2012 Lester "GaMerZ" Chan |
7
- | |
8
- | File Written By: |
9
- | - Lester "GaMerZ" Chan |
10
- | - http://lesterchan.net |
11
- | |
12
- | File Information: |
13
- | - Configure Poll Templates |
14
- | - wp-content/plugins/wp-polls/polls-templates.php |
15
- | |
16
- +----------------------------------------------------------------+
17
- */
18
-
19
-
20
  ### Check Whether User Can Manage Polls
21
  if(!current_user_can('manage_polls')) {
22
  die('Access Denied');
23
  }
24
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  ### Variables Variables Variables
26
  $base_name = plugin_basename('wp-polls/polls-templates.php');
27
  $base_page = 'admin.php?page='.$base_name;
@@ -31,8 +25,8 @@ $id = ( isset($_GET['id'] ) ? (int) sanitize_key( $_GET['id'] ) : 0 );
31
  if( isset($_POST['Submit']) && $_POST['Submit'] ) {
32
  check_admin_referer('wp-polls_templates');
33
  $poll_template_voteheader = wp_kses_post( trim( $_POST['poll_template_voteheader'] ) );
34
- $poll_template_votebody = wp_kses_post( trim($_POST['poll_template_votebody'] ) );
35
- $poll_template_votefooter = wp_kses_post( trim($_POST['poll_template_votefooter'] ) );
36
  $poll_template_resultheader = wp_kses_post( trim($_POST['poll_template_resultheader'] ) );
37
  $poll_template_resultbody = wp_kses_post( trim($_POST['poll_template_resultbody'] ) );
38
  $poll_template_resultbody2 = wp_kses_post( trim($_POST['poll_template_resultbody2'] ) );
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  ### Check Whether User Can Manage Polls
3
  if(!current_user_can('manage_polls')) {
4
  die('Access Denied');
5
  }
6
 
7
+ # Allow HTML
8
+ $allowed_tags = wp_kses_allowed_html( 'post' );
9
+ $allowed_tags['input'] = array(
10
+ 'type' => true,
11
+ 'id' => true,
12
+ 'name' => true,
13
+ 'value' => true,
14
+ 'class' => true,
15
+ 'onclick' => true,
16
+ );
17
+ $allowed_tags['a']['onclick'] = true;
18
+
19
  ### Variables Variables Variables
20
  $base_name = plugin_basename('wp-polls/polls-templates.php');
21
  $base_page = 'admin.php?page='.$base_name;
25
  if( isset($_POST['Submit']) && $_POST['Submit'] ) {
26
  check_admin_referer('wp-polls_templates');
27
  $poll_template_voteheader = wp_kses_post( trim( $_POST['poll_template_voteheader'] ) );
28
+ $poll_template_votebody = wp_kses( $_POST['poll_template_votebody'], $allowed_tags );
29
+ $poll_template_votefooter = wp_kses( $_POST['poll_template_votefooter'], $allowed_tags );
30
  $poll_template_resultheader = wp_kses_post( trim($_POST['poll_template_resultheader'] ) );
31
  $poll_template_resultbody = wp_kses_post( trim($_POST['poll_template_resultbody'] ) );
32
  $poll_template_resultbody2 = wp_kses_post( trim($_POST['poll_template_resultbody2'] ) );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://lesterchan.net/site/donation/
4
  Tags: poll, polls, polling, vote, booth, democracy, ajax, survey, post, widget
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
- Stable tag: 2.73.5
8
 
9
  Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.
10
 
@@ -27,6 +27,10 @@ WP-Polls is extremely customizable via templates and css styles and there are to
27
  I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
28
 
29
  ## Changelog
 
 
 
 
30
  ### Version 2.73.5
31
  * FIXED: Parsed error in SERVER variable.
32
 
@@ -185,4 +189,3 @@ I spent most of my free time creating, updating, maintaining and supporting thes
185
  <?php get_pollvoters(); ?>
186
  <?php endif; ?>
187
  ```
188
-
4
  Tags: poll, polls, polling, vote, booth, democracy, ajax, survey, post, widget
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
+ Stable tag: 2.73.6
8
 
9
  Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.
10
 
27
  I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
28
 
29
  ## Changelog
30
+ ### Version 2.73.6
31
+ * FIXED: Unable to vote for multiple answers
32
+ * FIXED: input HTML tags being removed when saving templates
33
+
34
  ### Version 2.73.5
35
  * FIXED: Parsed error in SERVER variable.
36
 
189
  <?php get_pollvoters(); ?>
190
  <?php endif; ?>
191
  ```
 
wp-polls.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-Polls
4
  Plugin URI: https://lesterchan.net/portfolio/programming/php/
5
  Description: Adds an AJAX poll system to your WordPress blog. You can easily include a poll into your WordPress's blog post/page. WP-Polls is extremely customizable via templates and css styles and there are tons of options for you to choose to ensure that WP-Polls runs the way you wanted. It now supports multiple selection of answers.
6
- Version: 2.73.5
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-polls
@@ -28,9 +28,8 @@ Text Domain: wp-polls
28
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
  */
30
 
31
-
32
  ### Version
33
- define( 'WP_POLLS_VERSION', '2.73.5' );
34
 
35
 
36
  ### Create Text Domain For Translations
@@ -346,7 +345,6 @@ function check_voted($poll_id) {
346
  if(!empty($check_voted_cookie)) {
347
  return $check_voted_cookie;
348
  }
349
-
350
  return check_voted_ip($poll_id);
351
  break;
352
  // Logged By Username
@@ -364,7 +362,6 @@ function check_voted_cookie( $poll_id ) {
364
  $get_voted_aids = explode( ',', $_COOKIE[ 'voted_' . $poll_id ] );
365
  $get_voted_aids = array_map( 'intval', array_map( 'sanitize_key', $get_voted_aids ) );
366
  }
367
-
368
  return $get_voted_aids;
369
  }
370
 
@@ -534,13 +531,15 @@ function display_pollvote($poll_id, $display_loading = true) {
534
 
535
  ### Function: Display Results Form
536
  function display_pollresult($poll_id, $user_voted = '', $display_loading = true) {
537
- do_action('wp_polls_display_pollresult');
538
  global $wpdb;
 
539
  $poll_id = (int) $poll_id;
540
  // User Voted
541
  if( empty( $user_voted ) ) {
542
  $user_voted = array();
543
  }
 
 
544
  // Temp Poll Result
545
  $temp_pollresult = '';
546
  // Most/Least Variables
@@ -703,7 +702,7 @@ function display_pollresult($poll_id, $user_voted = '', $display_loading = true)
703
  $temp_pollresult .= "</div>\n";
704
  if($display_loading) {
705
  $poll_ajax_style = get_option('poll_ajax_style');
706
- if((int) $poll_ajax_style['loading'] == 1) {
707
  $temp_pollresult .= "<div id=\"polls-$poll_question_id-loading\" class=\"wp-polls-loading\"><img src=\"".plugins_url('wp-polls/images/loading.gif')."\" width=\"16\" height=\"16\" alt=\"".__('Loading', 'wp-polls')." ...\" title=\"".__('Loading', 'wp-polls')." ...\" class=\"wp-polls-image\" />&nbsp;".__('Loading', 'wp-polls')." ...</div>\n";
708
  }
709
  }
@@ -1312,17 +1311,17 @@ function vote_poll() {
1312
  // Poll Vote
1313
  case 'process':
1314
  do_action('wp_polls_vote_poll');
1315
- $poll_aid = (int) sanitize_key( $_POST["poll_$poll_id"] );
1316
  $poll_aid_array = array_unique( array_map('intval', array_map('sanitize_key', explode( ',', $_POST["poll_$poll_id"] ) ) ) );
1317
- $is_real = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pollsa WHERE polla_aid = %d AND polla_qid = %d", array( $poll_aid, $poll_id ) ) );
1318
 
 
1319
  // The multiple ifs is ugly, I know it. Feel free to send a PR to fix it
1320
- if( $is_real > 0 ) {
1321
  if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
1322
  $is_poll_open = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pollsq WHERE pollq_id = %d AND pollq_active = 1", $poll_id ) );
1323
  if ( $is_poll_open > 0 ) {
1324
  $check_voted = check_voted($poll_id);
1325
- if ($check_voted === 0) {
1326
  if (!empty($user_identity)) {
1327
  $pollip_user = $user_identity;
1328
  } elseif ( ! empty( $_COOKIE['comment_author_' . COOKIEHASH] ) ) {
@@ -1340,9 +1339,9 @@ function vote_poll() {
1340
  if ($poll_logging_method === 1 || $poll_logging_method === 3) {
1341
  $cookie_expiry = (int) get_option('poll_cookielog_expiry');
1342
  if ($cookie_expiry === 0) {
1343
- $cookie_expiry = 30000000;
1344
  }
1345
- setcookie('voted_' . $poll_id, $poll_aid, ($pollip_timestamp + $cookie_expiry), apply_filters('wp_polls_cookiepath', SITECOOKIEPATH));
1346
  }
1347
  $i = 0;
1348
  foreach ($poll_aid_array as $polla_aid) {
3
  Plugin Name: WP-Polls
4
  Plugin URI: https://lesterchan.net/portfolio/programming/php/
5
  Description: Adds an AJAX poll system to your WordPress blog. You can easily include a poll into your WordPress's blog post/page. WP-Polls is extremely customizable via templates and css styles and there are tons of options for you to choose to ensure that WP-Polls runs the way you wanted. It now supports multiple selection of answers.
6
+ Version: 2.73.6
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-polls
28
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
  */
30
 
 
31
  ### Version
32
+ define( 'WP_POLLS_VERSION', '2.73.6' );
33
 
34
 
35
  ### Create Text Domain For Translations
345
  if(!empty($check_voted_cookie)) {
346
  return $check_voted_cookie;
347
  }
 
348
  return check_voted_ip($poll_id);
349
  break;
350
  // Logged By Username
362
  $get_voted_aids = explode( ',', $_COOKIE[ 'voted_' . $poll_id ] );
363
  $get_voted_aids = array_map( 'intval', array_map( 'sanitize_key', $get_voted_aids ) );
364
  }
 
365
  return $get_voted_aids;
366
  }
367
 
531
 
532
  ### Function: Display Results Form
533
  function display_pollresult($poll_id, $user_voted = '', $display_loading = true) {
 
534
  global $wpdb;
535
+ do_action( 'wp_polls_display_pollresult', $poll_id, $user_voted );
536
  $poll_id = (int) $poll_id;
537
  // User Voted
538
  if( empty( $user_voted ) ) {
539
  $user_voted = array();
540
  }
541
+ $user_voted = array_map( 'intval', $user_voted );
542
+
543
  // Temp Poll Result
544
  $temp_pollresult = '';
545
  // Most/Least Variables
702
  $temp_pollresult .= "</div>\n";
703
  if($display_loading) {
704
  $poll_ajax_style = get_option('poll_ajax_style');
705
+ if((int) $poll_ajax_style['loading'] === 1) {
706
  $temp_pollresult .= "<div id=\"polls-$poll_question_id-loading\" class=\"wp-polls-loading\"><img src=\"".plugins_url('wp-polls/images/loading.gif')."\" width=\"16\" height=\"16\" alt=\"".__('Loading', 'wp-polls')." ...\" title=\"".__('Loading', 'wp-polls')." ...\" class=\"wp-polls-image\" />&nbsp;".__('Loading', 'wp-polls')." ...</div>\n";
707
  }
708
  }
1311
  // Poll Vote
1312
  case 'process':
1313
  do_action('wp_polls_vote_poll');
 
1314
  $poll_aid_array = array_unique( array_map('intval', array_map('sanitize_key', explode( ',', $_POST["poll_$poll_id"] ) ) ) );
1315
+ $polla_aids = $wpdb->get_col( $wpdb->prepare( "SELECT polla_aid FROM $wpdb->pollsa WHERE polla_qid = %d", $poll_id ) );
1316
 
1317
+ $is_real = count( array_intersect( $poll_aid_array, $polla_aids ) ) === count( $poll_aid_array );
1318
  // The multiple ifs is ugly, I know it. Feel free to send a PR to fix it
1319
+ if( $is_real ) {
1320
  if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
1321
  $is_poll_open = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pollsq WHERE pollq_id = %d AND pollq_active = 1", $poll_id ) );
1322
  if ( $is_poll_open > 0 ) {
1323
  $check_voted = check_voted($poll_id);
1324
+ if ( empty( $check_voted ) ) {
1325
  if (!empty($user_identity)) {
1326
  $pollip_user = $user_identity;
1327
  } elseif ( ! empty( $_COOKIE['comment_author_' . COOKIEHASH] ) ) {
1339
  if ($poll_logging_method === 1 || $poll_logging_method === 3) {
1340
  $cookie_expiry = (int) get_option('poll_cookielog_expiry');
1341
  if ($cookie_expiry === 0) {
1342
+ $cookie_expiry = YEAR_IN_SECONDS;
1343
  }
1344
+ setcookie( 'voted_' . $poll_id, implode(',', $poll_aid_array ), $pollip_timestamp + $cookie_expiry, apply_filters( 'wp_polls_cookiepath', SITECOOKIEPATH ) );
1345
  }
1346
  $i = 0;
1347
  foreach ($poll_aid_array as $polla_aid) {