Version Description
Download this release
Release Info
Developer | GamerZ |
Plugin | WP-Polls |
Version | 2.73.4 |
Comparing to | |
See all releases |
Code changes from version 2.73.3 to 2.73.4
- polls-add.php +18 -18
- polls-logs.php +17 -17
- polls-manager.php +52 -52
- polls-options.php +20 -20
- polls-templates.php +17 -17
- readme.txt +32 -27
- wp-polls.php +1496 -1500
polls-add.php
CHANGED
@@ -20,12 +20,12 @@ if(!empty($_POST['do'])) {
|
|
20 |
if( ! empty( $pollq_question ) ) {
|
21 |
// Poll Start Date
|
22 |
$timestamp_sql = '';
|
23 |
-
$pollq_timestamp_day =
|
24 |
-
$pollq_timestamp_month =
|
25 |
-
$pollq_timestamp_year =
|
26 |
-
$pollq_timestamp_hour =
|
27 |
-
$pollq_timestamp_minute =
|
28 |
-
$pollq_timestamp_second =
|
29 |
$pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year);
|
30 |
if ($pollq_timestamp > current_time('timestamp')) {
|
31 |
$pollq_active = -1;
|
@@ -33,26 +33,26 @@ if(!empty($_POST['do'])) {
|
|
33 |
$pollq_active = 1;
|
34 |
}
|
35 |
// Poll End Date
|
36 |
-
$pollq_expiry_no = isset( $_POST['pollq_expiry_no'] ) ?
|
37 |
-
if ($pollq_expiry_no
|
38 |
$pollq_expiry = '';
|
39 |
} else {
|
40 |
-
$pollq_expiry_day =
|
41 |
-
$pollq_expiry_month =
|
42 |
-
$pollq_expiry_year =
|
43 |
-
$pollq_expiry_hour =
|
44 |
-
$pollq_expiry_minute =
|
45 |
-
$pollq_expiry_second =
|
46 |
$pollq_expiry = gmmktime($pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year);
|
47 |
if ($pollq_expiry <= current_time('timestamp')) {
|
48 |
$pollq_active = 0;
|
49 |
}
|
50 |
}
|
51 |
// Mutilple Poll
|
52 |
-
$pollq_multiple_yes =
|
53 |
$pollq_multiple = 0;
|
54 |
-
if ($pollq_multiple_yes
|
55 |
-
$pollq_multiple =
|
56 |
} else {
|
57 |
$pollq_multiple = 0;
|
58 |
}
|
@@ -83,7 +83,7 @@ if(!empty($_POST['do'])) {
|
|
83 |
}
|
84 |
// Add Poll Answers
|
85 |
$polla_answers = $_POST['polla_answers'];
|
86 |
-
$polla_qid =
|
87 |
foreach ($polla_answers as $polla_answer) {
|
88 |
$polla_answer = wp_kses_post( trim( $polla_answer ) );
|
89 |
if( ! empty( $polla_answer ) ) {
|
20 |
if( ! empty( $pollq_question ) ) {
|
21 |
// Poll Start Date
|
22 |
$timestamp_sql = '';
|
23 |
+
$pollq_timestamp_day = (int) sanitize_key($_POST['pollq_timestamp_day']);
|
24 |
+
$pollq_timestamp_month = (int) sanitize_key($_POST['pollq_timestamp_month']);
|
25 |
+
$pollq_timestamp_year = (int) sanitize_key($_POST['pollq_timestamp_year']);
|
26 |
+
$pollq_timestamp_hour = (int) sanitize_key($_POST['pollq_timestamp_hour']);
|
27 |
+
$pollq_timestamp_minute = (int) sanitize_key($_POST['pollq_timestamp_minute']);
|
28 |
+
$pollq_timestamp_second = (int) sanitize_key($_POST['pollq_timestamp_second']);
|
29 |
$pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year);
|
30 |
if ($pollq_timestamp > current_time('timestamp')) {
|
31 |
$pollq_active = -1;
|
33 |
$pollq_active = 1;
|
34 |
}
|
35 |
// Poll End Date
|
36 |
+
$pollq_expiry_no = isset( $_POST['pollq_expiry_no'] ) ? (int) sanitize_key($_POST['pollq_expiry_no']) : 0;
|
37 |
+
if ($pollq_expiry_no === 1) {
|
38 |
$pollq_expiry = '';
|
39 |
} else {
|
40 |
+
$pollq_expiry_day = (int) sanitize_key($_POST['pollq_expiry_day']);
|
41 |
+
$pollq_expiry_month = (int) sanitize_key($_POST['pollq_expiry_month']);
|
42 |
+
$pollq_expiry_year = (int) sanitize_key($_POST['pollq_expiry_year']);
|
43 |
+
$pollq_expiry_hour = (int) sanitize_key($_POST['pollq_expiry_hour']);
|
44 |
+
$pollq_expiry_minute = (int) sanitize_key($_POST['pollq_expiry_minute']);
|
45 |
+
$pollq_expiry_second = (int) sanitize_key($_POST['pollq_expiry_second']);
|
46 |
$pollq_expiry = gmmktime($pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year);
|
47 |
if ($pollq_expiry <= current_time('timestamp')) {
|
48 |
$pollq_active = 0;
|
49 |
}
|
50 |
}
|
51 |
// Mutilple Poll
|
52 |
+
$pollq_multiple_yes = (int) sanitize_key($_POST['pollq_multiple_yes']);
|
53 |
$pollq_multiple = 0;
|
54 |
+
if ($pollq_multiple_yes === 1) {
|
55 |
+
$pollq_multiple = (int) sanitize_key($_POST['pollq_multiple']);
|
56 |
} else {
|
57 |
$pollq_multiple = 0;
|
58 |
}
|
83 |
}
|
84 |
// Add Poll Answers
|
85 |
$polla_answers = $_POST['polla_answers'];
|
86 |
+
$polla_qid = (int) $wpdb->insert_id;
|
87 |
foreach ($polla_answers as $polla_answer) {
|
88 |
$polla_answer = wp_kses_post( trim( $polla_answer ) );
|
89 |
if( ! empty( $polla_answer ) ) {
|
polls-logs.php
CHANGED
@@ -10,8 +10,8 @@ $max_records = 2000;
|
|
10 |
$pollip_answers = array();
|
11 |
$poll_question_data = $wpdb->get_row( $wpdb->prepare( "SELECT pollq_multiple, pollq_question, pollq_totalvoters FROM $wpdb->pollsq WHERE pollq_id = %d", $poll_id ) );
|
12 |
$poll_question = wp_kses_post( removeslashes( $poll_question_data->pollq_question ) );
|
13 |
-
$poll_totalvoters =
|
14 |
-
$poll_multiple =
|
15 |
$poll_registered = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(pollip_userid) FROM $wpdb->pollsip WHERE pollip_qid = %d AND pollip_userid > 0", $poll_id ) );
|
16 |
$poll_comments = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(pollip_user) FROM $wpdb->pollsip WHERE pollip_qid = %d AND pollip_user != %s AND pollip_userid = 0", $poll_id, __( 'Guest', 'wp-polls' ) ) );
|
17 |
$poll_guest = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(pollip_user) FROM $wpdb->pollsip WHERE pollip_qid = %d AND pollip_user = %s", $poll_id, __( 'Guest', 'wp-polls' ) ) );
|
@@ -29,7 +29,7 @@ $users_voted_for = null;
|
|
29 |
$what_user_voted = null;
|
30 |
|
31 |
### Process Filters
|
32 |
-
if(!empty($_POST['do'])) {
|
33 |
check_admin_referer('wp-polls_logs');
|
34 |
$registered_sql = '';
|
35 |
$comment_sql = '';
|
@@ -39,12 +39,12 @@ if(!empty($_POST['do'])) {
|
|
39 |
$num_choices_sql = '';
|
40 |
$num_choices_sign_sql = '';
|
41 |
$order_by = '';
|
42 |
-
switch(
|
43 |
case 1:
|
44 |
-
$users_voted_for =
|
45 |
-
$exclude_registered = isset( $_POST['exclude_registered'] ) &&
|
46 |
-
$exclude_comment = isset( $_POST['exclude_comment'] ) &&
|
47 |
-
$exclude_guest = isset( $_POST['exclude_guest'] ) &&
|
48 |
$users_voted_for_sql = "AND pollip_aid = $users_voted_for";
|
49 |
if($exclude_registered) {
|
50 |
$registered_sql = 'AND pollip_userid = 0';
|
@@ -62,10 +62,10 @@ if(!empty($_POST['do'])) {
|
|
62 |
$order_by = 'pollip_timestamp DESC';
|
63 |
break;
|
64 |
case 2:
|
65 |
-
$exclude_registered_2 =
|
66 |
-
$exclude_comment_2 =
|
67 |
-
$num_choices =
|
68 |
-
$num_choices_sign =
|
69 |
switch($num_choices_sign) {
|
70 |
case 'more':
|
71 |
$num_choices_sign_sql = '>';
|
@@ -137,7 +137,7 @@ if(!empty($_POST['do'])) {
|
|
137 |
<?php
|
138 |
if($poll_answers_data) {
|
139 |
foreach($poll_answers_data as $data) {
|
140 |
-
$polla_id =
|
141 |
$polla_answers = removeslashes( strip_tags( esc_attr( $data->polla_answers ) ) );
|
142 |
if($polla_id == $users_voted_for) {
|
143 |
echo '<option value="'.$polla_id .'" selected="selected">'.$polla_answers.'</option>';
|
@@ -271,7 +271,7 @@ if(!empty($_POST['do'])) {
|
|
271 |
$j = 0;
|
272 |
$poll_last_aid = -1;
|
273 |
$temp_pollip_user = null;
|
274 |
-
if(isset($_POST['filter']) &&
|
275 |
echo "<tr class=\"thead\">\n";
|
276 |
echo "<th>".__('Answer', 'wp-polls')."</th>\n";
|
277 |
echo "<th>".__('IP', 'wp-polls')."</th>\n";
|
@@ -279,14 +279,14 @@ if(!empty($_POST['do'])) {
|
|
279 |
echo "<th>".__('Date', 'wp-polls')."</th>\n";
|
280 |
echo "</tr>\n";
|
281 |
foreach($poll_ips as $poll_ip) {
|
282 |
-
$pollip_aid =
|
283 |
$pollip_user = removeslashes($poll_ip->pollip_user);
|
284 |
$pollip_ip = $poll_ip->pollip_ip;
|
285 |
$pollip_host = $poll_ip->pollip_host;
|
286 |
$pollip_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_ip->pollip_timestamp));
|
287 |
|
288 |
$i = 0;
|
289 |
-
if($i % 2
|
290 |
$style = '';
|
291 |
} else {
|
292 |
$style = 'class="alternate"';
|
@@ -309,7 +309,7 @@ if(!empty($_POST['do'])) {
|
|
309 |
}
|
310 |
} else {
|
311 |
foreach($poll_ips as $poll_ip) {
|
312 |
-
$pollip_aid =
|
313 |
$pollip_user = apply_filters( 'poll_log_secret_ballot', removeslashes($poll_ip->pollip_user) );
|
314 |
$pollip_ip = $poll_ip->pollip_ip;
|
315 |
$pollip_host = $poll_ip->pollip_host;
|
10 |
$pollip_answers = array();
|
11 |
$poll_question_data = $wpdb->get_row( $wpdb->prepare( "SELECT pollq_multiple, pollq_question, pollq_totalvoters FROM $wpdb->pollsq WHERE pollq_id = %d", $poll_id ) );
|
12 |
$poll_question = wp_kses_post( removeslashes( $poll_question_data->pollq_question ) );
|
13 |
+
$poll_totalvoters = (int) $poll_question_data->pollq_totalvoters;
|
14 |
+
$poll_multiple = (int) $poll_question_data->pollq_multiple;
|
15 |
$poll_registered = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(pollip_userid) FROM $wpdb->pollsip WHERE pollip_qid = %d AND pollip_userid > 0", $poll_id ) );
|
16 |
$poll_comments = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(pollip_user) FROM $wpdb->pollsip WHERE pollip_qid = %d AND pollip_user != %s AND pollip_userid = 0", $poll_id, __( 'Guest', 'wp-polls' ) ) );
|
17 |
$poll_guest = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(pollip_user) FROM $wpdb->pollsip WHERE pollip_qid = %d AND pollip_user = %s", $poll_id, __( 'Guest', 'wp-polls' ) ) );
|
29 |
$what_user_voted = null;
|
30 |
|
31 |
### Process Filters
|
32 |
+
if( ! empty( $_POST['do'] ) ) {
|
33 |
check_admin_referer('wp-polls_logs');
|
34 |
$registered_sql = '';
|
35 |
$comment_sql = '';
|
39 |
$num_choices_sql = '';
|
40 |
$num_choices_sign_sql = '';
|
41 |
$order_by = '';
|
42 |
+
switch((int) sanitize_key( $_POST['filter'] ) ) {
|
43 |
case 1:
|
44 |
+
$users_voted_for = (int) sanitize_key( $_POST['users_voted_for'] );
|
45 |
+
$exclude_registered = isset( $_POST['exclude_registered'] ) && (int) sanitize_key( $_POST['exclude_registered'] ) === 1;
|
46 |
+
$exclude_comment = isset( $_POST['exclude_comment'] ) && (int) sanitize_key( $_POST['exclude_comment'] ) === 1;
|
47 |
+
$exclude_guest = isset( $_POST['exclude_guest'] ) && (int) sanitize_key( $_POST['exclude_guest'] ) === 1;
|
48 |
$users_voted_for_sql = "AND pollip_aid = $users_voted_for";
|
49 |
if($exclude_registered) {
|
50 |
$registered_sql = 'AND pollip_userid = 0';
|
62 |
$order_by = 'pollip_timestamp DESC';
|
63 |
break;
|
64 |
case 2:
|
65 |
+
$exclude_registered_2 = (int) sanitize_key( $_POST['exclude_registered_2'] );
|
66 |
+
$exclude_comment_2 = (int) sanitize_key( $_POST['exclude_comment_2'] );
|
67 |
+
$num_choices = (int) sanitize_key( $_POST['num_choices']);
|
68 |
+
$num_choices_sign = sanitize_key( $_POST['num_choices_sign'] );
|
69 |
switch($num_choices_sign) {
|
70 |
case 'more':
|
71 |
$num_choices_sign_sql = '>';
|
137 |
<?php
|
138 |
if($poll_answers_data) {
|
139 |
foreach($poll_answers_data as $data) {
|
140 |
+
$polla_id = (int) $data->polla_aid;
|
141 |
$polla_answers = removeslashes( strip_tags( esc_attr( $data->polla_answers ) ) );
|
142 |
if($polla_id == $users_voted_for) {
|
143 |
echo '<option value="'.$polla_id .'" selected="selected">'.$polla_answers.'</option>';
|
271 |
$j = 0;
|
272 |
$poll_last_aid = -1;
|
273 |
$temp_pollip_user = null;
|
274 |
+
if(isset($_POST['filter']) && (int) sanitize_key( $_POST['filter'] ) > 1) {
|
275 |
echo "<tr class=\"thead\">\n";
|
276 |
echo "<th>".__('Answer', 'wp-polls')."</th>\n";
|
277 |
echo "<th>".__('IP', 'wp-polls')."</th>\n";
|
279 |
echo "<th>".__('Date', 'wp-polls')."</th>\n";
|
280 |
echo "</tr>\n";
|
281 |
foreach($poll_ips as $poll_ip) {
|
282 |
+
$pollip_aid = (int) $poll_ip->pollip_aid;
|
283 |
$pollip_user = removeslashes($poll_ip->pollip_user);
|
284 |
$pollip_ip = $poll_ip->pollip_ip;
|
285 |
$pollip_host = $poll_ip->pollip_host;
|
286 |
$pollip_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_ip->pollip_timestamp));
|
287 |
|
288 |
$i = 0;
|
289 |
+
if($i % 2 === 0) {
|
290 |
$style = '';
|
291 |
} else {
|
292 |
$style = 'class="alternate"';
|
309 |
}
|
310 |
} else {
|
311 |
foreach($poll_ips as $poll_ip) {
|
312 |
+
$pollip_aid = (int) $poll_ip->pollip_aid;
|
313 |
$pollip_user = apply_filters( 'poll_log_secret_ballot', removeslashes($poll_ip->pollip_user) );
|
314 |
$pollip_ip = $poll_ip->pollip_ip;
|
315 |
$pollip_host = $poll_ip->pollip_host;
|
polls-manager.php
CHANGED
@@ -7,9 +7,9 @@ if(!current_user_can('manage_polls')) {
|
|
7 |
### Variables Variables Variables
|
8 |
$base_name = plugin_basename('wp-polls/polls-manager.php');
|
9 |
$base_page = 'admin.php?page='.$base_name;
|
10 |
-
$mode = ( isset( $_GET['mode'] ) ? trim( $_GET['mode'] ) : '' );
|
11 |
-
$poll_id = ( isset( $_GET['id'] ) ?
|
12 |
-
$poll_aid = ( isset( $_GET['aid'] ) ?
|
13 |
|
14 |
### Form Processing
|
15 |
if(!empty($_POST['do'])) {
|
@@ -19,56 +19,56 @@ if(!empty($_POST['do'])) {
|
|
19 |
case __('Edit Poll', 'wp-polls'):
|
20 |
check_admin_referer( 'wp-polls_edit-poll' );
|
21 |
// Poll ID
|
22 |
-
$pollq_id =
|
23 |
// Poll Total Votes
|
24 |
-
$pollq_totalvotes =
|
25 |
// Poll Total Voters
|
26 |
-
$pollq_totalvoters =
|
27 |
// Poll Question
|
28 |
$pollq_question = esc_sql( wp_kses_post( trim( $_POST['pollq_question'] ) ) );
|
29 |
// Poll Active
|
30 |
-
$pollq_active =
|
31 |
// Poll Start Date
|
32 |
$pollq_timestamp = isset( $_POST['poll_timestamp_old'] ) ? $_POST['poll_timestamp_old'] : current_time( 'timestamp' );
|
33 |
-
$edit_polltimestamp = isset( $_POST['edit_polltimestamp'] ) &&
|
34 |
-
if($edit_polltimestamp
|
35 |
-
$pollq_timestamp_day =
|
36 |
-
$pollq_timestamp_month =
|
37 |
-
$pollq_timestamp_year =
|
38 |
-
$pollq_timestamp_hour =
|
39 |
-
$pollq_timestamp_minute =
|
40 |
-
$pollq_timestamp_second =
|
41 |
$pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year);
|
42 |
if($pollq_timestamp > current_time('timestamp')) {
|
43 |
$pollq_active = -1;
|
44 |
}
|
45 |
}
|
46 |
// Poll End Date
|
47 |
-
$pollq_expiry_no = isset( $_POST['pollq_expiry_no'] ) ?
|
48 |
if($pollq_expiry_no == 1) {
|
49 |
$pollq_expiry = '';
|
50 |
} else {
|
51 |
-
$pollq_expiry_day =
|
52 |
-
$pollq_expiry_month =
|
53 |
-
$pollq_expiry_year =
|
54 |
-
$pollq_expiry_hour =
|
55 |
-
$pollq_expiry_minute =
|
56 |
-
$pollq_expiry_second =
|
57 |
$pollq_expiry = gmmktime($pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year);
|
58 |
if($pollq_expiry <= current_time('timestamp')) {
|
59 |
$pollq_active = 0;
|
60 |
}
|
61 |
-
if($edit_polltimestamp
|
62 |
if($pollq_expiry < $pollq_timestamp) {
|
63 |
$pollq_active = 0;
|
64 |
}
|
65 |
}
|
66 |
}
|
67 |
// Mutilple Poll
|
68 |
-
$pollq_multiple_yes =
|
69 |
$pollq_multiple = 0;
|
70 |
if($pollq_multiple_yes == 1) {
|
71 |
-
$pollq_multiple =
|
72 |
} else {
|
73 |
$pollq_multiple = 0;
|
74 |
}
|
@@ -109,11 +109,11 @@ if(!empty($_POST['do'])) {
|
|
109 |
$get_polla_aids = $wpdb->get_results( $wpdb->prepare( "SELECT polla_aid FROM $wpdb->pollsa WHERE polla_qid = %d ORDER BY polla_aid ASC", $pollq_id ) );
|
110 |
if($get_polla_aids) {
|
111 |
foreach($get_polla_aids as $get_polla_aid) {
|
112 |
-
$polla_aids[] =
|
113 |
}
|
114 |
foreach($polla_aids as $polla_aid) {
|
115 |
$polla_answers = wp_kses_post( trim( $_POST['polla_aid-'.$polla_aid] ) );
|
116 |
-
$polla_votes =
|
117 |
$edit_poll_answer = $wpdb->update(
|
118 |
$wpdb->pollsa,
|
119 |
array(
|
@@ -143,14 +143,14 @@ if(!empty($_POST['do'])) {
|
|
143 |
$text .= '<p style="color: red">'.sprintf(__('Invalid Poll \'%s\'.', 'wp-polls'), removeslashes($pollq_question)).'</p>';
|
144 |
}
|
145 |
// Add Poll Answers (If Needed)
|
146 |
-
$polla_answers_new = isset($_POST['polla_answers_new']) ? $_POST['polla_answers_new'] : null;
|
147 |
if(!empty($polla_answers_new)) {
|
148 |
$i = 0;
|
149 |
$polla_answers_new_votes = $_POST['polla_answers_new_votes'];
|
150 |
foreach($polla_answers_new as $polla_answer_new) {
|
151 |
$polla_answer_new = wp_kses_post( trim( $polla_answer_new ) );
|
152 |
if(!empty($polla_answer_new)) {
|
153 |
-
$polla_answer_new_vote =
|
154 |
$add_poll_answers = $wpdb->insert(
|
155 |
$wpdb->pollsa,
|
156 |
array(
|
@@ -198,12 +198,12 @@ switch($mode) {
|
|
198 |
$poll_answers = $wpdb->get_results( $wpdb->prepare( "SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = %d ORDER BY polla_aid ASC", $poll_id ) );
|
199 |
$poll_noquestion = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(polla_aid) FROM $wpdb->pollsa WHERE polla_qid = %d", $poll_id ) );
|
200 |
$poll_question_text = removeslashes($poll_question->pollq_question);
|
201 |
-
$poll_totalvotes =
|
202 |
$poll_timestamp = $poll_question->pollq_timestamp;
|
203 |
-
$poll_active =
|
204 |
$poll_expiry = trim($poll_question->pollq_expiry);
|
205 |
-
$poll_multiple =
|
206 |
-
$poll_totalvoters =
|
207 |
?>
|
208 |
<?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade">'.removeslashes($text).'</div>'; } else { echo '<div id="message" class="updated" style="display: none;"></div>'; } ?>
|
209 |
|
@@ -241,9 +241,9 @@ switch($mode) {
|
|
241 |
$pollip_answers = array();
|
242 |
$pollip_answers[0] = __('Null Votes', 'wp-polls');
|
243 |
foreach($poll_answers as $poll_answer) {
|
244 |
-
$polla_aid =
|
245 |
$polla_answers = removeslashes($poll_answer->polla_answers);
|
246 |
-
$polla_votes =
|
247 |
$pollip_answers[$polla_aid] = $polla_answers;
|
248 |
echo "<tr id=\"poll-answer-$polla_aid\">\n";
|
249 |
echo '<th width="20%" scope="row" valign="top">'.sprintf(__('Answer %s', 'wp-polls'), number_format_i18n($i)).'</th>'."\n";
|
@@ -388,15 +388,15 @@ switch($mode) {
|
|
388 |
$multiple_polls = array();
|
389 |
}
|
390 |
$i = 0;
|
391 |
-
$current_poll =
|
392 |
-
$latest_poll =
|
393 |
foreach($polls as $poll) {
|
394 |
-
$poll_id =
|
395 |
$poll_question = removeslashes($poll->pollq_question);
|
396 |
$poll_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll->pollq_timestamp));
|
397 |
-
$poll_totalvotes =
|
398 |
-
$poll_totalvoters =
|
399 |
-
$poll_active =
|
400 |
$poll_expiry = trim($poll->pollq_expiry);
|
401 |
if(empty($poll_expiry)) {
|
402 |
$poll_expiry_text = __('No Expiry', 'wp-polls');
|
@@ -409,28 +409,28 @@ switch($mode) {
|
|
409 |
$style = '';
|
410 |
}
|
411 |
if($current_poll > 0) {
|
412 |
-
if($current_poll
|
413 |
$style = 'class="highlight"';
|
414 |
}
|
415 |
-
} elseif($current_poll
|
416 |
-
if($poll_id
|
417 |
$style = 'class="highlight"';
|
418 |
}
|
419 |
-
} else if(in_array($poll_id, $multiple_polls)) {
|
420 |
$style = 'class="highlight"';
|
421 |
}
|
422 |
echo "<tr id=\"poll-$poll_id\" $style>\n";
|
423 |
echo '<td><strong>'.number_format_i18n($poll_id).'</strong></td>'."\n";
|
424 |
echo '<td>';
|
425 |
if($current_poll > 0) {
|
426 |
-
if($current_poll
|
427 |
echo '<strong>'.__('Displayed:', 'wp-polls').'</strong> ';
|
428 |
}
|
429 |
-
} elseif($current_poll
|
430 |
-
if($poll_id
|
431 |
echo '<strong>'.__('Displayed:', 'wp-polls').'</strong> ';
|
432 |
}
|
433 |
-
} else if(in_array($poll_id, $multiple_polls)) {
|
434 |
echo '<strong>'.__('Displayed:', 'wp-polls').'</strong> ';
|
435 |
}
|
436 |
echo wp_kses_post( $poll_question )."</td>\n";
|
@@ -438,9 +438,9 @@ switch($mode) {
|
|
438 |
echo "<td>$poll_date</td>\n";
|
439 |
echo "<td>$poll_expiry_text</td>\n";
|
440 |
echo '<td>';
|
441 |
-
if($poll_active
|
442 |
_e('Open', 'wp-polls');
|
443 |
-
} elseif($poll_active
|
444 |
_e('Future', 'wp-polls');
|
445 |
} else {
|
446 |
_e('Closed', 'wp-polls');
|
@@ -495,7 +495,7 @@ switch($mode) {
|
|
495 |
<br style="clear" />
|
496 |
<div align="center" id="poll_logs">
|
497 |
<?php
|
498 |
-
$poll_ips =
|
499 |
if($poll_ips > 0) {
|
500 |
?>
|
501 |
<strong><?php _e('Are You Sure You Want To Delete All Polls Logs?', 'wp-polls'); ?></strong><br /><br />
|
7 |
### Variables Variables Variables
|
8 |
$base_name = plugin_basename('wp-polls/polls-manager.php');
|
9 |
$base_page = 'admin.php?page='.$base_name;
|
10 |
+
$mode = ( isset( $_GET['mode'] ) ? sanitize_key( trim( $_GET['mode'] ) ) : '' );
|
11 |
+
$poll_id = ( isset( $_GET['id'] ) ? (int) sanitize_key( $_GET['id'] ) : 0 );
|
12 |
+
$poll_aid = ( isset( $_GET['aid'] ) ? (int) sanitize_key( $_GET['aid'] ) : 0 );
|
13 |
|
14 |
### Form Processing
|
15 |
if(!empty($_POST['do'])) {
|
19 |
case __('Edit Poll', 'wp-polls'):
|
20 |
check_admin_referer( 'wp-polls_edit-poll' );
|
21 |
// Poll ID
|
22 |
+
$pollq_id = (int) sanitize_key( $_POST['pollq_id'] );
|
23 |
// Poll Total Votes
|
24 |
+
$pollq_totalvotes = (int) sanitize_key($_POST['pollq_totalvotes']);
|
25 |
// Poll Total Voters
|
26 |
+
$pollq_totalvoters = (int) sanitize_key($_POST['pollq_totalvoters']);
|
27 |
// Poll Question
|
28 |
$pollq_question = esc_sql( wp_kses_post( trim( $_POST['pollq_question'] ) ) );
|
29 |
// Poll Active
|
30 |
+
$pollq_active = (int) sanitize_key($_POST['pollq_active']);
|
31 |
// Poll Start Date
|
32 |
$pollq_timestamp = isset( $_POST['poll_timestamp_old'] ) ? $_POST['poll_timestamp_old'] : current_time( 'timestamp' );
|
33 |
+
$edit_polltimestamp = isset( $_POST['edit_polltimestamp'] ) && (int) sanitize_key( $_POST['edit_polltimestamp'] ) === 1;
|
34 |
+
if($edit_polltimestamp === 1) {
|
35 |
+
$pollq_timestamp_day = (int) sanitize_key($_POST['pollq_timestamp_day']);
|
36 |
+
$pollq_timestamp_month = (int) sanitize_key($_POST['pollq_timestamp_month']);
|
37 |
+
$pollq_timestamp_year = (int) sanitize_key($_POST['pollq_timestamp_year']);
|
38 |
+
$pollq_timestamp_hour = (int) sanitize_key($_POST['pollq_timestamp_hour']);
|
39 |
+
$pollq_timestamp_minute = (int) sanitize_key($_POST['pollq_timestamp_minute']);
|
40 |
+
$pollq_timestamp_second = (int) sanitize_key($_POST['pollq_timestamp_second']);
|
41 |
$pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year);
|
42 |
if($pollq_timestamp > current_time('timestamp')) {
|
43 |
$pollq_active = -1;
|
44 |
}
|
45 |
}
|
46 |
// Poll End Date
|
47 |
+
$pollq_expiry_no = isset( $_POST['pollq_expiry_no'] ) ? (int) sanitize_key( $_POST['pollq_expiry_no'] ) : 0;
|
48 |
if($pollq_expiry_no == 1) {
|
49 |
$pollq_expiry = '';
|
50 |
} else {
|
51 |
+
$pollq_expiry_day = (int) sanitize_key($_POST['pollq_expiry_day']);
|
52 |
+
$pollq_expiry_month = (int) sanitize_key($_POST['pollq_expiry_month']);
|
53 |
+
$pollq_expiry_year = (int) sanitize_key($_POST['pollq_expiry_year']);
|
54 |
+
$pollq_expiry_hour = (int) sanitize_key($_POST['pollq_expiry_hour']);
|
55 |
+
$pollq_expiry_minute = (int) sanitize_key($_POST['pollq_expiry_minute']);
|
56 |
+
$pollq_expiry_second = (int) sanitize_key($_POST['pollq_expiry_second']);
|
57 |
$pollq_expiry = gmmktime($pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year);
|
58 |
if($pollq_expiry <= current_time('timestamp')) {
|
59 |
$pollq_active = 0;
|
60 |
}
|
61 |
+
if($edit_polltimestamp === 1) {
|
62 |
if($pollq_expiry < $pollq_timestamp) {
|
63 |
$pollq_active = 0;
|
64 |
}
|
65 |
}
|
66 |
}
|
67 |
// Mutilple Poll
|
68 |
+
$pollq_multiple_yes = (int) sanitize_key($_POST['pollq_multiple_yes']);
|
69 |
$pollq_multiple = 0;
|
70 |
if($pollq_multiple_yes == 1) {
|
71 |
+
$pollq_multiple = (int) sanitize_key($_POST['pollq_multiple']);
|
72 |
} else {
|
73 |
$pollq_multiple = 0;
|
74 |
}
|
109 |
$get_polla_aids = $wpdb->get_results( $wpdb->prepare( "SELECT polla_aid FROM $wpdb->pollsa WHERE polla_qid = %d ORDER BY polla_aid ASC", $pollq_id ) );
|
110 |
if($get_polla_aids) {
|
111 |
foreach($get_polla_aids as $get_polla_aid) {
|
112 |
+
$polla_aids[] = (int) $get_polla_aid->polla_aid;
|
113 |
}
|
114 |
foreach($polla_aids as $polla_aid) {
|
115 |
$polla_answers = wp_kses_post( trim( $_POST['polla_aid-'.$polla_aid] ) );
|
116 |
+
$polla_votes = (int) sanitize_key($_POST['polla_votes-'.$polla_aid]);
|
117 |
$edit_poll_answer = $wpdb->update(
|
118 |
$wpdb->pollsa,
|
119 |
array(
|
143 |
$text .= '<p style="color: red">'.sprintf(__('Invalid Poll \'%s\'.', 'wp-polls'), removeslashes($pollq_question)).'</p>';
|
144 |
}
|
145 |
// Add Poll Answers (If Needed)
|
146 |
+
$polla_answers_new = isset($_POST['polla_answers_new']) ? wp_kses_post( $_POST['polla_answers_new'] ) : null;
|
147 |
if(!empty($polla_answers_new)) {
|
148 |
$i = 0;
|
149 |
$polla_answers_new_votes = $_POST['polla_answers_new_votes'];
|
150 |
foreach($polla_answers_new as $polla_answer_new) {
|
151 |
$polla_answer_new = wp_kses_post( trim( $polla_answer_new ) );
|
152 |
if(!empty($polla_answer_new)) {
|
153 |
+
$polla_answer_new_vote = (int) sanitize_key( $polla_answers_new_votes[$i] );
|
154 |
$add_poll_answers = $wpdb->insert(
|
155 |
$wpdb->pollsa,
|
156 |
array(
|
198 |
$poll_answers = $wpdb->get_results( $wpdb->prepare( "SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = %d ORDER BY polla_aid ASC", $poll_id ) );
|
199 |
$poll_noquestion = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(polla_aid) FROM $wpdb->pollsa WHERE polla_qid = %d", $poll_id ) );
|
200 |
$poll_question_text = removeslashes($poll_question->pollq_question);
|
201 |
+
$poll_totalvotes = (int) $poll_question->pollq_totalvotes;
|
202 |
$poll_timestamp = $poll_question->pollq_timestamp;
|
203 |
+
$poll_active = (int) $poll_question->pollq_active;
|
204 |
$poll_expiry = trim($poll_question->pollq_expiry);
|
205 |
+
$poll_multiple = (int) $poll_question->pollq_multiple;
|
206 |
+
$poll_totalvoters = (int) $poll_question->pollq_totalvoters;
|
207 |
?>
|
208 |
<?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade">'.removeslashes($text).'</div>'; } else { echo '<div id="message" class="updated" style="display: none;"></div>'; } ?>
|
209 |
|
241 |
$pollip_answers = array();
|
242 |
$pollip_answers[0] = __('Null Votes', 'wp-polls');
|
243 |
foreach($poll_answers as $poll_answer) {
|
244 |
+
$polla_aid = (int) $poll_answer->polla_aid;
|
245 |
$polla_answers = removeslashes($poll_answer->polla_answers);
|
246 |
+
$polla_votes = (int) $poll_answer->polla_votes;
|
247 |
$pollip_answers[$polla_aid] = $polla_answers;
|
248 |
echo "<tr id=\"poll-answer-$polla_aid\">\n";
|
249 |
echo '<th width="20%" scope="row" valign="top">'.sprintf(__('Answer %s', 'wp-polls'), number_format_i18n($i)).'</th>'."\n";
|
388 |
$multiple_polls = array();
|
389 |
}
|
390 |
$i = 0;
|
391 |
+
$current_poll = (int) get_option('poll_currentpoll');
|
392 |
+
$latest_poll = (int) get_option('poll_latestpoll');
|
393 |
foreach($polls as $poll) {
|
394 |
+
$poll_id = (int) $poll->pollq_id;
|
395 |
$poll_question = removeslashes($poll->pollq_question);
|
396 |
$poll_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll->pollq_timestamp));
|
397 |
+
$poll_totalvotes = (int) $poll->pollq_totalvotes;
|
398 |
+
$poll_totalvoters = (int) $poll->pollq_totalvoters;
|
399 |
+
$poll_active = (int) $poll->pollq_active;
|
400 |
$poll_expiry = trim($poll->pollq_expiry);
|
401 |
if(empty($poll_expiry)) {
|
402 |
$poll_expiry_text = __('No Expiry', 'wp-polls');
|
409 |
$style = '';
|
410 |
}
|
411 |
if($current_poll > 0) {
|
412 |
+
if($current_poll === $poll_id) {
|
413 |
$style = 'class="highlight"';
|
414 |
}
|
415 |
+
} elseif($current_poll === 0) {
|
416 |
+
if($poll_id === $latest_poll) {
|
417 |
$style = 'class="highlight"';
|
418 |
}
|
419 |
+
} else if(in_array($poll_id, $multiple_polls, true)) {
|
420 |
$style = 'class="highlight"';
|
421 |
}
|
422 |
echo "<tr id=\"poll-$poll_id\" $style>\n";
|
423 |
echo '<td><strong>'.number_format_i18n($poll_id).'</strong></td>'."\n";
|
424 |
echo '<td>';
|
425 |
if($current_poll > 0) {
|
426 |
+
if($current_poll === $poll_id) {
|
427 |
echo '<strong>'.__('Displayed:', 'wp-polls').'</strong> ';
|
428 |
}
|
429 |
+
} elseif($current_poll === 0) {
|
430 |
+
if($poll_id === $latest_poll) {
|
431 |
echo '<strong>'.__('Displayed:', 'wp-polls').'</strong> ';
|
432 |
}
|
433 |
+
} else if(in_array($poll_id, $multiple_polls, true)) {
|
434 |
echo '<strong>'.__('Displayed:', 'wp-polls').'</strong> ';
|
435 |
}
|
436 |
echo wp_kses_post( $poll_question )."</td>\n";
|
438 |
echo "<td>$poll_date</td>\n";
|
439 |
echo "<td>$poll_expiry_text</td>\n";
|
440 |
echo '<td>';
|
441 |
+
if($poll_active === 1) {
|
442 |
_e('Open', 'wp-polls');
|
443 |
+
} elseif($poll_active === -1) {
|
444 |
_e('Future', 'wp-polls');
|
445 |
} else {
|
446 |
_e('Closed', 'wp-polls');
|
495 |
<br style="clear" />
|
496 |
<div align="center" id="poll_logs">
|
497 |
<?php
|
498 |
+
$poll_ips = (int) $wpdb->get_var( "SELECT COUNT(pollip_id) FROM $wpdb->pollsip" );
|
499 |
if($poll_ips > 0) {
|
500 |
?>
|
501 |
<strong><?php _e('Are You Sure You Want To Delete All Polls Logs?', 'wp-polls'); ?></strong><br /><br />
|
polls-options.php
CHANGED
@@ -26,7 +26,7 @@ if( ! current_user_can( 'manage_polls' ) ) {
|
|
26 |
### Variables Variables Variables
|
27 |
$base_name = plugin_basename( 'wp-polls/polls-options.php' );
|
28 |
$base_page = 'admin.php?page=' . $base_name;
|
29 |
-
$id = isset( $_GET['id'] ) ?
|
30 |
|
31 |
|
32 |
### Get Poll Bar Images
|
@@ -46,10 +46,10 @@ if( $handle = @opendir( $pollbar_path ) ) {
|
|
46 |
### If Form Is Submitted
|
47 |
if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
48 |
check_admin_referer('wp-polls_options');
|
49 |
-
$poll_bar_style = isset( $_POST['poll_bar_style'] ) && in_array( $_POST['poll_bar_style'], array_merge( array_keys( $poll_bars ), array( 'use_css' ) ) ) ? $_POST['poll_bar_style'] : 'default';
|
50 |
$poll_bar_background = isset( $_POST['poll_bar_bg'] ) ? substr( strip_tags( trim( $_POST['poll_bar_bg'] ) ), 0, 6 ) : '000000';
|
51 |
$poll_bar_border = isset( $_POST['poll_bar_border'] ) ? substr( strip_tags( trim( $_POST['poll_bar_border'] ) ), 0, 6 ) : '000000';
|
52 |
-
$poll_bar_height = isset( $_POST['poll_bar_height'] ) ?
|
53 |
$poll_bar = array(
|
54 |
'style' => $poll_bar_style,
|
55 |
'background' => $poll_bar_background,
|
@@ -57,21 +57,21 @@ if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
|
57 |
'height' => $poll_bar_height
|
58 |
);
|
59 |
$poll_ajax_style = array(
|
60 |
-
'loading' => isset( $_POST['poll_ajax_style_loading'] ) ?
|
61 |
-
'fading' => isset( $_POST['poll_ajax_style_fading'] ) ?
|
62 |
);
|
63 |
-
$poll_ans_sortby = isset( $_POST['poll_ans_sortby'] ) && in_array( $_POST['poll_ans_sortby'], array( 'polla_aid', 'polla_answers', 'RAND()' ) ) ? $_POST['poll_ans_sortby'] : 'polla_aid';
|
64 |
-
$poll_ans_sortorder = isset( $_POST['poll_ans_sortorder'] ) && in_array( $_POST['poll_ans_sortorder'], array( 'asc', 'desc' ) ) ? $_POST['poll_ans_sortorder'] : 'asc';
|
65 |
-
$poll_ans_result_sortby = isset( $_POST['poll_ans_result_sortby'] ) && in_array( $_POST['poll_ans_result_sortby'], array( 'polla_votes', 'polla_aid', 'polla_answers', 'RAND()' ) ) ? $_POST['poll_ans_result_sortby'] : 'polla_votes';
|
66 |
-
$poll_ans_result_sortorder = isset( $_POST['poll_ans_result_sortorder'] ) && in_array( $_POST['poll_ans_result_sortorder'], array( 'asc', 'desc' ) ) ? $_POST['poll_ans_result_sortorder'] : 'desc';
|
67 |
-
$poll_archive_perpage = isset( $_POST['poll_archive_perpage'] ) ?
|
68 |
-
$poll_archive_displaypoll = isset( $_POST['poll_archive_displaypoll'] ) ?
|
69 |
$poll_archive_url = isset( $_POST['poll_archive_url'] ) ? esc_url_raw( strip_tags( trim( $_POST['poll_archive_url'] ) ) ) : '';
|
70 |
-
$poll_currentpoll = isset( $_POST['poll_currentpoll'] ) ?
|
71 |
-
$poll_close = isset( $_POST['poll_close'] ) ?
|
72 |
-
$poll_logging_method = isset( $_POST['poll_logging_method'] ) ?
|
73 |
-
$poll_cookielog_expiry = isset( $_POST['poll_cookielog_expiry'] ) ?
|
74 |
-
$poll_allowtovote = isset( $_POST['poll_allowtovote'] ) ?
|
75 |
$update_poll_queries = array();
|
76 |
$update_poll_text = array();
|
77 |
$update_poll_queries[] = update_option('poll_bar', $poll_bar);
|
@@ -308,7 +308,7 @@ if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
|
308 |
</tr>
|
309 |
<tr>
|
310 |
<th scope="row" valign="top"><?php _e('Expiry Time For Cookie And Log:', 'wp-polls'); ?></th>
|
311 |
-
<td><input type="text" name="poll_cookielog_expiry" value="<?php echo
|
312 |
</tr>
|
313 |
</table>
|
314 |
|
@@ -317,7 +317,7 @@ if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
|
317 |
<table class="form-table">
|
318 |
<tr>
|
319 |
<th scope="row" valign="top"><?php _e('Number Of Polls Per Page:', 'wp-polls'); ?></th>
|
320 |
-
<td><input type="text" name="poll_archive_perpage" value="<?php echo
|
321 |
</tr>
|
322 |
<tr>
|
323 |
<th scope="row" valign="top"><?php _e('Type Of Polls To Display In Poll Archive:', 'wp-polls'); ?></th>
|
@@ -355,8 +355,8 @@ if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
|
355 |
if($polls) {
|
356 |
foreach($polls as $poll) {
|
357 |
$poll_question = removeslashes($poll->pollq_question);
|
358 |
-
$poll_id =
|
359 |
-
if($poll_id
|
360 |
echo '<option value="' . $poll_id . '" selected="selected">' . esc_attr( $poll_question ) . '</option>';
|
361 |
} else {
|
362 |
echo '<option value="' . $poll_id . '">' . esc_attr( $poll_question ) . '</option>';
|
26 |
### Variables Variables Variables
|
27 |
$base_name = plugin_basename( 'wp-polls/polls-options.php' );
|
28 |
$base_page = 'admin.php?page=' . $base_name;
|
29 |
+
$id = isset( $_GET['id'] ) ? (int) sanitize_key( $_GET['id'] ) : 0;
|
30 |
|
31 |
|
32 |
### Get Poll Bar Images
|
46 |
### If Form Is Submitted
|
47 |
if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
48 |
check_admin_referer('wp-polls_options');
|
49 |
+
$poll_bar_style = isset( $_POST['poll_bar_style'] ) && in_array( $_POST['poll_bar_style'], array_merge( array_keys( $poll_bars ), array( 'use_css' ) ), true ) ? $_POST['poll_bar_style'] : 'default';
|
50 |
$poll_bar_background = isset( $_POST['poll_bar_bg'] ) ? substr( strip_tags( trim( $_POST['poll_bar_bg'] ) ), 0, 6 ) : '000000';
|
51 |
$poll_bar_border = isset( $_POST['poll_bar_border'] ) ? substr( strip_tags( trim( $_POST['poll_bar_border'] ) ), 0, 6 ) : '000000';
|
52 |
+
$poll_bar_height = isset( $_POST['poll_bar_height'] ) ? (int) sanitize_key( $_POST['poll_bar_height'] ) : 10;
|
53 |
$poll_bar = array(
|
54 |
'style' => $poll_bar_style,
|
55 |
'background' => $poll_bar_background,
|
57 |
'height' => $poll_bar_height
|
58 |
);
|
59 |
$poll_ajax_style = array(
|
60 |
+
'loading' => isset( $_POST['poll_ajax_style_loading'] ) ? (int) sanitize_key( $_POST['poll_ajax_style_loading'] ) : 1,
|
61 |
+
'fading' => isset( $_POST['poll_ajax_style_fading'] ) ? (int) sanitize_key( $_POST['poll_ajax_style_fading'] ) : 1
|
62 |
);
|
63 |
+
$poll_ans_sortby = isset( $_POST['poll_ans_sortby'] ) && in_array( $_POST['poll_ans_sortby'], array( 'polla_aid', 'polla_answers', 'RAND()' ), true ) ? $_POST['poll_ans_sortby'] : 'polla_aid';
|
64 |
+
$poll_ans_sortorder = isset( $_POST['poll_ans_sortorder'] ) && in_array( $_POST['poll_ans_sortorder'], array( 'asc', 'desc' ), true ) ? $_POST['poll_ans_sortorder'] : 'asc';
|
65 |
+
$poll_ans_result_sortby = isset( $_POST['poll_ans_result_sortby'] ) && in_array( $_POST['poll_ans_result_sortby'], array( 'polla_votes', 'polla_aid', 'polla_answers', 'RAND()' ), true ) ? $_POST['poll_ans_result_sortby'] : 'polla_votes';
|
66 |
+
$poll_ans_result_sortorder = isset( $_POST['poll_ans_result_sortorder'] ) && in_array( $_POST['poll_ans_result_sortorder'], array( 'asc', 'desc' ), true ) ? $_POST['poll_ans_result_sortorder'] : 'desc';
|
67 |
+
$poll_archive_perpage = isset( $_POST['poll_archive_perpage'] ) ? (int) sanitize_key( $_POST['poll_archive_perpage'] ) : 0;
|
68 |
+
$poll_archive_displaypoll = isset( $_POST['poll_archive_displaypoll'] ) ? (int) sanitize_key( $_POST['poll_archive_displaypoll'] ) : 0;
|
69 |
$poll_archive_url = isset( $_POST['poll_archive_url'] ) ? esc_url_raw( strip_tags( trim( $_POST['poll_archive_url'] ) ) ) : '';
|
70 |
+
$poll_currentpoll = isset( $_POST['poll_currentpoll'] ) ? (int) sanitize_key( $_POST['poll_currentpoll'] ) : 0;
|
71 |
+
$poll_close = isset( $_POST['poll_close'] ) ? (int) sanitize_key( $_POST['poll_close'] ) : 0;
|
72 |
+
$poll_logging_method = isset( $_POST['poll_logging_method'] ) ? (int) sanitize_key( $_POST['poll_logging_method'] ) : 0;
|
73 |
+
$poll_cookielog_expiry = isset( $_POST['poll_cookielog_expiry'] ) ? (int) sanitize_key ($_POST['poll_cookielog_expiry'] ) : 0;
|
74 |
+
$poll_allowtovote = isset( $_POST['poll_allowtovote'] ) ? (int) sanitize_key( $_POST['poll_allowtovote'] ) : 0;
|
75 |
$update_poll_queries = array();
|
76 |
$update_poll_text = array();
|
77 |
$update_poll_queries[] = update_option('poll_bar', $poll_bar);
|
308 |
</tr>
|
309 |
<tr>
|
310 |
<th scope="row" valign="top"><?php _e('Expiry Time For Cookie And Log:', 'wp-polls'); ?></th>
|
311 |
+
<td><input type="text" name="poll_cookielog_expiry" value="<?php echo (int) esc_attr( get_option( 'poll_cookielog_expiry' ) ); ?>" size="10" /> <?php _e('seconds (0 to disable)', 'wp-polls'); ?></td>
|
312 |
</tr>
|
313 |
</table>
|
314 |
|
317 |
<table class="form-table">
|
318 |
<tr>
|
319 |
<th scope="row" valign="top"><?php _e('Number Of Polls Per Page:', 'wp-polls'); ?></th>
|
320 |
+
<td><input type="text" name="poll_archive_perpage" value="<?php echo (int) esc_attr( get_option( 'poll_archive_perpage' ) ); ?>" size="2" /></td>
|
321 |
</tr>
|
322 |
<tr>
|
323 |
<th scope="row" valign="top"><?php _e('Type Of Polls To Display In Poll Archive:', 'wp-polls'); ?></th>
|
355 |
if($polls) {
|
356 |
foreach($polls as $poll) {
|
357 |
$poll_question = removeslashes($poll->pollq_question);
|
358 |
+
$poll_id = (int) $poll->pollq_id;
|
359 |
+
if($poll_id === (int) get_option( 'poll_currentpoll' ) ) {
|
360 |
echo '<option value="' . $poll_id . '" selected="selected">' . esc_attr( $poll_question ) . '</option>';
|
361 |
} else {
|
362 |
echo '<option value="' . $poll_id . '">' . esc_attr( $poll_question ) . '</option>';
|
polls-templates.php
CHANGED
@@ -25,26 +25,26 @@ if(!current_user_can('manage_polls')) {
|
|
25 |
### Variables Variables Variables
|
26 |
$base_name = plugin_basename('wp-polls/polls-templates.php');
|
27 |
$base_page = 'admin.php?page='.$base_name;
|
28 |
-
$id = (isset($_GET['id']) ?
|
29 |
|
30 |
### If Form Is Submitted
|
31 |
if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
32 |
check_admin_referer('wp-polls_templates');
|
33 |
-
$poll_template_voteheader = trim($_POST['poll_template_voteheader']);
|
34 |
-
$poll_template_votebody = trim($_POST['poll_template_votebody']);
|
35 |
-
$poll_template_votefooter = trim($_POST['poll_template_votefooter']);
|
36 |
-
$poll_template_resultheader = trim($_POST['poll_template_resultheader']);
|
37 |
-
$poll_template_resultbody = trim($_POST['poll_template_resultbody']);
|
38 |
-
$poll_template_resultbody2 = trim($_POST['poll_template_resultbody2']);
|
39 |
-
$poll_template_resultfooter = trim($_POST['poll_template_resultfooter']);
|
40 |
-
$poll_template_resultfooter2 = trim($_POST['poll_template_resultfooter2']);
|
41 |
-
$poll_template_pollarchivelink = trim($_POST['poll_template_pollarchivelink']);
|
42 |
-
$poll_template_pollarchiveheader = trim($_POST['poll_template_pollarchiveheader']);
|
43 |
-
$poll_template_pollarchivefooter = trim($_POST['poll_template_pollarchivefooter']);
|
44 |
-
$poll_template_pollarchivepagingheader = trim($_POST['poll_template_pollarchivepagingheader']);
|
45 |
-
$poll_template_pollarchivepagingfooter = trim($_POST['poll_template_pollarchivepagingfooter']);
|
46 |
-
$poll_template_disable = trim($_POST['poll_template_disable']);
|
47 |
-
$poll_template_error = trim($_POST['poll_template_error']);
|
48 |
$update_poll_queries = array();
|
49 |
$update_poll_text = array();
|
50 |
$update_poll_queries[] = update_option('poll_template_voteheader', $poll_template_voteheader);
|
@@ -494,4 +494,4 @@ if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
|
494 |
<input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes', 'wp-polls'); ?>" />
|
495 |
</p>
|
496 |
</div>
|
497 |
-
</form>
|
25 |
### Variables Variables Variables
|
26 |
$base_name = plugin_basename('wp-polls/polls-templates.php');
|
27 |
$base_page = 'admin.php?page='.$base_name;
|
28 |
+
$id = ( isset($_GET['id'] ) ? (int) sanitize_key( $_GET['id'] ) : 0 );
|
29 |
|
30 |
### If Form Is Submitted
|
31 |
if( isset($_POST['Submit']) && $_POST['Submit'] ) {
|
32 |
check_admin_referer('wp-polls_templates');
|
33 |
+
$poll_template_voteheader = wp_kses_post( trim( $_POST['poll_template_voteheader'] ) );
|
34 |
+
$poll_template_votebody = wp_kses_post( trim($_POST['poll_template_votebody'] ) );
|
35 |
+
$poll_template_votefooter = wp_kses_post( trim($_POST['poll_template_votefooter'] ) );
|
36 |
+
$poll_template_resultheader = wp_kses_post( trim($_POST['poll_template_resultheader'] ) );
|
37 |
+
$poll_template_resultbody = wp_kses_post( trim($_POST['poll_template_resultbody'] ) );
|
38 |
+
$poll_template_resultbody2 = wp_kses_post( trim($_POST['poll_template_resultbody2'] ) );
|
39 |
+
$poll_template_resultfooter = wp_kses_post( trim($_POST['poll_template_resultfooter'] ) );
|
40 |
+
$poll_template_resultfooter2 = wp_kses_post( trim($_POST['poll_template_resultfooter2'] ) );
|
41 |
+
$poll_template_pollarchivelink = wp_kses_post( trim($_POST['poll_template_pollarchivelink'] ) );
|
42 |
+
$poll_template_pollarchiveheader = wp_kses_post( trim($_POST['poll_template_pollarchiveheader'] ) );
|
43 |
+
$poll_template_pollarchivefooter = wp_kses_post( trim($_POST['poll_template_pollarchivefooter'] ) );
|
44 |
+
$poll_template_pollarchivepagingheader = wp_kses_post( trim($_POST['poll_template_pollarchivepagingheader'] ) );
|
45 |
+
$poll_template_pollarchivepagingfooter = wp_kses_post( trim($_POST['poll_template_pollarchivepagingfooter'] ) );
|
46 |
+
$poll_template_disable = wp_kses_post( trim($_POST['poll_template_disable'] ) );
|
47 |
+
$poll_template_error = wp_kses_post( trim($_POST['poll_template_error'] ) );
|
48 |
$update_poll_queries = array();
|
49 |
$update_poll_text = array();
|
50 |
$update_poll_queries[] = update_option('poll_template_voteheader', $poll_template_voteheader);
|
494 |
<input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes', 'wp-polls'); ?>" />
|
495 |
</p>
|
496 |
</div>
|
497 |
+
</form>
|
readme.txt
CHANGED
@@ -4,39 +4,13 @@ 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 |
## 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 |
|
@@ -53,6 +27,9 @@ WP-Polls is extremely customizable via templates and css styles and there are to
|
|
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.
|
@@ -103,6 +80,34 @@ I spent most of my free time creating, updating, maintaining and supporting thes
|
|
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.
|
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.4
|
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 |
|
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.4
|
31 |
+
* FIXED: sanitize_key on top of intval.
|
32 |
+
|
33 |
### Version 2.73.3
|
34 |
* NEW: Added sort by votes casted to poll answers.
|
35 |
* NEW: For polls with mutiple answers, we divided by total votes instead of total voters. Props @ljxprime.
|
80 |
10. Poll - Archive
|
81 |
|
82 |
## Frequently Asked Questions
|
83 |
+
|
84 |
+
### General Usage (Without Widget)
|
85 |
+
|
86 |
+
```
|
87 |
+
<?php if ( function_exists( 'vote_poll' ) && ! in_pollarchive() ): ?>
|
88 |
+
<li>
|
89 |
+
<h2>Polls</h2>
|
90 |
+
<ul>
|
91 |
+
<li><?php get_poll();?></li>
|
92 |
+
</ul>
|
93 |
+
<?php display_polls_archive_link(); ?>
|
94 |
+
</li>
|
95 |
+
<?php endif; ?>
|
96 |
+
```
|
97 |
+
|
98 |
+
* To show specific poll, use `<?php get_poll(2); ?>` where 2 is your poll id.
|
99 |
+
* To show random poll, use `<?php get_poll(-2); ?>`
|
100 |
+
* To embed a specific poll in your post, use `[poll id="2"]` where 2 is your poll id.
|
101 |
+
* To embed a random poll in your post, use `[poll id="-2"]`
|
102 |
+
* To embed a specific poll's result in your post, use `[poll id="2" type="result"]` where 2 is your poll id.
|
103 |
+
|
104 |
+
### General Usage (With Widget)
|
105 |
+
1. Go to `WP-Admin -> Appearance -> Widgets`.
|
106 |
+
2. You can add the Polls Widget by clicking on the 'Add' link besides it.
|
107 |
+
3. After adding, you can configure the Polls Widget by clicking on the 'Edit' link besides it.
|
108 |
+
4. Click 'Save Changes'.
|
109 |
+
5. Scroll down for instructions on how to create a Polls Archive.
|
110 |
+
|
111 |
### How To Add A Polls Archive?
|
112 |
1. Go to `WP-Admin -> Pages -> Add New`.
|
113 |
2. Type any title you like in the post's title area.
|
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,32 +11,32 @@ Text Domain: wp-polls
|
|
11 |
|
12 |
|
13 |
/*
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
*/
|
30 |
|
31 |
|
32 |
### Version
|
33 |
-
define( 'WP_POLLS_VERSION', '2.73.
|
34 |
|
35 |
|
36 |
### Create Text Domain For Translations
|
37 |
add_action( 'plugins_loaded', 'polls_textdomain' );
|
38 |
function polls_textdomain() {
|
39 |
-
|
40 |
}
|
41 |
|
42 |
|
@@ -50,196 +50,195 @@ $wpdb->pollsip = $wpdb->prefix.'pollsip';
|
|
50 |
### Function: Poll Administration Menu
|
51 |
add_action( 'admin_menu', 'poll_menu' );
|
52 |
function poll_menu() {
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
}
|
60 |
|
61 |
|
62 |
### Function: Get Poll
|
63 |
function get_poll($temp_poll_id = 0, $display = true) {
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
}
|
168 |
}
|
169 |
|
170 |
|
171 |
### Function: Enqueue Polls JavaScripts/CSS
|
172 |
add_action('wp_enqueue_scripts', 'poll_scripts');
|
173 |
function poll_scripts() {
|
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 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
}
|
218 |
|
219 |
|
220 |
### Function: Enqueue Polls Stylesheets/JavaScripts In WP-Admin
|
221 |
add_action('admin_enqueue_scripts', 'poll_scripts_admin');
|
222 |
function poll_scripts_admin($hook_suffix) {
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
}
|
244 |
|
245 |
|
@@ -250,163 +249,164 @@ add_action('admin_footer-page-new.php', 'poll_footer_admin');
|
|
250 |
add_action('admin_footer-page.php', 'poll_footer_admin');
|
251 |
function poll_footer_admin() {
|
252 |
?>
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
<?php
|
265 |
}
|
266 |
|
267 |
### Function: Add Quick Tag For Poll In TinyMCE >= WordPress 2.5
|
268 |
add_action('init', 'poll_tinymce_addbuttons');
|
269 |
function poll_tinymce_addbuttons() {
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
}
|
279 |
function poll_tinymce_registerbutton($buttons) {
|
280 |
-
|
281 |
-
|
282 |
}
|
283 |
function poll_tinymce_addplugin($plugin_array) {
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
}
|
291 |
function poll_tinymce_translation($mce_translation) {
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
}
|
298 |
|
299 |
|
300 |
### Function: Check Who Is Allow To Vote
|
301 |
function check_allowtovote() {
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
}
|
326 |
|
327 |
|
328 |
### Funcrion: Check Voted By Cookie Or IP
|
329 |
function check_voted($poll_id) {
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
}
|
359 |
|
360 |
|
361 |
### Function: Check Voted By Cookie
|
362 |
-
function check_voted_cookie($poll_id) {
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
|
|
369 |
}
|
370 |
|
371 |
|
372 |
### Function: Check Voted By IP
|
373 |
function check_voted_ip( $poll_id ) {
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
}
|
388 |
|
389 |
|
390 |
### Function: Check Voted By Username
|
391 |
function check_voted_username($poll_id) {
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
}
|
411 |
|
412 |
add_filter('poll_template_voteheader_markup', 'poll_template_vote_markup', 10, 3);
|
@@ -415,869 +415,869 @@ add_filter('poll_template_votefooter_markup', 'poll_template_vote_markup', 10, 3
|
|
415 |
|
416 |
function poll_template_vote_markup($template, $poll_db_object, $variables) {
|
417 |
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
|
422 |
-
|
423 |
}
|
424 |
|
425 |
|
426 |
### Function: Display Voting Form
|
427 |
function display_pollvote($poll_id, $display_loading = true) {
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
}
|
533 |
|
534 |
|
535 |
### Function: Display Results Form
|
536 |
function display_pollresult($poll_id, $user_voted = '', $display_loading = true) {
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
}
|
716 |
|
717 |
|
718 |
### Function: Get IP Address
|
719 |
if(!function_exists('get_ipaddress')) {
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
}
|
733 |
|
734 |
|
735 |
### Function: Short Code For Inserting Polls Archive Into Page
|
736 |
add_shortcode('page_polls', 'poll_page_shortcode');
|
737 |
function poll_page_shortcode($atts) {
|
738 |
-
|
739 |
}
|
740 |
|
741 |
|
742 |
### Function: Short Code For Inserting Polls Into Posts
|
743 |
add_shortcode( 'poll', 'poll_shortcode' );
|
744 |
function poll_shortcode( $atts ) {
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
}
|
763 |
|
764 |
|
765 |
### Function: Get Poll Question Based On Poll ID
|
766 |
if(!function_exists('get_poll_question')) {
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
}
|
774 |
|
775 |
|
776 |
### Function: Get Poll Total Questions
|
777 |
if(!function_exists('get_pollquestions')) {
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
}
|
788 |
|
789 |
|
790 |
### Function: Get Poll Total Answers
|
791 |
if(!function_exists('get_pollanswers')) {
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
}
|
802 |
|
803 |
|
804 |
### Function: Get Poll Total Votes
|
805 |
if(!function_exists('get_pollvotes')) {
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
}
|
816 |
|
817 |
|
818 |
### Function: Get Poll Total Voters
|
819 |
if(!function_exists('get_pollvoters')) {
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
}
|
830 |
|
831 |
|
832 |
### Function: Check Voted To Get Voted Answer
|
833 |
function check_voted_multiple($poll_id, $polls_ips) {
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
}
|
844 |
|
845 |
|
846 |
### Function: Polls Archive Link
|
847 |
function polls_archive_link($page) {
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
}
|
858 |
|
859 |
|
860 |
### Function: Displays Polls Archive Link
|
861 |
function display_polls_archive_link($display = true) {
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
}
|
870 |
|
871 |
|
872 |
### Function: Display Polls Archive
|
873 |
function polls_archive() {
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
}
|
1157 |
|
1158 |
|
1159 |
// Edit Timestamp Options
|
1160 |
function poll_timestamp($poll_timestamp, $fieldname = 'pollq_timestamp', $display = 'block') {
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
}
|
1233 |
|
1234 |
|
1235 |
### Function: Place Cron
|
1236 |
function cron_polls_place() {
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
}
|
1242 |
|
1243 |
### Funcion: Check All Polls Status To Check If It Expires
|
1244 |
add_action('polls_cron', 'cron_polls_status');
|
1245 |
function cron_polls_status() {
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
}
|
1257 |
|
1258 |
|
1259 |
### Funcion: Get Latest Poll ID
|
1260 |
function polls_latest_id() {
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
}
|
1265 |
|
1266 |
|
1267 |
### Check If In Poll Archive Page
|
1268 |
function in_pollarchive() {
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
}
|
1282 |
|
1283 |
|
@@ -1285,462 +1285,458 @@ function in_pollarchive() {
|
|
1285 |
add_action('wp_ajax_polls', 'vote_poll');
|
1286 |
add_action('wp_ajax_nopriv_polls', 'vote_poll');
|
1287 |
function vote_poll() {
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
} // End switch($_REQUEST['view'])
|
1410 |
-
} // End if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'polls')
|
1411 |
-
exit();
|
1412 |
}
|
1413 |
|
1414 |
|
1415 |
### Function: Manage Polls
|
1416 |
add_action('wp_ajax_polls-admin', 'manage_poll');
|
1417 |
function manage_poll() {
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
}
|
1547 |
}
|
1548 |
|
1549 |
|
1550 |
function _polls_get_ans_sort() {
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
}
|
1565 |
|
1566 |
function _polls_get_ans_result_sort() {
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
}
|
1581 |
|
1582 |
|
1583 |
### Function: Plug Into WP-Stats
|
1584 |
add_action( 'plugins_loaded','polls_wp_stats' );
|
1585 |
function polls_wp_stats() {
|
1586 |
-
|
1587 |
-
|
1588 |
}
|
1589 |
|
1590 |
|
1591 |
### Function: Add WP-Polls General Stats To WP-Stats Page Options
|
1592 |
function polls_page_admin_general_stats($content) {
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
}
|
1601 |
|
1602 |
|
1603 |
### Function: Add WP-Polls General Stats To WP-Stats Page
|
1604 |
function polls_page_general_stats($content) {
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
}
|
1616 |
|
1617 |
|
1618 |
### Class: WP-Polls Widget
|
1619 |
class WP_Widget_Polls extends WP_Widget {
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
?>
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
<?php
|
1699 |
-
|
1700 |
}
|
1701 |
|
1702 |
|
1703 |
### Function: Init WP-Polls Widget
|
1704 |
add_action('widgets_init', 'widget_polls_init');
|
1705 |
function widget_polls_init() {
|
1706 |
-
|
1707 |
-
|
1708 |
}
|
1709 |
|
1710 |
if( ! function_exists( 'removeslashes' ) ) {
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
}
|
1716 |
|
1717 |
### Function: Activate Plugin
|
1718 |
register_activation_hook( __FILE__, 'polls_activation' );
|
1719 |
function polls_activation( $network_wide ) {
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
}
|
1734 |
|
1735 |
function polls_activate() {
|
1736 |
global $wpdb;
|
1737 |
|
1738 |
if(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
|
1739 |
-
|
1740 |
} elseif(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
|
1741 |
-
|
1742 |
} else {
|
1743 |
-
|
1744 |
}
|
1745 |
|
1746 |
// Create Poll Tables (3 Tables)
|
@@ -1748,37 +1744,37 @@ function polls_activate() {
|
|
1748 |
|
1749 |
$create_table = array();
|
1750 |
$create_table['pollsq'] = "CREATE TABLE $wpdb->pollsq (".
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
$create_table['pollsa'] = "CREATE TABLE $wpdb->pollsa (" .
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
$create_table['pollsip'] = "CREATE TABLE $wpdb->pollsip (" .
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
dbDelta( $create_table['pollsq'] );
|
1783 |
dbDelta( $create_table['pollsa'] );
|
1784 |
dbDelta( $create_table['pollsip'] );
|
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.4
|
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
|
18 |
+
the Free Software Foundation; either version 2 of the License, or
|
19 |
+
(at your option) any later version.
|
20 |
|
21 |
+
This program is distributed in the hope that it will be useful,
|
22 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
GNU General Public License for more details.
|
25 |
|
26 |
+
You should have received a copy of the GNU General Public License
|
27 |
+
along with this program; if not, write to the Free Software
|
28 |
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
29 |
*/
|
30 |
|
31 |
|
32 |
### Version
|
33 |
+
define( 'WP_POLLS_VERSION', '2.73.4' );
|
34 |
|
35 |
|
36 |
### Create Text Domain For Translations
|
37 |
add_action( 'plugins_loaded', 'polls_textdomain' );
|
38 |
function polls_textdomain() {
|
39 |
+
load_plugin_textdomain( 'wp-polls' );
|
40 |
}
|
41 |
|
42 |
|
50 |
### Function: Poll Administration Menu
|
51 |
add_action( 'admin_menu', 'poll_menu' );
|
52 |
function poll_menu() {
|
53 |
+
add_menu_page( __( 'Polls', 'wp-polls' ), __( 'Polls', 'wp-polls' ), 'manage_polls', 'wp-polls/polls-manager.php', '', 'dashicons-chart-bar' );
|
54 |
|
55 |
+
add_submenu_page( 'wp-polls/polls-manager.php', __( 'Manage Polls', 'wp-polls'), __( 'Manage Polls', 'wp-polls' ), 'manage_polls', 'wp-polls/polls-manager.php' );
|
56 |
+
add_submenu_page( 'wp-polls/polls-manager.php', __( 'Add Poll', 'wp-polls'), __( 'Add Poll', 'wp-polls' ), 'manage_polls', 'wp-polls/polls-add.php' );
|
57 |
+
add_submenu_page( 'wp-polls/polls-manager.php', __( 'Poll Options', 'wp-polls'), __( 'Poll Options', 'wp-polls' ), 'manage_polls', 'wp-polls/polls-options.php' );
|
58 |
+
add_submenu_page( 'wp-polls/polls-manager.php', __( 'Poll Templates', 'wp-polls'), __( 'Poll Templates', 'wp-polls' ), 'manage_polls', 'wp-polls/polls-templates.php' );
|
59 |
}
|
60 |
|
61 |
|
62 |
### Function: Get Poll
|
63 |
function get_poll($temp_poll_id = 0, $display = true) {
|
64 |
+
global $wpdb, $polls_loaded;
|
65 |
+
// Poll Result Link
|
66 |
+
if(isset($_GET['pollresult'])) {
|
67 |
+
$pollresult_id = (int) $_GET['pollresult'];
|
68 |
+
} else {
|
69 |
+
$pollresult_id = 0;
|
70 |
+
}
|
71 |
+
$temp_poll_id = (int) $temp_poll_id;
|
72 |
+
// Check Whether Poll Is Disabled
|
73 |
+
if((int) get_option('poll_currentpoll') === -1) {
|
74 |
+
if($display) {
|
75 |
+
echo removeslashes(get_option('poll_template_disable'));
|
76 |
+
return '';
|
77 |
+
}
|
78 |
+
|
79 |
+
return removeslashes(get_option('poll_template_disable'));
|
80 |
+
// Poll Is Enabled
|
81 |
+
} else {
|
82 |
+
do_action('wp_polls_get_poll');
|
83 |
+
// Hardcoded Poll ID Is Not Specified
|
84 |
+
switch($temp_poll_id) {
|
85 |
+
// Random Poll
|
86 |
+
case -2:
|
87 |
+
$poll_id = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq WHERE pollq_active = 1 ORDER BY RAND() LIMIT 1");
|
88 |
+
break;
|
89 |
+
// Latest Poll
|
90 |
+
case 0:
|
91 |
+
// Random Poll
|
92 |
+
if((int) get_option('poll_currentpoll') === -2) {
|
93 |
+
$random_poll_id = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq WHERE pollq_active = 1 ORDER BY RAND() LIMIT 1");
|
94 |
+
$poll_id = (int) $random_poll_id;
|
95 |
+
if($pollresult_id > 0) {
|
96 |
+
$poll_id = $pollresult_id;
|
97 |
+
} elseif((int) $_POST['poll_id'] > 0) {
|
98 |
+
$poll_id = (int) $_POST['poll_id'];
|
99 |
+
}
|
100 |
+
// Current Poll ID Is Not Specified
|
101 |
+
} elseif((int) get_option('poll_currentpoll') === 0) {
|
102 |
+
// Get Lastest Poll ID
|
103 |
+
$poll_id = (int) get_option('poll_latestpoll');
|
104 |
+
} else {
|
105 |
+
// Get Current Poll ID
|
106 |
+
$poll_id = (int) get_option('poll_currentpoll');
|
107 |
+
}
|
108 |
+
break;
|
109 |
+
// Take Poll ID From Arguments
|
110 |
+
default:
|
111 |
+
$poll_id = $temp_poll_id;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
// Assign All Loaded Poll To $polls_loaded
|
116 |
+
if(empty($polls_loaded)) {
|
117 |
+
$polls_loaded = array();
|
118 |
+
}
|
119 |
+
if(!in_array($poll_id, $polls_loaded, true)) {
|
120 |
+
$polls_loaded[] = $poll_id;
|
121 |
+
}
|
122 |
+
|
123 |
+
// User Click on View Results Link
|
124 |
+
if($pollresult_id === $poll_id) {
|
125 |
+
if($display) {
|
126 |
+
echo display_pollresult($poll_id);
|
127 |
+
} else {
|
128 |
+
return display_pollresult($poll_id);
|
129 |
+
}
|
130 |
+
// Check Whether User Has Voted
|
131 |
+
} else {
|
132 |
+
$poll_active = $wpdb->get_var( $wpdb->prepare( "SELECT pollq_active FROM $wpdb->pollsq WHERE pollq_id = %d", $poll_id ) );
|
133 |
+
$poll_active = (int) $poll_active;
|
134 |
+
$check_voted = check_voted( $poll_id );
|
135 |
+
$poll_close = 0;
|
136 |
+
if( $poll_active === 0 ) {
|
137 |
+
$poll_close = (int) get_option( 'poll_close' );
|
138 |
+
}
|
139 |
+
if( $poll_close === 2 ) {
|
140 |
+
if( $display ) {
|
141 |
+
echo '';
|
142 |
+
} else {
|
143 |
+
return '';
|
144 |
+
}
|
145 |
+
}
|
146 |
+
if( $poll_close === 1 || (int) $check_voted > 0 || ( is_array( $check_voted ) && count( $check_voted ) > 0 ) ) {
|
147 |
+
if($display) {
|
148 |
+
echo display_pollresult($poll_id, $check_voted);
|
149 |
+
} else {
|
150 |
+
return display_pollresult($poll_id, $check_voted);
|
151 |
+
}
|
152 |
+
} elseif( $poll_close === 3 || ! check_allowtovote() ) {
|
153 |
+
$disable_poll_js = '<script type="text/javascript">jQuery("#polls_form_'.$poll_id.' :input").each(function (i){jQuery(this).attr("disabled","disabled")});</script>';
|
154 |
+
if($display) {
|
155 |
+
echo display_pollvote($poll_id).$disable_poll_js;
|
156 |
+
} else {
|
157 |
+
return display_pollvote($poll_id).$disable_poll_js;
|
158 |
+
}
|
159 |
+
} elseif( $poll_active === 1 ) {
|
160 |
+
if($display) {
|
161 |
+
echo display_pollvote($poll_id);
|
162 |
+
} else {
|
163 |
+
return display_pollvote($poll_id);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
|
|
167 |
}
|
168 |
|
169 |
|
170 |
### Function: Enqueue Polls JavaScripts/CSS
|
171 |
add_action('wp_enqueue_scripts', 'poll_scripts');
|
172 |
function poll_scripts() {
|
173 |
+
if(@file_exists(get_stylesheet_directory().'/polls-css.css')) {
|
174 |
+
wp_enqueue_style('wp-polls', get_stylesheet_directory_uri().'/polls-css.css', false, WP_POLLS_VERSION, 'all');
|
175 |
+
} else {
|
176 |
+
wp_enqueue_style('wp-polls', plugins_url('wp-polls/polls-css.css'), false, WP_POLLS_VERSION, 'all');
|
177 |
+
}
|
178 |
+
if( is_rtl() ) {
|
179 |
+
if(@file_exists(get_stylesheet_directory().'/polls-css-rtl.css')) {
|
180 |
+
wp_enqueue_style('wp-polls-rtl', get_stylesheet_directory_uri().'/polls-css-rtl.css', false, WP_POLLS_VERSION, 'all');
|
181 |
+
} else {
|
182 |
+
wp_enqueue_style('wp-polls-rtl', plugins_url('wp-polls/polls-css-rtl.css'), false, WP_POLLS_VERSION, 'all');
|
183 |
+
}
|
184 |
+
}
|
185 |
+
$pollbar = get_option( 'poll_bar' );
|
186 |
+
if( $pollbar['style'] === 'use_css' ) {
|
187 |
+
$pollbar_css = '.wp-polls .pollbar {'."\n";
|
188 |
+
$pollbar_css .= "\t".'margin: 1px;'."\n";
|
189 |
+
$pollbar_css .= "\t".'font-size: '.($pollbar['height']-2).'px;'."\n";
|
190 |
+
$pollbar_css .= "\t".'line-height: '.$pollbar['height'].'px;'."\n";
|
191 |
+
$pollbar_css .= "\t".'height: '.$pollbar['height'].'px;'."\n";
|
192 |
+
$pollbar_css .= "\t".'background: #'.$pollbar['background'].';'."\n";
|
193 |
+
$pollbar_css .= "\t".'border: 1px solid #'.$pollbar['border'].';'."\n";
|
194 |
+
$pollbar_css .= '}'."\n";
|
195 |
+
} else {
|
196 |
+
$pollbar_css = '.wp-polls .pollbar {'."\n";
|
197 |
+
$pollbar_css .= "\t".'margin: 1px;'."\n";
|
198 |
+
$pollbar_css .= "\t".'font-size: '.($pollbar['height']-2).'px;'."\n";
|
199 |
+
$pollbar_css .= "\t".'line-height: '.$pollbar['height'].'px;'."\n";
|
200 |
+
$pollbar_css .= "\t".'height: '.$pollbar['height'].'px;'."\n";
|
201 |
+
$pollbar_css .= "\t".'background-image: url(\''.plugins_url('wp-polls/images/'.$pollbar['style'].'/pollbg.gif').'\');'."\n";
|
202 |
+
$pollbar_css .= "\t".'border: 1px solid #'.$pollbar['border'].';'."\n";
|
203 |
+
$pollbar_css .= '}'."\n";
|
204 |
+
}
|
205 |
+
wp_add_inline_style( 'wp-polls', $pollbar_css );
|
206 |
+
$poll_ajax_style = get_option('poll_ajax_style');
|
207 |
+
wp_enqueue_script('wp-polls', plugins_url('wp-polls/polls-js.js'), array('jquery'), WP_POLLS_VERSION, true);
|
208 |
+
wp_localize_script('wp-polls', 'pollsL10n', array(
|
209 |
+
'ajax_url' => admin_url('admin-ajax.php'),
|
210 |
+
'text_wait' => __('Your last request is still being processed. Please wait a while ...', 'wp-polls'),
|
211 |
+
'text_valid' => __('Please choose a valid poll answer.', 'wp-polls'),
|
212 |
+
'text_multiple' => __('Maximum number of choices allowed: ', 'wp-polls'),
|
213 |
+
'show_loading' => (int) $poll_ajax_style['loading'],
|
214 |
+
'show_fading' => (int) $poll_ajax_style['fading']
|
215 |
+
));
|
216 |
}
|
217 |
|
218 |
|
219 |
### Function: Enqueue Polls Stylesheets/JavaScripts In WP-Admin
|
220 |
add_action('admin_enqueue_scripts', 'poll_scripts_admin');
|
221 |
function poll_scripts_admin($hook_suffix) {
|
222 |
+
$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');
|
223 |
+
if(in_array($hook_suffix, $poll_admin_pages, true)) {
|
224 |
+
wp_enqueue_style('wp-polls-admin', plugins_url('wp-polls/polls-admin-css.css'), false, WP_POLLS_VERSION, 'all');
|
225 |
+
wp_enqueue_script('wp-polls-admin', plugins_url('wp-polls/polls-admin-js.js'), array('jquery'), WP_POLLS_VERSION, true);
|
226 |
+
wp_localize_script('wp-polls-admin', 'pollsAdminL10n', array(
|
227 |
+
'admin_ajax_url' => admin_url('admin-ajax.php'),
|
228 |
+
'text_direction' => is_rtl() ? 'right' : 'left',
|
229 |
+
'text_delete_poll' => __('Delete Poll', 'wp-polls'),
|
230 |
+
'text_no_poll_logs' => __('No poll logs available.', 'wp-polls'),
|
231 |
+
'text_delete_all_logs' => __('Delete All Logs', 'wp-polls'),
|
232 |
+
'text_checkbox_delete_all_logs' => __('Please check the \\\'Yes\\\' checkbox if you want to delete all logs.', 'wp-polls'),
|
233 |
+
'text_delete_poll_logs' => __('Delete Logs For This Poll Only', 'wp-polls'),
|
234 |
+
'text_checkbox_delete_poll_logs' => __('Please check the \\\'Yes\\\' checkbox if you want to delete all logs for this poll ONLY.', 'wp-polls'),
|
235 |
+
'text_delete_poll_ans' => __('Delete Poll Answer', 'wp-polls'),
|
236 |
+
'text_open_poll' => __('Open Poll', 'wp-polls'),
|
237 |
+
'text_close_poll' => __('Close Poll', 'wp-polls'),
|
238 |
+
'text_answer' => __('Answer', 'wp-polls'),
|
239 |
+
'text_remove_poll_answer' => __('Remove', 'wp-polls')
|
240 |
+
));
|
241 |
+
}
|
242 |
}
|
243 |
|
244 |
|
249 |
add_action('admin_footer-page.php', 'poll_footer_admin');
|
250 |
function poll_footer_admin() {
|
251 |
?>
|
252 |
+
<script type="text/javascript">
|
253 |
+
QTags.addButton('ed_wp_polls', '<?php echo esc_js(__('Poll', 'wp-polls')); ?>', function() {
|
254 |
+
var poll_id = jQuery.trim(prompt('<?php echo esc_js(__('Enter Poll ID', 'wp-polls')); ?>'));
|
255 |
+
while(isNaN(poll_id)) {
|
256 |
+
poll_id = jQuery.trim(prompt("<?php echo esc_js(__('Error: Poll ID must be numeric', 'wp-polls')); ?>\n\n<?php echo esc_js(__('Please enter Poll ID again', 'wp-polls')); ?>"));
|
257 |
+
}
|
258 |
+
if (poll_id >= -1 && poll_id != null && poll_id != "") {
|
259 |
+
QTags.insertContent('[poll id="' + poll_id + '"]');
|
260 |
+
}
|
261 |
+
});
|
262 |
+
</script>
|
263 |
<?php
|
264 |
}
|
265 |
|
266 |
### Function: Add Quick Tag For Poll In TinyMCE >= WordPress 2.5
|
267 |
add_action('init', 'poll_tinymce_addbuttons');
|
268 |
function poll_tinymce_addbuttons() {
|
269 |
+
if(!current_user_can('edit_posts') && ! current_user_can('edit_pages')) {
|
270 |
+
return;
|
271 |
+
}
|
272 |
+
if(get_user_option('rich_editing') === 'true') {
|
273 |
+
add_filter('mce_external_plugins', 'poll_tinymce_addplugin');
|
274 |
+
add_filter('mce_buttons', 'poll_tinymce_registerbutton');
|
275 |
+
add_filter('wp_mce_translation', 'poll_tinymce_translation');
|
276 |
+
}
|
277 |
}
|
278 |
function poll_tinymce_registerbutton($buttons) {
|
279 |
+
array_push($buttons, 'separator', 'polls');
|
280 |
+
return $buttons;
|
281 |
}
|
282 |
function poll_tinymce_addplugin($plugin_array) {
|
283 |
+
if(WP_DEBUG) {
|
284 |
+
$plugin_array['polls'] = plugins_url( 'wp-polls/tinymce/plugins/polls/plugin.js?v=' . WP_POLLS_VERSION );
|
285 |
+
} else {
|
286 |
+
$plugin_array['polls'] = plugins_url( 'wp-polls/tinymce/plugins/polls/plugin.min.js?v=' . WP_POLLS_VERSION );
|
287 |
+
}
|
288 |
+
return $plugin_array;
|
289 |
}
|
290 |
function poll_tinymce_translation($mce_translation) {
|
291 |
+
$mce_translation['Enter Poll ID'] = esc_js(__('Enter Poll ID', 'wp-polls'));
|
292 |
+
$mce_translation['Error: Poll ID must be numeric'] = esc_js(__('Error: Poll ID must be numeric', 'wp-polls'));
|
293 |
+
$mce_translation['Please enter Poll ID again'] = esc_js(__('Please enter Poll ID again', 'wp-polls'));
|
294 |
+
$mce_translation['Insert Poll'] = esc_js(__('Insert Poll', 'wp-polls'));
|
295 |
+
return $mce_translation;
|
296 |
}
|
297 |
|
298 |
|
299 |
### Function: Check Who Is Allow To Vote
|
300 |
function check_allowtovote() {
|
301 |
+
global $user_ID;
|
302 |
+
$user_ID = (int) $user_ID;
|
303 |
+
$allow_to_vote = (int) get_option( 'poll_allowtovote' );
|
304 |
+
switch($allow_to_vote) {
|
305 |
+
// Guests Only
|
306 |
+
case 0:
|
307 |
+
if($user_ID > 0) {
|
308 |
+
return false;
|
309 |
+
}
|
310 |
+
return true;
|
311 |
+
break;
|
312 |
+
// Registered Users Only
|
313 |
+
case 1:
|
314 |
+
if($user_ID === 0) {
|
315 |
+
return false;
|
316 |
+
}
|
317 |
+
return true;
|
318 |
+
break;
|
319 |
+
// Registered Users And Guests
|
320 |
+
case 2:
|
321 |
+
default:
|
322 |
+
return true;
|
323 |
+
}
|
324 |
}
|
325 |
|
326 |
|
327 |
### Funcrion: Check Voted By Cookie Or IP
|
328 |
function check_voted($poll_id) {
|
329 |
+
$poll_logging_method = (int) get_option( 'poll_logging_method' );
|
330 |
+
switch($poll_logging_method) {
|
331 |
+
// Do Not Log
|
332 |
+
case 0:
|
333 |
+
return 0;
|
334 |
+
break;
|
335 |
+
// Logged By Cookie
|
336 |
+
case 1:
|
337 |
+
return check_voted_cookie($poll_id);
|
338 |
+
break;
|
339 |
+
// Logged By IP
|
340 |
+
case 2:
|
341 |
+
return check_voted_ip($poll_id);
|
342 |
+
break;
|
343 |
+
// Logged By Cookie And IP
|
344 |
+
case 3:
|
345 |
+
$check_voted_cookie = check_voted_cookie($poll_id);
|
346 |
+
if(!empty($check_voted_cookie)) {
|
347 |
+
return $check_voted_cookie;
|
348 |
+
}
|
349 |
+
|
350 |
+
return check_voted_ip($poll_id);
|
351 |
+
break;
|
352 |
+
// Logged By Username
|
353 |
+
case 4:
|
354 |
+
return check_voted_username($poll_id);
|
355 |
+
break;
|
356 |
+
}
|
357 |
}
|
358 |
|
359 |
|
360 |
### Function: Check Voted By Cookie
|
361 |
+
function check_voted_cookie( $poll_id ) {
|
362 |
+
$get_voted_aids = 0;
|
363 |
+
if ( ! empty( $_COOKIE[ 'voted_' . $poll_id ] ) ) {
|
364 |
+
$get_voted_aids = explode( ',', $_COOKIE[ 'voted_' . $poll_id ] );
|
365 |
+
$get_voted_aids = array_map( 'intval', array_map( 'sanitize_key', $get_voted_aids ) );
|
366 |
+
}
|
367 |
+
|
368 |
+
return $get_voted_aids;
|
369 |
}
|
370 |
|
371 |
|
372 |
### Function: Check Voted By IP
|
373 |
function check_voted_ip( $poll_id ) {
|
374 |
+
global $wpdb;
|
375 |
+
$log_expiry = (int) get_option( 'poll_cookielog_expiry' );
|
376 |
+
$log_expiry_sql = '';
|
377 |
+
if( $log_expiry > 0 ) {
|
378 |
+
$log_expiry_sql = 'AND (' . current_time('timestamp') . '-(pollip_timestamp+0)) < ' . $log_expiry;
|
379 |
+
}
|
380 |
+
// Check IP From IP Logging Database
|
381 |
+
$get_voted_aids = $wpdb->get_col( $wpdb->prepare( "SELECT pollip_aid FROM $wpdb->pollsip WHERE pollip_qid = %d AND pollip_ip = %s", $poll_id, get_ipaddress() ) . $log_expiry_sql );
|
382 |
+
if( $get_voted_aids ) {
|
383 |
+
return $get_voted_aids;
|
384 |
+
}
|
385 |
+
|
386 |
+
return 0;
|
387 |
}
|
388 |
|
389 |
|
390 |
### Function: Check Voted By Username
|
391 |
function check_voted_username($poll_id) {
|
392 |
+
global $wpdb, $user_ID;
|
393 |
+
// Check IP If User Is Guest
|
394 |
+
if ( ! is_user_logged_in() ) {
|
395 |
+
return 1;
|
396 |
+
}
|
397 |
+
$pollsip_userid = (int) $user_ID;
|
398 |
+
$log_expiry = (int) get_option( 'poll_cookielog_expiry' );
|
399 |
+
$log_expiry_sql = '';
|
400 |
+
if( $log_expiry > 0 ) {
|
401 |
+
$log_expiry_sql = 'AND (' . current_time('timestamp') . '-(pollip_timestamp+0)) < ' . $log_expiry;
|
402 |
+
}
|
403 |
+
// Check User ID From IP Logging Database
|
404 |
+
$get_voted_aids = $wpdb->get_col( $wpdb->prepare( "SELECT pollip_aid FROM $wpdb->pollsip WHERE pollip_qid = %d AND pollip_userid = %d", $poll_id, $pollsip_userid ) . $log_expiry_sql );
|
405 |
+
if($get_voted_aids) {
|
406 |
+
return $get_voted_aids;
|
407 |
+
} else {
|
408 |
+
return 0;
|
409 |
+
}
|
410 |
}
|
411 |
|
412 |
add_filter('poll_template_voteheader_markup', 'poll_template_vote_markup', 10, 3);
|
415 |
|
416 |
function poll_template_vote_markup($template, $poll_db_object, $variables) {
|
417 |
|
418 |
+
foreach($variables as $placeholder => $value) {
|
419 |
+
$template = str_replace($placeholder, $value, $template);
|
420 |
+
}
|
421 |
|
422 |
+
return $template;
|
423 |
}
|
424 |
|
425 |
|
426 |
### Function: Display Voting Form
|
427 |
function display_pollvote($poll_id, $display_loading = true) {
|
428 |
+
do_action('wp_polls_display_pollvote');
|
429 |
+
global $wpdb;
|
430 |
+
// Temp Poll Result
|
431 |
+
$temp_pollvote = '';
|
432 |
+
// Get Poll Question Data
|
433 |
+
$poll_question = $wpdb->get_row( $wpdb->prepare( "SELECT pollq_id, pollq_question, pollq_totalvotes, pollq_timestamp, pollq_expiry, pollq_multiple, pollq_totalvoters FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $poll_id ) );
|
434 |
+
|
435 |
+
// Poll Question Variables
|
436 |
+
$poll_question_text = wp_kses_post( removeslashes( $poll_question->pollq_question ) );
|
437 |
+
$poll_question_id = (int) $poll_question->pollq_id;
|
438 |
+
$poll_question_totalvotes = (int) $poll_question->pollq_totalvotes;
|
439 |
+
$poll_question_totalvoters = (int) $poll_question->pollq_totalvoters;
|
440 |
+
$poll_start_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_question->pollq_timestamp));
|
441 |
+
$poll_expiry = trim($poll_question->pollq_expiry);
|
442 |
+
if(empty($poll_expiry)) {
|
443 |
+
$poll_end_date = __('No Expiry', 'wp-polls');
|
444 |
+
} else {
|
445 |
+
$poll_end_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_expiry));
|
446 |
+
}
|
447 |
+
$poll_multiple_ans = (int) $poll_question->pollq_multiple;
|
448 |
+
|
449 |
+
$template_question = removeslashes(get_option('poll_template_voteheader'));
|
450 |
+
|
451 |
+
$template_question = apply_filters('poll_template_voteheader_markup', $template_question, $poll_question, array(
|
452 |
+
'%POLL_QUESTION%' => $poll_question_text,
|
453 |
+
'%POLL_ID%' => $poll_question_id,
|
454 |
+
'%POLL_TOTALVOTES%' => $poll_question_totalvotes,
|
455 |
+
'%POLL_TOTALVOTERS%' => $poll_question_totalvoters,
|
456 |
+
'%POLL_START_DATE%' => $poll_start_date,
|
457 |
+
'%POLL_END_DATE%' => $poll_end_date,
|
458 |
+
'%POLL_MULTIPLE_ANS_MAX%' => $poll_multiple_ans > 0 ? $poll_multiple_ans : 1
|
459 |
+
));
|
460 |
+
|
461 |
+
// Get Poll Answers Data
|
462 |
+
list($order_by, $sort_order) = _polls_get_ans_sort();
|
463 |
+
$poll_answers = $wpdb->get_results( $wpdb->prepare( "SELECT polla_aid, polla_qid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = %d ORDER BY $order_by $sort_order", $poll_question_id ) );
|
464 |
+
// If There Is Poll Question With Answers
|
465 |
+
if($poll_question && $poll_answers) {
|
466 |
+
// Display Poll Voting Form
|
467 |
+
$temp_pollvote .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
|
468 |
+
$temp_pollvote .= "\t<form id=\"polls_form_$poll_question_id\" class=\"wp-polls-form\" action=\"" . sanitize_text_field( _SERVER['SCRIPT_NAME'] ) ."\" method=\"post\">\n";
|
469 |
+
$temp_pollvote .= "\t\t<p style=\"display: none;\"><input type=\"hidden\" id=\"poll_{$poll_question_id}_nonce\" name=\"wp-polls-nonce\" value=\"".wp_create_nonce('poll_'.$poll_question_id.'-nonce')."\" /></p>\n";
|
470 |
+
$temp_pollvote .= "\t\t<p style=\"display: none;\"><input type=\"hidden\" name=\"poll_id\" value=\"$poll_question_id\" /></p>\n";
|
471 |
+
if($poll_multiple_ans > 0) {
|
472 |
+
$temp_pollvote .= "\t\t<p style=\"display: none;\"><input type=\"hidden\" id=\"poll_multiple_ans_$poll_question_id\" name=\"poll_multiple_ans_$poll_question_id\" value=\"$poll_multiple_ans\" /></p>\n";
|
473 |
+
}
|
474 |
+
// Print Out Voting Form Header Template
|
475 |
+
$temp_pollvote .= "\t\t$template_question\n";
|
476 |
+
foreach($poll_answers as $poll_answer) {
|
477 |
+
// Poll Answer Variables
|
478 |
+
$poll_answer_id = (int) $poll_answer->polla_aid;
|
479 |
+
$poll_answer_text = wp_kses_post( removeslashes( $poll_answer->polla_answers ) );
|
480 |
+
$poll_answer_votes = (int) $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(
|
485 |
+
'%POLL_ID%' => $poll_question_id,
|
486 |
+
'%POLL_ANSWER_ID%' => $poll_answer_id,
|
487 |
+
'%POLL_ANSWER%' => $poll_answer_text,
|
488 |
+
'%POLL_ANSWER_VOTES%' => number_format_i18n($poll_answer_votes),
|
489 |
+
'%POLL_ANSWER_PERCENTAGE%' => $poll_answer_percentage,
|
490 |
+
"%POLL_CHECKBOX_RADIO%" => $poll_multiple_ans > 0 ? 'checkbox' : 'radio'
|
491 |
+
));
|
492 |
+
|
493 |
+
// Print Out Voting Form Body Template
|
494 |
+
$temp_pollvote .= "\t\t$template_answer\n";
|
495 |
+
}
|
496 |
+
// Determine Poll Result URL
|
497 |
+
$poll_result_url = esc_url_raw( $_SERVER['REQUEST_URI'] );
|
498 |
+
$poll_result_url = preg_replace('/pollresult=(\d+)/i', 'pollresult='.$poll_question_id, $poll_result_url);
|
499 |
+
if(isset($_GET['pollresult']) && (int) $_GET['pollresult'] === 0) {
|
500 |
+
if(strpos($poll_result_url, '?') !== false) {
|
501 |
+
$poll_result_url = "$poll_result_url&pollresult=$poll_question_id";
|
502 |
+
} else {
|
503 |
+
$poll_result_url = "$poll_result_url?pollresult=$poll_question_id";
|
504 |
+
}
|
505 |
+
}
|
506 |
+
// Voting Form Footer Variables
|
507 |
+
$template_footer = removeslashes(get_option('poll_template_votefooter'));
|
508 |
+
|
509 |
+
$template_footer = apply_filters('poll_template_votefooter_markup', $template_footer, $poll_question, array(
|
510 |
+
'%POLL_ID%' => $poll_question_id,
|
511 |
+
'%POLL_RESULT_URL%' => $poll_result_url,
|
512 |
+
'%POLL_START_DATE%' => $poll_start_date,
|
513 |
+
'%POLL_END_DATE%' => $poll_end_date,
|
514 |
+
'%POLL_MULTIPLE_ANS_MAX%' => $poll_multiple_ans > 0 ? $poll_multiple_ans : 1
|
515 |
+
));
|
516 |
+
|
517 |
+
// Print Out Voting Form Footer Template
|
518 |
+
$temp_pollvote .= "\t\t$template_footer\n";
|
519 |
+
$temp_pollvote .= "\t</form>\n";
|
520 |
+
$temp_pollvote .= "</div>\n";
|
521 |
+
if($display_loading) {
|
522 |
+
$poll_ajax_style = get_option('poll_ajax_style');
|
523 |
+
if((int) $poll_ajax_style['loading'] === 1) {
|
524 |
+
$temp_pollvote .= "<div id=\"polls-$poll_question_id-loading\" class=\"wp-polls-loading\"><img src=\"".plugins_url('wp-polls/images/loading.gif')."\" width=\"16\" height=\"16\" alt=\"".__('Loading', 'wp-polls')." ...\" title=\"".__('Loading', 'wp-polls')." ...\" class=\"wp-polls-image\" /> ".__('Loading', 'wp-polls')." ...</div>\n";
|
525 |
+
}
|
526 |
+
}
|
527 |
+
} else {
|
528 |
+
$temp_pollvote .= removeslashes(get_option('poll_template_disable'));
|
529 |
+
}
|
530 |
+
// Return Poll Vote Template
|
531 |
+
return $temp_pollvote;
|
532 |
}
|
533 |
|
534 |
|
535 |
### Function: Display Results Form
|
536 |
function display_pollresult($poll_id, $user_voted = '', $display_loading = true) {
|
537 |
+
do_action('wp_polls_display_pollresult');
|
538 |
+
global $wpdb;
|
539 |
+
$poll_id = (int) $poll_id;
|
540 |
+
// User Voted
|
541 |
+
if( empty( $user_voted ) ) {
|
542 |
+
$user_voted = array();
|
543 |
+
}
|
544 |
+
// Temp Poll Result
|
545 |
+
$temp_pollresult = '';
|
546 |
+
// Most/Least Variables
|
547 |
+
$poll_most_answer = '';
|
548 |
+
$poll_most_votes = 0;
|
549 |
+
$poll_most_percentage = 0;
|
550 |
+
$poll_least_answer = '';
|
551 |
+
$poll_least_votes = 0;
|
552 |
+
$poll_least_percentage = 0;
|
553 |
+
// Get Poll Question Data
|
554 |
+
$poll_question = $wpdb->get_row( $wpdb->prepare( "SELECT pollq_id, pollq_question, pollq_totalvotes, pollq_active, pollq_timestamp, pollq_expiry, pollq_multiple, pollq_totalvoters FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $poll_id ) );
|
555 |
+
// No poll could be loaded from the database
|
556 |
+
if (!$poll_question) {
|
557 |
+
return removeslashes(get_option('poll_template_disable'));
|
558 |
+
}
|
559 |
+
// Poll Question Variables
|
560 |
+
$poll_question_text = wp_kses_post( removeslashes( $poll_question->pollq_question ) );
|
561 |
+
$poll_question_id = (int) $poll_question->pollq_id;
|
562 |
+
$poll_question_totalvotes = (int) $poll_question->pollq_totalvotes;
|
563 |
+
$poll_question_totalvoters = (int) $poll_question->pollq_totalvoters;
|
564 |
+
$poll_question_active = (int) $poll_question->pollq_active;
|
565 |
+
$poll_start_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_question->pollq_timestamp));
|
566 |
+
$poll_expiry = trim($poll_question->pollq_expiry);
|
567 |
+
if(empty($poll_expiry)) {
|
568 |
+
$poll_end_date = __('No Expiry', 'wp-polls');
|
569 |
+
} else {
|
570 |
+
$poll_end_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $poll_expiry));
|
571 |
+
}
|
572 |
+
$poll_multiple_ans = (int) $poll_question->pollq_multiple;
|
573 |
+
$template_question = removeslashes(get_option('poll_template_resultheader'));
|
574 |
+
$template_question = str_replace("%POLL_QUESTION%", $poll_question_text, $template_question);
|
575 |
+
$template_question = str_replace("%POLL_ID%", $poll_question_id, $template_question);
|
576 |
+
$template_question = str_replace("%POLL_TOTALVOTES%", $poll_question_totalvotes, $template_question);
|
577 |
+
$template_question = str_replace("%POLL_TOTALVOTERS%", $poll_question_totalvoters, $template_question);
|
578 |
+
$template_question = str_replace("%POLL_START_DATE%", $poll_start_date, $template_question);
|
579 |
+
$template_question = str_replace("%POLL_END_DATE%", $poll_end_date, $template_question);
|
580 |
+
if($poll_multiple_ans > 0) {
|
581 |
+
$template_question = str_replace("%POLL_MULTIPLE_ANS_MAX%", $poll_multiple_ans, $template_question);
|
582 |
+
} else {
|
583 |
+
$template_question = str_replace("%POLL_MULTIPLE_ANS_MAX%", '1', $template_question);
|
584 |
+
}
|
585 |
+
// Get Poll Answers Data
|
586 |
+
list($order_by, $sort_order) = _polls_get_ans_result_sort();
|
587 |
+
$poll_answers = $wpdb->get_results( $wpdb->prepare( "SELECT polla_aid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid = %d ORDER BY $order_by $sort_order", $poll_question_id ) );
|
588 |
+
// If There Is Poll Question With Answers
|
589 |
+
if($poll_question && $poll_answers) {
|
590 |
+
// Store The Percentage Of The Poll
|
591 |
+
$poll_answer_percentage_array = array();
|
592 |
+
// Is The Poll Total Votes 0?
|
593 |
+
$poll_totalvotes_zero = true;
|
594 |
+
if($poll_question_totalvotes > 0) {
|
595 |
+
$poll_totalvotes_zero = false;
|
596 |
+
}
|
597 |
+
// Print Out Result Header Template
|
598 |
+
$temp_pollresult .= "<div id=\"polls-$poll_question_id\" class=\"wp-polls\">\n";
|
599 |
+
$temp_pollresult .= "\t\t$template_question\n";
|
600 |
+
foreach($poll_answers as $poll_answer) {
|
601 |
+
// Poll Answer Variables
|
602 |
+
$poll_answer_id = (int) $poll_answer->polla_aid;
|
603 |
+
$poll_answer_text = wp_kses_post( removeslashes($poll_answer->polla_answers) );
|
604 |
+
$poll_answer_votes = (int) $poll_answer->polla_votes;
|
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;
|
612 |
+
}
|
613 |
+
} else {
|
614 |
+
$poll_answer_percentage = 0;
|
615 |
+
$poll_answer_imagewidth = 1;
|
616 |
+
}
|
617 |
+
} else {
|
618 |
+
$poll_answer_percentage = 0;
|
619 |
+
$poll_answer_imagewidth = 1;
|
620 |
+
}
|
621 |
+
// Make Sure That Total Percentage Is 100% By Adding A Buffer To The Last Poll Answer
|
622 |
+
$round_percentage = apply_filters( 'wp_polls_round_percentage', false );
|
623 |
+
if( $round_percentage ) {
|
624 |
+
if ( $poll_multiple_ans === 0 ) {
|
625 |
+
$poll_answer_percentage_array[] = $poll_answer_percentage;
|
626 |
+
if ( count( $poll_answer_percentage_array ) === count( $poll_answers ) ) {
|
627 |
+
$percentage_error_buffer = 100 - array_sum( $poll_answer_percentage_array );
|
628 |
+
$poll_answer_percentage += $percentage_error_buffer;
|
629 |
+
if ( $poll_answer_percentage < 0 ) {
|
630 |
+
$poll_answer_percentage = 0;
|
631 |
+
}
|
632 |
+
}
|
633 |
+
}
|
634 |
+
}
|
635 |
+
|
636 |
+
// Let User See What Options They Voted
|
637 |
+
if(in_array($poll_answer_id, $user_voted, true)) {
|
638 |
+
// Results Body Variables
|
639 |
+
$template_answer = removeslashes(get_option('poll_template_resultbody2'));
|
640 |
+
$template_answer = str_replace("%POLL_ID%", $poll_question_id, $template_answer);
|
641 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
|
642 |
+
$template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
|
643 |
+
$template_answer = str_replace("%POLL_ANSWER_TEXT%", htmlspecialchars(strip_tags($poll_answer_text)), $template_answer);
|
644 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format_i18n($poll_answer_votes), $template_answer);
|
645 |
+
$template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
|
646 |
+
$template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
|
647 |
+
// Print Out Results Body Template
|
648 |
+
$temp_pollresult .= "\t\t$template_answer\n";
|
649 |
+
} else {
|
650 |
+
// Results Body Variables
|
651 |
+
$template_answer = removeslashes(get_option('poll_template_resultbody'));
|
652 |
+
$template_answer = str_replace("%POLL_ID%", $poll_question_id, $template_answer);
|
653 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $poll_answer_id, $template_answer);
|
654 |
+
$template_answer = str_replace("%POLL_ANSWER%", $poll_answer_text, $template_answer);
|
655 |
+
$template_answer = str_replace("%POLL_ANSWER_TEXT%", htmlspecialchars(strip_tags($poll_answer_text)), $template_answer);
|
656 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format_i18n($poll_answer_votes), $template_answer);
|
657 |
+
$template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
|
658 |
+
$template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
|
659 |
+
// Print Out Results Body Template
|
660 |
+
$temp_pollresult .= "\t\t$template_answer\n";
|
661 |
+
}
|
662 |
+
// Get Most Voted Data
|
663 |
+
if($poll_answer_votes > $poll_most_votes) {
|
664 |
+
$poll_most_answer = $poll_answer_text;
|
665 |
+
$poll_most_votes = $poll_answer_votes;
|
666 |
+
$poll_most_percentage = $poll_answer_percentage;
|
667 |
+
}
|
668 |
+
// Get Least Voted Data
|
669 |
+
if($poll_least_votes === 0) {
|
670 |
+
$poll_least_votes = $poll_answer_votes;
|
671 |
+
}
|
672 |
+
if($poll_answer_votes <= $poll_least_votes) {
|
673 |
+
$poll_least_answer = $poll_answer_text;
|
674 |
+
$poll_least_votes = $poll_answer_votes;
|
675 |
+
$poll_least_percentage = $poll_answer_percentage;
|
676 |
+
}
|
677 |
+
}
|
678 |
+
// Results Footer Variables
|
679 |
+
if(!empty($user_voted) || $poll_question_active === 0 || !check_allowtovote()) {
|
680 |
+
$template_footer = removeslashes(get_option('poll_template_resultfooter'));
|
681 |
+
} else {
|
682 |
+
$template_footer = removeslashes(get_option('poll_template_resultfooter2'));
|
683 |
+
}
|
684 |
+
$template_footer = str_replace("%POLL_START_DATE%", $poll_start_date, $template_footer);
|
685 |
+
$template_footer = str_replace("%POLL_END_DATE%", $poll_end_date, $template_footer);
|
686 |
+
$template_footer = str_replace("%POLL_ID%", $poll_question_id, $template_footer);
|
687 |
+
$template_footer = str_replace("%POLL_TOTALVOTES%", number_format_i18n($poll_question_totalvotes), $template_footer);
|
688 |
+
$template_footer = str_replace("%POLL_TOTALVOTERS%", number_format_i18n($poll_question_totalvoters), $template_footer);
|
689 |
+
$template_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_footer);
|
690 |
+
$template_footer = str_replace("%POLL_MOST_VOTES%", number_format_i18n($poll_most_votes), $template_footer);
|
691 |
+
$template_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_footer);
|
692 |
+
$template_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_footer);
|
693 |
+
$template_footer = str_replace("%POLL_LEAST_VOTES%", number_format_i18n($poll_least_votes), $template_footer);
|
694 |
+
$template_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_footer);
|
695 |
+
if($poll_multiple_ans > 0) {
|
696 |
+
$template_footer = str_replace("%POLL_MULTIPLE_ANS_MAX%", $poll_multiple_ans, $template_footer);
|
697 |
+
} else {
|
698 |
+
$template_footer = str_replace("%POLL_MULTIPLE_ANS_MAX%", '1', $template_footer);
|
699 |
+
}
|
700 |
+
// Print Out Results Footer Template
|
701 |
+
$temp_pollresult .= "\t\t$template_footer\n";
|
702 |
+
$temp_pollresult .= "\t\t<input type=\"hidden\" id=\"poll_{$poll_question_id}_nonce\" name=\"wp-polls-nonce\" value=\"".wp_create_nonce('poll_'.$poll_question_id.'-nonce')."\" />\n";
|
703 |
+
$temp_pollresult .= "</div>\n";
|
704 |
+
if($display_loading) {
|
705 |
+
$poll_ajax_style = get_option('poll_ajax_style');
|
706 |
+
if((int) $poll_ajax_style['loading'] == 1) {
|
707 |
+
$temp_pollresult .= "<div id=\"polls-$poll_question_id-loading\" class=\"wp-polls-loading\"><img src=\"".plugins_url('wp-polls/images/loading.gif')."\" width=\"16\" height=\"16\" alt=\"".__('Loading', 'wp-polls')." ...\" title=\"".__('Loading', 'wp-polls')." ...\" class=\"wp-polls-image\" /> ".__('Loading', 'wp-polls')." ...</div>\n";
|
708 |
+
}
|
709 |
+
}
|
710 |
+
} else {
|
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 |
|
718 |
### Function: Get IP Address
|
719 |
if(!function_exists('get_ipaddress')) {
|
720 |
+
function get_ipaddress() {
|
721 |
+
foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
|
722 |
+
if ( array_key_exists( $key, $_SERVER ) === true ) {
|
723 |
+
foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
|
724 |
+
$ip = trim( $ip );
|
725 |
+
if ( filter_var( $ip, FILTER_VALIDATE_IP ) !== false ) {
|
726 |
+
return esc_attr( $ip );
|
727 |
+
}
|
728 |
+
}
|
729 |
+
}
|
730 |
+
}
|
731 |
+
}
|
732 |
}
|
733 |
|
734 |
|
735 |
### Function: Short Code For Inserting Polls Archive Into Page
|
736 |
add_shortcode('page_polls', 'poll_page_shortcode');
|
737 |
function poll_page_shortcode($atts) {
|
738 |
+
return polls_archive();
|
739 |
}
|
740 |
|
741 |
|
742 |
### Function: Short Code For Inserting Polls Into Posts
|
743 |
add_shortcode( 'poll', 'poll_shortcode' );
|
744 |
function poll_shortcode( $atts ) {
|
745 |
+
$attributes = shortcode_atts( array( 'id' => 0, 'type' => 'vote' ), $atts );
|
746 |
+
if( ! is_feed() ) {
|
747 |
+
$id = (int) $attributes['id'];
|
748 |
+
|
749 |
+
// To maintain backward compatibility with [poll=1]. Props @tz-ua
|
750 |
+
if( ! $id && isset( $atts[0] ) ) {
|
751 |
+
$id = (int) trim( $atts[0], '="\'' );
|
752 |
+
}
|
753 |
+
|
754 |
+
if( $attributes['type'] === 'vote' ) {
|
755 |
+
return get_poll( $id, false );
|
756 |
+
} elseif( $attributes['type'] === 'result' ) {
|
757 |
+
return display_pollresult( $id );
|
758 |
+
}
|
759 |
+
} else {
|
760 |
+
return __( 'Note: There is a poll embedded within this post, please visit the site to participate in this post\'s poll.', 'wp-polls' );
|
761 |
+
}
|
762 |
}
|
763 |
|
764 |
|
765 |
### Function: Get Poll Question Based On Poll ID
|
766 |
if(!function_exists('get_poll_question')) {
|
767 |
+
function get_poll_question($poll_id) {
|
768 |
+
global $wpdb;
|
769 |
+
$poll_id = (int) $poll_id;
|
770 |
+
$poll_question = $wpdb->get_var( $wpdb->prepare( "SELECT pollq_question FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $poll_id ) );
|
771 |
+
return wp_kses_post( removeslashes( $poll_question ) );
|
772 |
+
}
|
773 |
}
|
774 |
|
775 |
|
776 |
### Function: Get Poll Total Questions
|
777 |
if(!function_exists('get_pollquestions')) {
|
778 |
+
function get_pollquestions($display = true) {
|
779 |
+
global $wpdb;
|
780 |
+
$totalpollq = (int) $wpdb->get_var("SELECT COUNT(pollq_id) FROM $wpdb->pollsq");
|
781 |
+
if($display) {
|
782 |
+
echo $totalpollq;
|
783 |
+
} else {
|
784 |
+
return $totalpollq;
|
785 |
+
}
|
786 |
+
}
|
787 |
}
|
788 |
|
789 |
|
790 |
### Function: Get Poll Total Answers
|
791 |
if(!function_exists('get_pollanswers')) {
|
792 |
+
function get_pollanswers($display = true) {
|
793 |
+
global $wpdb;
|
794 |
+
$totalpolla = (int) $wpdb->get_var("SELECT COUNT(polla_aid) FROM $wpdb->pollsa");
|
795 |
+
if($display) {
|
796 |
+
echo $totalpolla;
|
797 |
+
} else {
|
798 |
+
return $totalpolla;
|
799 |
+
}
|
800 |
+
}
|
801 |
}
|
802 |
|
803 |
|
804 |
### Function: Get Poll Total Votes
|
805 |
if(!function_exists('get_pollvotes')) {
|
806 |
+
function get_pollvotes($display = true) {
|
807 |
+
global $wpdb;
|
808 |
+
$totalvotes = (int) $wpdb->get_var("SELECT SUM(pollq_totalvotes) FROM $wpdb->pollsq");
|
809 |
+
if($display) {
|
810 |
+
echo $totalvotes;
|
811 |
+
} else {
|
812 |
+
return $totalvotes;
|
813 |
+
}
|
814 |
+
}
|
815 |
}
|
816 |
|
817 |
|
818 |
### Function: Get Poll Total Voters
|
819 |
if(!function_exists('get_pollvoters')) {
|
820 |
+
function get_pollvoters($display = true) {
|
821 |
+
global $wpdb;
|
822 |
+
$totalvoters = (int) $wpdb->get_var("SELECT SUM(pollq_totalvoters) FROM $wpdb->pollsq");
|
823 |
+
if($display) {
|
824 |
+
echo $totalvoters;
|
825 |
+
} else {
|
826 |
+
return $totalvoters;
|
827 |
+
}
|
828 |
+
}
|
829 |
}
|
830 |
|
831 |
|
832 |
### Function: Check Voted To Get Voted Answer
|
833 |
function check_voted_multiple($poll_id, $polls_ips) {
|
834 |
+
if(!empty($_COOKIE["voted_$poll_id"])) {
|
835 |
+
return explode(',', $_COOKIE["voted_$poll_id"]);
|
836 |
+
} else {
|
837 |
+
if($polls_ips) {
|
838 |
+
return $polls_ips;
|
839 |
+
} else {
|
840 |
+
return array();
|
841 |
+
}
|
842 |
+
}
|
843 |
}
|
844 |
|
845 |
|
846 |
### Function: Polls Archive Link
|
847 |
function polls_archive_link($page) {
|
848 |
+
$polls_archive_url = get_option('poll_archive_url');
|
849 |
+
if($page > 0) {
|
850 |
+
if(strpos($polls_archive_url, '?') !== false) {
|
851 |
+
$polls_archive_url = "$polls_archive_url&poll_page=$page";
|
852 |
+
} else {
|
853 |
+
$polls_archive_url = "$polls_archive_url?poll_page=$page";
|
854 |
+
}
|
855 |
+
}
|
856 |
+
return $polls_archive_url;
|
857 |
}
|
858 |
|
859 |
|
860 |
### Function: Displays Polls Archive Link
|
861 |
function display_polls_archive_link($display = true) {
|
862 |
+
$template_pollarchivelink = removeslashes(get_option('poll_template_pollarchivelink'));
|
863 |
+
$template_pollarchivelink = str_replace("%POLL_ARCHIVE_URL%", get_option('poll_archive_url'), $template_pollarchivelink);
|
864 |
+
if($display) {
|
865 |
+
echo $template_pollarchivelink;
|
866 |
+
} else{
|
867 |
+
return $template_pollarchivelink;
|
868 |
+
}
|
869 |
}
|
870 |
|
871 |
|
872 |
### Function: Display Polls Archive
|
873 |
function polls_archive() {
|
874 |
+
do_action('wp_polls_polls_archive');
|
875 |
+
global $wpdb, $in_pollsarchive;
|
876 |
+
// Polls Variables
|
877 |
+
$in_pollsarchive = true;
|
878 |
+
$page = isset($_GET['poll_page']) ? (int) sanitize_key( $_GET['poll_page'] ) : 0;
|
879 |
+
$polls_questions = array();
|
880 |
+
$polls_answers = array();
|
881 |
+
$polls_ips = array();
|
882 |
+
$polls_perpage = (int) get_option('poll_archive_perpage');
|
883 |
+
$poll_questions_ids = '0';
|
884 |
+
$poll_voted = false;
|
885 |
+
$poll_voted_aid = 0;
|
886 |
+
$poll_id = 0;
|
887 |
+
$pollsarchive_output_archive = '';
|
888 |
+
$polls_type = (int) get_option('poll_archive_displaypoll');
|
889 |
+
$polls_type_sql = '';
|
890 |
+
// Determine What Type Of Polls To Show
|
891 |
+
switch($polls_type) {
|
892 |
+
case 1:
|
893 |
+
$polls_type_sql = 'pollq_active = 0';
|
894 |
+
break;
|
895 |
+
case 2:
|
896 |
+
$polls_type_sql = 'pollq_active = 1';
|
897 |
+
break;
|
898 |
+
case 3:
|
899 |
+
$polls_type_sql = 'pollq_active IN (0,1)';
|
900 |
+
break;
|
901 |
+
}
|
902 |
+
// Get Total Polls
|
903 |
+
$total_polls = $wpdb->get_var("SELECT COUNT(pollq_id) FROM $wpdb->pollsq WHERE $polls_type_sql AND pollq_active != -1");
|
904 |
+
|
905 |
+
// Calculate Paging
|
906 |
+
$numposts = $total_polls;
|
907 |
+
$perpage = $polls_perpage;
|
908 |
+
$max_page = ceil($numposts/$perpage);
|
909 |
+
if(empty($page) || $page == 0) {
|
910 |
+
$page = 1;
|
911 |
+
}
|
912 |
+
$offset = ($page-1) * $perpage;
|
913 |
+
$pages_to_show = 10;
|
914 |
+
$pages_to_show_minus_1 = $pages_to_show-1;
|
915 |
+
$half_page_start = floor($pages_to_show_minus_1/2);
|
916 |
+
$half_page_end = ceil($pages_to_show_minus_1/2);
|
917 |
+
$start_page = $page - $half_page_start;
|
918 |
+
if($start_page <= 0) {
|
919 |
+
$start_page = 1;
|
920 |
+
}
|
921 |
+
$end_page = $page + $half_page_end;
|
922 |
+
if(($end_page - $start_page) !== $pages_to_show_minus_1) {
|
923 |
+
$end_page = $start_page + $pages_to_show_minus_1;
|
924 |
+
}
|
925 |
+
if($end_page > $max_page) {
|
926 |
+
$start_page = $max_page - $pages_to_show_minus_1;
|
927 |
+
$end_page = $max_page;
|
928 |
+
}
|
929 |
+
if($start_page <= 0) {
|
930 |
+
$start_page = 1;
|
931 |
+
}
|
932 |
+
if(($offset + $perpage) > $numposts) {
|
933 |
+
$max_on_page = $numposts;
|
934 |
+
} else {
|
935 |
+
$max_on_page = ($offset + $perpage);
|
936 |
+
}
|
937 |
+
if (($offset + 1) > ($numposts)) {
|
938 |
+
$display_on_page = $numposts;
|
939 |
+
} else {
|
940 |
+
$display_on_page = ($offset + 1);
|
941 |
+
}
|
942 |
+
|
943 |
+
// Get Poll Questions
|
944 |
+
$questions = $wpdb->get_results("SELECT * FROM $wpdb->pollsq WHERE $polls_type_sql ORDER BY pollq_id DESC LIMIT $offset, $polls_perpage");
|
945 |
+
if($questions) {
|
946 |
+
foreach($questions as $question) {
|
947 |
+
$polls_questions[] = array( 'id' => (int) $question->pollq_id, 'question' => wp_kses_post( removeslashes( $question->pollq_question ) ), 'timestamp' => $question->pollq_timestamp, 'totalvotes' => (int) $question->pollq_totalvotes, 'start' => $question->pollq_timestamp, 'end' => trim( $question->pollq_expiry ), 'multiple' => (int) $question->pollq_multiple, 'totalvoters' => (int) $question->pollq_totalvoters );
|
948 |
+
$poll_questions_ids .= (int) $question->pollq_id . ', ';
|
949 |
+
}
|
950 |
+
$poll_questions_ids = substr($poll_questions_ids, 0, -2);
|
951 |
+
}
|
952 |
+
|
953 |
+
// Get Poll Answers
|
954 |
+
list($order_by, $sort_order) = _polls_get_ans_result_sort();
|
955 |
+
$answers = $wpdb->get_results("SELECT polla_aid, polla_qid, polla_answers, polla_votes FROM $wpdb->pollsa WHERE polla_qid IN ($poll_questions_ids) ORDER BY $order_by $sort_order");
|
956 |
+
if($answers) {
|
957 |
+
foreach($answers as $answer) {
|
958 |
+
$polls_answers[(int)$answer->polla_qid][] = array( 'aid' => (int)$answer->polla_aid, 'qid' => (int) $answer->polla_qid, 'answers' => wp_kses_post( removeslashes( $answer->polla_answers ) ), 'votes' => (int) $answer->polla_votes );
|
959 |
+
}
|
960 |
+
}
|
961 |
+
|
962 |
+
// Get Poll IPs
|
963 |
+
$ips = $wpdb->get_results("SELECT pollip_qid, pollip_aid FROM $wpdb->pollsip WHERE pollip_qid IN ($poll_questions_ids) AND pollip_ip = '".get_ipaddress()."' ORDER BY pollip_qid ASC");
|
964 |
+
if($ips) {
|
965 |
+
foreach($ips as $ip) {
|
966 |
+
$polls_ips[(int) $ip->pollip_qid][] = (int) $ip->pollip_aid;
|
967 |
+
}
|
968 |
+
}
|
969 |
+
// Poll Archives
|
970 |
+
$pollsarchive_output_archive .= "<div class=\"wp-polls wp-polls-archive\">\n";
|
971 |
+
foreach($polls_questions as $polls_question) {
|
972 |
+
// Most/Least Variables
|
973 |
+
$poll_most_answer = '';
|
974 |
+
$poll_most_votes = 0;
|
975 |
+
$poll_most_percentage = 0;
|
976 |
+
$poll_least_answer = '';
|
977 |
+
$poll_least_votes = 0;
|
978 |
+
$poll_least_percentage = 0;
|
979 |
+
// Is The Poll Total Votes 0?
|
980 |
+
$poll_totalvotes_zero = true;
|
981 |
+
if($polls_question['totalvotes'] > 0) {
|
982 |
+
$poll_totalvotes_zero = false;
|
983 |
+
}
|
984 |
+
$poll_start_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $polls_question['start']));
|
985 |
+
if(empty($polls_question['end'])) {
|
986 |
+
$poll_end_date = __('No Expiry', 'wp-polls');
|
987 |
+
} else {
|
988 |
+
$poll_end_date = mysql2date(sprintf(__('%s @ %s', 'wp-polls'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $polls_question['end']));
|
989 |
+
}
|
990 |
+
// Archive Poll Header
|
991 |
+
$template_archive_header = removeslashes(get_option('poll_template_pollarchiveheader'));
|
992 |
+
// Poll Question Variables
|
993 |
+
$template_question = removeslashes(get_option('poll_template_resultheader'));
|
994 |
+
$template_question = str_replace("%POLL_QUESTION%", $polls_question['question'], $template_question);
|
995 |
+
$template_question = str_replace("%POLL_ID%", $polls_question['id'], $template_question);
|
996 |
+
$template_question = str_replace("%POLL_TOTALVOTES%", number_format_i18n($polls_question['totalvotes']), $template_question);
|
997 |
+
$template_question = str_replace("%POLL_TOTALVOTERS%", number_format_i18n($polls_question['totalvoters']), $template_question);
|
998 |
+
$template_question = str_replace("%POLL_START_DATE%", $poll_start_date, $template_question);
|
999 |
+
$template_question = str_replace("%POLL_END_DATE%", $poll_end_date, $template_question);
|
1000 |
+
if($polls_question['multiple'] > 0) {
|
1001 |
+
$template_question = str_replace("%POLL_MULTIPLE_ANS_MAX%", $polls_question['multiple'], $template_question);
|
1002 |
+
} else {
|
1003 |
+
$template_question = str_replace("%POLL_MULTIPLE_ANS_MAX%", '1', $template_question);
|
1004 |
+
}
|
1005 |
+
// Print Out Result Header Template
|
1006 |
+
$pollsarchive_output_archive .= $template_archive_header;
|
1007 |
+
$pollsarchive_output_archive .= $template_question;
|
1008 |
+
// Store The Percentage Of The Poll
|
1009 |
+
$poll_answer_percentage_array = array();
|
1010 |
+
foreach($polls_answers[$polls_question['id']] as $polls_answer) {
|
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;
|
1018 |
+
$poll_answer_imagewidth = 1;
|
1019 |
+
}
|
1020 |
+
} else {
|
1021 |
+
$poll_answer_percentage = 0;
|
1022 |
+
$poll_answer_imagewidth = 1;
|
1023 |
+
}
|
1024 |
+
// Make Sure That Total Percentage Is 100% By Adding A Buffer To The Last Poll Answer
|
1025 |
+
if($polls_question['multiple'] === 0) {
|
1026 |
+
$poll_answer_percentage_array[] = $poll_answer_percentage;
|
1027 |
+
if(count($poll_answer_percentage_array) === count($polls_answers[$polls_question['id']])) {
|
1028 |
+
$percentage_error_buffer = 100 - array_sum($poll_answer_percentage_array);
|
1029 |
+
$poll_answer_percentage = $poll_answer_percentage + $percentage_error_buffer;
|
1030 |
+
if($poll_answer_percentage < 0) {
|
1031 |
+
$poll_answer_percentage = 0;
|
1032 |
+
}
|
1033 |
+
}
|
1034 |
+
}
|
1035 |
+
$polls_answer['answers'] = wp_kses_post( $polls_answer['answers'] );
|
1036 |
+
// Let User See What Options They Voted
|
1037 |
+
if(isset( $polls_ips[$polls_question['id']] ) && in_array( $polls_answer['aid'], check_voted_multiple( $polls_question['id'], $polls_ips[$polls_question['id']] ), true ) ) {
|
1038 |
+
// Results Body Variables
|
1039 |
+
$template_answer = removeslashes(get_option('poll_template_resultbody2'));
|
1040 |
+
$template_answer = str_replace("%POLL_ID%", $polls_question['id'], $template_answer);
|
1041 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $polls_answer['aid'], $template_answer);
|
1042 |
+
$template_answer = str_replace("%POLL_ANSWER%", $polls_answer['answers'], $template_answer);
|
1043 |
+
$template_answer = str_replace("%POLL_ANSWER_TEXT%", htmlspecialchars(strip_tags($polls_answer['answers'])), $template_answer);
|
1044 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format_i18n($polls_answer['votes']), $template_answer);
|
1045 |
+
$template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
|
1046 |
+
$template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
|
1047 |
+
// Print Out Results Body Template
|
1048 |
+
$pollsarchive_output_archive .= $template_answer;
|
1049 |
+
} else {
|
1050 |
+
// Results Body Variables
|
1051 |
+
$template_answer = removeslashes(get_option('poll_template_resultbody'));
|
1052 |
+
$template_answer = str_replace("%POLL_ID%", $polls_question['id'], $template_answer);
|
1053 |
+
$template_answer = str_replace("%POLL_ANSWER_ID%", $polls_answer['aid'], $template_answer);
|
1054 |
+
$template_answer = str_replace("%POLL_ANSWER%", $polls_answer['answers'], $template_answer);
|
1055 |
+
$template_answer = str_replace("%POLL_ANSWER_TEXT%", htmlspecialchars(strip_tags($polls_answer['answers'])), $template_answer);
|
1056 |
+
$template_answer = str_replace("%POLL_ANSWER_VOTES%", number_format_i18n($polls_answer['votes']), $template_answer);
|
1057 |
+
$template_answer = str_replace("%POLL_ANSWER_PERCENTAGE%", $poll_answer_percentage, $template_answer);
|
1058 |
+
$template_answer = str_replace("%POLL_ANSWER_IMAGEWIDTH%", $poll_answer_imagewidth, $template_answer);
|
1059 |
+
// Print Out Results Body Template
|
1060 |
+
$pollsarchive_output_archive .= $template_answer;
|
1061 |
+
}
|
1062 |
+
// Get Most Voted Data
|
1063 |
+
if($polls_answer['votes'] > $poll_most_votes) {
|
1064 |
+
$poll_most_answer = $polls_answer['answers'];
|
1065 |
+
$poll_most_votes = $polls_answer['votes'];
|
1066 |
+
$poll_most_percentage = $poll_answer_percentage;
|
1067 |
+
}
|
1068 |
+
// Get Least Voted Data
|
1069 |
+
if($poll_least_votes === 0) {
|
1070 |
+
$poll_least_votes = $polls_answer['votes'];
|
1071 |
+
}
|
1072 |
+
if($polls_answer['votes'] <= $poll_least_votes) {
|
1073 |
+
$poll_least_answer = $polls_answer['answers'];
|
1074 |
+
$poll_least_votes = $polls_answer['votes'];
|
1075 |
+
$poll_least_percentage = $poll_answer_percentage;
|
1076 |
+
}
|
1077 |
+
}
|
1078 |
+
// Results Footer Variables
|
1079 |
+
$template_footer = removeslashes(get_option('poll_template_resultfooter'));
|
1080 |
+
$template_footer = str_replace("%POLL_ID%", $polls_question['id'], $template_footer);
|
1081 |
+
$template_footer = str_replace("%POLL_START_DATE%", $poll_start_date, $template_footer);
|
1082 |
+
$template_footer = str_replace("%POLL_END_DATE%", $poll_end_date, $template_footer);
|
1083 |
+
$template_footer = str_replace("%POLL_TOTALVOTES%", number_format_i18n($polls_question['totalvotes']), $template_footer);
|
1084 |
+
$template_footer = str_replace("%POLL_TOTALVOTERS%", number_format_i18n($polls_question['totalvoters']), $template_footer);
|
1085 |
+
$template_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_footer);
|
1086 |
+
$template_footer = str_replace("%POLL_MOST_VOTES%", number_format_i18n($poll_most_votes), $template_footer);
|
1087 |
+
$template_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_footer);
|
1088 |
+
$template_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_footer);
|
1089 |
+
$template_footer = str_replace("%POLL_LEAST_VOTES%", number_format_i18n($poll_least_votes), $template_footer);
|
1090 |
+
$template_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_footer);
|
1091 |
+
if($polls_question['multiple'] > 0) {
|
1092 |
+
$template_footer = str_replace("%POLL_MULTIPLE_ANS_MAX%", $polls_question['multiple'], $template_footer);
|
1093 |
+
} else {
|
1094 |
+
$template_footer = str_replace("%POLL_MULTIPLE_ANS_MAX%", '1', $template_footer);
|
1095 |
+
}
|
1096 |
+
// Archive Poll Footer
|
1097 |
+
$template_archive_footer = removeslashes(get_option('poll_template_pollarchivefooter'));
|
1098 |
+
$template_archive_footer = str_replace("%POLL_START_DATE%", $poll_start_date, $template_archive_footer);
|
1099 |
+
$template_archive_footer = str_replace("%POLL_END_DATE%", $poll_end_date, $template_archive_footer);
|
1100 |
+
$template_archive_footer = str_replace("%POLL_TOTALVOTES%", number_format_i18n($polls_question['totalvotes']), $template_archive_footer);
|
1101 |
+
$template_archive_footer = str_replace("%POLL_TOTALVOTERS%", number_format_i18n($polls_question['totalvoters']), $template_archive_footer);
|
1102 |
+
$template_archive_footer = str_replace("%POLL_MOST_ANSWER%", $poll_most_answer, $template_archive_footer);
|
1103 |
+
$template_archive_footer = str_replace("%POLL_MOST_VOTES%", number_format_i18n($poll_most_votes), $template_archive_footer);
|
1104 |
+
$template_archive_footer = str_replace("%POLL_MOST_PERCENTAGE%", $poll_most_percentage, $template_archive_footer);
|
1105 |
+
$template_archive_footer = str_replace("%POLL_LEAST_ANSWER%", $poll_least_answer, $template_archive_footer);
|
1106 |
+
$template_archive_footer = str_replace("%POLL_LEAST_VOTES%", number_format_i18n($poll_least_votes), $template_archive_footer);
|
1107 |
+
$template_archive_footer = str_replace("%POLL_LEAST_PERCENTAGE%", $poll_least_percentage, $template_archive_footer);
|
1108 |
+
if($polls_question['multiple'] > 0) {
|
1109 |
+
$template_archive_footer = str_replace("%POLL_MULTIPLE_ANS_MAX%", $polls_question['multiple'], $template_archive_footer);
|
1110 |
+
} else {
|
1111 |
+
$template_archive_footer = str_replace("%POLL_MULTIPLE_ANS_MAX%", '1', $template_archive_footer);
|
1112 |
+
}
|
1113 |
+
// Print Out Results Footer Template
|
1114 |
+
$pollsarchive_output_archive .= $template_footer;
|
1115 |
+
// Print Out Archive Poll Footer Template
|
1116 |
+
$pollsarchive_output_archive .= $template_archive_footer;
|
1117 |
+
}
|
1118 |
+
$pollsarchive_output_archive .= "</div>\n";
|
1119 |
+
|
1120 |
+
// Polls Archive Paging
|
1121 |
+
if($max_page > 1) {
|
1122 |
+
$pollsarchive_output_archive .= removeslashes(get_option('poll_template_pollarchivepagingheader'));
|
1123 |
+
if(function_exists('wp_pagenavi')) {
|
1124 |
+
$pollsarchive_output_archive .= '<div class="wp-pagenavi">'."\n";
|
1125 |
+
} else {
|
1126 |
+
$pollsarchive_output_archive .= '<div class="wp-polls-paging">'."\n";
|
1127 |
+
}
|
1128 |
+
$pollsarchive_output_archive .= '<span class="pages"> '.sprintf(__('Page %s of %s', 'wp-polls'), number_format_i18n($page), number_format_i18n($max_page)).' </span>';
|
1129 |
+
if ($start_page >= 2 && $pages_to_show < $max_page) {
|
1130 |
+
$pollsarchive_output_archive .= '<a href="'.polls_archive_link(1).'" title="'.__('« First', 'wp-polls').'"> '.__('« First', 'wp-polls').' </a>';
|
1131 |
+
$pollsarchive_output_archive .= '<span class="extend">...</span>';
|
1132 |
+
}
|
1133 |
+
if($page > 1) {
|
1134 |
+
$pollsarchive_output_archive .= '<a href="'.polls_archive_link(($page-1)).'" title="'.__('«', 'wp-polls').'"> '.__('«', 'wp-polls').' </a>';
|
1135 |
+
}
|
1136 |
+
for($i = $start_page; $i <= $end_page; $i++) {
|
1137 |
+
if($i === $page) {
|
1138 |
+
$pollsarchive_output_archive .= '<span class="current"> '.number_format_i18n($i).' </span>';
|
1139 |
+
} else {
|
1140 |
+
$pollsarchive_output_archive .= '<a href="'.polls_archive_link($i).'" title="'.number_format_i18n($i).'"> '.number_format_i18n($i).' </a>';
|
1141 |
+
}
|
1142 |
+
}
|
1143 |
+
if(empty($page) || ($page+1) <= $max_page) {
|
1144 |
+
$pollsarchive_output_archive .= '<a href="'.polls_archive_link(($page+1)).'" title="'.__('»', 'wp-polls').'"> '.__('»', 'wp-polls').' </a>';
|
1145 |
+
}
|
1146 |
+
if ($end_page < $max_page) {
|
1147 |
+
$pollsarchive_output_archive .= '<span class="extend">...</span>';
|
1148 |
+
$pollsarchive_output_archive .= '<a href="'.polls_archive_link($max_page).'" title="'.__('Last »', 'wp-polls').'"> '.__('Last »', 'wp-polls').' </a>';
|
1149 |
+
}
|
1150 |
+
$pollsarchive_output_archive .= '</div>';
|
1151 |
+
$pollsarchive_output_archive .= removeslashes(get_option('poll_template_pollarchivepagingfooter'));
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
// Output Polls Archive Page
|
1155 |
+
return apply_filters('polls_archive', $pollsarchive_output_archive);
|
1156 |
}
|
1157 |
|
1158 |
|
1159 |
// Edit Timestamp Options
|
1160 |
function poll_timestamp($poll_timestamp, $fieldname = 'pollq_timestamp', $display = 'block') {
|
1161 |
+
global $month;
|
1162 |
+
echo '<div id="'.$fieldname.'" style="display: '.$display.'">'."\n";
|
1163 |
+
$day = (int) gmdate('j', $poll_timestamp);
|
1164 |
+
echo '<select name="'.$fieldname.'_day" size="1">'."\n";
|
1165 |
+
for($i = 1; $i <=31; $i++) {
|
1166 |
+
if($day === $i) {
|
1167 |
+
echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
1168 |
+
} else {
|
1169 |
+
echo "<option value=\"$i\">$i</option>\n";
|
1170 |
+
}
|
1171 |
+
}
|
1172 |
+
echo '</select> '."\n";
|
1173 |
+
$month2 = (int) gmdate('n', $poll_timestamp);
|
1174 |
+
echo '<select name="'.$fieldname.'_month" size="1">'."\n";
|
1175 |
+
for($i = 1; $i <= 12; $i++) {
|
1176 |
+
if ($i < 10) {
|
1177 |
+
$ii = '0'.$i;
|
1178 |
+
} else {
|
1179 |
+
$ii = $i;
|
1180 |
+
}
|
1181 |
+
if($month2 === $i) {
|
1182 |
+
echo "<option value=\"$i\" selected=\"selected\">$month[$ii]</option>\n";
|
1183 |
+
} else {
|
1184 |
+
echo "<option value=\"$i\">$month[$ii]</option>\n";
|
1185 |
+
}
|
1186 |
+
}
|
1187 |
+
echo '</select> '."\n";
|
1188 |
+
$year = (int) gmdate('Y', $poll_timestamp);
|
1189 |
+
echo '<select name="'.$fieldname.'_year" size="1">'."\n";
|
1190 |
+
for($i = 2000; $i <= ($year+10); $i++) {
|
1191 |
+
if($year === $i) {
|
1192 |
+
echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
1193 |
+
} else {
|
1194 |
+
echo "<option value=\"$i\">$i</option>\n";
|
1195 |
+
}
|
1196 |
+
}
|
1197 |
+
echo '</select> @'."\n";
|
1198 |
+
echo '<span dir="ltr">'."\n";
|
1199 |
+
$hour = (int) gmdate('H', $poll_timestamp);
|
1200 |
+
echo '<select name="'.$fieldname.'_hour" size="1">'."\n";
|
1201 |
+
for($i = 0; $i < 24; $i++) {
|
1202 |
+
if($hour === $i) {
|
1203 |
+
echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
1204 |
+
} else {
|
1205 |
+
echo "<option value=\"$i\">$i</option>\n";
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
echo '</select> :'."\n";
|
1209 |
+
$minute = (int) gmdate('i', $poll_timestamp);
|
1210 |
+
echo '<select name="'.$fieldname.'_minute" size="1">'."\n";
|
1211 |
+
for($i = 0; $i < 60; $i++) {
|
1212 |
+
if($minute === $i) {
|
1213 |
+
echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
1214 |
+
} else {
|
1215 |
+
echo "<option value=\"$i\">$i</option>\n";
|
1216 |
+
}
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
echo '</select> :'."\n";
|
1220 |
+
$second = (int) gmdate('s', $poll_timestamp);
|
1221 |
+
echo '<select name="'.$fieldname.'_second" size="1">'."\n";
|
1222 |
+
for($i = 0; $i <= 60; $i++) {
|
1223 |
+
if($second === $i) {
|
1224 |
+
echo "<option value=\"$i\" selected=\"selected\">$i</option>\n";
|
1225 |
+
} else {
|
1226 |
+
echo "<option value=\"$i\">$i</option>\n";
|
1227 |
+
}
|
1228 |
+
}
|
1229 |
+
echo '</select>'."\n";
|
1230 |
+
echo '</span>'."\n";
|
1231 |
+
echo '</div>'."\n";
|
1232 |
}
|
1233 |
|
1234 |
|
1235 |
### Function: Place Cron
|
1236 |
function cron_polls_place() {
|
1237 |
+
wp_clear_scheduled_hook('polls_cron');
|
1238 |
+
if (!wp_next_scheduled('polls_cron')) {
|
1239 |
+
wp_schedule_event(time(), 'hourly', 'polls_cron');
|
1240 |
+
}
|
1241 |
}
|
1242 |
|
1243 |
### Funcion: Check All Polls Status To Check If It Expires
|
1244 |
add_action('polls_cron', 'cron_polls_status');
|
1245 |
function cron_polls_status() {
|
1246 |
+
global $wpdb;
|
1247 |
+
// Close Poll
|
1248 |
+
$close_polls = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_active = 0 WHERE pollq_expiry < '".current_time('timestamp')."' AND pollq_expiry != '' AND pollq_active != 0");
|
1249 |
+
// Open Future Polls
|
1250 |
+
$active_polls = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_active = 1 WHERE pollq_timestamp <= '".current_time('timestamp')."' AND pollq_active = -1");
|
1251 |
+
// Update Latest Poll If Future Poll Is Opened
|
1252 |
+
if($active_polls) {
|
1253 |
+
$update_latestpoll = update_option('poll_latestpoll', polls_latest_id());
|
1254 |
+
}
|
1255 |
+
return;
|
1256 |
}
|
1257 |
|
1258 |
|
1259 |
### Funcion: Get Latest Poll ID
|
1260 |
function polls_latest_id() {
|
1261 |
+
global $wpdb;
|
1262 |
+
$poll_id = $wpdb->get_var("SELECT pollq_id FROM $wpdb->pollsq WHERE pollq_active = 1 ORDER BY pollq_timestamp DESC LIMIT 1");
|
1263 |
+
return (int) $poll_id;
|
1264 |
}
|
1265 |
|
1266 |
|
1267 |
### Check If In Poll Archive Page
|
1268 |
function in_pollarchive() {
|
1269 |
+
$poll_archive_url = get_option('poll_archive_url');
|
1270 |
+
$poll_archive_url_array = explode('/', $poll_archive_url);
|
1271 |
+
$poll_archive_url = $poll_archive_url_array[count($poll_archive_url_array)-1];
|
1272 |
+
if(empty($poll_archive_url)) {
|
1273 |
+
$poll_archive_url = $poll_archive_url_array[count($poll_archive_url_array)-2];
|
1274 |
+
}
|
1275 |
+
$current_url = esc_url_raw( $_SERVER['REQUEST_URI'] );
|
1276 |
+
if(strpos($current_url, $poll_archive_url) === false) {
|
1277 |
+
return false;
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
return true;
|
1281 |
}
|
1282 |
|
1283 |
|
1285 |
add_action('wp_ajax_polls', 'vote_poll');
|
1286 |
add_action('wp_ajax_nopriv_polls', 'vote_poll');
|
1287 |
function vote_poll() {
|
1288 |
+
global $wpdb, $user_identity, $user_ID;
|
1289 |
+
|
1290 |
+
if( isset( $_REQUEST['action'] ) && sanitize_key( $_REQUEST['action'] ) === 'polls') {
|
1291 |
+
// Load Headers
|
1292 |
+
polls_textdomain();
|
1293 |
+
header('Content-Type: text/html; charset='.get_option('blog_charset').'');
|
1294 |
+
|
1295 |
+
// Get Poll ID
|
1296 |
+
$poll_id = (isset($_REQUEST['poll_id']) ? (int) sanitize_key( $_REQUEST['poll_id'] ) : 0);
|
1297 |
+
|
1298 |
+
// Ensure Poll ID Is Valid
|
1299 |
+
if($poll_id === 0) {
|
1300 |
+
_e('Invalid Poll ID', 'wp-polls');
|
1301 |
+
exit();
|
1302 |
+
}
|
1303 |
+
|
1304 |
+
// Verify Referer
|
1305 |
+
if( ! check_ajax_referer( 'poll_'.$poll_id.'-nonce', 'poll_'.$poll_id.'_nonce', false ) ) {
|
1306 |
+
_e('Failed To Verify Referrer', 'wp-polls');
|
1307 |
+
exit();
|
1308 |
+
}
|
1309 |
+
|
1310 |
+
// Which View
|
1311 |
+
switch( sanitize_key( $_REQUEST['view'] ) ) {
|
1312 |
+
// Poll Vote
|
1313 |
+
case 'process':
|
1314 |
+
do_action('wp_polls_vote_poll');
|
1315 |
+
$poll_aid = (int) sanitize_key( $_POST["poll_$poll_id"] );
|
1316 |
+
$poll_aid_array = array_unique( array_map('intval', array_map('sanitize_key', explode( ',', $_POST["poll_$poll_id"] ) ) ) );
|
1317 |
+
$is_real = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pollsa WHERE polla_aid = %d AND polla_qid = %d", array( $poll_aid, $poll_id ) ) );
|
1318 |
+
|
1319 |
+
// The multiple ifs is ugly, I know it. Feel free to send a PR to fix it
|
1320 |
+
if( $is_real > 0 ) {
|
1321 |
+
if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
|
1322 |
+
$is_poll_open = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pollsq WHERE pollq_id = %d AND pollq_active = 1", $poll_id ) );
|
1323 |
+
if ( $is_poll_open > 0 ) {
|
1324 |
+
$check_voted = check_voted($poll_id);
|
1325 |
+
if ($check_voted === 0) {
|
1326 |
+
if (!empty($user_identity)) {
|
1327 |
+
$pollip_user = $user_identity;
|
1328 |
+
} elseif ( ! empty( $_COOKIE['comment_author_' . COOKIEHASH] ) ) {
|
1329 |
+
$pollip_user = $_COOKIE['comment_author_' . COOKIEHASH];
|
1330 |
+
} else {
|
1331 |
+
$pollip_user = __('Guest', 'wp-polls');
|
1332 |
+
}
|
1333 |
+
$pollip_user = sanitize_text_field( $pollip_user );
|
1334 |
+
$pollip_userid = (int) $user_ID;
|
1335 |
+
$pollip_ip = get_ipaddress();
|
1336 |
+
$pollip_host = @gethostbyaddr($pollip_ip);
|
1337 |
+
$pollip_timestamp = current_time('timestamp');
|
1338 |
+
// Only Create Cookie If User Choose Logging Method 1 Or 2
|
1339 |
+
$poll_logging_method = (int) get_option('poll_logging_method');
|
1340 |
+
if ($poll_logging_method === 1 || $poll_logging_method === 3) {
|
1341 |
+
$cookie_expiry = (int) get_option('poll_cookielog_expiry');
|
1342 |
+
if ($cookie_expiry === 0) {
|
1343 |
+
$cookie_expiry = 30000000;
|
1344 |
+
}
|
1345 |
+
setcookie('voted_' . $poll_id, $poll_aid, ($pollip_timestamp + $cookie_expiry), apply_filters('wp_polls_cookiepath', SITECOOKIEPATH));
|
1346 |
+
}
|
1347 |
+
$i = 0;
|
1348 |
+
foreach ($poll_aid_array as $polla_aid) {
|
1349 |
+
$update_polla_votes = $wpdb->query( "UPDATE $wpdb->pollsa SET polla_votes = (polla_votes + 1) WHERE polla_qid = $poll_id AND polla_aid = $polla_aid" );
|
1350 |
+
if (!$update_polla_votes) {
|
1351 |
+
unset($poll_aid_array[$i]);
|
1352 |
+
}
|
1353 |
+
$i++;
|
1354 |
+
}
|
1355 |
+
$vote_q = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes+" . count( $poll_aid_array ) . "), pollq_totalvoters = (pollq_totalvoters + 1) WHERE pollq_id = $poll_id AND pollq_active = 1");
|
1356 |
+
if ($vote_q) {
|
1357 |
+
foreach ($poll_aid_array as $polla_aid) {
|
1358 |
+
$wpdb->insert(
|
1359 |
+
$wpdb->pollsip,
|
1360 |
+
array(
|
1361 |
+
'pollip_qid' => $poll_id,
|
1362 |
+
'pollip_aid' => $polla_aid,
|
1363 |
+
'pollip_ip' => $pollip_ip,
|
1364 |
+
'pollip_host' => $pollip_host,
|
1365 |
+
'pollip_timestamp' => $pollip_timestamp,
|
1366 |
+
'pollip_user' => $pollip_user,
|
1367 |
+
'pollip_userid' => $pollip_userid
|
1368 |
+
),
|
1369 |
+
array(
|
1370 |
+
'%s',
|
1371 |
+
'%s',
|
1372 |
+
'%s',
|
1373 |
+
'%s',
|
1374 |
+
'%s',
|
1375 |
+
'%s',
|
1376 |
+
'%d'
|
1377 |
+
)
|
1378 |
+
);
|
1379 |
+
}
|
1380 |
+
echo display_pollresult($poll_id, $poll_aid_array, false);
|
1381 |
+
do_action( 'wp_polls_vote_poll_success' );
|
1382 |
+
} else {
|
1383 |
+
printf(__('Unable To Update Poll Total Votes And Poll Total Voters. Poll ID #%s', 'wp-polls'), $poll_id);
|
1384 |
+
} // End if($vote_a)
|
1385 |
+
} else {
|
1386 |
+
printf(__('You Had Already Voted For This Poll. Poll ID #%s', 'wp-polls'), $poll_id);
|
1387 |
+
} // End if($check_voted)
|
1388 |
+
} else {
|
1389 |
+
printf( __( 'Poll ID #%s is closed', 'wp-polls' ), $poll_id );
|
1390 |
+
} // End if($is_poll_open > 0)
|
1391 |
+
} else {
|
1392 |
+
printf(__('Invalid Poll ID. Poll ID #%s', 'wp-polls'), $poll_id);
|
1393 |
+
} // End if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote())
|
1394 |
+
} else {
|
1395 |
+
printf(__('Invalid Answer to Poll ID #%s', 'wp-polls'), $poll_id);
|
1396 |
+
} //End if(!isRealAnswer($poll_id,$poll_aid))
|
1397 |
+
break;
|
1398 |
+
// Poll Result
|
1399 |
+
case 'result':
|
1400 |
+
echo display_pollresult($poll_id, 0, false);
|
1401 |
+
break;
|
1402 |
+
// Poll Booth Aka Poll Voting Form
|
1403 |
+
case 'booth':
|
1404 |
+
echo display_pollvote($poll_id, false);
|
1405 |
+
break;
|
1406 |
+
} // End switch($_REQUEST['view'])
|
1407 |
+
} // End if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'polls')
|
1408 |
+
exit();
|
|
|
|
|
|
|
1409 |
}
|
1410 |
|
1411 |
|
1412 |
### Function: Manage Polls
|
1413 |
add_action('wp_ajax_polls-admin', 'manage_poll');
|
1414 |
function manage_poll() {
|
1415 |
+
global $wpdb;
|
1416 |
+
### Form Processing
|
1417 |
+
if( isset( $_POST['action'] ) && sanitize_key( $_POST['action'] ) === 'polls-admin' ) {
|
1418 |
+
if( ! empty( $_POST['do'] ) ) {
|
1419 |
+
// Set Header
|
1420 |
+
header('Content-Type: text/html; charset='.get_option('blog_charset').'');
|
1421 |
+
|
1422 |
+
// Decide What To Do
|
1423 |
+
switch($_POST['do']) {
|
1424 |
+
// Delete Polls Logs
|
1425 |
+
case __('Delete All Logs', 'wp-polls'):
|
1426 |
+
check_ajax_referer('wp-polls_delete-polls-logs');
|
1427 |
+
if( sanitize_key( trim( $_POST['delete_logs_yes'] ) ) === 'yes') {
|
1428 |
+
$delete_logs = $wpdb->query("DELETE FROM $wpdb->pollsip");
|
1429 |
+
if($delete_logs) {
|
1430 |
+
echo '<p style="color: green;">'.__('All Polls Logs Have Been Deleted.', 'wp-polls').'</p>';
|
1431 |
+
} else {
|
1432 |
+
echo '<p style="color: red;">'.__('An Error Has Occurred While Deleting All Polls Logs.', 'wp-polls').'</p>';
|
1433 |
+
}
|
1434 |
+
}
|
1435 |
+
break;
|
1436 |
+
// Delete Poll Logs For Individual Poll
|
1437 |
+
case __('Delete Logs For This Poll Only', 'wp-polls'):
|
1438 |
+
check_ajax_referer('wp-polls_delete-poll-logs');
|
1439 |
+
$pollq_id = (int) sanitize_key( $_POST['pollq_id'] );
|
1440 |
+
$pollq_question = $wpdb->get_var( $wpdb->prepare( "SELECT pollq_question FROM $wpdb->pollsq WHERE pollq_id = %d", $pollq_id ) );
|
1441 |
+
if( sanitize_key( trim( $_POST['delete_logs_yes'] ) ) === 'yes') {
|
1442 |
+
$delete_logs = $wpdb->delete( $wpdb->pollsip, array( 'pollip_qid' => $pollq_id ), array( '%d' ) );
|
1443 |
+
if( $delete_logs ) {
|
1444 |
+
echo '<p style="color: green;">'.sprintf(__('All Logs For \'%s\' Has Been Deleted.', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
|
1445 |
+
} else {
|
1446 |
+
echo '<p style="color: red;">'.sprintf(__('An Error Has Occurred While Deleting All Logs For \'%s\'', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
|
1447 |
+
}
|
1448 |
+
}
|
1449 |
+
break;
|
1450 |
+
// Delete Poll's Answer
|
1451 |
+
case __('Delete Poll Answer', 'wp-polls'):
|
1452 |
+
check_ajax_referer('wp-polls_delete-poll-answer');
|
1453 |
+
$pollq_id = (int) sanitize_key( $_POST['pollq_id'] );
|
1454 |
+
$polla_aid = (int) sanitize_key( $_POST['polla_aid'] );
|
1455 |
+
$poll_answers = $wpdb->get_row( $wpdb->prepare( "SELECT polla_votes, polla_answers FROM $wpdb->pollsa WHERE polla_aid = %d AND polla_qid = %d", $polla_aid, $pollq_id ) );
|
1456 |
+
$polla_votes = (int) $poll_answers->polla_votes;
|
1457 |
+
$polla_answers = wp_kses_post( removeslashes( trim( $poll_answers->polla_answers ) ) );
|
1458 |
+
$delete_polla_answers = $wpdb->delete( $wpdb->pollsa, array( 'polla_aid' => $polla_aid, 'polla_qid' => $pollq_id ), array( '%d', '%d' ) );
|
1459 |
+
$delete_pollip = $wpdb->delete( $wpdb->pollsip, array( 'pollip_qid' => $pollq_id, 'pollip_aid' => $polla_aid ), array( '%d', '%d' ) );
|
1460 |
+
$update_pollq_totalvotes = $wpdb->query( "UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes - $polla_votes) WHERE pollq_id = $pollq_id" );
|
1461 |
+
if($delete_polla_answers) {
|
1462 |
+
echo '<p style="color: green;">'.sprintf(__('Poll Answer \'%s\' Deleted Successfully.', 'wp-polls'), $polla_answers).'</p>';
|
1463 |
+
} else {
|
1464 |
+
echo '<p style="color: red;">'.sprintf(__('Error In Deleting Poll Answer \'%s\'.', 'wp-polls'), $polla_answers).'</p>';
|
1465 |
+
}
|
1466 |
+
break;
|
1467 |
+
// Open Poll
|
1468 |
+
case __('Open Poll', 'wp-polls'):
|
1469 |
+
check_ajax_referer('wp-polls_open-poll');
|
1470 |
+
$pollq_id = (int) sanitize_key( $_POST['pollq_id'] );
|
1471 |
+
$pollq_question = $wpdb->get_var( $wpdb->prepare( "SELECT pollq_question FROM $wpdb->pollsq WHERE pollq_id = %d", $pollq_id ) );
|
1472 |
+
$open_poll = $wpdb->update(
|
1473 |
+
$wpdb->pollsq,
|
1474 |
+
array(
|
1475 |
+
'pollq_active' => 1
|
1476 |
+
),
|
1477 |
+
array(
|
1478 |
+
'pollq_id' => $pollq_id
|
1479 |
+
),
|
1480 |
+
array(
|
1481 |
+
'%d'
|
1482 |
+
),
|
1483 |
+
array(
|
1484 |
+
'%d'
|
1485 |
+
)
|
1486 |
+
);
|
1487 |
+
if( $open_poll ) {
|
1488 |
+
echo '<p style="color: green;">'.sprintf(__('Poll \'%s\' Is Now Opened', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
|
1489 |
+
} else {
|
1490 |
+
echo '<p style="color: red;">'.sprintf(__('Error Opening Poll \'%s\'', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
|
1491 |
+
}
|
1492 |
+
break;
|
1493 |
+
// Close Poll
|
1494 |
+
case __('Close Poll', 'wp-polls'):
|
1495 |
+
check_ajax_referer('wp-polls_close-poll');
|
1496 |
+
$pollq_id = (int) sanitize_key( $_POST['pollq_id'] );
|
1497 |
+
$pollq_question = $wpdb->get_var( $wpdb->prepare( "SELECT pollq_question FROM $wpdb->pollsq WHERE pollq_id = %d", $pollq_id ) );
|
1498 |
+
$close_poll = $wpdb->update(
|
1499 |
+
$wpdb->pollsq,
|
1500 |
+
array(
|
1501 |
+
'pollq_active' => 0
|
1502 |
+
),
|
1503 |
+
array(
|
1504 |
+
'pollq_id' => $pollq_id
|
1505 |
+
),
|
1506 |
+
array(
|
1507 |
+
'%d'
|
1508 |
+
),
|
1509 |
+
array(
|
1510 |
+
'%d'
|
1511 |
+
)
|
1512 |
+
);
|
1513 |
+
if( $close_poll ) {
|
1514 |
+
echo '<p style="color: green;">'.sprintf(__('Poll \'%s\' Is Now Closed', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
|
1515 |
+
} else {
|
1516 |
+
echo '<p style="color: red;">'.sprintf(__('Error Closing Poll \'%s\'', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
|
1517 |
+
}
|
1518 |
+
break;
|
1519 |
+
// Delete Poll
|
1520 |
+
case __('Delete Poll', 'wp-polls'):
|
1521 |
+
check_ajax_referer('wp-polls_delete-poll');
|
1522 |
+
$pollq_id = (int) sanitize_key( $_POST['pollq_id'] );
|
1523 |
+
$pollq_question = $wpdb->get_var( $wpdb->prepare( "SELECT pollq_question FROM $wpdb->pollsq WHERE pollq_id = %d", $pollq_id ) );
|
1524 |
+
$delete_poll_question = $wpdb->delete( $wpdb->pollsq, array( 'pollq_id' => $pollq_id ), array( '%d' ) );
|
1525 |
+
$delete_poll_answers = $wpdb->delete( $wpdb->pollsa, array( 'polla_qid' => $pollq_id ), array( '%d' ) );
|
1526 |
+
$delete_poll_ip = $wpdb->delete( $wpdb->pollsip, array( 'pollip_qid' => $pollq_id ), array( '%d' ) );
|
1527 |
+
$poll_option_lastestpoll = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'poll_latestpoll'");
|
1528 |
+
if(!$delete_poll_question) {
|
1529 |
+
echo '<p style="color: red;">'.sprintf(__('Error In Deleting Poll \'%s\' Question', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
|
1530 |
+
}
|
1531 |
+
if(empty($text)) {
|
1532 |
+
echo '<p style="color: green;">'.sprintf(__('Poll \'%s\' Deleted Successfully', 'wp-polls'), wp_kses_post( removeslashes( $pollq_question ) ) ).'</p>';
|
1533 |
+
}
|
1534 |
+
|
1535 |
+
// Update Lastest Poll ID To Poll Options
|
1536 |
+
update_option( 'poll_latestpoll', polls_latest_id() );
|
1537 |
+
do_action( 'wp_polls_delete_poll', $pollq_id );
|
1538 |
+
break;
|
1539 |
+
}
|
1540 |
+
exit();
|
1541 |
+
}
|
1542 |
+
}
|
|
|
1543 |
}
|
1544 |
|
1545 |
|
1546 |
function _polls_get_ans_sort() {
|
1547 |
+
$order_by = get_option( 'poll_ans_sortby' );
|
1548 |
+
switch( $order_by ) {
|
1549 |
+
case 'polla_votes':
|
1550 |
+
case 'polla_aid':
|
1551 |
+
case 'polla_answers':
|
1552 |
+
case 'RAND()':
|
1553 |
+
break;
|
1554 |
+
default:
|
1555 |
+
$order_by = 'polla_aid';
|
1556 |
+
break;
|
1557 |
+
}
|
1558 |
+
$sort_order = get_option( 'poll_ans_sortorder' ) === 'desc' ? 'desc' : 'asc';
|
1559 |
+
return array( $order_by, $sort_order );
|
1560 |
}
|
1561 |
|
1562 |
function _polls_get_ans_result_sort() {
|
1563 |
+
$order_by = get_option( 'poll_ans_result_sortby' );
|
1564 |
+
switch( $order_by ) {
|
1565 |
+
case 'polla_votes':
|
1566 |
+
case 'polla_aid':
|
1567 |
+
case 'polla_answers':
|
1568 |
+
case 'RAND()':
|
1569 |
+
break;
|
1570 |
+
default:
|
1571 |
+
$order_by = 'polla_aid';
|
1572 |
+
break;
|
1573 |
+
}
|
1574 |
+
$sort_order = get_option( 'poll_ans_result_sortorder' ) === 'desc' ? 'desc' : 'asc';
|
1575 |
+
return array( $order_by, $sort_order );
|
1576 |
}
|
1577 |
|
1578 |
|
1579 |
### Function: Plug Into WP-Stats
|
1580 |
add_action( 'plugins_loaded','polls_wp_stats' );
|
1581 |
function polls_wp_stats() {
|
1582 |
+
add_filter( 'wp_stats_page_admin_plugins', 'polls_page_admin_general_stats' );
|
1583 |
+
add_filter( 'wp_stats_page_plugins', 'polls_page_general_stats' );
|
1584 |
}
|
1585 |
|
1586 |
|
1587 |
### Function: Add WP-Polls General Stats To WP-Stats Page Options
|
1588 |
function polls_page_admin_general_stats($content) {
|
1589 |
+
$stats_display = get_option('stats_display');
|
1590 |
+
if( (int) $stats_display['polls'] === 1) {
|
1591 |
+
$content .= '<input type="checkbox" name="stats_display[]" id="wpstats_polls" value="polls" checked="checked" /> <label for="wpstats_polls">'.__('WP-Polls', 'wp-polls').'</label><br />'."\n";
|
1592 |
+
} else {
|
1593 |
+
$content .= '<input type="checkbox" name="stats_display[]" id="wpstats_polls" value="polls" /> <label for="wpstats_polls">'.__('WP-Polls', 'wp-polls').'</label><br />'."\n";
|
1594 |
+
}
|
1595 |
+
return $content;
|
1596 |
}
|
1597 |
|
1598 |
|
1599 |
### Function: Add WP-Polls General Stats To WP-Stats Page
|
1600 |
function polls_page_general_stats($content) {
|
1601 |
+
$stats_display = get_option('stats_display');
|
1602 |
+
if( (int) $stats_display['polls'] === 1) {
|
1603 |
+
$content .= '<p><strong>'.__('WP-Polls', 'wp-polls').'</strong></p>'."\n";
|
1604 |
+
$content .= '<ul>'."\n";
|
1605 |
+
$content .= '<li>'.sprintf(_n('<strong>%s</strong> poll was created.', '<strong>%s</strong> polls were created.', get_pollquestions(false), 'wp-polls'), number_format_i18n(get_pollquestions(false))).'</li>'."\n";
|
1606 |
+
$content .= '<li>'.sprintf(_n('<strong>%s</strong> polls\' answer was given.', '<strong>%s</strong> polls\' answers were given.', get_pollanswers(false), 'wp-polls'), number_format_i18n(get_pollanswers(false))).'</li>'."\n";
|
1607 |
+
$content .= '<li>'.sprintf(_n('<strong>%s</strong> vote was cast.', '<strong>%s</strong> votes were cast.', get_pollvotes(false), 'wp-polls'), number_format_i18n(get_pollvotes(false))).'</li>'."\n";
|
1608 |
+
$content .= '</ul>'."\n";
|
1609 |
+
}
|
1610 |
+
return $content;
|
1611 |
}
|
1612 |
|
1613 |
|
1614 |
### Class: WP-Polls Widget
|
1615 |
class WP_Widget_Polls extends WP_Widget {
|
1616 |
+
// Constructor
|
1617 |
+
public function __construct() {
|
1618 |
+
$widget_ops = array('description' => __('WP-Polls polls', 'wp-polls'));
|
1619 |
+
parent::__construct('polls-widget', __('Polls', 'wp-polls'), $widget_ops);
|
1620 |
+
}
|
1621 |
+
|
1622 |
+
// Display Widget
|
1623 |
+
public function widget( $args, $instance ) {
|
1624 |
+
$title = apply_filters( 'widget_title', esc_attr( $instance['title'] ) );
|
1625 |
+
$poll_id = (int) $instance['poll_id'];
|
1626 |
+
$display_pollarchive = (int) $instance['display_pollarchive'];
|
1627 |
+
echo $args['before_widget'];
|
1628 |
+
if( ! empty( $title ) ) {
|
1629 |
+
echo $args['before_title'] . $title . $args['after_title'];
|
1630 |
+
}
|
1631 |
+
get_poll( $poll_id );
|
1632 |
+
if( $display_pollarchive ) {
|
1633 |
+
display_polls_archive_link();
|
1634 |
+
}
|
1635 |
+
echo $args['after_widget'];
|
1636 |
+
}
|
1637 |
+
|
1638 |
+
// When Widget Control Form Is Posted
|
1639 |
+
public function update($new_instance, $old_instance) {
|
1640 |
+
if (!isset($new_instance['submit'])) {
|
1641 |
+
return false;
|
1642 |
+
}
|
1643 |
+
$instance = $old_instance;
|
1644 |
+
$instance['title'] = strip_tags($new_instance['title']);
|
1645 |
+
$instance['poll_id'] = (int) $new_instance['poll_id'];
|
1646 |
+
$instance['display_pollarchive'] = (int) $new_instance['display_pollarchive'];
|
1647 |
+
return $instance;
|
1648 |
+
}
|
1649 |
+
|
1650 |
+
// DIsplay Widget Control Form
|
1651 |
+
public function form($instance) {
|
1652 |
+
global $wpdb;
|
1653 |
+
$instance = wp_parse_args((array) $instance, array('title' => __('Polls', 'wp-polls'), 'poll_id' => 0, 'display_pollarchive' => 1));
|
1654 |
+
$title = esc_attr($instance['title']);
|
1655 |
+
$poll_id = (int) $instance['poll_id'];
|
1656 |
+
$display_pollarchive = (int) $instance['display_pollarchive'];
|
1657 |
?>
|
1658 |
+
<p>
|
1659 |
+
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wp-polls'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label>
|
1660 |
+
</p>
|
1661 |
+
<p>
|
1662 |
+
<label for="<?php echo $this->get_field_id('display_pollarchive'); ?>"><?php _e('Display Polls Archive Link Below Poll?', 'wp-polls'); ?>
|
1663 |
+
<select name="<?php echo $this->get_field_name('display_pollarchive'); ?>" id="<?php echo $this->get_field_id('display_pollarchive'); ?>" class="widefat">
|
1664 |
+
<option value="0"<?php selected(0, $display_pollarchive); ?>><?php _e('No', 'wp-polls'); ?></option>
|
1665 |
+
<option value="1"<?php selected(1, $display_pollarchive); ?>><?php _e('Yes', 'wp-polls'); ?></option>
|
1666 |
+
</select>
|
1667 |
+
</label>
|
1668 |
+
</p>
|
1669 |
+
<p>
|
1670 |
+
<label for="<?php echo $this->get_field_id('poll_id'); ?>"><?php _e('Poll To Display:', 'wp-polls'); ?>
|
1671 |
+
<select name="<?php echo $this->get_field_name('poll_id'); ?>" id="<?php echo $this->get_field_id('poll_id'); ?>" class="widefat">
|
1672 |
+
<option value="-1"<?php selected(-1, $poll_id); ?>><?php _e('Do NOT Display Poll (Disable)', 'wp-polls'); ?></option>
|
1673 |
+
<option value="-2"<?php selected(-2, $poll_id); ?>><?php _e('Display Random Poll', 'wp-polls'); ?></option>
|
1674 |
+
<option value="0"<?php selected(0, $poll_id); ?>><?php _e('Display Latest Poll', 'wp-polls'); ?></option>
|
1675 |
+
<optgroup> </optgroup>
|
1676 |
+
<?php
|
1677 |
+
$polls = $wpdb->get_results("SELECT pollq_id, pollq_question FROM $wpdb->pollsq ORDER BY pollq_id DESC");
|
1678 |
+
if($polls) {
|
1679 |
+
foreach($polls as $poll) {
|
1680 |
+
$pollq_question = wp_kses_post( removeslashes( $poll->pollq_question ) );
|
1681 |
+
$pollq_id = (int) $poll->pollq_id;
|
1682 |
+
if($pollq_id === $poll_id) {
|
1683 |
+
echo "<option value=\"$pollq_id\" selected=\"selected\">$pollq_question</option>\n";
|
1684 |
+
} else {
|
1685 |
+
echo "<option value=\"$pollq_id\">$pollq_question</option>\n";
|
1686 |
+
}
|
1687 |
+
}
|
1688 |
+
}
|
1689 |
+
?>
|
1690 |
+
</select>
|
1691 |
+
</label>
|
1692 |
+
</p>
|
1693 |
+
<input type="hidden" id="<?php echo $this->get_field_id('submit'); ?>" name="<?php echo $this->get_field_name('submit'); ?>" value="1" />
|
1694 |
<?php
|
1695 |
+
}
|
1696 |
}
|
1697 |
|
1698 |
|
1699 |
### Function: Init WP-Polls Widget
|
1700 |
add_action('widgets_init', 'widget_polls_init');
|
1701 |
function widget_polls_init() {
|
1702 |
+
polls_textdomain();
|
1703 |
+
register_widget('WP_Widget_Polls');
|
1704 |
}
|
1705 |
|
1706 |
if( ! function_exists( 'removeslashes' ) ) {
|
1707 |
+
function removeslashes( $string ) {
|
1708 |
+
$string = implode( '', explode( '\\', $string ) );
|
1709 |
+
return stripslashes( trim( $string ) );
|
1710 |
+
}
|
1711 |
}
|
1712 |
|
1713 |
### Function: Activate Plugin
|
1714 |
register_activation_hook( __FILE__, 'polls_activation' );
|
1715 |
function polls_activation( $network_wide ) {
|
1716 |
+
if ( is_multisite() && $network_wide ) {
|
1717 |
+
$ms_sites = wp_get_sites();
|
1718 |
+
|
1719 |
+
if( 0 < count( $ms_sites ) ) {
|
1720 |
+
foreach ( $ms_sites as $ms_site ) {
|
1721 |
+
switch_to_blog( $ms_site['blog_id'] );
|
1722 |
+
polls_activate();
|
1723 |
+
restore_current_blog();
|
1724 |
+
}
|
1725 |
+
}
|
1726 |
+
} else {
|
1727 |
+
polls_activate();
|
1728 |
+
}
|
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)
|
1744 |
|
1745 |
$create_table = array();
|
1746 |
$create_table['pollsq'] = "CREATE TABLE $wpdb->pollsq (".
|
1747 |
+
"pollq_id int(10) NOT NULL auto_increment," .
|
1748 |
+
"pollq_question varchar(200) character set utf8 NOT NULL default ''," .
|
1749 |
+
"pollq_timestamp varchar(20) NOT NULL default ''," .
|
1750 |
+
"pollq_totalvotes int(10) NOT NULL default '0'," .
|
1751 |
+
"pollq_active tinyint(1) NOT NULL default '1'," .
|
1752 |
+
"pollq_expiry int(10) NOT NULL default '0'," .
|
1753 |
+
"pollq_multiple tinyint(3) NOT NULL default '0'," .
|
1754 |
+
"pollq_totalvoters int(10) NOT NULL default '0'," .
|
1755 |
+
"PRIMARY KEY (pollq_id)" .
|
1756 |
+
") $charset_collate;";
|
1757 |
$create_table['pollsa'] = "CREATE TABLE $wpdb->pollsa (" .
|
1758 |
+
"polla_aid int(10) NOT NULL auto_increment," .
|
1759 |
+
"polla_qid int(10) NOT NULL default '0'," .
|
1760 |
+
"polla_answers varchar(200) character set utf8 NOT NULL default ''," .
|
1761 |
+
"polla_votes int(10) NOT NULL default '0'," .
|
1762 |
+
"PRIMARY KEY (polla_aid)" .
|
1763 |
+
") $charset_collate;";
|
1764 |
$create_table['pollsip'] = "CREATE TABLE $wpdb->pollsip (" .
|
1765 |
+
"pollip_id int(10) NOT NULL auto_increment," .
|
1766 |
+
"pollip_qid int(10) NOT NULL default '0'," .
|
1767 |
+
"pollip_aid int(10) NOT NULL default '0'," .
|
1768 |
+
"pollip_ip varchar(100) NOT NULL default ''," .
|
1769 |
+
"pollip_host VARCHAR(200) NOT NULL default ''," .
|
1770 |
+
"pollip_timestamp int(10) NOT NULL default '0'," .
|
1771 |
+
"pollip_user tinytext NOT NULL," .
|
1772 |
+
"pollip_userid int(10) NOT NULL default '0'," .
|
1773 |
+
"PRIMARY KEY (pollip_id)," .
|
1774 |
+
"KEY pollip_ip (pollip_ip)," .
|
1775 |
+
"KEY pollip_qid (pollip_qid)," .
|
1776 |
+
"KEY pollip_ip_qid (pollip_ip, pollip_qid)" .
|
1777 |
+
") $charset_collate;";
|
1778 |
dbDelta( $create_table['pollsq'] );
|
1779 |
dbDelta( $create_table['pollsa'] );
|
1780 |
dbDelta( $create_table['pollsip'] );
|