admin-toolbar.php
6 years ago
admin.php
6 years ago
cache.php
6 years ago
cdn.php
6 years ago
cli.php
6 years ago
column.php
6 years ago
css-utilities.php
6 years ago
index.html
11 years ago
js-utilities.php
6 years ago
preload.php
6 years ago
single-preload.php
6 years ago
wp-polls.php
9 years ago
wp-polls.php
63 lines
| 1 | <?php |
| 2 | class WpPollsForWpFc{ |
| 3 | public function __construct(){ |
| 4 | |
| 5 | } |
| 6 | |
| 7 | public function hook(){ |
| 8 | add_action( 'wp_ajax_nopriv_wpfc_wppolls_ajax_request', array($this, "wpfc_wppolls_ajax_request")); |
| 9 | add_action( 'wp_ajax_wpfc_wppolls_ajax_request', array($this, "wpfc_wppolls_ajax_request")); |
| 10 | add_action( 'wp_footer', array($this, "wpfc_wp_polls") ); |
| 11 | |
| 12 | } |
| 13 | |
| 14 | public function wpfc_wp_polls() { ?> |
| 15 | <script type="text/javascript"> |
| 16 | jQuery(document).ready(function(){ |
| 17 | var wpfcWpfcAjaxCall = function(polls){ |
| 18 | if(polls.length > 0){ |
| 19 | poll_id = polls.last().attr('id').match(/\d+/)[0]; |
| 20 | |
| 21 | jQuery.ajax({ |
| 22 | type: 'POST', |
| 23 | url: pollsL10n.ajax_url, |
| 24 | dataType : "json", |
| 25 | data : {"action": "wpfc_wppolls_ajax_request", "poll_id": poll_id, "nonce" : "<?php echo wp_create_nonce('wpfcpoll'); ?>"}, |
| 26 | cache: false, |
| 27 | success: function(data){ |
| 28 | if(data === true){ |
| 29 | poll_result(poll_id); |
| 30 | }else if(data === false){ |
| 31 | poll_booth(poll_id); |
| 32 | } |
| 33 | polls.length = polls.length - 1; |
| 34 | |
| 35 | setTimeout(function(){ |
| 36 | wpfcWpfcAjaxCall(polls); |
| 37 | }, 1000); |
| 38 | } |
| 39 | }); |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | var polls = jQuery('div[id^=\"polls-\"][id$=\"-loading\"]'); |
| 44 | wpfcWpfcAjaxCall(polls); |
| 45 | }); |
| 46 | </script><?php |
| 47 | } |
| 48 | |
| 49 | public function wpfc_wppolls_ajax_request(){ |
| 50 | if(wp_verify_nonce(esc_attr($_POST["nonce"]), 'wpfcpoll')){ |
| 51 | $result = check_voted(esc_attr($_POST["poll_id"])); |
| 52 | |
| 53 | if($result){ |
| 54 | die("true"); |
| 55 | }else{ |
| 56 | die("false"); |
| 57 | } |
| 58 | }else{ |
| 59 | die("Expired: wpfcpoll"); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | ?> |