WP-Polls - Version 2.67

Version Description

N/A

Download this release

Release Info

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

Code changes from version 2.66 to 2.67

polls-js.dev.js CHANGED
@@ -83,12 +83,12 @@ function poll_result(current_poll_id) {
83
  if(pollsL10n.show_loading) {
84
  $('#polls-' + poll_id + '-loading').show();
85
  }
86
- $.ajax({type: 'GET', url: pollsL10n.ajax_url, data: 'action=polls&view=result&poll_id=' + poll_id + '&poll_' + poll_id + '_nonce=' + poll_nonce, cache: false, success: poll_process_success});
87
  } else {
88
  if(pollsL10n.show_loading) {
89
  $('#polls-' + poll_id + '-loading').show();
90
  }
91
- $.ajax({type: 'GET', url: pollsL10n.ajax_url, data: 'action=polls&view=result&poll_id=' + poll_id + '&poll_' + poll_id + '_nonce=' + poll_nonce, cache: false, success: poll_process_success});
92
  }
93
  } else {
94
  alert(pollsL10n.text_wait);
@@ -108,12 +108,12 @@ function poll_booth(current_poll_id) {
108
  if(pollsL10n.show_loading) {
109
  $('#polls-' + poll_id + '-loading').show();
110
  }
111
- $.ajax({type: 'GET', url: pollsL10n.ajax_url, data: 'action=polls&view=booth&poll_id=' + poll_id + '&poll_' + poll_id + '_nonce=' + poll_nonce, cache: false, success: poll_process_success});
112
  } else {
113
  if(pollsL10n.show_loading) {
114
  $('#polls-' + poll_id + '-loading').show();
115
  }
116
- $.ajax({type: 'GET', url: pollsL10n.ajax_url, data: 'action=polls&view=booth&poll_id=' + poll_id + '&poll_' + poll_id + '_nonce=' + poll_nonce, cache: false, success: poll_process_success});
117
  }
118
  } else {
119
  alert(pollsL10n.text_wait);
@@ -140,4 +140,4 @@ function poll_process_success(data) {
140
  // Set is_being_voted Status
141
  function set_is_being_voted(voted_status) {
142
  is_being_voted = voted_status;
143
- }
83
  if(pollsL10n.show_loading) {
84
  $('#polls-' + poll_id + '-loading').show();
85
  }
86
+ $.ajax({type: 'POST', xhrFields: {withCredentials: true}, url: pollsL10n.ajax_url, data: 'action=polls&view=result&poll_id=' + poll_id + '&poll_' + poll_id + '_nonce=' + poll_nonce, cache: false, success: poll_process_success});
87
  } else {
88
  if(pollsL10n.show_loading) {
89
  $('#polls-' + poll_id + '-loading').show();
90
  }
91
+ $.ajax({type: 'POST', xhrFields: {withCredentials: true}, url: pollsL10n.ajax_url, data: 'action=polls&view=result&poll_id=' + poll_id + '&poll_' + poll_id + '_nonce=' + poll_nonce, cache: false, success: poll_process_success});
92
  }
93
  } else {
94
  alert(pollsL10n.text_wait);
108
  if(pollsL10n.show_loading) {
109
  $('#polls-' + poll_id + '-loading').show();
110
  }
111
+ $.ajax({type: 'POST', xhrFields: {withCredentials: true}, url: pollsL10n.ajax_url, data: 'action=polls&view=booth&poll_id=' + poll_id + '&poll_' + poll_id + '_nonce=' + poll_nonce, cache: false, success: poll_process_success});
112
  } else {
113
  if(pollsL10n.show_loading) {
114
  $('#polls-' + poll_id + '-loading').show();
115
  }
116
+ $.ajax({type: 'POST', xhrFields: {withCredentials: true}, url: pollsL10n.ajax_url, data: 'action=polls&view=booth&poll_id=' + poll_id + '&poll_' + poll_id + '_nonce=' + poll_nonce, cache: false, success: poll_process_success});
117
  }
