WP-Polls - Version 2.74.1

Version Description

Download this release

Release Info

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

Code changes from version 2.74 to 2.74.1

Files changed (3) hide show
  1. polls-add.php +187 -186
  2. readme.txt +6 -1
  3. wp-polls.php +91 -70
polls-add.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  ### Check Whether User Can Manage Polls
3
  if(!current_user_can('manage_polls')) {
4
- die('Access Denied');
5
  }
6
 
7
  ### Poll Manager
@@ -9,123 +9,124 @@ $base_name = plugin_basename('wp-polls/polls-manager.php');
9
  $base_page = 'admin.php?page='.$base_name;
10
 
11
  ### Form Processing
12
- if(!empty($_POST['do'])) {
13
- // Decide What To Do
14
- switch($_POST['do']) {
15
- // Add Poll
16
- case __('Add Poll', 'wp-polls'):
17
- check_admin_referer('wp-polls_add-poll');
18
- // Poll Question
19
- $pollq_question = wp_kses_post( trim( $_POST['pollq_question'] ) );
20
- if( ! empty( $pollq_question ) ) {
21
- // Poll Start Date
22
- $timestamp_sql = '';
23
- $pollq_timestamp_day = (int) sanitize_key($_POST['pollq_timestamp_day']);
24
- $pollq_timestamp_month = (int) sanitize_key($_POST['pollq_timestamp_month']);
25
- $pollq_timestamp_year = (int) sanitize_key($_POST['pollq_timestamp_year']);
26
- $pollq_timestamp_hour = (int) sanitize_key($_POST['pollq_timestamp_hour']);
27
- $pollq_timestamp_minute = (int) sanitize_key($_POST['pollq_timestamp_minute']);
28
- $pollq_timestamp_second = (int) sanitize_key($_POST['pollq_timestamp_second']);
29
- $pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year);
30
- if ($pollq_timestamp > current_time('timestamp')) {
31
- $pollq_active = -1;
32
- } else {
33
- $pollq_active = 1;
34
- }
35
- // Poll End Date
36
- $pollq_expiry_no = isset( $_POST['pollq_expiry_no'] ) ? (int) sanitize_key($_POST['pollq_expiry_no']) : 0;
37
- if ($pollq_expiry_no === 1) {
38
- $pollq_expiry = '';
39
- } else {
40
- $pollq_expiry_day = (int) sanitize_key($_POST['pollq_expiry_day']);
41
- $pollq_expiry_month = (int) sanitize_key($_POST['pollq_expiry_month']);
42
- $pollq_expiry_year = (int) sanitize_key($_POST['pollq_expiry_year']);
43
- $pollq_expiry_hour = (int) sanitize_key($_POST['pollq_expiry_hour']);
44
- $pollq_expiry_minute = (int) sanitize_key($_POST['pollq_expiry_minute']);
45
- $pollq_expiry_second = (int) sanitize_key($_POST['pollq_expiry_second']);
46
- $pollq_expiry = gmmktime($pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year);
47
- if ($pollq_expiry <= current_time('timestamp')) {
48
- $pollq_active = 0;
49
- }
50
- }
51
- // Mutilple Poll
52
- $pollq_multiple_yes = (int) sanitize_key($_POST['pollq_multiple_yes']);
53
- $pollq_multiple = 0;
54
- if ($pollq_multiple_yes === 1) {
55
- $pollq_multiple = (int) sanitize_key($_POST['pollq_multiple']);
56
- } else {
57
- $pollq_multiple = 0;
58
- }
59
- // Insert Poll
60
- $add_poll_question = $wpdb->insert(
61
- $wpdb->pollsq,
62
- array(
63
- 'pollq_question' => $pollq_question,
64
- 'pollq_timestamp' => $pollq_timestamp,
65
- 'pollq_totalvotes' => 0,
66
- 'pollq_active' => $pollq_active,
67
- 'pollq_expiry' => $pollq_expiry,
68
- 'pollq_multiple' => $pollq_multiple,
69
- 'pollq_totalvoters' => 0
70
- ),
71
- array(
72
- '%s',
73
- '%s',
74
- '%d',
75
- '%d',
76
- '%s',
77
- '%d',
78
- '%d'
79
- )
80
- );
81
- if ( ! $add_poll_question ) {
82
- $text .= '<p style="color: red;">' . sprintf(__('Error In Adding Poll \'%s\'.', 'wp-polls'), $pollq_question) . '</p>';
83
- }
84
- // Add Poll Answers
85
- $polla_answers = $_POST['polla_answers'];
86
- $polla_qid = (int) $wpdb->insert_id;
87
- foreach ($polla_answers as $polla_answer) {
88
- $polla_answer = wp_kses_post( trim( $polla_answer ) );
89
- if( ! empty( $polla_answer ) ) {
90
- $add_poll_answers = $wpdb->insert(
91
- $wpdb->pollsa,
92
- array(
93
- 'polla_qid' => $polla_qid,
94
- 'polla_answers' => $polla_answer,
95
- 'polla_votes' => 0
96
- ),
97
- array(
98
- '%d',
99
- '%s',
100
- '%d'
101
- )
102
- );
103
- if ( ! $add_poll_answers ) {
104
- $text .= '<p style="color: red;">' . sprintf(__('Error In Adding Poll\'s Answer \'%s\'.', 'wp-polls'), $polla_answer) . '</p>';
105
- }
106
- } else {
107
- $text .= '<p style="color: red;">' . __( 'Poll\'s Answer is empty.', 'wp-polls' ) . '</p>';
108
- }
109
- }
110
- // Update Lastest Poll ID To Poll Options
111
- $latest_pollid = polls_latest_id();
112
- $update_latestpoll = update_option('poll_latestpoll', $latest_pollid);
113
- // If poll starts in the future use the correct poll ID
114
- $latest_pollid = ( $latest_pollid < $polla_qid ) ? $polla_qid : $latest_pollid;
115
- if ( empty( $text ) ) {
116
- $text = '<p style="color: green;">' . sprintf( __( 'Poll \'%s\' (ID: %s) added successfully. Embed this poll with the shortcode: %s or go back to <a href="%s">Manage Polls</a>', 'wp-polls' ), $pollq_question, $latest_pollid, '<input type="text" value=\'[poll id="' . $latest_pollid . '"]\' readonly="readonly" size="10" />', $base_page ) . '</p>';
117
- } else {
118
- if( $add_poll_question ) {
119
- $text .= '<p style="color: green;">' . sprintf( __( 'Poll \'%s\' (ID: %s) (Shortcode: %s) added successfully, but there are some errors with the Poll\'s Answers. Embed this poll with the shortcode: %s or go back to <a href="%s">Manage Polls</a>', 'wp-polls' ), $pollq_question, $latest_pollid, '<input type="text" value=\'[poll id="' . $latest_pollid . '"]\' readonly="readonly" size="10" />' ) .'</p>';
120
- }
121
- }
122
- do_action( 'wp_polls_add_poll', $latest_pollid );
123
- cron_polls_place();
124
- } else {
125
- $text .= '<p style="color: red;">' . __( 'Poll Question is empty.', 'wp-polls' ) . '</p>';
126
- }
127
- break;
128
- }
 
