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