118
  } else {
119
  alert(pollsL10n.text_wait);
140
  // Set is_being_voted Status
141
  function set_is_being_voted(voted_status) {
142
  is_being_voted = voted_status;
143
+ }
polls-js.js CHANGED
@@ -2,6 +2,6 @@ var poll_id=0,poll_answer_id="",is_being_voted=!1;pollsL10n.show_loading=parseIn
2
  function poll_vote(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_being_voted(!0),poll_id=b,poll_answer_id="",poll_multiple_ans_count=poll_multiple_ans=0,a("#poll_multiple_ans_"+poll_id).length&&(poll_multiple_ans=parseInt(a("#poll_multiple_ans_"+poll_id).val())),a("#polls_form_"+poll_id+" input:checkbox, #polls_form_"+poll_id+" input:radio, #polls_form_"+poll_id+" option").each(function(b){if(a(this).is(":checked")||a(this).is(":selected"))0<poll_multiple_ans?
3
  (poll_answer_id=a(this).val()+","+poll_answer_id,poll_multiple_ans_count++):poll_answer_id=parseInt(a(this).val())}),0<poll_multiple_ans?0<poll_multiple_ans_count&&poll_multiple_ans_count<=poll_multiple_ans?(poll_answer_id=poll_answer_id.substring(0,poll_answer_id.length-1),poll_process()):0==poll_multiple_ans_count?(set_is_being_voted(!1),alert(pollsL10n.text_valid)):(set_is_being_voted(!1),alert(pollsL10n.text_multiple+" "+poll_multiple_ans)):0<poll_answer_id?poll_process():(set_is_being_voted(!1),
4
  alert(pollsL10n.text_valid)))})}function poll_process(){jQuery(document).ready(function(b){poll_nonce=b("#poll_"+poll_id+"_nonce").val();pollsL10n.show_fading&&b("#polls-"+poll_id).fadeTo("def",0);pollsL10n.show_loading&&b("#polls-"+poll_id+"-loading").show();b.ajax({type:"POST",xhrFields:{withCredentials:!0},url:pollsL10n.ajax_url,data:"action=polls&view=process&poll_id="+poll_id+"&poll_"+poll_id+"="+poll_answer_id+"&poll_"+poll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success})})}
5
- function poll_result(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_being_voted(!0),poll_id=b,poll_nonce=a("#poll_"+poll_id+"_nonce").val(),pollsL10n.show_fading&&a("#polls-"+poll_id).fadeTo("def",0),pollsL10n.show_loading&&a("#polls-"+poll_id+"-loading").show(),a.ajax({type:"GET",url:pollsL10n.ajax_url,data:"action=polls&view=result&poll_id="+poll_id+"&poll_"+poll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success}))})}
6
- function poll_booth(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_being_voted(!0),poll_id=b,poll_nonce=a("#poll_"+poll_id+"_nonce").val(),pollsL10n.show_fading&&a("#polls-"+poll_id).fadeTo("def",0),pollsL10n.show_loading&&a("#polls-"+poll_id+"-loading").show(),a.ajax({type:"GET",url:pollsL10n.ajax_url,data:"action=polls&view=booth&poll_id="+poll_id+"&poll_"+poll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success}))})}
7
  function poll_process_success(b){jQuery(document).ready(function(a){a("#polls-"+poll_id).replaceWith(b);pollsL10n.show_loading&&a("#polls-"+poll_id+"-loading").hide();pollsL10n.show_fading&&a("#polls-"+poll_id).fadeTo("def",1);set_is_being_voted(!1)})}function set_is_being_voted(b){is_being_voted=b};
2
  function poll_vote(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_being_voted(!0),poll_id=b,poll_answer_id="",poll_multiple_ans_count=poll_multiple_ans=0,a("#poll_multiple_ans_"+poll_id).length&&(poll_multiple_ans=parseInt(a("#poll_multiple_ans_"+poll_id).val())),a("#polls_form_"+poll_id+" input:checkbox, #polls_form_"+poll_id+" input:radio, #polls_form_"+poll_id+" option").each(function(b){if(a(this).is(":checked")||a(this).is(":selected"))0<poll_multiple_ans?
3
  (poll_answer_id=a(this).val()+","+poll_answer_id,poll_multiple_ans_count++):poll_answer_id=parseInt(a(this).val())}),0<poll_multiple_ans?0<poll_multiple_ans_count&&poll_multiple_ans_count<=poll_multiple_ans?(poll_answer_id=poll_answer_id.substring(0,poll_answer_id.length-1),poll_process()):0==poll_multiple_ans_count?(set_is_being_voted(!1),alert(pollsL10n.text_valid)):(set_is_being_voted(!1),alert(pollsL10n.text_multiple+" "+poll_multiple_ans)):0<poll_answer_id?poll_process():(set_is_being_voted(!1),
4
  alert(pollsL10n.text_valid)))})}function poll_process(){jQuery(document).ready(function(b){poll_nonce=b("#poll_"+poll_id+"_nonce").val();pollsL10n.show_fading&&b("#polls-"+poll_id).fadeTo("def",0);pollsL10n.show_loading&&b("#polls-"+poll_id+"-loading").show();b.ajax({type:"POST",xhrFields:{withCredentials:!0},url:pollsL10n.ajax_url,data:"action=polls&view=process&poll_id="+poll_id+"&poll_"+poll_id+"="+poll_answer_id+"&poll_"+poll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success})})}