129
  }
130
 
131
  ### Add Poll Form
@@ -136,73 +137,73 @@ $count = 0;
136
  <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
137
  <?php wp_nonce_field('wp-polls_add-poll'); ?>
138
  <div class="wrap">
139
- <h2><?php _e('Add Poll', 'wp-polls'); ?></h2>
140
- <!-- Poll Question -->
141
- <h3><?php _e('Poll Question', 'wp-polls'); ?></h3>
142
- <table class="form-table">
143
- <tr>
144
- <th width="20%" scope="row" valign="top"><?php _e('Question', 'wp-polls') ?></th>
145
- <td width="80%"><input type="text" size="70" name="pollq_question" value="" /></td>
146
- </tr>
147
- </table>
148
- <!-- Poll Answers -->
149
- <h3><?php _e('Poll Answers', 'wp-polls'); ?></h3>
150
- <table class="form-table">
151
- <tfoot>
152
- <tr>
153
- <td width="20%">&nbsp;</td>
154
- <td width="80%"><input type="button" value="<?php _e('Add Answer', 'wp-polls') ?>" onclick="add_poll_answer_add();" class="button" /></td>
155
- </tr>
156
- </tfoot>
157
- <tbody id="poll_answers">
158
- <?php
159
- for($i = 1; $i <= $poll_noquestion; $i++) {
160
- echo "<tr id=\"poll-answer-$i\">\n";
161
- echo "<th width=\"20%\" scope=\"row\" valign=\"top\">".sprintf(__('Answer %s', 'wp-polls'), number_format_i18n($i))."</th>\n";
162
- echo "<td width=\"80%\"><input type=\"text\" size=\"50\" maxlength=\"200\" name=\"polla_answers[]\" />&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\"".__('Remove', 'wp-polls')."\" onclick=\"remove_poll_answer_add(".$i.");\" class=\"button\" /></td>\n";
163
- echo "</tr>\n";
164
- $count++;
165
- }
166
- ?>
167
- </tbody>
168
- </table>
169
- <!-- Poll Multiple Answers -->
170
- <h3><?php _e('Poll Multiple Answers', 'wp-polls') ?></h3>
171
- <table class="form-table">
172
- <tr>
173
- <th width="40%" scope="row" valign="top"><?php _e('Allows Users To Select More Than One Answer?', 'wp-polls'); ?></th>
174
- <td width="60%">
175
- <select name="pollq_multiple_yes" id="pollq_multiple_yes" size="1" onchange="check_pollq_multiple();">
176
- <option value="0"><?php _e('No', 'wp-polls'); ?></option>
177
- <option value="1"><?php _e('Yes', 'wp-polls'); ?></option>
178
- </select>
179
- </td>
180
- </tr>
181
- <tr>
182
- <th width="40%" scope="row" valign="top"><?php _e('Maximum Number Of Selected Answers Allowed?', 'wp-polls') ?></th>
183
- <td width="60%">
184
- <select name="pollq_multiple" id="pollq_multiple" size="1" disabled="disabled">
185
- <?php
186
- for($i = 1; $i <= $poll_noquestion; $i++) {
187
- echo "<option value=\"$i\">".number_format_i18n($i)."</option>\n";
188
- }
189
- ?>
190
- </select>
191
- </td>
192
- </tr>
193
- </table>
194
- <!-- Poll Start/End Date -->
195
- <h3><?php _e('Poll Start/End Date', 'wp-polls'); ?></h3>
196
- <table class="form-table">
197
- <tr>
198
- <th width="20%" scope="row" valign="top"><?php _e('Start Date/Time', 'wp-polls') ?></th>
199
- <td width="80%"><?php poll_timestamp(current_time('timestamp')); ?></td>
200
- </tr>
201
- <tr>
202
- <th width="20%" scope="row" valign="top"><?php _e('End Date/Time', 'wp-polls') ?></th>
203
- <td width="80%"><input type="checkbox" name="pollq_expiry_no" id="pollq_expiry_no" value="1" checked="checked" onclick="check_pollexpiry();" />&nbsp;&nbsp;<label for="pollq_expiry_no"><?php _e('Do NOT Expire This Poll', 'wp-polls'); ?></label><?php poll_timestamp(current_time('timestamp'), 'pollq_expiry', 'none'); ?></td>
204
- </tr>
205
- </table>
206
- <p style="text-align: center;"><input type="submit" name="do" value="<?php _e('Add Poll', 'wp-polls'); ?>" class="button-primary" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-polls'); ?>" class="button" onclick="javascript:history.go(-1)" /></p>
207
  </div>
208
  </form>
1
  <?php
2
  ### Check Whether User Can Manage Polls
3
  if(!current_user_can('manage_polls')) {
4
+ die('Access Denied');
5
  }
6
 
7
  ### Poll Manager
9
  $base_page = 'admin.php?page='.$base_name;
10
 
11
  ### Form Processing
