Version Description
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-Polls |
Version | 2.73.3 |
Comparing to | |
See all releases |
Code changes from version 2.73.2 to 2.73.3
- polls-options.php +1 -0
- readme.txt +90 -108
- 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 |
-
|
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.
|
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 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
[![Build Status](https://travis-ci.org/lesterchan/wp-polls.svg?branch=master)](https://travis-ci.org/lesterchan/wp-polls)
|
16 |
|
17 |
-
|
18 |
[https://github.com/lesterchan/wp-polls](https://github.com/lesterchan/wp-polls "https://github.com/lesterchan/wp-polls")
|
19 |
|
20 |
-
|
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 |
-
|
24 |
* Plugin icon by [Freepik](http://www.freepik.com) from [Flaticon](http://www.flaticon.com)
|
25 |
|
26 |
-
|
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 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
* NEW: Bump WordPress 4.7
|
32 |
* FIXED: Change cron to hourly instead of twice daily.
|
33 |
|
34 |
-
|
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 |
-
|
40 |
* NEW: Display Poll Questions at the top of the Poll Logs table
|
41 |
* FIXED: Remove slashes
|
42 |
|
43 |
-
|
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 |
-
|
50 |
* FIXED: Use wp_kses_post() to get filter always bad tags
|
51 |
|
52 |
-
|
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 |
-
|
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 |
-
<?php if (function_exists('vote_poll') && !in_pollarchive()): ?>
|
71 |
-
<li>
|
72 |
-
<h2>Polls</h2>
|
73 |
-
<ul>
|
74 |
-
<li><?php get_poll();?></li>
|
75 |
-
</ul>
|
76 |
-
<?php display_polls_archive_link(); ?>
|
77 |
-
</li>
|
78 |
-
<?php endif; ?>
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
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.
|
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
|
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.
|
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
|
137 |
-
$poll_close = intval(get_option('poll_close'));
|
138 |
} else {
|
139 |
$poll_close = 0;
|
140 |
}
|
141 |
-
if(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() ||
|
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
|
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 = $
|
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/$
|
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['
|
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 |
-
|
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 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
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 |
}
|