5
+ function poll_result(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_being_voted(!0),poll_id=b,poll_nonce=a("#poll_"+poll_id+"_nonce").val(),pollsL10n.show_fading&&a("#polls-"+poll_id).fadeTo("def",0),pollsL10n.show_loading&&a("#polls-"+poll_id+"-loading").show(),a.ajax({type:"POST",xhrFields:{withCredentials:!0},url:pollsL10n.ajax_url,data:"action=polls&view=result&poll_id="+poll_id+"&poll_"+poll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success}))})}
6
+ function poll_booth(b){jQuery(document).ready(function(a){is_being_voted?alert(pollsL10n.text_wait):(set_is_being_voted(!0),poll_id=b,poll_nonce=a("#poll_"+poll_id+"_nonce").val(),pollsL10n.show_fading&&a("#polls-"+poll_id).fadeTo("def",0),pollsL10n.show_loading&&a("#polls-"+poll_id+"-loading").show(),a.ajax({type:"POST",xhrFields:{withCredentials:!0},url:pollsL10n.ajax_url,data:"action=polls&view=booth&poll_id="+poll_id+"&poll_"+poll_id+"_nonce="+poll_nonce,cache:!1,success:poll_process_success}))})}
7
  function poll_process_success(b){jQuery(document).ready(function(a){a("#polls-"+poll_id).replaceWith(b);pollsL10n.show_loading&&a("#polls-"+poll_id+"-loading").hide();pollsL10n.show_fading&&a("#polls-"+poll_id).fadeTo("def",1);set_is_being_voted(!1)})}function set_is_being_voted(b){is_being_voted=b};
readme.txt CHANGED
@@ -3,29 +3,36 @@ Contributors: GamerZ
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: poll, polls, polling, vote, booth, democracy, ajax, survey, post, widget
5
  Requires at least: 3.9
6
- Tested up to: 3.9
7
- Stable tag: 2.66
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
  = Development =