12
+ if ( ! empty($_POST['do'] ) ) {
13
+ // Decide What To Do
14
+ switch ( $_POST['do'] ) {
15
+ // Add Poll
16
+ case __( 'Add Poll', 'wp-polls' ):
17
+ check_admin_referer( 'wp-polls_add-poll' );
18
+ $text = '';
19
+ // Poll Question
20
+ $pollq_question = isset( $_POST['pollq_question'] ) ? wp_kses_post( trim( $_POST['pollq_question'] ) ) : '';
21
+ if ( ! empty( $pollq_question ) ) {
22
+ // Poll Start Date
23
+ $timestamp_sql = '';
24
+ $pollq_timestamp_day = isset( $_POST['pollq_timestamp_day'] ) ? (int) sanitize_key( $_POST['pollq_timestamp_day'] ) : 0;
25
+ $pollq_timestamp_month = isset( $_POST['pollq_timestamp_month'] ) ? (int) sanitize_key( $_POST['pollq_timestamp_month'] ) : 0;
26
+ $pollq_timestamp_year = isset( $_POST['pollq_timestamp_year'] ) ? (int) sanitize_key( $_POST['pollq_timestamp_year'] ) : 0;
27
+ $pollq_timestamp_hour = isset( $_POST['pollq_timestamp_hour'] ) ? (int) sanitize_key( $_POST['pollq_timestamp_hour'] ) : 0;
28
+ $pollq_timestamp_minute = isset( $_POST['pollq_timestamp_minute'] ) ? (int) sanitize_key( $_POST['pollq_timestamp_minute'] ) : 0;
29
+ $pollq_timestamp_second = isset( $_POST['pollq_timestamp_second'] ) ? (int) sanitize_key( $_POST['pollq_timestamp_second'] ) : 0;
30
+ $pollq_timestamp = gmmktime( $pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year );
31
+ if ( $pollq_timestamp > current_time( 'timestamp' ) ) {
32
+ $pollq_active = -1;
33
+ } else {
34
+ $pollq_active = 1;
35
+ }
36
+ // Poll End Date
37
+ $pollq_expiry_no = isset( $_POST['pollq_expiry_no'] ) ? (int) sanitize_key( $_POST['pollq_expiry_no'] ) : 0;
38
+ if ( $pollq_expiry_no === 1 ) {
39
+ $pollq_expiry = 0;
40
+ } else {
41
+ $pollq_expiry_day = isset( $_POST['pollq_expiry_day'] ) ? (int) sanitize_key( $_POST['pollq_expiry_day'] ) : 0;
42
+ $pollq_expiry_month = isset( $_POST['pollq_expiry_month'] ) ? (int) sanitize_key( $_POST['pollq_expiry_month'] ) : 0;
43
+ $pollq_expiry_year = isset( $_POST['pollq_expiry_year'] ) ? (int) sanitize_key( $_POST['pollq_expiry_year'] ) : 0;
44
+ $pollq_expiry_hour = isset( $_POST['pollq_expiry_hour'] ) ? (int) sanitize_key( $_POST['pollq_expiry_hour'] ) : 0;
45
+ $pollq_expiry_minute = isset( $_POST['pollq_expiry_minute'] ) ? (int) sanitize_key( $_POST['pollq_expiry_minute'] ) : 0;
46
+ $pollq_expiry_second = isset( $_POST['pollq_expiry_second'] ) ? (int) sanitize_key( $_POST['pollq_expiry_second'] ) : 0;
47
+ $pollq_expiry = gmmktime( $pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year );
48
+ if ( $pollq_expiry <= current_time( 'timestamp' ) ) {
49
+ $pollq_active = 0;
50
+ }
51
+ }
52
+ // Mutilple Poll
53
+ $pollq_multiple_yes = isset( $_POST['pollq_multiple_yes'] ) ? (int) sanitize_key( $_POST['pollq_multiple_yes'] ) : 0;
54
+ $pollq_multiple = 0;
55
+ if ( $pollq_multiple_yes === 1 ) {
56
+ $pollq_multiple = isset( $_POST['pollq_multiple'] ) ? (int) sanitize_key( $_POST['pollq_multiple'] ) : 0;
57
+ } else {
58
+ $pollq_multiple = 0;
59
+ }
60
+ // Insert Poll
61
+ $add_poll_question = $wpdb->insert(
62
+ $wpdb->pollsq,
63
+ array(
64
+ 'pollq_question' => $pollq_question,
65
+ 'pollq_timestamp' => $pollq_timestamp,
66
+ 'pollq_totalvotes' => 0,
67
+ 'pollq_active' => $pollq_active,
68
+ 'pollq_expiry' => $pollq_expiry,
69
+ 'pollq_multiple' => $pollq_multiple,
70
+ 'pollq_totalvoters' => 0
71
+ ),
72
+ array(
73
+ '%s',
74
+ '%s',
75
+ '%d',
76
+ '%d',
77
+ '%d',
78
+ '%d',
79
+ '%d'
80
+ )
81
+ );
82
+ if ( ! $add_poll_question ) {
83
+ $text .= '<p style="color: red;">' . sprintf(__('Error In Adding Poll \'%s\'.', 'wp-polls'), $pollq_question) . '</p>';
84
+ }
85
+ // Add Poll Answers
86
+ $polla_answers = isset( $_POST['polla_answers'] ) ? $_POST['polla_answers'] : array();
87
+ $polla_qid = (int) $wpdb->insert_id;
88
+ foreach ( $polla_answers as $polla_answer ) {
89
+ $polla_answer = wp_kses_post( trim( $polla_answer ) );
90
+ if ( ! empty( $polla_answer ) ) {
91
+ $add_poll_answers = $wpdb->insert(
92
+ $wpdb->pollsa,
93
+ array(
94
+ 'polla_qid' => $polla_qid,
95
+ 'polla_answers' => $polla_answer,
96
+ 'polla_votes' => 0
97
+ ),
98
+ array(
99
+ '%d',
100
+ '%s',
101
+ '%d'
102
+ )
103
+ );
104
+ if ( ! $add_poll_answers ) {
105
+ $text .= '<p style="color: red;">' . sprintf(__('Error In Adding Poll\'s Answer \'%s\'.', 'wp-polls'), $polla_answer) . '</p>';
106
+ }
107
+ } else {
108
+ $text .= '<p style="color: red;">' . __( 'Poll\'s Answer is empty.', 'wp-polls' ) . '</p>';
109
+ }
110
+ }
111
+ // Update Lastest Poll ID To Poll Options
112
+ $latest_pollid = polls_latest_id();
113
+ $update_latestpoll = update_option( 'poll_latestpoll', $latest_pollid );
114
+ // If poll starts in the future use the correct poll ID
115
+ $latest_pollid = ( $latest_pollid < $polla_qid ) ? $polla_qid : $latest_pollid;
116
+ if ( empty( $text ) ) {
117
+ $text = '<p style="color: green;">' . sprintf( __( 'Poll \'%s\' (ID: %s) added successfully. Embed this poll with the shortcode: %s or go back to <a href="%s">Manage Polls</a>', 'wp-polls' ), $pollq_question, $latest_pollid, '<input type="text" value=\'[poll id="' . $latest_pollid . '"]\' readonly="readonly" size="10" />', $base_page ) . '</p>';
118
+ } else {
119
+ if ( $add_poll_question ) {
120
+ $text .= '<p style="color: green;">' . sprintf( __( 'Poll \'%s\' (ID: %s) (Shortcode: %s) added successfully, but there are some errors with the Poll\'s Answers. Embed this poll with the shortcode: %s or go back to <a href="%s">Manage Polls</a>', 'wp-polls' ), $pollq_question, $latest_pollid, '<input type="text" value=\'[poll id="' . $latest_pollid . '"]\' readonly="readonly" size="10" />' ) .'</p>';
121
+ }
122
+ }
123
+ do_action( 'wp_polls_add_poll', $latest_pollid );
124
+ cron_polls_place();
125
+ } else {
126
+ $text .= '<p style="color: red;">' . __( 'Poll Question is empty.', 'wp-polls' ) . '</p>';
127
+ }
128
+ break;
129
+ }
130
  }
