WP-Polls - Version 2.73.3

Version Description

Download this release

Release Info

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

Code changes from version 2.73.2 to 2.73.3

Files changed (3) hide show
  1. polls-options.php +1 -0
  2. readme.txt +90 -108
  3. wp-polls.php +183 -180
polls-options.php CHANGED
@@ -233,6 +233,7 @@ if( isset($_POST['Submit']) && $_POST['Submit'] ) {
233
  <th scope="row" valign="top"><?php _e('Sort Poll Answers By:', 'wp-polls'); ?></th>
234
  <td>
235
  <select name="poll_ans_sortby" size="1">
 
236
  <option value="polla_aid"<?php selected('polla_aid', get_option('poll_ans_sortby')); ?>><?php _e('Exact Order', 'wp-polls'); ?></option>
237
  <option value="polla_answers"<?php selected('polla_answers', get_option('poll_ans_sortby')); ?>><?php _e('Alphabetical Order', 'wp-polls'); ?></option>
238
  <option value="RAND()"<?php selected('RAND()', get_option('poll_ans_sortby')); ?>><?php _e('Random Order', 'wp-polls'); ?></option>
233
  <th scope="row" valign="top"><?php _e('Sort Poll Answers By:', 'wp-polls'); ?></th>
234
  <td>
235
  <select name="poll_ans_sortby" size="1">
236
+ <option value="polla_votes"<?php selected('polla_votes', get_option('poll_ans_sortby')); ?>><?php _e('Votes Cast', 'wp-polls'); ?></option>
237
  <option value="polla_aid"<?php selected('polla_aid', get_option('poll_ans_sortby')); ?>><?php _e('Exact Order', 'wp-polls'); ?></option>
238
  <option value="polla_answers"<?php selected('polla_answers', get_option('poll_ans_sortby')); ?>><?php _e('Alphabetical Order', 'wp-polls'); ?></option>
239
  <option value="RAND()"<?php selected('RAND()', get_option('poll_ans_sortby')); ?>><?php _e('Random Order', 'wp-polls'); ?></option>
readme.txt CHANGED
@@ -1,110 +1,95 @@
1
- === WP-Polls ===
2
  Contributors: GamerZ
3
  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.2
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
 
11
- == Description ==
12
  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.
13
 
14
- = Build Status =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  [![Build Status](https://travis-ci.org/lesterchan/wp-polls.svg?branch=master)](https://travis-ci.org/lesterchan/wp-polls)
16
 
17
- = Development =
18
  [https://github.com/lesterchan/wp-polls](https://github.com/lesterchan/wp-polls "https://github.com/lesterchan/wp-polls")
19
 
20
- = Translations =
21
  [http://dev.wp-plugins.org/browser/wp-polls/i18n/](http://dev.wp-plugins.org/browser/wp-polls/i18n/ "http://dev.wp-plugins.org/browser/wp-polls/i18n/")
22
 
23
- = Credits =
24
  * Plugin icon by [Freepik](http://www.freepik.com) from [Flaticon](http://www.flaticon.com)
25
 
26
- = Donations =
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.2 =
 
 
 
 
 
 
 
31
  * NEW: Bump WordPress 4.7
32
  * FIXED: Change cron to hourly instead of twice daily.
33
 
34
- = Version 2.73.1 =
35
  * FIXED: Allow local IP
36
  * FIXED: XSS on Poll bar option. Props [Netsparker Web Application Security Scanner](https://www.netsparker.com/)
37
  * FIXED: Stricter Poll pptions check
38
 
39
- = Version 2.73 =
40
  * NEW: Display Poll Questions at the top of the Poll Logs table
41
  * FIXED: Remove slashes
42
 
43
- = Version 2.72 =
44
  * NEW: Use translate.wordpress.org to translate the plugin
45
  * FIXED: SQL Injection fixes. Props [Jay Dansand](https://github.com/jaydansand)
46
  * FIXED: Use $wpdb->insert(), $wpdb->update() and $wpdb->delete() as much as possible
47
  * FIXED Remove poll_archive_show option from UI
48
 
49
- = Version 2.71 =
50
  * FIXED: Use wp_kses_post() to get filter always bad tags
51
 
52
- = Version 2.70 =
53
  * NEW: Add wp_polls_vote_poll_success action hook
54
  * NEW: Add wp_polls_add_poll, wp_polls_update_poll, wp_polls_delete_poll action hooks
55
  * FIXED: PHP Notices
56
  * FIXED: Removed not needed wp_print_scripts
57
  * FIXED: Use esc_attr() and esc_textarea() instead of htmlspecialchars(). Props [Govind Singh](https://in.linkedin.com/pub/govind-singh/21/1a9/bab)
58
 
59
- == Installation ==
60
-
61
- 1. Open `wp-content/plugins` Folder
62
- 2. Put: `Folder: wp-polls`
63
- 3. Activate `WP-Polls` Plugin
64
- 4. Go to `WP-Admin -> WP-Polls`
65
-
66
- = General Usage (Without Widget) =
67
- 1. Open `wp-content/themes/<YOUR THEME NAME>/sidebar.php`
68
- 2. Add:
69
- <code>
70
- &lt;?php if (function_exists('vote_poll') && !in_pollarchive()): ?&gt;
71
- &nbsp;&nbsp;&lt;li&gt;
72
- &nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Polls&lt;/h2&gt;
73
- &nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;
74
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;?php get_poll();?&gt;&lt;/li&gt;
75
- &nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;
76
- &nbsp;&nbsp;&nbsp;&nbsp;&lt;?php display_polls_archive_link(); ?&gt;
77
- &nbsp;&nbsp;&lt;/li&gt;
78
- &lt;?php endif; ?&gt;
79
- </code>
80
-
81
- * To show specific poll, use `<?php get_poll(2); ?>` where 2 is your poll id.
82
- * To show random poll, use `<?php get_poll(-2); ?>`
83
- * To embed a specific poll in your post, use `[poll id="2"]` where 2 is your poll id.
84
- * To embed a random poll in your post, use `[poll id="-2"]`
85
- * To embed a specific poll's result in your post, use `[poll id="2" type="result"]` where 2 is your poll id.
86
-
87
- = General Usage (With Widget) =
88
- 1. Go to `WP-Admin -> Appearance -> Widgets`.
89
- 2. You can add the Polls Widget by clicking on the 'Add' link besides it.
90
- 3. After adding, you can configure the Polls Widget by clicking on the 'Edit' link besides it.
91
- 4. Click 'Save Changes'.
92
- 5. Scroll down for instructions on how to create a Polls Archive.
93
-
94
- == Upgrading ==
95
-
96
- 1. Deactivate `WP-Polls` Plugin
97
- 2. Open `wp-content/plugins` Folder
98
- 3. Put/Overwrite: `Folder: wp-polls`
99
- 4. Activate `WP-Polls` Plugin
100
- 5. Go to `WP-Admin -> Polls -> Polls Templates` and restore all the template variables to `Default`
101
- 6. Go to `WP-Admin -> Appearance -> Widgets` and re-add the Poll Widget
102
-
103
- == Upgrade Notice ==
104
-
105
- N/A
106
-
107
- == Screenshots ==
108
 
109
  1. Admin - All Poll
110
  2. Admin - Manage Polls
@@ -117,10 +102,8 @@ N/A
117
  9. Poll - Results
118
  10. Poll - Archive
119
 
120
- == Frequently Asked Questions ==
121
-
122
-
123
- = How To Add A Polls Archive? =
124
  1. Go to `WP-Admin -> Pages -> Add New`.
125
  2. Type any title you like in the post's title area.
126
  3. If you ARE using nice permalinks, after typing the title, WordPress will generate the permalink to the page. You will see an 'Edit' link just beside the permalink.
@@ -130,25 +113,25 @@ N/A
130
 
131
  * If you ARE NOT using nice permalinks, you need to go to `WP-Admin -> Polls -> Poll Options` and under `Poll Archive -> Polls Archive URL`, you need to fill in the URL to the Polls Archive Page you created above.
132
 
133
- = Why doesn't my poll's answers add up to 100%? =
134
  * It is because of rounding issues. To make it always round up to 100%, the last poll's answer will get the remainding percentage added to it. To enable this feature, add this to your theme's functions.php: `add_filter( 'wp_polls_round_percentage', '__return_true' );`
135
 
136
- = How Does WP-Polls Load CSS? =
137
  * WP-Polls will load `polls-css.css` from your theme's directory if it exists.
138
  * If it doesn't exists, it will just load the default `polls-css.css` that comes with WP-Polls.
139
  * This will allow you to upgrade WP-Polls without worrying about overwriting your polls styles that you have created.
140
 
141
- = Why In Internet Explorer (IE) The poll's Text Appear Jagged? =
142
  * To solve this issue, Open poll-css.css
143
  * Find: `/* background-color: #ffffff; */`
144
  * Replace: `background-color: #ffffff;` (where #ffffff should be your background color for the poll.)
145
 
146
- = How Do I Have Individual Colors For Each Poll's Bar? =
147
  * Courtesy Of [TreedBox.com](http://treedbox.com "TreedBox.com")
148
  * Open poll-css.css
149
  * Add to the end of the file:
150
 
151
- <code>
152
  .wp-polls-ul li:nth-child(01) .pollbar{ background:#8FA0C5}
153
  .wp-polls-ul li:nth-child(02) .pollbar{ background:#FF8}
154
  .wp-polls-ul li:nth-child(03) .pollbar{ background:#ff8a3b}
@@ -161,38 +144,37 @@ N/A
161
  .wp-polls-ul li:nth-child(10) .pollbar{ background:#a67c52}
162
  .wp-polls-ul li .pollbar{ transition: background 0.7s ease-in-out }
163
  .wp-polls-ul li .pollbar:hover{ background:#F00 }
164
- </code>
165
-
166
- = Polls Stats (Outside WP Loop) =
167
-
168
- = To Display Total Polls =
169
- * Use:
170
- <code>
171
- &lt;?php if (function_exists('get_pollquestions')): ?&gt;
172
- &nbsp;&nbsp;&lt;?php get_pollquestions(); ?&gt;
173
- &lt;?php endif; ?&gt;
174
- </code>
175
-
176
- = To Display Total Poll Answers =
177
- * Use:
178
- <code>
179
- &lt;?php if (function_exists('get_pollanswers')): ?&gt;
180
- &nbsp;&nbsp;&lt;?php get_pollanswers(); ?&gt;
181
- &lt;?php endif; ?&gt;
182
- </code>
183
-
184
- = To Display Total Poll Votes =
185
- * Use:
186
- <code>
187
- &lt;?php if (function_exists('get_pollvotes')): ?&gt;
188
- &nbsp;&nbsp;&lt;?php get_pollvotes(); ?&gt;
189
- &lt;?php endif; ?&gt;
190
- </code>
191
-
192
- = To Display Total Poll Voters =
193
- * Use:
194
- <code>
195
- &lt;?php if (function_exists('get_pollvoters')): ?&gt;
196
- &nbsp;&nbsp;&lt;?php get_pollvoters(); ?&gt;
197
- &lt;?php endif; ?&gt;
198
- </code>
1
+ # WP-Polls
2
  Contributors: GamerZ
3
  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.3
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
 
11
+ ## Description
12
  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.
13
 
14
+ ### General Usage (Without Widget)
15
+ ```
16
+ <?php if ( function_exists( 'vote_poll' ) && ! in_pollarchive() ): ?>
17
+ <li>
18
+ <h2>Polls</h2>
19
+ <ul>
20
+ <li><?php get_poll();?></li>
21
+ </ul>
22
+ <?php display_polls_archive_link(); ?>
23
+ </li>
24
+ <?php endif; ?>
25
+ ```
26
+
27
+ * To show specific poll, use `<?php get_poll(2); ?>` where 2 is your poll id.
28
+ * To show random poll, use `<?php get_poll(-2); ?>`
29
+ * To embed a specific poll in your post, use `[poll id="2"]` where 2 is your poll id.
30
+ * To embed a random poll in your post, use `[poll id="-2"]`
31
+ * To embed a specific poll's result in your post, use `[poll id="2" type="result"]` where 2 is your poll id.
32
+
33
+ ### General Usage (With Widget)
34
+ 1. Go to `WP-Admin -> Appearance -> Widgets`.
35
+ 2. You can add the Polls Widget by clicking on the 'Add' link besides it.
36
+ 3. After adding, you can configure the Polls Widget by clicking on the 'Edit' link besides it.
37
+ 4. Click 'Save Changes'.
38
+ 5. Scroll down for instructions on how to create a Polls Archive.
39
+
40
+ ### Build Status
41
  [![Build Status](https://travis-ci.org/lesterchan/wp-polls.svg?branch=master)](https://travis-ci.org/lesterchan/wp-polls)
42
 
43
+ ### Development
44
  [https://github.com/lesterchan/wp-polls](https://github.com/lesterchan/wp-polls "https://github.com/lesterchan/wp-polls")
45
 
46
+ ### Translations
47
  [http://dev.wp-plugins.org/browser/wp-polls/i18n/](http://dev.wp-plugins.org/browser/wp-polls/i18n/ "http://dev.wp-plugins.org/browser/wp-polls/i18n/")
48
 
49
+ ### Credits
50
  * Plugin icon by [Freepik](http://www.freepik.com) from [Flaticon](http://www.flaticon.com)
51
 
52
+ ### Donations
53
  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.
54
 
55
+ ## Changelog
56
+ ### Version 2.73.3
57
+ * NEW: Added sort by votes casted to poll answers.
58
+ * NEW: For polls with mutiple answers, we divided by total votes instead of total voters. Props @ljxprime.
59
+ * FIXED: Do not display poll option is not respected when poll is closed.
60
+ * FIXED: pollip_qid, pollip_aid, pollip_timestamp are now int(10) in pollsip table.
61
+ * FIXED: pollq_expiry is now int(10) in pollsq table.
62
+
63
+ ### Version 2.73.2
64
  * NEW: Bump WordPress 4.7
65
  * FIXED: Change cron to hourly instead of twice daily.
66
 
67
+ ### Version 2.73.1
68
  * FIXED: Allow local IP
69
  * FIXED: XSS on Poll bar option. Props [Netsparker Web Application Security Scanner](https://www.netsparker.com/)
70
  * FIXED: Stricter Poll pptions check
71
 
72
+ ### Version 2.73
73
  * NEW: Display Poll Questions at the top of the Poll Logs table
74
  * FIXED: Remove slashes
75
 
76
+ ### Version 2.72
77
  * NEW: Use translate.wordpress.org to translate the plugin
78
  * FIXED: SQL Injection fixes. Props [Jay Dansand](https://github.com/jaydansand)
79
  * FIXED: Use $wpdb->insert(), $wpdb->update() and $wpdb->delete() as much as possible
80
  * FIXED Remove poll_archive_show option from UI
81
 
82
+ ### Version 2.71
83
  * FIXED: Use wp_kses_post() to get filter always bad tags
84
 
85
+ ### Version 2.70
86
  * NEW: Add wp_polls_vote_poll_success action hook
87
  * NEW: Add wp_polls_add_poll, wp_polls_update_poll, wp_polls_delete_poll action hooks
88
  * FIXED: PHP Notices
89
  * FIXED: Removed not needed wp_print_scripts
90
  * FIXED: Use esc_attr() and esc_textarea() instead of htmlspecialchars(). Props [Govind Singh](https://in.linkedin.com/pub/govind-singh/21/1a9/bab)
91
 
92
+ ## Screenshots
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
  1. Admin - All Poll
95
  2. Admin - Manage Polls
102
  9. Poll - Results
103
  10. Poll - Archive
104
 
105
+ ## Frequently Asked Questions
106
+ ### How To Add A Polls Archive?
 
 
107
  1. Go to `WP-Admin -> Pages -> Add New`.
108
  2. Type any title you like in the post's title area.
109
  3. If you ARE using nice permalinks, after typing the title, WordPress will generate the permalink to the page. You will see an 'Edit' link just beside the permalink.
113
 
114
  * If you ARE NOT using nice permalinks, you need to go to `WP-Admin -> Polls -> Poll Options` and under `Poll Archive -> Polls Archive URL`, you need to fill in the URL to the Polls Archive Page you created above.
115
 
116
+ ### Why doesn't my poll's answers add up to 100%?
117
  * It is because of rounding issues. To make it always round up to 100%, the last poll's answer will get the remainding percentage added to it. To enable this feature, add this to your theme's functions.php: `add_filter( 'wp_polls_round_percentage', '__return_true' );`
118
 
119
+ ### How Does WP-Polls Load CSS?
120
  * WP-Polls will load `polls-css.css` from your theme's directory if it exists.
121
  * If it doesn't exists, it will just load the default `polls-css.css` that comes with WP-Polls.
122
  * This will allow you to upgrade WP-Polls without worrying about overwriting your polls styles that you have created.
123
 
124
+ ### Why In Internet Explorer (IE) The poll's Text Appear Jagged?
125
  * To solve this issue, Open poll-css.css
126
  * Find: `/* background-color: #ffffff; */`
127
  * Replace: `background-color: #ffffff;` (where #ffffff should be your background color for the poll.)
128
 
129
+ ### How Do I Have Individual Colors For Each Poll's Bar?
130
  * Courtesy Of [TreedBox.com](http://treedbox.com "TreedBox.com")
131
  * Open poll-css.css
132
  * Add to the end of the file:
133
 
134
+ ```
135
  .wp-polls-ul li:nth-child(01) .pollbar{ background:#8FA0C5}
136
  .wp-polls-ul li:nth-child(02) .pollbar{ background:#FF8}
137
  .wp-polls-ul li:nth-child(03) .pollbar{ background:#ff8a3b}
144
  .wp-polls-ul li:nth-child(10) .pollbar{ background:#a67c52}
145
  .wp-polls-ul li .pollbar{ transition: background 0.7s ease-in-out }
146
  .wp-polls-ul li .pollbar:hover{ background:#F00 }
147
+ ```
148
+
149
+ ### To Display Total Polls
150
+
151
+ ```
152
+ <?php if ( function_exists( 'get_pollquestions' ) ): ?>
153
+ <?php get_pollquestions(); ?>
154
+ <?php endif; ?>
155
+ ```
156
+
157
+ ### To Display Total Poll Answers
158
+
159
+ ```
160
+ <?php if ( function_exists( 'get_pollanswers' ) ): ?>
161
+ <?php get_pollanswers(); ?>
162
+ <?php endif; ?>
163
+ ```
164
+
165
+ ### To Display Total Poll Votes
166
+
167
+ ```
168
+ <?php if ( function_exists( 'get_pollvotes' ) ): ?>
169
+ <?php get_pollvotes(); ?>
170
+ <?php endif; ?>
171
+ ```
172
+
173
+ ### To Display Total Poll Voters
174
+
175
+ ```
176
+ <?php if ( function_exists( 'get_pollvoters' ) ): ?>
177
+ <?php get_pollvoters(); ?>
178
+ <?php endif; ?>
179
+ ```
180
+
 
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.2
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-polls
@@ -11,7 +11,7 @@ Text Domain: wp-polls
11
 
12
 
13
  /*
14
- Copyright 2016 Lester Chan (email : lesterchan@gmail.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ Text Domain: wp-polls
30
 
31
 
32
  ### Version
33
- define( 'WP_POLLS_VERSION', '2.73.2' );
34
 
35
 
36
  ### Create Text Domain For Translations
@@ -124,7 +124,6 @@ function get_poll($temp_poll_id = 0, $display = true) {
124
  if($pollresult_id == $poll_id) {
125
  if($display) {
126
  echo display_pollresult($poll_id);
127
- return;
128
  } else {
129
  return display_pollresult($poll_id);
130
  }
@@ -133,30 +132,34 @@ function get_poll($temp_poll_id = 0, $display = true) {
133
  $poll_active = $wpdb->get_var( $wpdb->prepare( "SELECT pollq_active FROM $wpdb->pollsq WHERE pollq_id = %d", $poll_id ) );
134
  $poll_active = intval($poll_active);
135
  $check_voted = check_voted($poll_id);
136
- if($poll_active == 0) {
137
- $poll_close = intval(get_option('poll_close'));
138
  } else {
139
  $poll_close = 0;
140
  }
141
- if(intval($check_voted) > 0 || (is_array($check_voted) && sizeof($check_voted) > 0) || ($poll_active == 0 && $poll_close == 1)) {
 
 
 
 
 
 
 
142
  if($display) {
143
  echo display_pollresult($poll_id, $check_voted);
144
- return;
145
  } else {
146
  return display_pollresult($poll_id, $check_voted);
147
  }
148
- } elseif(!check_allowtovote() || ($poll_active == 0 && $poll_close == 3)) {
149
  $disable_poll_js = '<script type="text/javascript">jQuery("#polls_form_'.$poll_id.' :input").each(function (i){jQuery(this).attr("disabled","disabled")});</script>';
150
  if($display) {
151
  echo display_pollvote($poll_id).$disable_poll_js;
152
- return;
153
  } else {
154
  return display_pollvote($poll_id).$disable_poll_js;
155
  }
156
- } elseif($poll_active == 1) {
157
  if($display) {
158
  echo display_pollvote($poll_id);
159
- return;
160
  } else {
161
  return display_pollvote($poll_id);
162
  }
@@ -475,7 +478,7 @@ function display_pollvote($poll_id, $display_loading = true) {
475
  $poll_answer_id = intval($poll_answer->polla_aid);
476
  $poll_answer_text = wp_kses_post( removeslashes( $poll_answer->polla_answers ) );
477
  $poll_answer_votes = intval($poll_answer->polla_votes);
478
- $poll_answer_percentage = $poll_question_totalvoters > 0 ? round((($poll_answer_votes/$poll_question_totalvoters)*100)) : 0;
479
  $template_answer = removeslashes(get_option('poll_template_votebody'));
480
 
481
  $template_answer = apply_filters('poll_template_votebody_markup', $template_answer, $poll_answer, array(
@@ -602,7 +605,7 @@ function display_pollresult($poll_id, $user_voted = '', $display_loading = true)
602
  // Calculate Percentage And Image Bar Width
603
  if(!$poll_totalvotes_zero) {
604
  if($poll_answer_votes > 0) {
605
- $poll_answer_percentage = round((($poll_answer_votes/$poll_question_totalvoters)*100));
606
  $poll_answer_imagewidth = round($poll_answer_percentage);
607
  if($poll_answer_imagewidth == 100) {
608
  $poll_answer_imagewidth = 99;
@@ -708,7 +711,7 @@ function display_pollresult($poll_id, $user_voted = '', $display_loading = true)
708
  $temp_pollresult .= removeslashes(get_option('poll_template_disable'));
709
  }
710
  // Return Poll Result
711
- return $temp_pollresult;
712
  }
713
 
714
 
@@ -1008,7 +1011,7 @@ function polls_archive() {
1008
  // Calculate Percentage And Image Bar Width
1009
  if(!$poll_totalvotes_zero) {
1010
  if($polls_answer['votes'] > 0) {
1011
- $poll_answer_percentage = round((($polls_answer['votes']/$polls_question['totalvoters'])*100));
1012
  $poll_answer_imagewidth = round($poll_answer_percentage*0.9);
1013
  } else {
1014
  $poll_answer_percentage = 0;
@@ -1532,9 +1535,9 @@ function manage_poll() {
1532
  if(empty($text)) {
1533
  echo '<p style="color: green;">'.sprintf(__('Poll \'%s\' Deleted Successfully', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
1534
  }
 
1535
  // Update Lastest Poll ID To Poll Options
1536
- $latest_pollid = polls_latest_id();
1537
- $update_latestpoll = update_option('poll_latestpoll', $latest_pollid);
1538
  do_action( 'wp_polls_delete_poll', $pollq_id );
1539
  break;
1540
  }
@@ -1547,6 +1550,7 @@ function manage_poll() {
1547
  function _polls_get_ans_sort() {
1548
  $order_by = get_option( 'poll_ans_sortby' );
1549
  switch( $order_by ) {
 
1550
  case 'polla_aid':
1551
  case 'polla_answers':
1552
  case 'RAND()':
@@ -1729,166 +1733,165 @@ function polls_activation( $network_wide ) {
1729
  }
1730
 
1731
  function polls_activate() {
1732
- global $wpdb;
1733
-
1734
- if(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
1735
- include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
1736
- } elseif(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
1737
- include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
1738
- } else {
1739
- die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
1740
- }
1741
-
1742
- // Create Poll Tables (3 Tables)
1743
- $charset_collate = '';
1744
- if( $wpdb->has_cap( 'collation' ) ) {
1745
- if(!empty($wpdb->charset)) {
1746
- $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1747
- }
1748
- if(!empty($wpdb->collate)) {
1749
- $charset_collate .= " COLLATE $wpdb->collate";
1750
- }
1751
- }
1752
- $create_table = array();
1753
- $create_table['pollsq'] = "CREATE TABLE $wpdb->pollsq (".
1754
- "pollq_id int(10) NOT NULL auto_increment,".
1755
- "pollq_question varchar(200) character set utf8 NOT NULL default '',".
1756
- "pollq_timestamp varchar(20) NOT NULL default '',".
1757
- "pollq_totalvotes int(10) NOT NULL default '0',".
1758
- "pollq_active tinyint(1) NOT NULL default '1',".
1759
- "pollq_expiry varchar(20) NOT NULL default '',".
1760
- "pollq_multiple tinyint(3) NOT NULL default '0',".
1761
- "pollq_totalvoters int(10) NOT NULL default '0',".
1762
- "PRIMARY KEY (pollq_id)) $charset_collate;";
1763
- $create_table['pollsa'] = "CREATE TABLE $wpdb->pollsa (".
1764
- "polla_aid int(10) NOT NULL auto_increment,".
1765
- "polla_qid int(10) NOT NULL default '0',".
1766
- "polla_answers varchar(200) character set utf8 NOT NULL default '',".
1767
- "polla_votes int(10) NOT NULL default '0',".
1768
- "PRIMARY KEY (polla_aid)) $charset_collate;";
1769
- $create_table['pollsip'] = "CREATE TABLE $wpdb->pollsip (".
1770
- "pollip_id int(10) NOT NULL auto_increment,".
1771
- "pollip_qid varchar(10) NOT NULL default '',".
1772
- "pollip_aid varchar(10) NOT NULL default '',".
1773
- "pollip_ip varchar(100) NOT NULL default '',".
1774
- "pollip_host VARCHAR(200) NOT NULL default '',".
1775
- "pollip_timestamp varchar(20) NOT NULL default '0000-00-00 00:00:00',".
1776
- "pollip_user tinytext NOT NULL,".
1777
- "pollip_userid int(10) NOT NULL default '0',".
1778
- "PRIMARY KEY (pollip_id),".
1779
- "KEY pollip_ip (pollip_ip),".
1780
- "KEY pollip_qid (pollip_qid),".
1781
- "KEY pollip_ip_qid (pollip_ip, pollip_qid)".
1782
- ") $charset_collate;";
1783
- maybe_create_table($wpdb->pollsq, $create_table['pollsq']);
1784
- maybe_create_table($wpdb->pollsa, $create_table['pollsa']);
1785
- maybe_create_table($wpdb->pollsip, $create_table['pollsip']);
1786
- // Check Whether It is Install Or Upgrade
1787
- $first_poll = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq LIMIT 1");
1788
- // If Install, Insert 1st Poll Question With 5 Poll Answers
1789
- if(empty($first_poll)) {
1790
- // Insert Poll Question (1 Record)
1791
- $insert_pollq = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (1, '".__('How Is My Site?', 'wp-polls')."', '".current_time('timestamp')."', 0, 1, '', 0, 0);");
1792
- if($insert_pollq) {
1793
- // Insert Poll Answers (5 Records)
1794
- $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (1, 1, '".__('Good', 'wp-polls')."', 0);");
1795
- $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (2, 1, '".__('Excellent', 'wp-polls')."', 0);");
1796
- $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (3, 1, '".__('Bad', 'wp-polls')."', 0);");
1797
- $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (4, 1, '".__('Can Be Improved', 'wp-polls')."', 0);");
1798
- $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (5, 1, '".__('No Comments', 'wp-polls')."', 0);");
1799
- }
1800
- }
1801
- // Add In Options (16 Records)
1802
- add_option('poll_template_voteheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>'.
1803
- '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
1804
- '<ul class="wp-polls-ul">');
1805
- add_option('poll_template_votebody', '<li><input type="%POLL_CHECKBOX_RADIO%" id="poll-answer-%POLL_ANSWER_ID%" name="poll_%POLL_ID%" value="%POLL_ANSWER_ID%" /> <label for="poll-answer-%POLL_ANSWER_ID%">%POLL_ANSWER%</label></li>');
1806
- add_option('poll_template_votefooter', '</ul>'.
1807
- '<p style="text-align: center;"><input type="button" name="vote" value=" '.__('Vote', 'wp-polls').' " class="Buttons" onclick="poll_vote(%POLL_ID%);" /></p>'.
1808
- '<p style="text-align: center;"><a href="#ViewPollResults" onclick="poll_result(%POLL_ID%); return false;" title="'.__('View Results Of This Poll', 'wp-polls').'">'.__('View Results', 'wp-polls').'</a></p>'.
1809
- '</div>');
1810
- add_option('poll_template_resultheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>'.
1811
- '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
1812
- '<ul class="wp-polls-ul">');
1813
- add_option('poll_template_resultbody', '<li>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%'.__(',', 'wp-polls').' %POLL_ANSWER_VOTES% '.__('Votes', 'wp-polls').')</small><div class="pollbar" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="%POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% '.__('Votes', 'wp-polls').')"></div></li>');
1814
- add_option('poll_template_resultbody2', '<li><strong><i>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%'.__(',', 'wp-polls').' %POLL_ANSWER_VOTES% '.__('Votes', 'wp-polls').')</small></i></strong><div class="pollbar" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="'.__('You Have Voted For This Choice', 'wp-polls').' - %POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% '.__('Votes', 'wp-polls').')"></div></li>');
1815
- add_option('poll_template_resultfooter', '</ul>'.
1816
- '<p style="text-align: center;">'.__('Total Voters', 'wp-polls').': <strong>%POLL_TOTALVOTERS%</strong></p>'.
1817
- '</div>');
1818
- add_option('poll_template_resultfooter2', '</ul>'.
1819
- '<p style="text-align: center;">'.__('Total Voters', 'wp-polls').': <strong>%POLL_TOTALVOTERS%</strong></p>'.
1820
- '<p style="text-align: center;"><a href="#VotePoll" onclick="poll_booth(%POLL_ID%); return false;" title="'.__('Vote For This Poll', 'wp-polls').'">'.__('Vote', 'wp-polls').'</a></p>'.
1821
- '</div>');
1822
- add_option('poll_template_disable', __('Sorry, there are no polls available at the moment.', 'wp-polls'));
1823
- add_option('poll_template_error', __('An error has occurred when processing your poll.', 'wp-polls'));
1824
- add_option('poll_currentpoll', 0);
1825
- add_option('poll_latestpoll', 1);
1826
- add_option('poll_archive_perpage', 5);
1827
- add_option('poll_ans_sortby', 'polla_aid');
1828
- add_option('poll_ans_sortorder', 'asc');
1829
- add_option('poll_ans_result_sortby', 'polla_votes');
1830
- add_option('poll_ans_result_sortorder', 'desc');
1831
- // Database Upgrade For WP-Polls 2.1
1832
- add_option('poll_logging_method', '3');
1833
- add_option('poll_allowtovote', '2');
1834
- maybe_add_column($wpdb->pollsq, 'pollq_active', "ALTER TABLE $wpdb->pollsq ADD pollq_active TINYINT( 1 ) NOT NULL DEFAULT '1';");
1835
- // Database Upgrade For WP-Polls 2.12
1836
- maybe_add_column($wpdb->pollsip, 'pollip_userid', "ALTER TABLE $wpdb->pollsip ADD pollip_userid INT( 10 ) NOT NULL DEFAULT '0';");
1837
- add_option('poll_archive_url', site_url('pollsarchive'));
1838
- // Database Upgrade For WP-Polls 2.13
1839
- add_option('poll_bar', array('style' => 'default', 'background' => 'd8e1eb', 'border' => 'c8c8c8', 'height' => 8));
1840
- // Database Upgrade For WP-Polls 2.14
1841
- maybe_add_column($wpdb->pollsq, 'pollq_expiry', "ALTER TABLE $wpdb->pollsq ADD pollq_expiry varchar(20) NOT NULL default '';");
1842
- add_option('poll_close', 1);
1843
- // Database Upgrade For WP-Polls 2.20
1844
- add_option('poll_ajax_style', array('loading' => 1, 'fading' => 1));
1845
- add_option('poll_template_pollarchivelink', '<ul>'.
1846
- '<li><a href="%POLL_ARCHIVE_URL%">'.__('Polls Archive', 'wp-polls').'</a></li>'.
1847
- '</ul>');
1848
- add_option('poll_archive_displaypoll', 2);
1849
- add_option('poll_template_pollarchiveheader', '');
1850
- add_option('poll_template_pollarchivefooter', '<p>'.__('Start Date:', 'wp-polls').' %POLL_START_DATE%<br />'.__('End Date:', 'wp-polls').' %POLL_END_DATE%</p>');
1851
- maybe_add_column($wpdb->pollsq, 'pollq_multiple', "ALTER TABLE $wpdb->pollsq ADD pollq_multiple TINYINT( 3 ) NOT NULL DEFAULT '0';");
1852
- $pollq_totalvoters = maybe_add_column($wpdb->pollsq, 'pollq_totalvoters', "ALTER TABLE $wpdb->pollsq ADD pollq_totalvoters INT( 10 ) NOT NULL DEFAULT '0';");
1853
- if($pollq_totalvoters) {
1854
- $pollq_totalvoters = intval($wpdb->get_var("SELECT SUM(pollq_totalvoters) FROM $wpdb->pollsq"));
1855
- if($pollq_totalvoters == 0) {
1856
- $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvoters = pollq_totalvotes");
1857
- }
1858
- }
1859
- // Database Upgrade For WP-Polls 2.30
1860
- add_option('poll_cookielog_expiry', 0);
1861
- add_option('poll_template_pollarchivepagingheader', '');
1862
- add_option('poll_template_pollarchivepagingfooter', '');
1863
- // Database Upgrade For WP-Polls 2.50
1864
- delete_option('poll_archive_show');
1865
-
1866
- // Index
1867
- $index = $wpdb->get_results( "SHOW INDEX FROM $wpdb->pollsip;" );
1868
- $key_name = array();
1869
- if( sizeof( $index ) > 0 ) {
1870
- foreach( $index as $i ) {
1871
- $key_name[]= $i->Key_name;
1872
- }
1873
- }
1874
- if ( ! in_array( 'pollip_ip', $key_name ) ) {
1875
- $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_ip (pollip_ip);" );
1876
- }
1877
- if ( ! in_array( 'pollip_qid', $key_name ) ) {
1878
- $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_qid (pollip_qid);" );
1879
- }
1880
- if ( ! in_array( 'pollip_ip_qid_aid', $key_name ) ) {
1881
- $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_ip_qid_aid (pollip_ip, pollip_qid, pollip_aid);" );
1882
- }
1883
- // No longer needed index
1884
- if ( in_array( 'pollip_ip_qid', $key_name ) ) {
1885
- $wpdb->query( "ALTER TABLE $wpdb->pollsip DROP INDEX pollip_ip_qid;" );
1886
- }
1887
-
1888
- // Set 'manage_polls' Capabilities To Administrator
1889
- $role = get_role( 'administrator' );
1890
- if( ! $role->has_cap( 'manage_polls' ) ) {
1891
- $role->add_cap( 'manage_polls' );
1892
- }
1893
- cron_polls_place();
1894
  }
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.3
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-polls
11
 
12
 
13
  /*
14
+ Copyright 2017 Lester Chan (email : lesterchan@gmail.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
30
 
31
 
32
  ### Version
33
+ define( 'WP_POLLS_VERSION', '2.73.3' );
34
 
35
 
36
  ### Create Text Domain For Translations
124
  if($pollresult_id == $poll_id) {
125
  if($display) {
126
  echo display_pollresult($poll_id);
 
127
  } else {
128
  return display_pollresult($poll_id);
129
  }
132
  $poll_active = $wpdb->get_var( $wpdb->prepare( "SELECT pollq_active FROM $wpdb->pollsq WHERE pollq_id = %d", $poll_id ) );
133
  $poll_active = intval($poll_active);
134
  $check_voted = check_voted($poll_id);
135
+ if( $poll_active === 0 ) {
136
+ $poll_close = intval( get_option( 'poll_close' ) );
137
  } else {
138
  $poll_close = 0;
139
  }
140
+ if( $poll_close === 2 ) {
141
+ if( $display ) {
142
+ echo '';
143
+ } else {
144
+ return '';
145
+ }
146
+ }
147
+ if( intval( $check_voted ) > 0 || ( is_array( $check_voted ) && count( $check_voted ) > 0 ) || $poll_close === 1 ) {
148
  if($display) {
149
  echo display_pollresult($poll_id, $check_voted);
 
150
  } else {
151
  return display_pollresult($poll_id, $check_voted);
152
  }
153
+ } elseif( ! check_allowtovote() || $poll_close === 3 ) {
154
  $disable_poll_js = '<script type="text/javascript">jQuery("#polls_form_'.$poll_id.' :input").each(function (i){jQuery(this).attr("disabled","disabled")});</script>';
155
  if($display) {
156
  echo display_pollvote($poll_id).$disable_poll_js;
 
157
  } else {
158
  return display_pollvote($poll_id).$disable_poll_js;
159
  }
160
+ } elseif( $poll_active === 1 ) {
161
  if($display) {
162
  echo display_pollvote($poll_id);
 
163
  } else {
164
  return display_pollvote($poll_id);
165
  }
478
  $poll_answer_id = intval($poll_answer->polla_aid);
479
  $poll_answer_text = wp_kses_post( removeslashes( $poll_answer->polla_answers ) );
480
  $poll_answer_votes = intval($poll_answer->polla_votes);
481
+ $poll_answer_percentage = $poll_question_totalvotes > 0 ? round((($poll_answer_votes/$poll_question_totalvotes)*100)) : 0;
482
  $template_answer = removeslashes(get_option('poll_template_votebody'));
483
 
484
  $template_answer = apply_filters('poll_template_votebody_markup', $template_answer, $poll_answer, array(
605
  // Calculate Percentage And Image Bar Width
606
  if(!$poll_totalvotes_zero) {
607
  if($poll_answer_votes > 0) {
608
+ $poll_answer_percentage = round((($poll_answer_votes/$poll_question_totalvotes)*100));
609
  $poll_answer_imagewidth = round($poll_answer_percentage);
610
  if($poll_answer_imagewidth == 100) {
611
  $poll_answer_imagewidth = 99;
711
  $temp_pollresult .= removeslashes(get_option('poll_template_disable'));
712
  }
713
  // Return Poll Result
714
+ return apply_filters('poll_result_markup', $temp_pollresult);
715
  }
716
 
717
 
1011
  // Calculate Percentage And Image Bar Width
1012
  if(!$poll_totalvotes_zero) {
1013
  if($polls_answer['votes'] > 0) {
1014
+ $poll_answer_percentage = round((($polls_answer['votes']/$polls_question['totalvotes'])*100));
1015
  $poll_answer_imagewidth = round($poll_answer_percentage*0.9);
1016
  } else {
1017
  $poll_answer_percentage = 0;
1535
  if(empty($text)) {
1536
  echo '<p style="color: green;">'.sprintf(__('Poll \'%s\' Deleted Successfully', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
1537
  }
1538
+
1539
  // Update Lastest Poll ID To Poll Options
1540
+ update_option( 'poll_latestpoll', polls_latest_id() );
 
1541
  do_action( 'wp_polls_delete_poll', $pollq_id );
1542
  break;
1543
  }
1550
  function _polls_get_ans_sort() {
1551
  $order_by = get_option( 'poll_ans_sortby' );
1552
  switch( $order_by ) {
1553
+ case 'polla_votes':
1554
  case 'polla_aid':
1555
  case 'polla_answers':
1556
  case 'RAND()':
1733
  }
1734
 
1735
  function polls_activate() {
1736
+ global $wpdb;
1737
+
1738
+ if(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
1739
+ include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
1740
+ } elseif(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
1741
+ include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
1742
+ } else {
1743
+ die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
1744
+ }
1745
+
1746
+ // Create Poll Tables (3 Tables)
1747
+ $charset_collate = $wpdb->get_charset_collate();
1748
+
1749
+ $create_table = array();
1750
+ $create_table['pollsq'] = "CREATE TABLE $wpdb->pollsq (".
1751
+ "pollq_id int(10) NOT NULL auto_increment," .
1752
+ "pollq_question varchar(200) character set utf8 NOT NULL default ''," .
1753
+ "pollq_timestamp varchar(20) NOT NULL default ''," .
1754
+ "pollq_totalvotes int(10) NOT NULL default '0'," .
1755
+ "pollq_active tinyint(1) NOT NULL default '1'," .
1756
+ "pollq_expiry int(10) NOT NULL default '0'," .
1757
+ "pollq_multiple tinyint(3) NOT NULL default '0'," .
1758
+ "pollq_totalvoters int(10) NOT NULL default '0'," .
1759
+ "PRIMARY KEY (pollq_id)" .
1760
+ ") $charset_collate;";
1761
+ $create_table['pollsa'] = "CREATE TABLE $wpdb->pollsa (" .
1762
+ "polla_aid int(10) NOT NULL auto_increment," .
1763
+ "polla_qid int(10) NOT NULL default '0'," .
1764
+ "polla_answers varchar(200) character set utf8 NOT NULL default ''," .
1765
+ "polla_votes int(10) NOT NULL default '0'," .
1766
+ "PRIMARY KEY (polla_aid)" .
1767
+ ") $charset_collate;";
1768
+ $create_table['pollsip'] = "CREATE TABLE $wpdb->pollsip (" .
1769
+ "pollip_id int(10) NOT NULL auto_increment," .
1770
+ "pollip_qid int(10) NOT NULL default '0'," .
1771
+ "pollip_aid int(10) NOT NULL default '0'," .
1772
+ "pollip_ip varchar(100) NOT NULL default ''," .
1773
+ "pollip_host VARCHAR(200) NOT NULL default ''," .
1774
+ "pollip_timestamp int(10) NOT NULL default '0'," .
1775
+ "pollip_user tinytext NOT NULL," .
1776
+ "pollip_userid int(10) NOT NULL default '0'," .
1777
+ "PRIMARY KEY (pollip_id)," .
1778
+ "KEY pollip_ip (pollip_ip)," .
1779
+ "KEY pollip_qid (pollip_qid)," .
1780
+ "KEY pollip_ip_qid (pollip_ip, pollip_qid)" .
1781
+ ") $charset_collate;";
1782
+ dbDelta( $create_table['pollsq'] );
1783
+ dbDelta( $create_table['pollsa'] );
1784
+ dbDelta( $create_table['pollsip'] );
1785
+ // Check Whether It is Install Or Upgrade
1786
+ $first_poll = $wpdb->get_var( "SELECT pollq_id FROM $wpdb->pollsq LIMIT 1" );
1787
+ // If Install, Insert 1st Poll Question With 5 Poll Answers
1788
+ if ( empty( $first_poll ) ) {
1789
+ // Insert Poll Question (1 Record)
1790
+ $insert_pollq = $wpdb->insert( $wpdb->pollsq, array( 'pollq_question' => __( 'How Is My Site?', 'wp-polls' ), 'pollq_timestamp' => current_time( 'timestamp' ) ), array( '%s', '%s' ) );
1791
+ if ( $insert_pollq ) {
1792
+ // Insert Poll Answers (5 Records)
1793
+ $wpdb->insert( $wpdb->pollsa, array( 'polla_qid' => $insert_pollq, 'polla_answers' => __( 'Good', 'wp-polls' ) ), array( '%d', '%s' ) );
1794
+ $wpdb->insert( $wpdb->pollsa, array( 'polla_qid' => $insert_pollq, 'polla_answers' => __( 'Excellent', 'wp-polls' ) ), array( '%d', '%s' ) );
1795
+ $wpdb->insert( $wpdb->pollsa, array( 'polla_qid' => $insert_pollq, 'polla_answers' => __( 'Bad', 'wp-polls' ) ), array( '%d', '%s' ) );
1796
+ $wpdb->insert( $wpdb->pollsa, array( 'polla_qid' => $insert_pollq, 'polla_answers' => __( 'Can Be Improved', 'wp-polls' ) ), array( '%d', '%s' ) );
1797
+ $wpdb->insert( $wpdb->pollsa, array( 'polla_qid' => $insert_pollq, 'polla_answers' => __( 'No Comments', 'wp-polls' ) ), array( '%d', '%s' ) );
1798
+ }
1799
+ }
1800
+ // Add In Options (16 Records)
1801
+ add_option('poll_template_voteheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>'.
1802
+ '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
1803
+ '<ul class="wp-polls-ul">');
1804
+ add_option('poll_template_votebody', '<li><input type="%POLL_CHECKBOX_RADIO%" id="poll-answer-%POLL_ANSWER_ID%" name="poll_%POLL_ID%" value="%POLL_ANSWER_ID%" /> <label for="poll-answer-%POLL_ANSWER_ID%">%POLL_ANSWER%</label></li>');
1805
+ add_option('poll_template_votefooter', '</ul>'.
1806
+ '<p style="text-align: center;"><input type="button" name="vote" value=" '.__('Vote', 'wp-polls').' " class="Buttons" onclick="poll_vote(%POLL_ID%);" /></p>'.
1807
+ '<p style="text-align: center;"><a href="#ViewPollResults" onclick="poll_result(%POLL_ID%); return false;" title="'.__('View Results Of This Poll', 'wp-polls').'">'.__('View Results', 'wp-polls').'</a></p>'.
1808
+ '</div>');
1809
+ add_option('poll_template_resultheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>'.
1810
+ '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">'.
1811
+ '<ul class="wp-polls-ul">');
1812
+ add_option('poll_template_resultbody', '<li>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%'.__(',', 'wp-polls').' %POLL_ANSWER_VOTES% '.__('Votes', 'wp-polls').')</small><div class="pollbar" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="%POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% '.__('Votes', 'wp-polls').')"></div></li>');
1813
+ add_option('poll_template_resultbody2', '<li><strong><i>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%'.__(',', 'wp-polls').' %POLL_ANSWER_VOTES% '.__('Votes', 'wp-polls').')</small></i></strong><div class="pollbar" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="'.__('You Have Voted For This Choice', 'wp-polls').' - %POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% '.__('Votes', 'wp-polls').')"></div></li>');
1814
+ add_option('poll_template_resultfooter', '</ul>'.
1815
+ '<p style="text-align: center;">'.__('Total Voters', 'wp-polls').': <strong>%POLL_TOTALVOTERS%</strong></p>'.
1816
+ '</div>');
1817
+ add_option('poll_template_resultfooter2', '</ul>'.
1818
+ '<p style="text-align: center;">'.__('Total Voters', 'wp-polls').': <strong>%POLL_TOTALVOTERS%</strong></p>'.
1819
+ '<p style="text-align: center;"><a href="#VotePoll" onclick="poll_booth(%POLL_ID%); return false;" title="'.__('Vote For This Poll', 'wp-polls').'">'.__('Vote', 'wp-polls').'</a></p>'.
1820
+ '</div>');
1821
+ add_option('poll_template_disable', __('Sorry, there are no polls available at the moment.', 'wp-polls'));
1822
+ add_option('poll_template_error', __('An error has occurred when processing your poll.', 'wp-polls'));
1823
+ add_option('poll_currentpoll', 0);
1824
+ add_option('poll_latestpoll', 1);
1825
+ add_option('poll_archive_perpage', 5);
1826
+ add_option('poll_ans_sortby', 'polla_aid');
1827
+ add_option('poll_ans_sortorder', 'asc');
1828
+ add_option('poll_ans_result_sortby', 'polla_votes');
1829
+ add_option('poll_ans_result_sortorder', 'desc');
1830
+ // Database Upgrade For WP-Polls 2.1
1831
+ add_option('poll_logging_method', '3');
1832
+ add_option('poll_allowtovote', '2');
1833
+ // Database Upgrade For WP-Polls 2.12
1834
+ add_option('poll_archive_url', site_url('pollsarchive'));
1835
+ // Database Upgrade For WP-Polls 2.13
1836
+ add_option('poll_bar', array('style' => 'default', 'background' => 'd8e1eb', 'border' => 'c8c8c8', 'height' => 8));
1837
+ // Database Upgrade For WP-Polls 2.14
1838
+ add_option('poll_close', 1);
1839
+ // Database Upgrade For WP-Polls 2.20
1840
+ add_option('poll_ajax_style', array('loading' => 1, 'fading' => 1));
1841
+ add_option('poll_template_pollarchivelink', '<ul>'.
1842
+ '<li><a href="%POLL_ARCHIVE_URL%">'.__('Polls Archive', 'wp-polls').'</a></li>'.
1843
+ '</ul>');
1844
+ add_option('poll_archive_displaypoll', 2);
1845
+ add_option('poll_template_pollarchiveheader', '');
1846
+ add_option('poll_template_pollarchivefooter', '<p>'.__('Start Date:', 'wp-polls').' %POLL_START_DATE%<br />'.__('End Date:', 'wp-polls').' %POLL_END_DATE%</p>');
1847
+
1848
+ $pollq_totalvoters = (int) $wpdb->get_var( "SELECT SUM(pollq_totalvoters) FROM $wpdb->pollsq" );
1849
+ if ( 0 === $pollq_totalvoters ) {
1850
+ $wpdb->query( "UPDATE $wpdb->pollsq SET pollq_totalvoters = pollq_totalvotes" );
1851
+ }
1852
+
1853
+ // Database Upgrade For WP-Polls 2.30
1854
+ add_option('poll_cookielog_expiry', 0);
1855
+ add_option('poll_template_pollarchivepagingheader', '');
1856
+ add_option('poll_template_pollarchivepagingfooter', '');
1857
+ // Database Upgrade For WP-Polls 2.50
1858
+ delete_option('poll_archive_show');
1859
+
1860
+ // Index
1861
+ $index = $wpdb->get_results( "SHOW INDEX FROM $wpdb->pollsip;" );
1862
+ $key_name = array();
1863
+ if( count( $index ) > 0 ) {
1864
+ foreach( $index as $i ) {
1865
+ $key_name[]= $i->Key_name;
1866
+ }
1867
+ }
1868
+ if ( ! in_array( 'pollip_ip', $key_name, true ) ) {
1869
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_ip (pollip_ip);" );
1870
+ }
1871
+ if ( ! in_array( 'pollip_qid', $key_name, true ) ) {
1872
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_qid (pollip_qid);" );
1873
+ }
1874
+ if ( ! in_array( 'pollip_ip_qid_aid', $key_name, true ) ) {
1875
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_ip_qid_aid (pollip_ip, pollip_qid, pollip_aid);" );
1876
+ }
1877
+ // No longer needed index
1878
+ if ( in_array( 'pollip_ip_qid', $key_name, true ) ) {
1879
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip DROP INDEX pollip_ip_qid;" );
1880
+ }
1881
+
1882
+ // Change column datatype for wp_pollsip
1883
+ $col_pollip_qid = $wpdb->get_row( "DESCRIBE $wpdb->pollsip pollip_qid" );
1884
+ if( 'varchar(10)' === $col_pollip_qid->Type ) {
1885
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip MODIFY COLUMN pollip_qid int(10) NOT NULL default '0';" );
1886
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip MODIFY COLUMN pollip_aid int(10) NOT NULL default '0';" );
1887
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip MODIFY COLUMN pollip_timestamp int(10) NOT NULL default '0';" );
1888
+ $wpdb->query( "ALTER TABLE $wpdb->pollsq MODIFY COLUMN pollq_expiry int(10) NOT NULL default '0';" );
1889
+ }
1890
+
1891
+ // Set 'manage_polls' Capabilities To Administrator
1892
+ $role = get_role( 'administrator' );
1893
+ if( ! $role->has_cap( 'manage_polls' ) ) {
1894
+ $role->add_cap( 'manage_polls' );
1895
+ }
1896
+ cron_polls_place();
 
1897
  }