15
- * [https://github.com/lesterchan/wp-polls](https://github.com/lesterchan/wp-polls "https://github.com/lesterchan/wp-polls")
16
 
17
  = Translations =
18
- * [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/")
19
 
20
  = Credits =
21
- * __ngetext() by [Anna Ozeritskaya](http://hweia.ru/ "Anna Ozeritskaya")
22
- * Right To Left Language Support by [Kambiz R. Khojasteh](http://persian-programming.com/ "Kambiz R. Khojasteh")
23
 
24
  = Donations =
25
- * 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 appericiate it. If not feel free to use it without any obligations.
26
 
27
  == Changelog ==
28
 
 
 
 
 
 
29
  = Version 2.66 =
30
  * FIXED: Notices from polls_archive function. Props. @prettyboymp.
31
  * FIXED: Ajax request in parallel with animation. Props @nodecode.
@@ -269,17 +276,17 @@ WP-Polls is extremely customizable via templates and css styles and there are to
269
 
270
  = General Usage (Without Widget) =
271
  1. Open `wp-content/themes/<YOUR THEME NAME>/sidebar.php`
272
- 2. Add:
273
  <code>
274
- &lt;?php if (function_exists('vote_poll') && !in_pollarchive()): ?&gt;
275
- &nbsp;&nbsp;&lt;li&gt;
276
- &nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Polls&lt;/h2&gt;
277
- &nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;
278
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;?php get_poll();?&gt;&lt;/li&gt;
279
- &nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;
280
- &nbsp;&nbsp;&nbsp;&nbsp;&lt;?php display_polls_archive_link(); ?&gt;
281
- &nbsp;&nbsp;&lt;/li&gt;
282
- &lt;?php endif; ?&gt;
283
  </code>
284
 
285
  * To show specific poll, use `<?php get_poll(2); ?>` where 2 is your poll id.
@@ -350,50 +357,50 @@ N/A
350
  * Add to the end of the file:
351
 
352
  <code>
353
- .wp-polls-ul li:nth-child(01) .pollbar{ background:#8FA0C5}
354
- .wp-polls-ul li:nth-child(02) .pollbar{ background:#FF8}
355
- .wp-polls-ul li:nth-child(03) .pollbar{ background:#ff8a3b}
356
- .wp-polls-ul li:nth-child(04) .pollbar{ background:#a61e2a}
357
- .wp-polls-ul li:nth-child(05) .pollbar{ background:#4ebbff}
358
- .wp-polls-ul li:nth-child(06) .pollbar{ background:#fbca54}
359
- .wp-polls-ul li:nth-child(07) .pollbar{ background:#aad34f}
360
- .wp-polls-ul li:nth-child(08) .pollbar{ background:#66cc9a}
361
- .wp-polls-ul li:nth-child(09) .pollbar{ background:#98CBCB}
362
- .wp-polls-ul li:nth-child(10) .pollbar{ background:#a67c52}
363
- .wp-polls-ul li .pollbar{ transition: background 0.7s ease-in-out }
364
  .wp-polls-ul li .pollbar:hover{ background:#F00 }
365
  </code>
366
 
367
  = Polls Stats (Outside WP Loop) =
368
 
369
  = To Display Total Polls =
370
- * Use:
371
  <code>
372
- &lt;?php if (function_exists('get_pollquestions')): ?&gt;
373
- &nbsp;&nbsp;&lt;?php get_pollquestions(); ?&gt;
374
  &lt;?php endif; ?&gt;
375
  </code>
376
 
377
  = To Display Total Poll Answers =
378
- * Use:
379
  <code>
380
- &lt;?php if (function_exists('get_pollanswers')): ?&gt;
381
- &nbsp;&nbsp;&lt;?php get_pollanswers(); ?&gt;
382
  &lt;?php endif; ?&gt;
383
  </code>
384
 
385
  = To Display Total Poll Votes =
386
- * Use:
387
  <code>
388
- &lt;?php if (function_exists('get_pollvotes')): ?&gt;
389
- &nbsp;&nbsp;&lt;?php get_pollvotes(); ?&gt;
390
  &lt;?php endif; ?&gt;
391
  </code>
392
 
393
  = To Display Total Poll Voters =
394
- * Use:
395
  <code>
396
- &lt;?php if (function_exists('get_pollvoters')): ?&gt;
397
- &nbsp;&nbsp;&lt;?php get_pollvoters(); ?&gt;
398
  &lt;?php endif; ?&gt;
399
  </code>
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: poll, polls, polling, vote, booth, democracy, ajax, survey, post, widget
5
  Requires at least: 3.9
6
+ Tested up to: 4.0
7
+ Stable tag: 2.67
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 appericiate it. If not feel free to use it without any obligations.
28
 
29
  == Changelog ==
30
 
31
+ = Version 2.67 =
32
+ * NEW: Use POST for View Results and Vote link
33
+ * FIXED: Added ?v=VERSION_NUMBER to the plugin TinyMCE JS because it is breaking a lot of editors due to cache issue
34
+ * FIXED: Added backward compatibility with [poll=1] in order not to break older polls
35
+
36
  = Version 2.66 =
37
  * FIXED: Notices from polls_archive function. Props. @prettyboymp.
38
  * FIXED: Ajax request in parallel with animation. Props @nodecode.
276
 
277
  = General Usage (Without Widget) =
278
  1. Open `wp-content/themes/<YOUR THEME NAME>/sidebar.php`
279
+ 2. Add:
280
  <code>
281
+ &lt;?php if (function_exists('vote_poll') && !in_pollarchive()): ?&gt;
282
+ &nbsp;&nbsp;&lt;li&gt;
283
+ &nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Polls&lt;/h2&gt;
284
+ &nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;
285
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;?php get_poll();?&gt;&lt;/li&gt;
286
+ &nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;
287
+ &nbsp;&nbsp;&nbsp;&nbsp;&lt;?php display_polls_archive_link(); ?&gt;
288
+ &nbsp;&nbsp;&lt;/li&gt;
289
+ &lt;?php endif; ?&gt;
290
  </code>
291
 
292
  * To show specific poll, use `<?php get_poll(2); ?>` where 2 is your poll id.
357
  * Add to the end of the file:
358
 
359
  <code>
360
+ .wp-polls-ul li:nth-child(01) .pollbar{ background:#8FA0C5}
361
+ .wp-polls-ul li:nth-child(02) .pollbar{ background:#FF8}
362
+ .wp-polls-ul li:nth-child(03) .pollbar{ background:#ff8a3b}
363
+ .wp-polls-ul li:nth-child(04) .pollbar{ background:#a61e2a}
364
+ .wp-polls-ul li:nth-child(05) .pollbar{ background:#4ebbff}
365
+ .wp-polls-ul li:nth-child(06) .pollbar{ background:#fbca54}
366
+ .wp-polls-ul li:nth-child(07) .pollbar{ background:#aad34f}
367
+ .wp-polls-ul li:nth-child(08) .pollbar{ background:#66cc9a}
368
+ .wp-polls-ul li:nth-child(09) .pollbar{ background:#98CBCB}
369
+ .wp-polls-ul li:nth-child(10) .pollbar{ background:#a67c52}
370
+ .wp-polls-ul li .pollbar{ transition: background 0.7s ease-in-out }
371
  .wp-polls-ul li .pollbar:hover{ background:#F00 }
372
  </code>
373
 
374
  = Polls Stats (Outside WP Loop) =
375
 
376
  = To Display Total Polls =
377
+ * Use:
378
  <code>
379
+ &lt;?php if (function_exists('get_pollquestions')): ?&gt;
380
+ &nbsp;&nbsp;&lt;?php get_pollquestions(); ?&gt;
381
  &lt;?php endif; ?&gt;
382
  </code>
383
 
384
  = To Display Total Poll Answers =
385
+ * Use:
386
  <code>
387
+ &lt;?php if (function_exists('get_pollanswers')): ?&gt;
388
+ &nbsp;&nbsp;&lt;?php get_pollanswers(); ?&gt;
389
  &lt;?php endif; ?&gt;
390
  </code>
391
 
392
  = To Display Total Poll Votes =
393
+ * Use:
394
  <code>
395
+ &lt;?php if (function_exists('get_pollvotes')): ?&gt;
396
+ &nbsp;&nbsp;&lt;?php get_pollvotes(); ?&gt;
397
  &lt;?php endif; ?&gt;
398
  </code>
399
 
400
  = To Display Total Poll Voters =
401
+ * Use:
402
  <code>
403
+ &lt;?php if (function_exists('get_pollvoters')): ?&gt;
404
+ &nbsp;&nbsp;&lt;?php get_pollvoters(); ?&gt;
405
  &lt;?php endif; ?&gt;
406
  </code>
screenshot-1.png DELETED
Binary file
screenshot-10.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
screenshot-3.png DELETED
Binary file
screenshot-4.png DELETED
Binary file
screenshot-5.png DELETED
Binary file
screenshot-6.png DELETED
Binary file
screenshot-7.png DELETED
Binary file
screenshot-8.png DELETED
Binary file
screenshot-9.png DELETED
Binary file
wp-polls.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-Polls
4
  Plugin URI: http://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.66
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-polls
@@ -11,7 +11,7 @@ Text Domain: wp-polls
11
 
12
 
13
  /*
14
- Copyright 2013 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
@@ -29,6 +29,10 @@ Text Domain: wp-polls
29
  */
30
 
31
 
 
 
 
 
32
  ### Create Text Domain For Translations
33
  add_action( 'plugins_loaded', 'polls_textdomain' );
34
  function polls_textdomain() {
@@ -38,9 +42,9 @@ function polls_textdomain() {
38
 
39
  ### Polls Table Name
40
  global $wpdb;
41
- $wpdb->pollsq = $wpdb->prefix.'pollsq';
42
- $wpdb->pollsa = $wpdb->prefix.'pollsa';
43
- $wpdb->pollsip = $wpdb->prefix.'pollsip';
44
 
45
 
46
  ### Function: Poll Administration Menu
@@ -76,6 +80,7 @@ function get_poll($temp_poll_id = 0, $display = true) {
76
  }
77
  // Poll Is Enabled
78
  } else {
 
79
  // Hardcoded Poll ID Is Not Specified
80
  switch($temp_poll_id) {
81
  // Random Poll
@@ -195,22 +200,22 @@ add_action('wp_enqueue_scripts', 'poll_scripts');
195
  function poll_scripts() {
196
  global $text_direction;
197
  if(@file_exists(get_stylesheet_directory().'/polls-css.css')) {
198
- wp_enqueue_style('wp-polls', get_stylesheet_directory_uri().'/polls-css.css', false, '2.63', 'all');
199
  } else {
200
- wp_enqueue_style('wp-polls', plugins_url('wp-polls/polls-css.css'), false, '2.63', 'all');
201
  }
202
  if('rtl' == $text_direction) {
203
  if(@file_exists(get_stylesheet_directory().'/polls-css-rtl.css')) {
204
- wp_enqueue_style('wp-polls-rtl', get_stylesheet_directory_uri().'/polls-css-rtl.css', false, '2.63', 'all');
205
  } else {
206
- wp_enqueue_style('wp-polls-rtl', plugins_url('wp-polls/polls-css-rtl.css'), false, '2.63', 'all');
207
  }
208
  }
209
  $poll_ajax_style = get_option('poll_ajax_style');
210
  $pollbar = get_option('poll_bar');
211
- wp_enqueue_script('wp-polls', plugins_url('wp-polls/polls-js.js'), array('jquery'), '2.63', true);
212
  wp_localize_script('wp-polls', 'pollsL10n', array(
213
- 'ajax_url' => admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http')),
214
  'text_wait' => __('Your last request is still being processed. Please wait a while ...', 'wp-polls'),
215
  'text_valid' => __('Please choose a valid poll answer.', 'wp-polls'),
216
  'text_multiple' => __('Maximum number of choices allowed: ', 'wp-polls'),
@@ -226,10 +231,10 @@ function poll_scripts_admin($hook_suffix) {
226
  global $text_direction;
227
  $poll_admin_pages = array('wp-polls/polls-manager.php', 'wp-polls/polls-add.php', 'wp-polls/polls-options.php', 'wp-polls/polls-templates.php', 'wp-polls/polls-uninstall.php');
228
  if(in_array($hook_suffix, $poll_admin_pages)) {
229
- wp_enqueue_style('wp-polls-admin', plugins_url('wp-polls/polls-admin-css.css'), false, '2.63', 'all');
230
- wp_enqueue_script('wp-polls-admin', plugins_url('wp-polls/polls-admin-js.js'), array('jquery'), '2.63', true);
231
  wp_localize_script('wp-polls-admin', 'pollsAdminL10n', array(
232
- 'admin_ajax_url' => admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http')),
233
  'text_direction' => ('rtl' == $text_direction) ? 'left' : 'right',
234
  'text_delete_poll' => __('Delete Poll', 'wp-polls'),
235
  'text_no_poll_logs' => __('No poll logs available.', 'wp-polls'),
@@ -286,9 +291,9 @@ function poll_tinymce_registerbutton($buttons) {
286
  }
287
  function poll_tinymce_addplugin($plugin_array) {
288
  if(WP_DEBUG) {
289
- $plugin_array['polls'] = plugins_url('wp-polls/tinymce/plugins/polls/plugin.js');
290
  } else {
291
- $plugin_array['polls'] = plugins_url('wp-polls/tinymce/plugins/polls/plugin.min.js');
292
  }
293
  return $plugin_array;
294
  }
@@ -429,6 +434,7 @@ function poll_template_vote_markup($template, $poll_db_object, $variables) {
429
 
430
  ### Function: Display Voting Form
431
  function display_pollvote($poll_id, $display_loading = true) {
 
432
  global $wpdb;
433
  // Temp Poll Result
434
  $temp_pollvote = '';
@@ -534,6 +540,7 @@ function display_pollvote($poll_id, $display_loading = true) {
534
 
535
  ### Function: Display Results Form
536
  function display_pollresult($poll_id, $user_voted = '', $display_loading = true) {
 
537
  global $wpdb;
538
  $poll_id = intval($poll_id);
539
  // User Voted
@@ -732,18 +739,24 @@ function poll_page_shortcode($atts) {
732
 
733
 
734
  ### Function: Short Code For Inserting Polls Into Posts
735
- add_shortcode('poll', 'poll_shortcode');
736
  function poll_shortcode($atts) {
737
- extract(shortcode_atts(array('id' => 0, 'type' => 'vote'), $atts));
738
- if(!is_feed()) {
739
- $id = intval($id);
740
- if($type == 'vote') {
741
- return get_poll($id, false);
742
- } elseif($type == 'result') {
743
- return display_pollresult($id);
 
 
 
 
 
 
744
  }
745
  } else {
746
- return __('Note: There is a poll embedded within this post, please visit the site to participate in this post\'s poll.', 'wp-polls');
747
  }
748
  }
749
 
@@ -857,6 +870,7 @@ function display_polls_archive_link($display = true) {
857
 
858
  ### Function: Display Polls Archive
859
  function polls_archive() {
 
860
  global $wpdb, $in_pollsarchive;
861
  // Polls Variables
862
  $in_pollsarchive = true;
@@ -1299,6 +1313,7 @@ function vote_poll() {
1299
  {
1300
  // Poll Vote
1301
  case 'process':
 
1302
  $poll_aid = $_POST["poll_$poll_id"];
1303
  $poll_aid_array = array_unique(array_map('intval', explode(',', $poll_aid)));
1304
  if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
@@ -1617,7 +1632,7 @@ function create_poll_table() {
1617
  }
1618
  // Create Poll Tables (3 Tables)
1619
  $charset_collate = '';
1620
- if($wpdb->supports_collation()) {
1621
  if(!empty($wpdb->charset)) {
1622
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1623
  }
@@ -1652,7 +1667,7 @@ function create_poll_table() {
1652
  "pollip_user tinytext NOT NULL,".
1653
  "pollip_userid int(10) NOT NULL default '0',".
1654
  "PRIMARY KEY (pollip_id),".
1655
- "KEY pollip_ip (pollip_id),".
1656
  "KEY pollip_qid (pollip_qid),".
1657
  "KEY pollip_ip_qid (pollip_ip, pollip_qid)".
1658
  ") $charset_collate;";
@@ -1738,11 +1753,24 @@ function create_poll_table() {
1738
  add_option('poll_template_pollarchivepagingfooter', '');
1739
  // Database Upgrade For WP-Polls 2.50
1740
  delete_option('poll_archive_show');
1741
- // Database Upgrade For WP-Polls 2.61
1742
- $wpdb->query("ALTER TABLE $wpdb->pollsip ADD INDEX pollip_ip (pollip_ip);");
1743
- $wpdb->query("ALTER TABLE $wpdb->pollsip ADD INDEX pollip_qid (pollip_qid);");
1744
- // Database Upgrade WP-Polls 2.65
1745
- $wpdb->query("ALTER TABLE $wpdb->pollsip ADD INDEX pollip_ip_qid (pollip_ip, pollip_qid);");
 
 
 
 
 
 
 
 
 
 
 
 
 
1746
 
1747
  // Set 'manage_polls' Capabilities To Administrator
1748
  $role = get_role('administrator');
3
  Plugin Name: WP-Polls
4
  Plugin URI: http://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.67
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-polls
11
 
12
 
13
  /*
14
+ Copyright 2014 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
29
  */
30
 
31
 
32
+ ### Version
33
+ define( 'WP_POLLS_VERSION', 2.67 );
34
+
35
+
36
  ### Create Text Domain For Translations
37
  add_action( 'plugins_loaded', 'polls_textdomain' );
38
  function polls_textdomain() {
42
 
43
  ### Polls Table Name
44
  global $wpdb;
45
+ $wpdb->pollsq = $wpdb->prefix.'pollsq';
46
+ $wpdb->pollsa = $wpdb->prefix.'pollsa';
47
+ $wpdb->pollsip = $wpdb->prefix.'pollsip';
48
 
49
 
50
  ### Function: Poll Administration Menu
80
  }
81
  // Poll Is Enabled
82
  } else {
83
+ do_action('wp_polls_get_poll');
84
  // Hardcoded Poll ID Is Not Specified
85
  switch($temp_poll_id) {
86
  // Random Poll
200
  function poll_scripts() {
201
  global $text_direction;
202
  if(@file_exists(get_stylesheet_directory().'/polls-css.css')) {
203
+ wp_enqueue_style('wp-polls', get_stylesheet_directory_uri().'/polls-css.css', false, WP_POLLS_VERSION, 'all');
204
  } else {
205
+ wp_enqueue_style('wp-polls', plugins_url('wp-polls/polls-css.css'), false, WP_POLLS_VERSION, 'all');
206
  }
207
  if('rtl' == $text_direction) {
208
  if(@file_exists(get_stylesheet_directory().'/polls-css-rtl.css')) {
209
+ wp_enqueue_style('wp-polls-rtl', get_stylesheet_directory_uri().'/polls-css-rtl.css', false, WP_POLLS_VERSION, 'all');
210
  } else {
211
+ wp_enqueue_style('wp-polls-rtl', plugins_url('wp-polls/polls-css-rtl.css'), false, WP_POLLS_VERSION, 'all');
212
  }
213
  }
214
  $poll_ajax_style = get_option('poll_ajax_style');
215
  $pollbar = get_option('poll_bar');
216
+ wp_enqueue_script('wp-polls', plugins_url('wp-polls/polls-js.js'), array('jquery'), WP_POLLS_VERSION, true);
217
  wp_localize_script('wp-polls', 'pollsL10n', array(
218
+ 'ajax_url' => admin_url('admin-ajax.php'),
219
  'text_wait' => __('Your last request is still being processed. Please wait a while ...', 'wp-polls'),
220
  'text_valid' => __('Please choose a valid poll answer.', 'wp-polls'),
221
  'text_multiple' => __('Maximum number of choices allowed: ', 'wp-polls'),
231
  global $text_direction;
232
  $poll_admin_pages = array('wp-polls/polls-manager.php', 'wp-polls/polls-add.php', 'wp-polls/polls-options.php', 'wp-polls/polls-templates.php', 'wp-polls/polls-uninstall.php');
233
  if(in_array($hook_suffix, $poll_admin_pages)) {
234
+ wp_enqueue_style('wp-polls-admin', plugins_url('wp-polls/polls-admin-css.css'), false, WP_POLLS_VERSION, 'all');
235
+ wp_enqueue_script('wp-polls-admin', plugins_url('wp-polls/polls-admin-js.js'), array('jquery'), WP_POLLS_VERSION, true);
236
  wp_localize_script('wp-polls-admin', 'pollsAdminL10n', array(
237
+ 'admin_ajax_url' => admin_url('admin-ajax.php'),
238
  'text_direction' => ('rtl' == $text_direction) ? 'left' : 'right',
239
  'text_delete_poll' => __('Delete Poll', 'wp-polls'),
240
  'text_no_poll_logs' => __('No poll logs available.', 'wp-polls'),
291
  }
292
  function poll_tinymce_addplugin($plugin_array) {
293
  if(WP_DEBUG) {
294
+ $plugin_array['polls'] = plugins_url( 'wp-polls/tinymce/plugins/polls/plugin.js?v=' . WP_POLLS_VERSION );
295
  } else {
296
+ $plugin_array['polls'] = plugins_url( 'wp-polls/tinymce/plugins/polls/plugin.min.js?v=' . WP_POLLS_VERSION );
297
  }
298
  return $plugin_array;
299
  }
434
 
435
  ### Function: Display Voting Form
436
  function display_pollvote($poll_id, $display_loading = true) {
437
+ do_action('wp_polls_display_pollvote');
438
  global $wpdb;
439
  // Temp Poll Result
440
  $temp_pollvote = '';
540
 
541
  ### Function: Display Results Form
542
  function display_pollresult($poll_id, $user_voted = '', $display_loading = true) {
543
+ do_action('wp_polls_display_pollresult');
544
  global $wpdb;
545
  $poll_id = intval($poll_id);
546
  // User Voted
739
 
740
 
741
  ### Function: Short Code For Inserting Polls Into Posts
742
+ add_shortcode( 'poll', 'poll_shortcode' );
743
  function poll_shortcode($atts) {
744
+ $attributes = shortcode_atts( array( 'id' => 0, 'type' => 'vote' ), $atts );
745
+ if( !is_feed() ) {
746
+ $id = intval( $attributes['id'] );
747
+
748
+ // To maintain backward compatibility with [poll=1]. Props @tz-ua
749
+ if( !$id ) {
750
+ $id = intval( trim( $atts[0], '="\'' ) );
751
+ }
752
+
753
+ if( $attributes['type'] === 'vote' ) {
754
+ return get_poll( $id, false );
755
+ } elseif( $attributes['type'] === 'result' ) {
756
+ return display_pollresult( $id );
757
  }
758
  } else {
759
+ return __( 'Note: There is a poll embedded within this post, please visit the site to participate in this post\'s poll.', 'wp-polls' );
760
  }
761
  }
762
 
870
 
871
  ### Function: Display Polls Archive
872
  function polls_archive() {
873
+ do_action('wp_polls_polls_archive');
874
  global $wpdb, $in_pollsarchive;
875
  // Polls Variables
876
  $in_pollsarchive = true;
1313
  {
1314
  // Poll Vote
1315
  case 'process':
1316
+ do_action('wp_polls_vote_poll');
1317
  $poll_aid = $_POST["poll_$poll_id"];
1318
  $poll_aid_array = array_unique(array_map('intval', explode(',', $poll_aid)));
1319
  if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
1632
  }
1633
  // Create Poll Tables (3 Tables)
1634
  $charset_collate = '';
1635
+ if( $wpdb->has_cap( 'collation' ) ) {
1636
  if(!empty($wpdb->charset)) {
1637
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1638
  }
1667
  "pollip_user tinytext NOT NULL,".
1668
  "pollip_userid int(10) NOT NULL default '0',".
1669
  "PRIMARY KEY (pollip_id),".
1670
+ "KEY pollip_ip (pollip_ip),".
1671
  "KEY pollip_qid (pollip_qid),".
1672
  "KEY pollip_ip_qid (pollip_ip, pollip_qid)".
1673
  ") $charset_collate;";
1753
  add_option('poll_template_pollarchivepagingfooter', '');
1754
  // Database Upgrade For WP-Polls 2.50
1755
  delete_option('poll_archive_show');
1756
+
1757
+ // Index
1758
+ $index = $wpdb->get_results( "SHOW INDEX FROM $wpdb->pollsip;" );
1759
+ $key_name = array();
1760
+ if( sizeof( $index ) > 0 ) {
1761
+ foreach( $index as $i ) {
1762
+ $key_name[]= $i->Key_name;
1763
+ }
1764
+ }
1765
+ if ( !in_array( 'pollip_ip', $key_name ) ) {
1766
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_ip (pollip_ip);" );
1767
+ }
1768
+ if ( !in_array( 'pollip_qid', $key_name ) ) {
1769
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_qid (pollip_qid);" );
1770
+ }
1771
+ if ( !in_array( 'pollip_ip_qid', $key_name ) ) {
1772
+ $wpdb->query( "ALTER TABLE $wpdb->pollsip ADD INDEX pollip_ip_qid (pollip_ip, pollip_qid);" );
1773
+ }
1774
 
1775
  // Set 'manage_polls' Capabilities To Administrator
1776
  $role = get_role('administrator');