131
 
132
  ### Add Poll Form
137
  <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
138
  <?php wp_nonce_field('wp-polls_add-poll'); ?>
139
  <div class="wrap">
140
+ <h2><?php _e('Add Poll', 'wp-polls'); ?></h2>
141
+ <!-- Poll Question -->
142
+ <h3><?php _e('Poll Question', 'wp-polls'); ?></h3>
143
+ <table class="form-table">
144
+ <tr>
145
+ <th width="20%" scope="row" valign="top"><?php _e('Question', 'wp-polls') ?></th>
146
+ <td width="80%"><input type="text" size="70" name="pollq_question" value="" /></td>
147
+ </tr>
148
+ </table>
149
+ <!-- Poll Answers -->
150
+ <h3><?php _e('Poll Answers', 'wp-polls'); ?></h3>
151
+ <table class="form-table">
152
+ <tfoot>
153
+ <tr>
154
+ <td width="20%">&nbsp;</td>
155
+ <td width="80%"><input type="button" value="<?php _e('Add Answer', 'wp-polls') ?>" onclick="add_poll_answer_add();" class="button" /></td>
156
+ </tr>
157
+ </tfoot>
158
+ <tbody id="poll_answers">
159
+ <?php
160
+ for($i = 1; $i <= $poll_noquestion; $i++) {
161
+ echo "<tr id=\"poll-answer-$i\">\n";
162
+ echo "<th width=\"20%\" scope=\"row\" valign=\"top\">".sprintf(__('Answer %s', 'wp-polls'), number_format_i18n($i))."</th>\n";
163
+ echo "<td width=\"80%\"><input type=\"text\" size=\"50\" maxlength=\"200\" name=\"polla_answers[]\" />&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\"".__('Remove', 'wp-polls')."\" onclick=\"remove_poll_answer_add(".$i.");\" class=\"button\" /></td>\n";
164
+ echo "</tr>\n";
165
+ $count++;
166
+ }
167
+ ?>
168
+ </tbody>
169
+ </table>
170
+ <!-- Poll Multiple Answers -->
171
+ <h3><?php _e('Poll Multiple Answers', 'wp-polls') ?></h3>
172
+ <table class="form-table">
173
+ <tr>
174
+ <th width="40%" scope="row" valign="top"><?php _e('Allows Users To Select More Than One Answer?', 'wp-polls'); ?></th>
175
+ <td width="60%">
176
+ <select name="pollq_multiple_yes" id="pollq_multiple_yes" size="1" onchange="check_pollq_multiple();">
177
+ <option value="0"><?php _e('No', 'wp-polls'); ?></option>
178
+ <option value="1"><?php _e('Yes', 'wp-polls'); ?></option>
179
+ </select>
180
+ </td>
181
+ </tr>
182
+ <tr>
183
+ <th width="40%" scope="row" valign="top"><?php _e('Maximum Number Of Selected Answers Allowed?', 'wp-polls') ?></th>
184
+ <td width="60%">
185
+ <select name="pollq_multiple" id="pollq_multiple" size="1" disabled="disabled">
186
+ <?php
187
+ for($i = 1; $i <= $poll_noquestion; $i++) {
188
+ echo "<option value=\"$i\">".number_format_i18n($i)."</option>\n";
189
+ }
190
+ ?>
191
+ </select>
192
+ </td>
193
+ </tr>
194
+ </table>
195
+ <!-- Poll Start/End Date -->
196
+ <h3><?php _e('Poll Start/End Date', 'wp-polls'); ?></h3>
197
+ <table class="form-table">
198
+ <tr>
199
+ <th width="20%" scope="row" valign="top"><?php _e('Start Date/Time', 'wp-polls') ?></th>
200
+ <td width="80%"><?php poll_timestamp(current_time('timestamp')); ?></td>
201
+ </tr>
202
+ <tr>
203
+ <th width="20%" scope="row" valign="top"><?php _e('End Date/Time', 'wp-polls') ?></th>
204
+ <td width="80%"><input type="checkbox" name="pollq_expiry_no" id="pollq_expiry_no" value="1" checked="checked" onclick="check_pollexpiry();" />&nbsp;&nbsp;<label for="pollq_expiry_no"><?php _e('Do NOT Expire This Poll', 'wp-polls'); ?></label><?php poll_timestamp(current_time('timestamp'), 'pollq_expiry', 'none'); ?></td>
205
+ </tr>
206
+ </table>
207
+ <p style="text-align: center;"><input type="submit" name="do" value="<?php _e('Add Poll', 'wp-polls'); ?>" class="button-primary" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-polls'); ?>" class="button" onclick="javascript:history.go(-1)" /></p>
208
  </div>
209
  </form>
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.9.6
6
  Tested up to: 5.0
7
- Stable tag: 2.74
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
 
@@ -24,6 +24,11 @@ WP-Polls is extremely customizable via templates and css styles and there are to
24
  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.
25
 
26
  ## Changelog
 
 
 
 
 
27
  ### Version 2.74
28
  * NEW: Hashed IP and anonymize Hostname to make it GDPR compliance
29
  * NEW: If Do Not Log is set in Poll Options, do not log to DB
4
  Tags: poll, polls, polling, vote, booth, democracy, ajax, survey, post, widget
5
  Requires at least: 4.9.6
6
  Tested up to: 5.0
7
+ Stable tag: 2.74.1
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
 
24
  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.
25
 
26
  ## Changelog
27
+ ### Version 2.74.1
28
+ * FIXED: Don't use PHP 5.4 Short array syntax.
29
+ * FIXED: Division by zero
30
+ * FIXED: Wrong database column type for pollq_expiry
31
+
32
  ### Version 2.74
33
  * NEW: Hashed IP and anonymize Hostname to make it GDPR compliance
34
  * NEW: If Do Not Log is set in Poll Options, do not log to DB
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.74
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-polls
@@ -29,7 +29,7 @@ Text Domain: wp-polls
29
  */
30
 
31
  ### Version
32
- define( 'WP_POLLS_VERSION', '2.74' );
33
 
34
 
35
  ### Create Text Domain For Translations
@@ -470,23 +470,23 @@ function display_pollvote($poll_id, $display_loading = true) {
470
  }
471
  // Print Out Voting Form Header Template
472
  $temp_pollvote .= "\t\t$template_question\n";
473
- foreach($poll_answers as $poll_answer) {
474
  // Poll Answer Variables
475
  $poll_answer_id = (int) $poll_answer->polla_aid;
476
  $poll_answer_text = wp_kses_post( removeslashes( $poll_answer->polla_answers ) );
477
  $poll_answer_votes = (int) $poll_answer->polla_votes;
478
  $poll_answer_percentage = $poll_question_totalvotes > 0 ? round( ( $poll_answer_votes / $poll_question_totalvotes ) * 100 ) : 0;
479
- $poll_multiple_answer_percentage = round( ( $poll_answer_votes / $poll_question_totalvoters ) * 100 );
480
- $template_answer = removeslashes(get_option('poll_template_votebody'));
481
 
482
- $template_answer = apply_filters('poll_template_votebody_markup', $template_answer, $poll_answer, array(
483
  '%POLL_ID%' => $poll_question_id,
484
  '%POLL_ANSWER_ID%' => $poll_answer_id,
485
  '%POLL_ANSWER%' => $poll_answer_text,
486
- '%POLL_ANSWER_VOTES%' => number_format_i18n($poll_answer_votes),
487
  '%POLL_ANSWER_PERCENTAGE%' => $poll_answer_percentage,
488
  '%POLL_MULTIPLE_ANSWER_PERCENTAGE%' => $poll_multiple_answer_percentage,
489
- "%POLL_CHECKBOX_RADIO%" => $poll_multiple_ans > 0 ? 'checkbox' : 'radio'
490
  ));
491
 
492
  // Print Out Voting Form Body Template
@@ -532,7 +532,7 @@ function display_pollvote($poll_id, $display_loading = true) {
532
 
533
 
534
  ### Function: Display Results Form
535
- function display_pollresult($poll_id, $user_voted = array(), $display_loading = true) {
536
  global $wpdb;
537
  do_action( 'wp_polls_display_pollresult', $poll_id, $user_voted );
538
  $poll_id = (int) $poll_id;
@@ -558,8 +558,8 @@ function display_pollresult($poll_id, $user_voted = array(), $display_loading =
558
  // Get Poll Question Data
559
  $poll_question = $wpdb->get_row( $wpdb->prepare( "SELECT pollq_id, pollq_question, pollq_totalvotes, pollq_active, pollq_timestamp, pollq_expiry, pollq_multiple, pollq_totalvoters FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $poll_id ) );
560
  // No poll could be loaded from the database
561
- if (!$poll_question) {
562
- return removeslashes(get_option('poll_template_disable'));
563
  }
564
  // Poll Question Variables
565
  $poll_question_text = wp_kses_post( removeslashes( $poll_question->pollq_question ) );
@@ -567,45 +567,54 @@ function display_pollresult($poll_id, $user_voted = array(), $display_loading =
567
  $poll_question_totalvotes = (int) $poll_question->pollq_totalvotes;
568
  $poll_question_totalvoters = (int) $poll_question->pollq_totalvoters;
569
  $poll_question_active = (int) $poll_question->pollq_active;
570
- $poll_start_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_question->pollq_timestamp));
571
- $poll_expiry = trim($poll_question->pollq_expiry);
572
- if(empty($poll_expiry)) {
573
- $poll_end_date = __('No Expiry', 'wp-polls');
574
  } else {
575
- $poll_end_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_expiry));
576
  }
577
  $poll_multiple_ans = (int) $poll_question->pollq_multiple;
578
- $template_question = removeslashes(get_option('poll_template_resultheader'));
579
- $template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
580
- $template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
581
- $template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
582
- $template_question = str_replace("%POLL_TOTALVOTERS%", $poll_question_totalvoters, $template_question);
583
- $template_question = str_replace("%POLL_START_DATE%", $poll_start_date, $template_question);
584
- $template_question = str_replace("%POLL_END_DATE%", $poll_end_date, $template_question);
 
 
 
 
 
 
 
 
 
585
  if($poll_multiple_ans > 0) {
586
- $template_question = str_replace("%POLL_MULTIPLE_ANS_MAX%", $poll_multiple_ans, $template_question);
587
  } else {
588
- $template_question = str_replace("%POLL_MULTIPLE_ANS_MAX%", '1', $template_question);
589
  }
590
  // Get Poll Answers Data
591
- list($order_by, $sort_order) = _polls_get_ans_result_sort();
592
  $poll_answers = $wpdb->get_results( $wpdb->prepare( "SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = %d ORDER BY $order_by $sort_order", $poll_question_id ) );
593
  // If There Is Poll Question With Answers
594
- if($poll_question && $poll_answers) {
595
  // Store The Percentage Of The Poll
596
  $poll_answer_percentage_array = array();
597
  // Is The Poll Total Votes 0?
598
  $poll_totalvotes_zero = true;
599
- if($poll_question_totalvotes > 0) {
600
  $poll_totalvotes_zero = false;
601
  }
602
  // Print Out Result Header Template
603
  $temp_pollresult .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
604
  $temp_pollresult .= "\t\t$template_question\n";
605
- foreach($poll_answers as $poll_answer) {
606
  // Poll Answer Variables
607
  $poll_answer_id = (int) $poll_answer->polla_aid;
608
- $poll_answer_text = wp_kses_post( removeslashes($poll_answer->polla_answers) );
609
  $poll_answer_votes = (int) $poll_answer->polla_votes;
610
  // Calculate Percentage And Image Bar Width
611
  $poll_answer_percentage = 0;
@@ -614,22 +623,20 @@ function display_pollresult($poll_id, $user_voted = array(), $display_loading =
614
  if ( ! $poll_totalvotes_zero && $poll_answer_votes > 0 ) {
615
  $poll_answer_percentage = round( ( $poll_answer_votes / $poll_question_totalvotes ) * 100 );
616
  $poll_multiple_answer_percentage = round( ( $poll_answer_votes / $poll_question_totalvoters ) * 100 );
617
- $poll_answer_imagewidth = round($poll_answer_percentage);
618
- if($poll_answer_imagewidth === 100) {
619
  $poll_answer_imagewidth = 99;
620
  }
621
  }
622
  // Make Sure That Total Percentage Is 100% By Adding A Buffer To The Last Poll Answer
623
  $round_percentage = apply_filters( 'wp_polls_round_percentage', false );
624
- if( $round_percentage ) {
625
- if ( $poll_multiple_ans === 0 ) {
626
- $poll_answer_percentage_array[] = $poll_answer_percentage;
627
- if ( count( $poll_answer_percentage_array ) === count( $poll_answers ) ) {
628
- $percentage_error_buffer = 100 - array_sum( $poll_answer_percentage_array );
629
- $poll_answer_percentage += $percentage_error_buffer;
630
- if ( $poll_answer_percentage < 0 ) {
631
- $poll_answer_percentage = 0;
632
- }
633
  }
634
  }
635
  }
@@ -637,13 +644,13 @@ function display_pollresult($poll_id, $user_voted = array(), $display_loading =
637
  // Let User See What Options They Voted
638
  if ( in_array( $poll_answer_id, $user_voted, true ) ) {
639
  // Results Body Variables
640
- $template_answer = removeslashes(get_option('poll_template_resultbody2'));
641
  } else {
642
  // Results Body Variables
643
- $template_answer = removeslashes(get_option('poll_template_resultbody'));
644
  }
645
 
646
- $template_answer = str_replace( [
647
  '%POLL_ID%',
648
  '%POLL_ANSWER_ID%',
649
  '%POLL_ANSWER%',
@@ -651,8 +658,8 @@ function display_pollresult($poll_id, $user_voted = array(), $display_loading =
651
  '%POLL_ANSWER_VOTES%',
652
  '%POLL_ANSWER_PERCENTAGE%',
653
  '%POLL_MULTIPLE_ANSWER_PERCENTAGE%',
654
- '%POLL_ANSWER_IMAGEWIDTH%',
655
- ], [
656
  $poll_question_id,
657
  $poll_answer_id,
658
  $poll_answer_text,
@@ -660,8 +667,8 @@ function display_pollresult($poll_id, $user_voted = array(), $display_loading =
660
  number_format_i18n( $poll_answer_votes ),
661
  $poll_answer_percentage,
662
  $poll_multiple_answer_percentage,
663
- $poll_answer_imagewidth,
664
- ], $template_answer );
665
 
666
  // Print Out Results Body Template
667
  $temp_pollresult .= "\t\t$template_answer\n";
@@ -683,42 +690,56 @@ function display_pollresult($poll_id, $user_voted = array(), $display_loading =
683
  }
684
  }
685
  // Results Footer Variables
686
- if(!empty($user_voted) || $poll_question_active === 0 || !check_allowtovote()) {
687
- $template_footer = removeslashes(get_option('poll_template_resultfooter'));
688
  } else {
689
- $template_footer = removeslashes(get_option('poll_template_resultfooter2'));
690
  }
691
- $template_footer = str_replace("%POLL_START_DATE%", $poll_start_date, $template_footer);
692
- $template_footer = str_replace("%POLL_END_DATE%", $poll_end_date, $template_footer);
693
- $template_footer = str_replace("%POLL_ID%", $poll_question_id, $template_footer);
694
- $template_footer = str_replace("%POLL_TOTALVOTES%", number_format_i18n($poll_question_totalvotes), $template_footer);
695
- $template_footer = str_replace("%POLL_TOTALVOTERS%", number_format_i18n($poll_question_totalvoters), $template_footer);
696
- $template_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_footer);
697
- $template_footer = str_replace("%POLL_MOST_VOTES%", number_format_i18n($poll_most_votes), $template_footer);
698
- $template_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_footer);
699
- $template_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_footer);
700
- $template_footer = str_replace("%POLL_LEAST_VOTES%", number_format_i18n($poll_least_votes), $template_footer);
701
- $template_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_footer);
702
- if($poll_multiple_ans > 0) {
703
- $template_footer = str_replace("%POLL_MULTIPLE_ANS_MAX%", $poll_multiple_ans, $template_footer);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  } else {
705
- $template_footer = str_replace("%POLL_MULTIPLE_ANS_MAX%", '1', $template_footer);
706
  }
707
  // Print Out Results Footer Template
708
  $temp_pollresult .= "\t\t$template_footer\n";
709
  $temp_pollresult .= "\t\t<input type=\"hidden\" id=\"poll_{$poll_question_id}_nonce\" name=\"wp-polls-nonce\" value=\"".wp_create_nonce('poll_'.$poll_question_id.'-nonce')."\" />\n";
710
  $temp_pollresult .= "</div>\n";
711
- if($display_loading) {
712
- $poll_ajax_style = get_option('poll_ajax_style');
713
- if((int) $poll_ajax_style['loading'] === 1) {
714
  $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";
715
  }
716
  }
717
  } else {
718
- $temp_pollresult .= removeslashes(get_option('poll_template_disable'));
719
  }
720
  // Return Poll Result
721
- return apply_filters('poll_result_markup', $temp_pollresult);
722
  }
723
 
724
 
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.74.1
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-polls
29
  */
30
 
31
  ### Version
32
+ define( 'WP_POLLS_VERSION', '2.74.1' );
33
 
34
 
35
  ### Create Text Domain For Translations
470
  }
471
  // Print Out Voting Form Header Template
472
  $temp_pollvote .= "\t\t$template_question\n";
473
+ foreach ( $poll_answers as $poll_answer ) {
474
  // Poll Answer Variables
475
  $poll_answer_id = (int) $poll_answer->polla_aid;
476
  $poll_answer_text = wp_kses_post( removeslashes( $poll_answer->polla_answers ) );
477
  $poll_answer_votes = (int) $poll_answer->polla_votes;
478
  $poll_answer_percentage = $poll_question_totalvotes > 0 ? round( ( $poll_answer_votes / $poll_question_totalvotes ) * 100 ) : 0;
479
+ $poll_multiple_answer_percentage = $poll_question_totalvoters > 0 ? round( ( $poll_answer_votes / $poll_question_totalvoters ) * 100 ) : 0;
480
+ $template_answer = removeslashes( get_option( 'poll_template_votebody' ) );
481
 
482
+ $template_answer = apply_filters( 'poll_template_votebody_markup', $template_answer, $poll_answer, array(
483
  '%POLL_ID%' => $poll_question_id,
484
  '%POLL_ANSWER_ID%' => $poll_answer_id,
485
  '%POLL_ANSWER%' => $poll_answer_text,
486
+ '%POLL_ANSWER_VOTES%' => number_format_i18n( $poll_answer_votes ),
487
  '%POLL_ANSWER_PERCENTAGE%' => $poll_answer_percentage,
488
  '%POLL_MULTIPLE_ANSWER_PERCENTAGE%' => $poll_multiple_answer_percentage,
489
+ '%POLL_CHECKBOX_RADIO%' => $poll_multiple_ans > 0 ? 'checkbox' : 'radio'
490
  ));
491
 
492
  // Print Out Voting Form Body Template
532
 
533
 
534
  ### Function: Display Results Form
535
+ function display_pollresult( $poll_id, $user_voted = array(), $display_loading = true ) {
536
  global $wpdb;
537
  do_action( 'wp_polls_display_pollresult', $poll_id, $user_voted );
538
  $poll_id = (int) $poll_id;
558
  // Get Poll Question Data
559
  $poll_question = $wpdb->get_row( $wpdb->prepare( "SELECT pollq_id, pollq_question, pollq_totalvotes, pollq_active, pollq_timestamp, pollq_expiry, pollq_multiple, pollq_totalvoters FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $poll_id ) );
560
  // No poll could be loaded from the database
561
+ if ( ! $poll_question ) {
562
+ return removeslashes( get_option( 'poll_template_disable' ) );
563
  }
564
  // Poll Question Variables
565
  $poll_question_text = wp_kses_post( removeslashes( $poll_question->pollq_question ) );
567
  $poll_question_totalvotes = (int) $poll_question->pollq_totalvotes;
568
  $poll_question_totalvoters = (int) $poll_question->pollq_totalvoters;
569
  $poll_question_active = (int) $poll_question->pollq_active;
570
+ $poll_start_date = mysql2date( sprintf( __( '%s @ %s', 'wp-polls' ), get_option( 'date_format' ), get_option( 'time_format' ) ), gmdate( 'Y-m-d H:i:s', $poll_question->pollq_timestamp ) );
571
+ $poll_expiry = trim( $poll_question->pollq_expiry );
572
+ if ( empty( $poll_expiry ) ) {
573
+ $poll_end_date = __( 'No Expiry', 'wp-polls' );
574
  } else {
575
+ $poll_end_date = mysql2date( sprintf( __( '%s @ %s', 'wp-polls' ), get_option( 'date_format' ), get_option( 'time_format' ) ), gmdate( 'Y-m-d H:i:s', $poll_expiry ) );
576
  }
577
  $poll_multiple_ans = (int) $poll_question->pollq_multiple;
578
+ $template_question = removeslashes( get_option( 'poll_template_resultheader' ) );
579
+ $template_question = str_replace( array(
580
+ '%POLL_QUESTION%',
581
+ '%POLL_ID%',
582
+ '%POLL_TOTALVOTES%',
583
+ '%POLL_TOTALVOTERS%',
584
+ '%POLL_START_DATE%',
585
+ '%POLL_END_DATE%'
586
+ ), array(
587
+ $poll_question_text,
588
+ $poll_question_id,
589
+ $poll_question_totalvotes,
590
+ $poll_question_totalvoters,
591
+ $poll_start_date,
592
+ $poll_end_date
593
+ ), $template_question );
594
  if($poll_multiple_ans > 0) {
595
+ $template_question = str_replace( '%POLL_MULTIPLE_ANS_MAX%', $poll_multiple_ans, $template_question );
596
  } else {
597
+ $template_question = str_replace( '%POLL_MULTIPLE_ANS_MAX%', '1', $template_question );
598
  }
599
  // Get Poll Answers Data
600
+ list( $order_by, $sort_order ) = _polls_get_ans_result_sort();
601
  $poll_answers = $wpdb->get_results( $wpdb->prepare( "SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = %d ORDER BY $order_by $sort_order", $poll_question_id ) );
602
  // If There Is Poll Question With Answers
603
+ if ( $poll_question && $poll_answers ) {
604
  // Store The Percentage Of The Poll
605
  $poll_answer_percentage_array = array();
606
  // Is The Poll Total Votes 0?
607
  $poll_totalvotes_zero = true;
608
+ if ( $poll_question_totalvotes > 0 ) {
609
  $poll_totalvotes_zero = false;
610
  }
611
  // Print Out Result Header Template
612
  $temp_pollresult .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
613
  $temp_pollresult .= "\t\t$template_question\n";
614
+ foreach ( $poll_answers as $poll_answer ) {
615
  // Poll Answer Variables
616
  $poll_answer_id = (int) $poll_answer->polla_aid;
617
+ $poll_answer_text = wp_kses_post( removeslashes( $poll_answer->polla_answers ) );
618
  $poll_answer_votes = (int) $poll_answer->polla_votes;
619
  // Calculate Percentage And Image Bar Width
620
  $poll_answer_percentage = 0;
623
  if ( ! $poll_totalvotes_zero && $poll_answer_votes > 0 ) {
624
  $poll_answer_percentage = round( ( $poll_answer_votes / $poll_question_totalvotes ) * 100 );
625
  $poll_multiple_answer_percentage = round( ( $poll_answer_votes / $poll_question_totalvoters ) * 100 );
626
+ $poll_answer_imagewidth = round( $poll_answer_percentage );
627
+ if ( $poll_answer_imagewidth === 100 ) {
628
  $poll_answer_imagewidth = 99;
629
  }
630
  }
631
  // Make Sure That Total Percentage Is 100% By Adding A Buffer To The Last Poll Answer
632
  $round_percentage = apply_filters( 'wp_polls_round_percentage', false );
633
+ if ( $round_percentage && $poll_multiple_ans === 0 ) {
634
+ $poll_answer_percentage_array[] = $poll_answer_percentage;
635
+ if ( count( $poll_answer_percentage_array ) === count( $poll_answers ) ) {
636
+ $percentage_error_buffer = 100 - array_sum( $poll_answer_percentage_array );
637
+ $poll_answer_percentage += $percentage_error_buffer;
638
+ if ( $poll_answer_percentage < 0 ) {
639
+ $poll_answer_percentage = 0;
 
 
640
  }
641
  }
642
  }
644
  // Let User See What Options They Voted
645
  if ( in_array( $poll_answer_id, $user_voted, true ) ) {
646
  // Results Body Variables
647
+ $template_answer = removeslashes( get_option( 'poll_template_resultbody2' ) );
648
  } else {
649
  // Results Body Variables
650
+ $template_answer = removeslashes (get_option( 'poll_template_resultbody' ) );
651
  }
652
 
653
+ $template_answer = str_replace( array(
654
  '%POLL_ID%',
655
  '%POLL_ANSWER_ID%',
656
  '%POLL_ANSWER%',
658
  '%POLL_ANSWER_VOTES%',
659
  '%POLL_ANSWER_PERCENTAGE%',
660
  '%POLL_MULTIPLE_ANSWER_PERCENTAGE%',
661
+ '%POLL_ANSWER_IMAGEWIDTH%'
662
+ ), array(
663
  $poll_question_id,
664
  $poll_answer_id,
665
  $poll_answer_text,
667
  number_format_i18n( $poll_answer_votes ),
668
  $poll_answer_percentage,
669
  $poll_multiple_answer_percentage,
670
+ $poll_answer_imagewidth
671
+ ), $template_answer );
672
 
673
  // Print Out Results Body Template
674
  $temp_pollresult .= "\t\t$template_answer\n";
690
  }
691
  }
692
  // Results Footer Variables
693
+ if ( ! empty( $user_voted ) || $poll_question_active === 0 || ! check_allowtovote() ) {
694
+ $template_footer = removeslashes( get_option( 'poll_template_resultfooter' ) );
695
  } else {
696
+ $template_footer = removeslashes( get_option( 'poll_template_resultfooter2' ) );
697
  }
698
+ $template_footer = str_replace( array(
699
+ '%POLL_START_DATE%',
700
+ '%POLL_END_DATE%',
701
+ '%POLL_ID%',
702
+ '%POLL_TOTALVOTES%',
703
+ '%POLL_TOTALVOTERS%',
704
+ '%POLL_MOST_ANSWER%',
705
+ '%POLL_MOST_VOTES%',
706
+ '%POLL_MOST_PERCENTAGE%',
707
+ '%POLL_LEAST_ANSWER%',
708
+ '%POLL_LEAST_VOTES%',
709
+ '%POLL_LEAST_PERCENTAGE%'
710
+ ), array(
711
+ $poll_start_date,
712
+ $poll_end_date,
713
+ $poll_question_id,
714
+ number_format_i18n( $poll_question_totalvotes ),
715
+ number_format_i18n( $poll_question_totalvoters ),
716
+ $poll_most_answer,
717
+ number_format_i18n( $poll_most_votes ),
718
+ $poll_most_percentage,
719
+ $poll_least_answer,
720
+ number_format_i18n( $poll_least_votes ),
721
+ $poll_least_percentage
722
+ ), $template_footer );
723
+ if ( $poll_multiple_ans > 0 ) {
724
+ $template_footer = str_replace( '%POLL_MULTIPLE_ANS_MAX%', $poll_multiple_ans, $template_footer );
725
  } else {
726
+ $template_footer = str_replace( '%POLL_MULTIPLE_ANS_MAX%', '1', $template_footer );
727
  }
728
  // Print Out Results Footer Template
729
  $temp_pollresult .= "\t\t$template_footer\n";
730
  $temp_pollresult .= "\t\t<input type=\"hidden\" id=\"poll_{$poll_question_id}_nonce\" name=\"wp-polls-nonce\" value=\"".wp_create_nonce('poll_'.$poll_question_id.'-nonce')."\" />\n";
731
  $temp_pollresult .= "</div>\n";
732
+ if ( $display_loading ) {
733
+ $poll_ajax_style = get_option( 'poll_ajax_style' );
734
+ if ( (int) $poll_ajax_style['loading'] === 1 ) {
735
  $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";
736
  }
737
  }
738
  } else {
739
+ $temp_pollresult .= removeslashes( get_option ('poll_template_disable' ) );
740
  }
741
  // Return Poll Result
742
+ return apply_filters( 'poll_result_markup', $temp_pollresult );
743
  }
744
 
745