Version Description
- Fixed issues with cloning poll
- Fixed conflicts with different plugins
- Fixed issue with pagination on archive page
- Fixed issue with logs page
- Fixed issue with facebook voting
- Added new shortcuts for email notifications
- Added new column for username in view votes page
Download this release
Release Info
Developer | yourownprogrammer |
Plugin | YOP Poll |
Version | 5.7.6 |
Comparing to | |
See all releases |
Code changes from version 5.7.4 to 5.7.6
- css/yop-poll-slider.css +20 -1
- inc/maintenance.php +598 -584
- inc/poll_admin.php +3 -2
- inc/public-admin.php +2 -2
- js/yop-poll-general-options.js +1 -1
- lib/Twig/AutoloaderYOP.php +48 -0
- models/abstract_model.php +522 -617
- models/poll_model.php +740 -760
- readme.txt +13 -0
- templates/polls_add_edit_template.html +48 -47
- tinymce/yop-poll-editor-functions.js +1 -1
- twig-gettext-extractor/twig-gettext-extractor.php +1 -1
- yop_poll.php +3 -3
css/yop-poll-slider.css
CHANGED
@@ -198,7 +198,7 @@
|
|
198 |
|
199 |
.yop-poll-pro-slider .yop-poll-pro-template-li p, .yop-poll-widget-slider .yop-poll-widget-template-li p, .yop-poll-buy-slider .yop-poll-buy-template-li p {
|
200 |
|
201 |
-
margin: 0;
|
202 |
|
203 |
padding: 3px;
|
204 |
|
@@ -532,6 +532,25 @@
|
|
532 |
transition: all 0.3s linear;
|
533 |
|
534 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
li:before, li:after {
|
536 |
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
|
537 |
}
|
198 |
|
199 |
.yop-poll-pro-slider .yop-poll-pro-template-li p, .yop-poll-widget-slider .yop-poll-widget-template-li p, .yop-poll-buy-slider .yop-poll-buy-template-li p {
|
200 |
|
201 |
+
margin: 0 auto;
|
202 |
|
203 |
padding: 3px;
|
204 |
|
532 |
transition: all 0.3s linear;
|
533 |
|
534 |
}
|
535 |
+
|
536 |
+
.yop-poll-page-template-buy p, .yop-poll-widget-template-buy p, .yop-poll-buy-template-buy p {
|
537 |
+
|
538 |
+
background: #00A8FF;
|
539 |
+
|
540 |
+
color: #FFF;
|
541 |
+
|
542 |
+
-webkit-transition: all 0.3s linear;
|
543 |
+
|
544 |
+
-moz-transition: all 0.3s linear;
|
545 |
+
|
546 |
+
-ms-transition: all 0.3s linear;
|
547 |
+
|
548 |
+
-o-transition: all 0.3s linear;
|
549 |
+
|
550 |
+
transition: all 0.3s linear;
|
551 |
+
|
552 |
+
}
|
553 |
+
|
554 |
li:before, li:after {
|
555 |
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
|
556 |
}
|
inc/maintenance.php
CHANGED
@@ -1,23 +1,25 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class YOP_POLL_Maintenance
|
|
|
4 |
|
5 |
-
private function network_propagate(
|
6 |
-
|
7 |
-
|
|
|
8 |
|
9 |
-
if(
|
10 |
|
11 |
$old_blog = $GLOBALS['wpdb']->blogid;
|
12 |
|
13 |
-
$blogids
|
14 |
|
15 |
-
foreach(
|
16 |
|
17 |
-
switch_to_blog(
|
18 |
|
19 |
-
yop_poll_create_table_names(
|
20 |
-
$version = get_option(
|
21 |
|
22 |
/* if ( version_compare( $version, '4.9.2', '<=' ) &&isset($version)) {
|
23 |
yop_poll_dump(12);
|
@@ -28,79 +30,66 @@ class YOP_POLL_Maintenance {
|
|
28 |
} */
|
29 |
|
30 |
|
|
|
31 |
|
32 |
-
|
33 |
|
34 |
-
|
35 |
|
36 |
-
$_p
|
37 |
|
38 |
-
$_p['
|
39 |
|
40 |
-
$_p['
|
41 |
|
42 |
-
$_p['
|
43 |
-
|
44 |
-
$_p['post_type'] = 'page';
|
45 |
|
46 |
$_p['comment_status'] = 'open';
|
47 |
|
48 |
-
$_p['ping_status']
|
49 |
-
|
50 |
-
$_p['post_category'] = array( 1 ); // the default 'Uncategorised'
|
51 |
-
|
52 |
|
|
|
53 |
|
54 |
-
$poll_archive_page_id = wp_insert_post( $_p );
|
55 |
|
|
|
56 |
|
57 |
|
58 |
-
}
|
59 |
-
|
60 |
-
else {
|
61 |
|
62 |
$poll_archive_page_id = $poll_archive_page['ID'];
|
63 |
|
64 |
}
|
65 |
|
66 |
|
|
|
67 |
|
|
|
68 |
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
$version = get_option( "yop_poll_version" );
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
$default_options = get_option( 'yop_poll_options' );
|
79 |
-
|
80 |
-
$default_options['archive_url'] = get_permalink( $poll_archive_page_id );
|
81 |
|
82 |
$default_options['yop_poll_archive_page_id'] = $poll_archive_page_id;
|
83 |
|
84 |
|
85 |
-
|
86 |
//addind default options
|
87 |
|
88 |
-
update_option(
|
89 |
-
|
90 |
|
91 |
|
92 |
}
|
93 |
|
94 |
-
switch_to_blog(
|
95 |
|
96 |
-
yop_poll_create_table_names(
|
97 |
|
98 |
return;
|
99 |
|
100 |
}
|
101 |
}
|
102 |
|
103 |
-
$version = get_option(
|
104 |
|
105 |
/* if ( version_compare( $version, '4.9.2', '<=' ) &&isset($version)) {
|
106 |
yop_poll_dump(12);
|
@@ -112,180 +101,173 @@ class YOP_POLL_Maintenance {
|
|
112 |
} */
|
113 |
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
118 |
-
|
119 |
|
120 |
-
|
121 |
|
122 |
-
$_p
|
123 |
|
124 |
-
$_p['
|
125 |
-
|
126 |
-
$_p['post_content'] = "[yop_poll_archive]";
|
127 |
-
|
128 |
-
$_p['post_status'] = 'publish';
|
129 |
-
|
130 |
-
$_p['post_type'] = 'page';
|
131 |
|
132 |
$_p['comment_status'] = 'open';
|
133 |
|
134 |
-
$_p['ping_status']
|
135 |
-
|
136 |
-
$_p['post_category'] = array( 1 ); // the default 'Uncategorised'
|
137 |
|
|
|
138 |
|
139 |
|
140 |
-
$poll_archive_page_id = wp_insert_post(
|
141 |
|
142 |
|
143 |
-
|
144 |
-
}
|
145 |
-
|
146 |
-
else {
|
147 |
|
148 |
$poll_archive_page_id = $poll_archive_page['ID'];
|
149 |
|
150 |
}
|
151 |
|
152 |
|
153 |
-
|
154 |
//addind default options
|
155 |
|
156 |
-
call_user_func(
|
157 |
-
|
158 |
|
159 |
|
160 |
-
$default_options
|
161 |
|
162 |
-
$default_options['archive_url']
|
163 |
|
164 |
$default_options['yop_poll_archive_page_id'] = $poll_archive_page_id;
|
165 |
|
166 |
|
167 |
-
|
168 |
//addind default options
|
169 |
|
170 |
-
update_option(
|
171 |
-
|
172 |
|
173 |
|
174 |
}
|
175 |
|
176 |
-
function propagate_activation(
|
|
|
177 |
if (version_compare(phpversion(), '5.3', '<')) {
|
178 |
wp_die("Php version isn't high enough!");
|
179 |
}
|
180 |
|
181 |
-
$this->network_propagate(
|
182 |
|
183 |
}
|
184 |
|
185 |
-
function propagate_deactivation(
|
|
|
186 |
global $wpdb;
|
187 |
// $wpdb->query( "DROP TABLE `" . $wpdb->prefix . "yop_pollmeta`, `" . $wpdb->prefix . "yop_polls`, `" . $wpdb->prefix . "yop_poll_answermeta`, `" . $wpdb->prefix . "yop_poll_answers`, `" . $wpdb->prefix . "yop_poll_custom_fields`, `" . $wpdb->prefix . "yop_poll_logs`, `" . $wpdb->prefix . "yop_poll_voters`, `" . $wpdb->prefix . "yop_poll_bans`, `" . $wpdb->prefix . "yop_poll_templates`, `" . $wpdb->prefix . "yop_poll_votes_custom_fields`, `" . $wpdb->prefix . "yop_poll_facebook_users`" );
|
188 |
-
$this->network_propagate(
|
189 |
}
|
190 |
-
|
191 |
-
|
|
|
|
|
192 |
global $wpdb;
|
193 |
|
194 |
-
if (
|
195 |
if (!(version_compare(phpversion(), '5.3', '<'))) {
|
196 |
-
ini_set("memory_limit","1024M");
|
197 |
-
require_once(
|
198 |
-
require_once(
|
199 |
-
if(empty($current_options)){
|
200 |
-
$current_options=get_option(
|
201 |
|
202 |
-
$default=get_option(
|
203 |
}
|
204 |
$capObj = YOP_POLL_Capabilities::get_instance();
|
205 |
$capObj->install_capabilities();
|
206 |
Yop_Poll_DbSchema::create_poll_database_tables();
|
207 |
-
$wpdb->query(
|
208 |
-
|
209 |
-
|
210 |
-
$new_options=array(
|
211 |
-
|
212 |
-
'user_interface_type'
|
213 |
-
'is_default_answer'
|
214 |
-
'poll_start_date'
|
215 |
-
'poll_end_date'
|
216 |
-
'view_results'
|
217 |
-
'view_results_start_date'
|
218 |
-
'view_results_permissions'
|
219 |
-
'view_results_type'
|
220 |
-
'answer_result_label'
|
221 |
-
'vote_button_label'
|
222 |
-
'template_width'
|
223 |
-
'widget_template_width'
|
224 |
-
'view_results_link'
|
225 |
-
'view_results_link_label'
|
226 |
-
'view_back_to_vote_link'
|
227 |
-
'view_back_to_vote_link_label'
|
228 |
-
'view_total_votes'
|
229 |
-
'view_total_votes_label'
|
230 |
-
'view_total_answers'
|
231 |
-
'view_total_answers_label'
|
232 |
-
'message_after_vote'
|
233 |
-
'vote_permisions'
|
234 |
-
'vote_permisions_wordpress'
|
235 |
-
'vote_permisions_wordpress_label'
|
236 |
-
'vote_permisions_anonymous'
|
237 |
-
'vote_permisions_anonymous_label'
|
238 |
-
'blocking_voters'
|
239 |
-
'blocking_voters_interval_value'
|
240 |
-
'blocking_voters_interval_unit'
|
241 |
-
'limit_number_of_votes_per_user'
|
242 |
-
'number_of_votes_per_user'
|
243 |
-
'percentages_decimals'
|
244 |
-
'use_default_loading_image'
|
245 |
-
'loading_image_url'
|
246 |
-
'redirect_after_vote'
|
247 |
-
'redirect_after_vote_url'
|
248 |
-
'date_format'
|
249 |
-
'view_poll_archive_link'
|
250 |
-
'auto_generate_poll_page'
|
251 |
-
'has_auto_generate_poll_page'
|
252 |
-
'use_captcha'
|
253 |
-
'send_email_notifications'
|
254 |
-
'allow_other_answers'
|
255 |
-
'other_answers_label'
|
256 |
-
'is_default_other_answer'
|
257 |
-
'add_other_answers_to_default_answers'
|
258 |
-
'display_other_answers_values'
|
259 |
-
'allow_multiple_answers'
|
260 |
-
'allow_multiple_answers_number'
|
261 |
-
'allow_multiple_answers_min_number'
|
262 |
-
'display_answers'
|
263 |
-
'display_answers_tabulated_cols'
|
264 |
-
'sorting_results'
|
265 |
-
'sorting_answers'
|
266 |
-
'sorting_results_direction'
|
267 |
-
'sorting_answers_direction'
|
268 |
-
'singular_answer_result_votes_number_label' =>
|
269 |
-
'plural_answer_result_votes_number_label'
|
270 |
-
'display_results'
|
271 |
-
'display_results_tabulated_cols'
|
272 |
-
'bar_background'
|
273 |
-
'bar_height'
|
274 |
-
'bar_border_color'
|
275 |
-
'bar_border_width'
|
276 |
-
'bar_border_style'
|
277 |
-
'sorting_archive_polls'
|
278 |
-
'sorting_archive_polls_rule'
|
279 |
-
'archive_url'
|
280 |
-
'archive_link_label'
|
281 |
-
'show_poll_in_archive'
|
282 |
-
'poll_archive_order'
|
283 |
-
'archive_polls_per_page'
|
284 |
-
'email_notifications_from_name'
|
285 |
-
'email_notifications_from_email'
|
286 |
-
'email_notifications_recipients'
|
287 |
-
'email_notifications_subject'
|
288 |
-
'email_notifications_body'
|
289 |
|
290 |
<p>Vote Details:</p>
|
291 |
|
@@ -316,57 +298,57 @@ class YOP_POLL_Maintenance {
|
|
316 |
[/QUESTION]
|
317 |
|
318 |
<p><b>Vote ID:</b> <br />%VOTE_ID%</p>',
|
319 |
-
'schedule_reset_poll_stats'
|
320 |
-
'schedule_reset_poll_date'
|
321 |
-
'schedule_reset_poll_recurring_value'
|
322 |
-
'schedule_reset_poll_recurring_unit'
|
323 |
-
'singular_answer_result_votes_number_label' => __yop_poll(
|
324 |
-
'plural_answer_result_votes_number_label'
|
325 |
-
'start_scheduler'
|
326 |
-
'use_the_same_template_for_widget'
|
327 |
-
'vote_permisions_facebook'
|
328 |
|
329 |
-
'vote_permisions_facebook_label'
|
330 |
|
331 |
-
'facebook_share_after_vote'
|
332 |
|
333 |
-
'facebook_share_description'
|
334 |
|
335 |
-
'vote_permisions_google'
|
336 |
|
337 |
-
'vote_permisions_google_label'
|
338 |
|
339 |
-
'show_google_share_button'
|
340 |
-
'google_integration'
|
341 |
-
'facebook_integration'
|
342 |
-
'facebook_show_comments_widget'
|
343 |
// 'view_total_answers_label' => __yop_poll( 'Poll total answers: %POLL-TOTAL-ANSWERS%' ),
|
344 |
|
345 |
);
|
346 |
-
if(
|
347 |
-
$new_options['blocking_voters'
|
348 |
-
else{
|
349 |
-
if(
|
350 |
-
$new_options['blocking_voters'
|
351 |
}
|
352 |
-
list($g1
|
353 |
-
$new_options['view_results_permissions'
|
354 |
-
list($g1
|
355 |
-
$new_options['view_results_link'
|
356 |
-
|
357 |
-
|
358 |
YOP_POLL_Maintenance::activation_hook($default);
|
359 |
-
$wpdb->query(
|
360 |
|
361 |
}
|
362 |
}
|
363 |
-
$installed_version = get_option(
|
364 |
|
365 |
-
if (
|
366 |
ini_set('max_execution_time', 700);
|
367 |
-
ini_set("memory_limit","512M");
|
368 |
-
$default_poll_options = get_option(
|
369 |
-
$default_poll_options['email_notifications_body']
|
370 |
|
371 |
<p>Vote Details:</p>
|
372 |
|
@@ -397,10 +379,10 @@ class YOP_POLL_Maintenance {
|
|
397 |
[/QUESTION]
|
398 |
|
399 |
<p><b>Vote ID:</b> <br />%VOTE_ID%</p>';
|
400 |
-
update_option(
|
401 |
-
$templates
|
402 |
-
foreach($templates as $template){
|
403 |
-
$template['js']=
|
404 |
function stripBorder_%POLL-ID%(object) {
|
405 |
object.each(function() {
|
406 |
if( parseInt(jQuery(this).width() ) > 0) {
|
@@ -509,10 +491,10 @@ function runOnPollStateChange_%POLL-ID%() {
|
|
509 |
NOWDOC;
|
510 |
self::update_poll_template_in_database(($template));
|
511 |
}
|
512 |
-
$polls=self::yop_poll_get_polls_for_body_mail_update();
|
513 |
-
foreach($polls as $poll){
|
514 |
-
|
515 |
-
$current->email_notifications_body='<p>A new vote was registered on %VOTE_DATE% for %POLL_NAME%</p>
|
516 |
|
517 |
<p>Vote Details:</p>
|
518 |
|
@@ -546,36 +528,36 @@ NOWDOC;
|
|
546 |
$current->save();
|
547 |
|
548 |
}
|
549 |
-
update_option(
|
550 |
}
|
551 |
-
$installed_version = get_option(
|
552 |
-
if (
|
553 |
-
update_option(
|
554 |
}
|
555 |
-
$installed_version = get_option(
|
556 |
-
if (
|
557 |
-
update_option(
|
558 |
}
|
559 |
-
$installed_version = get_option(
|
560 |
|
561 |
-
if (
|
562 |
global $wpdb;
|
563 |
-
update_option(
|
564 |
-
$default_poll_options = get_option(
|
565 |
-
$default_poll_options['show_results_in']="bar";
|
566 |
-
update_option(
|
567 |
|
568 |
-
$wpdb->query(
|
569 |
-
update_option(
|
570 |
|
571 |
}
|
572 |
-
if (
|
573 |
global $wpdb;
|
574 |
-
update_option(
|
575 |
|
576 |
-
$templates
|
577 |
-
foreach($templates as $template){
|
578 |
-
$template['js']=
|
579 |
function stripBorder_%POLL-ID%(object) {
|
580 |
object.each(function() {
|
581 |
if( parseInt(jQuery(this).width() ) > 0) {
|
@@ -730,7 +712,7 @@ function runOnPollStateChange_%POLL-ID%() {
|
|
730 |
|
731 |
};
|
732 |
NOWDOC;
|
733 |
-
$template['after_vote_template_chart']=
|
734 |
[QUESTION_CONTAINER]
|
735 |
<div id = "yop-poll-question-container-%POLL-ID%-%QUESTION-ID%" class = "yop-poll-question-container-%POLL-ID%">
|
736 |
<div id = "yop-poll-question-%POLL-ID%-%QUESTION-ID%"
|
@@ -753,25 +735,34 @@ NOWDOC;
|
|
753 |
NOWDOC;
|
754 |
self::update_poll_template_in_database2($template);
|
755 |
}
|
756 |
-
update_option(
|
757 |
|
758 |
}
|
759 |
-
if (
|
760 |
global $wpdb;
|
761 |
-
update_option(
|
762 |
}
|
763 |
-
if (
|
764 |
global $wpdb;
|
765 |
-
update_option(
|
766 |
}
|
767 |
-
if (
|
768 |
global $wpdb;
|
769 |
-
update_option(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
770 |
}
|
771 |
}
|
772 |
-
|
|
|
|
|
773 |
global $wpdb;
|
774 |
-
$sql = $wpdb->query(
|
775 |
UPDATE " . $wpdb->yop_poll_templates . "
|
776 |
SET name = %s,
|
777 |
before_vote_template = %s,
|
@@ -784,138 +775,149 @@ NOWDOC;
|
|
784 |
last_modified = %s
|
785 |
WHERE
|
786 |
id = %d
|
787 |
-
", $template['name'], $template['before_vote_template'], $template['after_vote_template']
|
788 |
return $sql;
|
789 |
}
|
790 |
-
|
|
|
|
|
791 |
global $wpdb;
|
792 |
-
$result = $wpdb->get_results((
|
793 |
SELECT ID
|
794 |
-
FROM " . $wpdb->yop_polls." ORDER BY ID ASC
|
795 |
-
"
|
796 |
return $result;
|
797 |
}
|
798 |
-
|
799 |
-
|
|
|
|
|
800 |
|
801 |
$default_poll_options['is_default_answer'] = 'no';
|
802 |
-
$default_poll_options['poll_start_date'
|
803 |
-
$default_poll_options['poll_end_date']
|
804 |
|
805 |
-
update_option(
|
806 |
}
|
807 |
|
808 |
-
private function uninstall_default_options()
|
|
|
809 |
// delete_option( "yop_poll_version" );
|
810 |
// delete_option( "yop_poll_options" );
|
811 |
}
|
812 |
|
813 |
-
public function activate(
|
814 |
-
|
815 |
-
|
|
|
816 |
}
|
817 |
|
818 |
-
if(
|
819 |
-
$error = new WP_Error (
|
820 |
-
$error = new WP_Error (
|
821 |
}
|
822 |
|
823 |
-
if(
|
824 |
-
wp_die(
|
825 |
}
|
826 |
|
827 |
|
828 |
-
require_once(
|
829 |
-
require_once(
|
830 |
$this->install_default_options();
|
831 |
$capObj = YOP_POLL_Capabilities::get_instance();
|
832 |
$capObj->install_capabilities();
|
833 |
Yop_Poll_DbSchema::install_database();
|
834 |
}
|
835 |
|
836 |
-
public function deactivatedelete(
|
837 |
-
|
|
|
838 |
Yop_Poll_DbSchema::delete_database_tables();
|
839 |
$capObj = YOP_POLL_Capabilities::get_instance();
|
840 |
$capObj->uninstall_capabilities();
|
841 |
$this->uninstall_default_options();
|
842 |
}
|
843 |
|
844 |
-
function new_blog(
|
845 |
-
|
846 |
-
|
|
|
847 |
}
|
848 |
-
if(
|
849 |
$old_blog = $GLOBALS['wpdb']->blogid;
|
850 |
-
switch_to_blog(
|
851 |
-
yop_poll_create_table_names(
|
852 |
-
$this->activate(
|
853 |
-
switch_to_blog(
|
854 |
-
yop_poll_create_table_names(
|
855 |
}
|
856 |
}
|
857 |
|
858 |
-
function delete_blog(
|
|
|
859 |
$old_blog = $GLOBALS['wpdb']->blogid;
|
860 |
-
switch_to_blog(
|
861 |
-
yop_poll_create_table_names(
|
862 |
-
$this->deactivatedelete(
|
863 |
-
require_once(
|
864 |
// Yop_Poll_DbSchema::delete_database_tables();
|
865 |
$capObj = YOP_POLL_Capabilities::get_instance();
|
866 |
$capObj->uninstall_capabilities();
|
867 |
$this->uninstall_default_options();
|
868 |
-
switch_to_blog(
|
869 |
-
yop_poll_create_table_names(
|
870 |
}
|
871 |
|
872 |
-
function update()
|
|
|
873 |
}
|
874 |
|
875 |
-
public function activation_hook($default)
|
|
|
876 |
ini_set('max_execution_time', 700);
|
877 |
-
$current_options=get_option(
|
878 |
-
$polls
|
879 |
-
$answers
|
880 |
-
$logs
|
881 |
-
$bans
|
882 |
$custom_fields = self::yop_poll_get_custom_fields_from_db();
|
883 |
-
$custom_votes
|
884 |
-
$metas
|
885 |
-
$answers_meta
|
886 |
-
$templates
|
887 |
-
foreach($templates as $template){
|
888 |
-
$template['before_vote_template'] ="[QUESTION_CONTAINER]". $template['before_vote_template'];
|
889 |
-
$template['before_vote_template']=str_replace('%POLL-ANSWER-LABEL%','%POLL-ANSWER-LABEL% [ANSWER_RESULT_CONTAINER]'
|
890 |
-
$template['before_vote_template']=str_replace('%POLL-TOTAL-ANSWERS%','%POLL-TOTAL-ANSWERS-LABEL%'
|
891 |
-
$template['before_vote_template']=str_replace('%POLL-TOTAL-VOTES%','%POLL-TOTAL-VOTES-LABEL%'
|
892 |
-
$template['after_vote_template']=str_replace('%POLL-TOTAL-VOTES%','%POLL-TOTAL-VOTES-LABEL%'
|
893 |
-
$template['after_vote_template']=str_replace('%POLL-TOTAL-ANSWERS%','%POLL-TOTAL-ANSWERS-LABEL%'
|
894 |
-
$template['after_end_date_template']=str_replace('%POLL-TOTAL-ANSWERS%','%POLL-TOTAL-ANSWERS-LABEL%'
|
895 |
-
$template['after_end_date_template']=str_replace('%POLL-TOTAL-VOTES%','%POLL-TOTAL-VOTES-LABEL%'
|
896 |
-
$template['before_vote_template']=preg_replace('/%POLL-ANSWER-RESULT-BAR%/','%POLL-ANSWER-RESULT-BAR% [/ANSWER_RESULT_CONTAINER]'
|
897 |
$find = '[/ANSWER_RESULT_CONTAINER]';
|
898 |
$replace = '';
|
899 |
// $template['before_vote_template']= preg_replace(strrev("/$find/"),strrev($replace),strrev( $template['before_vote_template']),1);
|
900 |
-
$template['after_vote_template'] ="[QUESTION_CONTAINER]". $template['after_vote_template'];
|
901 |
-
$template['after_end_date_template'] ="[QUESTION_CONTAINER]". $template['after_end_date_template'];
|
902 |
/* if(strpos($template['before_vote_template'],"[CAPTCHA_CONTAINER]"))
|
903 |
$template['before_vote_template']=str_replace('[CAPTCHA_CONTAINER]','[/QUESTION_CONTAINER][CAPTCHA_CONTAINER]',$template['before_vote_template']);
|
904 |
else{
|
905 |
$template['before_vote_template']=str_replace('<div id="yop-poll-vote-%POLL-ID%" class="yop-poll-footer">','[/QUESTION_CONTAINER]<div id="yop-poll-vote-%POLL-ID%" class="yop-poll-footer">',$template['before_vote_template']);
|
906 |
} */
|
907 |
-
$template['before_vote_template']= $template['before_vote_template'].'[/QUESTION_CONTAINER]'
|
908 |
-
if(strpos($template['before_vote_template'],"%POLL-QUESTION%")&&strpos($template['before_vote_template'],'%POLL-NAME%')){
|
909 |
-
$template['before_vote_template']=str_replace('%POLL-QUESTION%',''
|
910 |
-
$template['before_vote_template']=str_replace('%POLL-NAME%','%POLL-QUESTION%'
|
911 |
}
|
912 |
-
if(strpos($template['after_vote_template'],"%POLL-QUESTION%")&&strpos($template['after_vote_template'],'%POLL-NAME%')){
|
913 |
-
$template['after_vote_template']=str_replace('%POLL-QUESTION%',''
|
914 |
-
$template['after_vote_template']=str_replace('%POLL-NAME%','%POLL-QUESTION%'
|
915 |
}
|
916 |
-
$template['after_vote_template']=
|
917 |
-
$template['after_end_date_template']
|
918 |
-
$template['js']
|
919 |
function stripBorder_%POLL-ID%(object) {
|
920 |
object.each(function() {
|
921 |
if( parseInt(jQuery(this).width() ) > 0) {
|
@@ -1071,60 +1073,60 @@ function runOnPollStateChange_%POLL-ID%() {
|
|
1071 |
};
|
1072 |
|
1073 |
NOWDOC;
|
1074 |
-
$template['js'] = addslashes(
|
1075 |
-
$templates_ids[$template['id']]=self::insert_template_in_databease(($template));
|
1076 |
}
|
1077 |
|
1078 |
-
foreach(
|
1079 |
|
1080 |
-
foreach(
|
1081 |
-
if(
|
1082 |
$answers_ordonate[$poll['id']][] = (array)$answer;
|
1083 |
}
|
1084 |
-
if(
|
1085 |
break;
|
1086 |
}
|
1087 |
|
1088 |
-
foreach(
|
1089 |
-
if(
|
1090 |
-
$logs_ordonate[$poll['id']][]
|
1091 |
$logs_ordonate_details[$log['id']][] = $answer['answer'];
|
1092 |
}
|
1093 |
}
|
1094 |
-
foreach(
|
1095 |
-
if(
|
1096 |
$answer_meta_ordonate[$answer['id']][] = (array)$answer_meta;
|
1097 |
}
|
1098 |
}
|
1099 |
}
|
1100 |
|
1101 |
-
foreach(
|
1102 |
-
if(
|
1103 |
$bans_ordonate[$poll['id']][] = (array)$ban;
|
1104 |
}
|
1105 |
-
if(
|
1106 |
break;
|
1107 |
}
|
1108 |
}
|
1109 |
|
1110 |
-
foreach(
|
1111 |
-
if(
|
1112 |
$metas_ordonate[$poll['id']][] = (array)$meta;
|
1113 |
}
|
1114 |
-
if(
|
1115 |
break;
|
1116 |
}
|
1117 |
}
|
1118 |
|
1119 |
-
foreach(
|
1120 |
-
if(
|
1121 |
$custom_fields_ordonate[$poll['id']][] = (array)$custom_field;
|
1122 |
-
if(
|
1123 |
break;
|
1124 |
}
|
1125 |
|
1126 |
-
foreach(
|
1127 |
-
if(
|
1128 |
$custom_votes_fields_ordonate[$custom_field['id']][] = (array)$custom_vote;
|
1129 |
}
|
1130 |
}
|
@@ -1133,18 +1135,18 @@ NOWDOC;
|
|
1133 |
}
|
1134 |
|
1135 |
|
1136 |
-
foreach(
|
1137 |
-
$current_poll
|
1138 |
-
$current_poll->poll_author
|
1139 |
-
$current_poll->ID
|
1140 |
-
$current_poll->poll_title
|
1141 |
-
$current_poll->poll_name
|
1142 |
-
$current_poll->poll_date
|
1143 |
$current_poll->poll_modified = $poll['last_modified'];
|
1144 |
-
$current_poll->poll_status
|
1145 |
-
$current_poll->poll_type
|
1146 |
-
$current_poll->poll_status
|
1147 |
-
$current_poll->email_notifications_body='<p>A new vote was registered on %VOTE_DATE% for %POLL_NAME%</p>
|
1148 |
|
1149 |
<p>Vote Details:</p>
|
1150 |
|
@@ -1175,188 +1177,178 @@ NOWDOC;
|
|
1175 |
[/QUESTION]
|
1176 |
|
1177 |
<p><b>Vote ID:</b> <br />%VOTE_ID%</p>';
|
1178 |
-
if(
|
1179 |
-
|
1180 |
-
$current_poll->poll_end_date =convert_date ($poll['end_date'],'d-m-Y H:i:s',1 );
|
1181 |
|
1182 |
-
|
1183 |
|
1184 |
-
else {
|
1185 |
|
1186 |
$current_poll->poll_end_date = "01-01-2038 23:59:59";
|
1187 |
|
1188 |
}
|
1189 |
|
1190 |
-
if(
|
1191 |
|
1192 |
-
$current_poll->poll_start_date = convert_date($poll['start_date'],'d-m-Y H:i:s',1
|
1193 |
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
else {
|
1197 |
|
1198 |
$current_poll->poll_start_date = "01-01-2038 23:59:59";
|
1199 |
|
1200 |
}
|
1201 |
$current_poll->poll_total_votes = $poll['total_votes'];
|
1202 |
-
$question
|
1203 |
-
$question->type
|
1204 |
-
$question->question
|
1205 |
-
$question->question_date
|
1206 |
-
$question->question_author
|
1207 |
-
$question->question_modified
|
1208 |
-
$question->question_status
|
1209 |
-
$question->poll_order
|
1210 |
-
$i
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
$
|
1218 |
-
$question->allow_other_answers= 'yes';
|
1219 |
}
|
1220 |
}
|
1221 |
-
$q[]
|
1222 |
// yop_poll_dump($current_poll);
|
1223 |
$current_poll->questions = $q;
|
1224 |
-
$current_poll->auto_generate_poll_page="no";
|
1225 |
-
$current_poll_id
|
1226 |
-
$current_poll_id
|
1227 |
// yop_poll_dump($current_poll->save())
|
1228 |
-
$no_modif=0;
|
1229 |
-
$no_modif2=0;
|
1230 |
-
$current_poll_meta
|
1231 |
-
if(
|
1232 |
-
$poll_option = maybe_unserialize(
|
1233 |
-
foreach(
|
1234 |
-
if(
|
1235 |
|
1236 |
-
if($key=='view_results_permissions'){
|
1237 |
|
1238 |
-
list($g1
|
1239 |
-
if($g1=="quest"){
|
1240 |
-
$g1="guest";
|
1241 |
|
1242 |
}
|
1243 |
|
1244 |
-
$current_poll_meta[$key] = array($g1
|
1245 |
-
$no_modif=1;
|
1246 |
|
1247 |
-
}
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
$g1="guest";
|
1253 |
|
1254 |
}
|
1255 |
-
$no_modif2=1;
|
1256 |
-
$current_poll_meta[$key] = array($g1
|
1257 |
-
}
|
1258 |
-
else
|
1259 |
$current_poll_meta[$key] = $poll_option[$key];
|
1260 |
|
1261 |
|
1262 |
} else
|
1263 |
-
$current_poll_meta[$key]
|
1264 |
}
|
1265 |
}
|
1266 |
-
$current_poll_meta['view_results'] = array($poll_option['view_results']
|
1267 |
$current_poll_meta['sorting_results'] = $default['sorting_answers'];
|
1268 |
-
if(!isset($poll_option['view_results_link'])){
|
1269 |
-
$current_poll_meta['view_results_link']="yes";
|
1270 |
-
}
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
if(empty( $current_poll_meta['view_results'][0])) {
|
1277 |
$current_poll_meta['view_results'] = array('after');
|
1278 |
}
|
1279 |
-
if($no_modif==0 ||empty($current_poll_meta['view_results'])){
|
1280 |
-
$current_poll_meta['view_results_permissions'] = array(
|
1281 |
|
1282 |
}
|
1283 |
|
1284 |
-
if($no_modif2==0||empty($current_poll_meta['vote_permisions'])){
|
1285 |
-
$current_poll_meta['vote_permisions'] = array(
|
1286 |
}
|
1287 |
|
1288 |
-
if(
|
1289 |
-
$current_poll_meta['blocking_voters'
|
1290 |
else {
|
1291 |
-
if(
|
1292 |
-
$current_poll_meta['blocking_voters'
|
1293 |
else
|
1294 |
-
$current_poll_meta['blocking_voters'
|
1295 |
-
}
|
1296 |
-
$current_poll_meta['facebook_share_after_vote']="no";
|
1297 |
-
$current_poll_meta['show_google_share_button']="no";
|
1298 |
-
$current_poll_meta['facebook_show_comments_widget'] ="no";
|
1299 |
-
$current_poll_meta['facebook_share_description'] = __yop_poll( 'Just casted an YOP Poll vote on ' ) . get_bloginfo( 'name' );
|
1300 |
-
if(isset($poll_option['show_in_archive']))
|
1301 |
-
$current_poll_meta['show_poll_in_archive']=$poll_option['show_in_archive'] ;
|
1302 |
-
if(isset($poll_option['schedule_reset_poll_date']))
|
1303 |
-
$current_poll_meta['schedule_reset_poll_date']=$poll_option['schedule_reset_poll_date'] ;
|
1304 |
-
if(isset($poll_option['template'])){
|
1305 |
-
$current_poll_meta['template']=$templates_ids[ $poll_option['template']];
|
1306 |
-
} else $current_poll_meta['template']=1;
|
1307 |
-
if(isset($poll_option['widget_template'])){
|
1308 |
-
$current_poll_meta['widget_template']=$templates_ids[ $poll_option['widget_template']];
|
1309 |
}
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1313 |
}
|
1314 |
-
if(isset($poll_option['view_total_answers_label'])){
|
1315 |
-
$current_poll_meta['view_total_answers_label']
|
1316 |
}
|
1317 |
-
if(isset($poll_option['answer_result_label'])){
|
1318 |
-
$current_poll_meta['answer_result_label']
|
1319 |
}
|
1320 |
-
if(
|
1321 |
-
$current_poll_meta['vote_permisions_anonymous']="yes";
|
1322 |
}
|
1323 |
-
update_yop_poll_question_meta(
|
1324 |
-
update_yop_poll_meta(
|
1325 |
-
if($poll['show_in_archive'] =="yes"){
|
1326 |
-
self::save_poll_order($current_poll_id
|
1327 |
}
|
1328 |
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
if($default['sorting_answers']=="alphabetical"){
|
1333 |
-
$answers_ordonate[$poll['id']]=self::get_answers_order_by_alph($poll['id']
|
1334 |
}
|
1335 |
-
foreach(
|
1336 |
-
$ans
|
1337 |
-
$ans->answer
|
1338 |
-
$ans->answer_author
|
1339 |
-
$ans->answer_date
|
1340 |
$ans->answer_modified = $poll['last_modified'];
|
1341 |
-
if(
|
1342 |
$ans->type = "text";
|
1343 |
-
}
|
1344 |
-
|
1345 |
-
$
|
1346 |
-
$question->allow_other_answers = 'yes';
|
1347 |
$ans->type = "other";
|
1348 |
}
|
1349 |
-
$ans->answer_status
|
1350 |
-
$ans->votes
|
1351 |
-
$ans->question_order = $i
|
1352 |
|
1353 |
-
if(
|
1354 |
$answersa[] = $ans;
|
1355 |
-
if(
|
1356 |
-
$answer_option
|
1357 |
$answer_options = $ans->options;
|
1358 |
-
foreach(
|
1359 |
-
if(
|
1360 |
$ans->$key = $answer_option[$key];
|
1361 |
}
|
1362 |
|
@@ -1364,87 +1356,88 @@ NOWDOC;
|
|
1364 |
$ans->options = $answer_options;
|
1365 |
}
|
1366 |
|
1367 |
-
$question->addAnswer(
|
1368 |
|
1369 |
$question->save_answers();
|
1370 |
$answersids[$answer_ordonate['id']] = $ans->ID;
|
1371 |
}
|
1372 |
|
1373 |
}
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
|
|
1387 |
}
|
1388 |
-
}
|
1389 |
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
}
|
1416 |
-
if(!empty($custom_field_vote[$poll['id']]))
|
1417 |
-
foreach( $custom_field_vote[$poll['id']] as $vote ) {
|
1418 |
-
if( $vote['vote_id'] == $log_ordonate['vote_id'] ) {
|
1419 |
-
$vote_details[1]["q-" . $current_poll_id]['cf'][] = $vote['id'];
|
1420 |
}
|
|
|
|
|
|
|
|
|
|
|
1421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1422 |
}
|
1423 |
-
|
1424 |
-
|
1425 |
-
$
|
1426 |
-
$
|
1427 |
-
|
1428 |
-
insert_log_in_db( $log );
|
1429 |
-
unset( $vote_details[1]["q-" . $current_poll_id]['answers'] );
|
1430 |
}
|
1431 |
-
unset( $vote_details );
|
1432 |
-
}
|
1433 |
-
if(!empty($bans_ordonate[$poll['id']]))
|
1434 |
-
foreach( $bans_ordonate[$poll['id']] as $ban_ordonate ) {
|
1435 |
-
$ban = $ban_ordonate;
|
1436 |
-
$ban['poll_id'] = $current_poll_id;
|
1437 |
-
self::insert_ban_in_db( $ban );
|
1438 |
-
}
|
1439 |
|
1440 |
|
1441 |
}
|
1442 |
|
1443 |
}
|
1444 |
|
1445 |
-
public function insert_template_in_databease($template)
|
|
|
1446 |
global $wpdb;
|
1447 |
-
$sql= $wpdb->query(
|
1448 |
INSERT INTO " . $wpdb->yop_poll_templates . "
|
1449 |
SET
|
1450 |
template_author = %d,
|
@@ -1458,12 +1451,14 @@ NOWDOC;
|
|
1458 |
date_added = %s,
|
1459 |
last_modified = %s,
|
1460 |
status = %s
|
1461 |
-
", $template['template_author'], $template['name'], $template['before_vote_template'], $template['after_vote_template'], $template['before_start_date_template'], $template['after_end_date_template'], $template['css'], $template['js'], current_time(
|
1462 |
return $GLOBALS['wpdb']->insert_id;
|
1463 |
}
|
1464 |
-
|
|
|
|
|
1465 |
global $wpdb;
|
1466 |
-
$sql = $wpdb->query(
|
1467 |
UPDATE " . $wpdb->yop_poll_templates . "
|
1468 |
SET name = %s,
|
1469 |
before_vote_template = %s,
|
@@ -1475,145 +1470,164 @@ NOWDOC;
|
|
1475 |
last_modified = %s
|
1476 |
WHERE
|
1477 |
id = %d
|
1478 |
-
", $template['name'], $template['before_vote_template'], $template['after_vote_template'], $template['before_start_date_template'], $template['after_end_date_template'], $template['css'], $template['js'], current_time(
|
1479 |
return $sql;
|
1480 |
}
|
1481 |
-
|
|
|
|
|
1482 |
global $wpdb;
|
1483 |
-
$result = $wpdb->get_results((
|
1484 |
SELECT *
|
1485 |
FROM " . $wpdb->prefix . "yop_polls ORDER BY id ASC
|
1486 |
-
"
|
1487 |
return $result;
|
1488 |
|
1489 |
}
|
1490 |
|
1491 |
-
public function yop_poll_get_polls_meta_from_db()
|
|
|
1492 |
global $wpdb;
|
1493 |
-
$result = $wpdb->get_results(
|
1494 |
SELECT *
|
1495 |
FROM " . $wpdb->prefix . "yop_pollmeta ORDER BY yop_poll_id ASC
|
1496 |
-
"
|
1497 |
return $result;
|
1498 |
|
1499 |
}
|
1500 |
|
1501 |
-
public function yop_poll_get_answers_meta_from_db()
|
|
|
1502 |
global $wpdb;
|
1503 |
|
1504 |
-
$result = $wpdb->get_results(
|
1505 |
SELECT *
|
1506 |
FROM " . $wpdb->prefix . "yop_poll_answermeta
|
1507 |
-
"
|
1508 |
return $result;
|
1509 |
|
1510 |
}
|
1511 |
|
1512 |
-
public function yop_poll_get_templates_from_db()
|
|
|
1513 |
global $wpdb;
|
1514 |
-
$result = $wpdb->get_results(
|
1515 |
SELECT *
|
1516 |
FROM " . $wpdb->prefix . "yop_poll_templates
|
1517 |
-
"
|
1518 |
return $result;
|
1519 |
}
|
1520 |
-
|
|
|
|
|
1521 |
global $wpdb;
|
1522 |
-
$result = $wpdb->get_results(
|
1523 |
SELECT *
|
1524 |
FROM " . $wpdb->yop_poll_templates
|
1525 |
-
|
1526 |
return $result;
|
1527 |
}
|
1528 |
|
1529 |
-
public function yop_poll_get_custom_fields_from_db()
|
|
|
1530 |
global $wpdb;
|
1531 |
-
$result = $wpdb->get_results(
|
1532 |
SELECT *
|
1533 |
FROM " . $wpdb->prefix . "yop_poll_custom_fields ORDER BY poll_id ASC
|
1534 |
-
"
|
1535 |
return $result;
|
1536 |
}
|
1537 |
|
1538 |
-
public function yop_poll_get_custom_fields_votes_from_db()
|
|
|
1539 |
global $wpdb;
|
1540 |
-
$result = $wpdb->get_results(
|
1541 |
SELECT *
|
1542 |
FROM " . $wpdb->prefix . "yop_poll_votes_custom_fields
|
1543 |
-
"
|
1544 |
return $result;
|
1545 |
}
|
1546 |
|
1547 |
-
public function yop_poll_get_bans_from_db()
|
|
|
1548 |
global $wpdb;
|
1549 |
-
$result = $wpdb->get_results(
|
1550 |
SELECT *
|
1551 |
FROM " . $wpdb->prefix . "yop_poll_bans ORDER BY poll_id ASC
|
1552 |
-
"
|
1553 |
return $result;
|
1554 |
}
|
1555 |
-
|
|
|
|
|
1556 |
global $wpdb;
|
1557 |
-
$result = $wpdb->get_results(
|
1558 |
SELECT *
|
1559 |
FROM " . $wpdb->prefix . "yop_poll_answers ORDER BY poll_id ASC
|
1560 |
-
"
|
1561 |
return $result;
|
1562 |
}
|
1563 |
-
|
|
|
|
|
1564 |
global $wpdb;
|
1565 |
-
$result = $wpdb->get_results(
|
1566 |
SELECT *
|
1567 |
FROM " . $wpdb->prefix . "yop_poll_answers WHERE poll_id=%d ORDER BY votes $dir
|
1568 |
-
"
|
1569 |
return $result;
|
1570 |
}
|
1571 |
|
1572 |
-
public function get_answers_order_by_alph($poll_id
|
|
|
1573 |
global $wpdb;
|
1574 |
-
$result = $wpdb->get_results(
|
1575 |
SELECT *
|
1576 |
FROM " . $wpdb->prefix . "yop_poll_answers WHERE poll_id=%d ORDER BY answer $dir
|
1577 |
-
"
|
1578 |
return $result;
|
1579 |
}
|
1580 |
|
1581 |
-
public function yop_poll_get_logs_from_db()
|
|
|
1582 |
global $wpdb;
|
1583 |
-
$result = $wpdb->get_results(
|
1584 |
SELECT *
|
1585 |
FROM " . $wpdb->prefix . "yop_poll_logs
|
1586 |
-
"
|
1587 |
return $result;
|
1588 |
}
|
1589 |
|
1590 |
-
private static function insert_ban_in_db(
|
|
|
1591 |
global $wpdb;
|
1592 |
-
$sql = $wpdb->query(
|
1593 |
INSERT INTO $wpdb->yop_poll_bans
|
1594 |
( poll_id,type,value,period ,unit)
|
1595 |
VALUES(%d,%s,%s,%d,%s)
|
1596 |
-
", $ban['poll_id'], $ban['type'], $ban['value'], intval(
|
1597 |
-
return $wpdb->get_results(
|
1598 |
}
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
|
|
|
|
1602 |
$poll_archive_order = array();
|
1603 |
-
}if( trim( $poll_order ) <= 0 ) {
|
1604 |
-
$poll_order = 1;
|
1605 |
}
|
1606 |
-
|
1607 |
-
|
1608 |
-
unset( $poll_archive_order[$key] );
|
1609 |
}
|
1610 |
-
|
1611 |
-
|
|
|
1612 |
}
|
1613 |
-
|
1614 |
-
|
|
|
|
|
1615 |
}
|
1616 |
-
update_option(
|
1617 |
}
|
1618 |
|
1619 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class YOP_POLL_Maintenance
|
4 |
+
{
|
5 |
|
6 |
+
private function network_propagate($pfunction, $networkwide)
|
7 |
+
{
|
8 |
+
error_reporting(0);
|
9 |
+
if (function_exists('is_multisite') && is_multisite()) {
|
10 |
|
11 |
+
if ($networkwide) {
|
12 |
|
13 |
$old_blog = $GLOBALS['wpdb']->blogid;
|
14 |
|
15 |
+
$blogids = $GLOBALS['wpdb']->get_col("SELECT blog_id FROM {$GLOBALS['wpdb']->blogs}");
|
16 |
|
17 |
+
foreach ($blogids as $blog_id) {
|
18 |
|
19 |
+
switch_to_blog($blog_id);
|
20 |
|
21 |
+
yop_poll_create_table_names($GLOBALS['wpdb']->prefix);
|
22 |
+
$version = get_option("yop_poll_version");
|
23 |
|
24 |
/* if ( version_compare( $version, '4.9.2', '<=' ) &&isset($version)) {
|
25 |
yop_poll_dump(12);
|
30 |
} */
|
31 |
|
32 |
|
33 |
+
$poll_archive_page = get_page_by_path('yop-poll-archive', ARRAY_A);
|
34 |
|
35 |
+
if (!$poll_archive_page) {
|
36 |
|
37 |
+
$_p = array();
|
38 |
|
39 |
+
$_p['post_title'] = 'Yop Poll Archive';
|
40 |
|
41 |
+
$_p['post_content'] = "[yop_poll_archive]";
|
42 |
|
43 |
+
$_p['post_status'] = 'publish';
|
44 |
|
45 |
+
$_p['post_type'] = 'page';
|
|
|
|
|
46 |
|
47 |
$_p['comment_status'] = 'open';
|
48 |
|
49 |
+
$_p['ping_status'] = 'open';
|
|
|
|
|
|
|
50 |
|
51 |
+
$_p['post_category'] = array(1); // the default 'Uncategorised'
|
52 |
|
|
|
53 |
|
54 |
+
$poll_archive_page_id = wp_insert_post($_p);
|
55 |
|
56 |
|
57 |
+
} else {
|
|
|
|
|
58 |
|
59 |
$poll_archive_page_id = $poll_archive_page['ID'];
|
60 |
|
61 |
}
|
62 |
|
63 |
|
64 |
+
call_user_func(array($this, $pfunction), $networkwide);
|
65 |
|
66 |
+
$version = get_option("yop_poll_version");
|
67 |
|
68 |
|
69 |
+
$default_options = get_option('yop_poll_options');
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
+
$default_options['archive_url'] = get_permalink($poll_archive_page_id);
|
|
|
|
|
|
|
72 |
|
73 |
$default_options['yop_poll_archive_page_id'] = $poll_archive_page_id;
|
74 |
|
75 |
|
|
|
76 |
//addind default options
|
77 |
|
78 |
+
update_option('yop_poll_options', $default_options);
|
|
|
79 |
|
80 |
|
81 |
}
|
82 |
|
83 |
+
switch_to_blog($old_blog);
|
84 |
|
85 |
+
yop_poll_create_table_names($GLOBALS['wpdb']->prefix);
|
86 |
|
87 |
return;
|
88 |
|
89 |
}
|
90 |
}
|
91 |
|
92 |
+
$version = get_option("yop_poll_version");
|
93 |
|
94 |
/* if ( version_compare( $version, '4.9.2', '<=' ) &&isset($version)) {
|
95 |
yop_poll_dump(12);
|
101 |
} */
|
102 |
|
103 |
|
104 |
+
$poll_archive_page = get_page_by_path('yop-poll-archive', ARRAY_A);
|
105 |
|
106 |
+
if (!$poll_archive_page) {
|
107 |
|
108 |
+
$_p = array();
|
109 |
|
110 |
+
$_p['post_title'] = 'Yop Poll Archive';
|
111 |
|
112 |
+
$_p['post_content'] = "[yop_poll_archive]";
|
113 |
|
114 |
+
$_p['post_status'] = 'publish';
|
115 |
|
116 |
+
$_p['post_type'] = 'page';
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
$_p['comment_status'] = 'open';
|
119 |
|
120 |
+
$_p['ping_status'] = 'open';
|
|
|
|
|
121 |
|
122 |
+
$_p['post_category'] = array(1); // the default 'Uncategorised'
|
123 |
|
124 |
|
125 |
+
$poll_archive_page_id = wp_insert_post($_p);
|
126 |
|
127 |
|
128 |
+
} else {
|
|
|
|
|
|
|
129 |
|
130 |
$poll_archive_page_id = $poll_archive_page['ID'];
|
131 |
|
132 |
}
|
133 |
|
134 |
|
|
|
135 |
//addind default options
|
136 |
|
137 |
+
call_user_func(array($this, $pfunction), $networkwide);
|
|
|
138 |
|
139 |
|
140 |
+
$default_options = get_option('yop_poll_options');
|
141 |
|
142 |
+
$default_options['archive_url'] = get_permalink($poll_archive_page_id);
|
143 |
|
144 |
$default_options['yop_poll_archive_page_id'] = $poll_archive_page_id;
|
145 |
|
146 |
|
|
|
147 |
//addind default options
|
148 |
|
149 |
+
update_option('yop_poll_options', $default_options);
|
|
|
150 |
|
151 |
|
152 |
}
|
153 |
|
154 |
+
function propagate_activation($networkwide)
|
155 |
+
{
|
156 |
if (version_compare(phpversion(), '5.3', '<')) {
|
157 |
wp_die("Php version isn't high enough!");
|
158 |
}
|
159 |
|
160 |
+
$this->network_propagate('activate', $networkwide);
|
161 |
|
162 |
}
|
163 |
|
164 |
+
function propagate_deactivation($networkwide)
|
165 |
+
{
|
166 |
global $wpdb;
|
167 |
// $wpdb->query( "DROP TABLE `" . $wpdb->prefix . "yop_pollmeta`, `" . $wpdb->prefix . "yop_polls`, `" . $wpdb->prefix . "yop_poll_answermeta`, `" . $wpdb->prefix . "yop_poll_answers`, `" . $wpdb->prefix . "yop_poll_custom_fields`, `" . $wpdb->prefix . "yop_poll_logs`, `" . $wpdb->prefix . "yop_poll_voters`, `" . $wpdb->prefix . "yop_poll_bans`, `" . $wpdb->prefix . "yop_poll_templates`, `" . $wpdb->prefix . "yop_poll_votes_custom_fields`, `" . $wpdb->prefix . "yop_poll_facebook_users`" );
|
168 |
+
$this->network_propagate('deactivate', $networkwide);
|
169 |
}
|
170 |
+
|
171 |
+
public function some_function($x = 0, $current_options = array())
|
172 |
+
{
|
173 |
+
$installed_version = get_option("yop_poll_version");
|
174 |
global $wpdb;
|
175 |
|
176 |
+
if (version_compare($installed_version, '4.9.3', '<=') || $x == 1) {
|
177 |
if (!(version_compare(phpversion(), '5.3', '<'))) {
|
178 |
+
ini_set("memory_limit", "1024M");
|
179 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
180 |
+
require_once(YOP_POLL_INC . 'db_schema.php');
|
181 |
+
if (empty($current_options)) {
|
182 |
+
$current_options = get_option('yop_poll_options');
|
183 |
|
184 |
+
$default = get_option('yop_poll_options');
|
185 |
}
|
186 |
$capObj = YOP_POLL_Capabilities::get_instance();
|
187 |
$capObj->install_capabilities();
|
188 |
Yop_Poll_DbSchema::create_poll_database_tables();
|
189 |
+
$wpdb->query('ALTER TABLE `' . $wpdb->yop_polls . '` CHANGE `ID` `ID` INT( 11 ) NOT NULL ');
|
190 |
+
$this->install_default_options();
|
191 |
+
|
192 |
+
$new_options = array(
|
193 |
+
|
194 |
+
'user_interface_type' => 'beginner',
|
195 |
+
'is_default_answer' => $current_options['is_default_answer'],
|
196 |
+
'poll_start_date' => current_time('mysql'),
|
197 |
+
'poll_end_date' => '01-01-2038 23:59:59',
|
198 |
+
'view_results' => array($current_options['view_results']),
|
199 |
+
'view_results_start_date' => convert_date($current_options['view_results_start_date'], 'd-m-Y H:i:s', 1),
|
200 |
+
'view_results_permissions' => array('guest', 'registered'),
|
201 |
+
'view_results_type' => $current_options['view_results_type'],
|
202 |
+
'answer_result_label' => $current_options['answer_result_label'],
|
203 |
+
'vote_button_label' => $current_options['vote_button_label'],
|
204 |
+
'template_width' => $current_options['template_width'],
|
205 |
+
'widget_template_width' => $current_options['widget_template_width'],
|
206 |
+
'view_results_link' => $current_options['view_results_link'],
|
207 |
+
'view_results_link_label' => $current_options['view_results_link_label'],
|
208 |
+
'view_back_to_vote_link' => $current_options['view_back_to_vote_link'],
|
209 |
+
'view_back_to_vote_link_label' => $current_options['view_back_to_vote_link_label'],
|
210 |
+
'view_total_votes' => $current_options['view_total_votes'],
|
211 |
+
'view_total_votes_label' => $current_options['view_total_votes_label'],
|
212 |
+
'view_total_answers' => $current_options['view_total_answers'],
|
213 |
+
'view_total_answers_label' => $current_options['view_total_answers_label'],
|
214 |
+
'message_after_vote' => $current_options['message_after_vote'],
|
215 |
+
'vote_permisions' => array('guest', 'registered'),
|
216 |
+
'vote_permisions_wordpress' => $current_options['vote_permisions_wordpress'],
|
217 |
+
'vote_permisions_wordpress_label' => $current_options['vote_permisions_wordpress_label'],
|
218 |
+
'vote_permisions_anonymous' => $current_options['vote_permisions_anonymous'],
|
219 |
+
'vote_permisions_anonymous_label' => $current_options['vote_permisions_anonymous_label'],
|
220 |
+
'blocking_voters' => array($current_options['blocking_voters']),
|
221 |
+
'blocking_voters_interval_value' => $current_options['blocking_voters_interval_value'],
|
222 |
+
'blocking_voters_interval_unit' => $current_options['blocking_voters_interval_unit'],
|
223 |
+
'limit_number_of_votes_per_user' => $current_options['limit_number_of_votes_per_user'],
|
224 |
+
'number_of_votes_per_user' => $current_options['number_of_votes_per_user'],
|
225 |
+
'percentages_decimals' => $current_options['percentages_decimals'],
|
226 |
+
'use_default_loading_image' => $current_options['use_default_loading_image'],
|
227 |
+
'loading_image_url' => $current_options['loading_image_url'],
|
228 |
+
'redirect_after_vote' => $current_options['redirect_after_vote'],
|
229 |
+
'redirect_after_vote_url' => $current_options['redirect_after_vote_url'],
|
230 |
+
'date_format' => 'UE',
|
231 |
+
'view_poll_archive_link' => $current_options['view_poll_archive_link'],
|
232 |
+
'auto_generate_poll_page' => $current_options['auto_generate_poll_page'],
|
233 |
+
'has_auto_generate_poll_page' => $current_options['has_auto_generate_poll_page'],
|
234 |
+
'use_captcha' => $current_options['use_captcha'],
|
235 |
+
'send_email_notifications' => $current_options['send_email_notifications'],
|
236 |
+
'allow_other_answers' => $current_options['allow_other_answers'],
|
237 |
+
'other_answers_label' => $current_options['other_answers_label'],
|
238 |
+
'is_default_other_answer' => $current_options['is_default_other_answer'],
|
239 |
+
'add_other_answers_to_default_answers' => $current_options['add_other_answers_to_default_answers'],
|
240 |
+
'display_other_answers_values' => $current_options['display_other_answers_values'],
|
241 |
+
'allow_multiple_answers' => $current_options['allow_multiple_answers'],
|
242 |
+
'allow_multiple_answers_number' => $current_options['allow_multiple_answers_number'],
|
243 |
+
'allow_multiple_answers_min_number' => $current_options['allow_multiple_answers_min_number'],
|
244 |
+
'display_answers' => $current_options['display_answers'],
|
245 |
+
'display_answers_tabulated_cols' => $current_options['display_answers_tabulated_cols'],
|
246 |
+
'sorting_results' => 'as_defined',
|
247 |
+
'sorting_answers' => 'as_defined',
|
248 |
+
'sorting_results_direction' => $current_options['sorting_results_direction'],
|
249 |
+
'sorting_answers_direction' => $current_options['sorting_answers_direction'],
|
250 |
+
'singular_answer_result_votes_number_label' => $current_options['singular_answer_result_votes_number_label'],
|
251 |
+
'plural_answer_result_votes_number_label' => $current_options['plural_answer_result_votes_number_label'],
|
252 |
+
'display_results' => $current_options['display_results'],
|
253 |
+
'display_results_tabulated_cols' => $current_options['display_results_tabulated_cols'],
|
254 |
+
'bar_background' => $current_options['bar_background'],
|
255 |
+
'bar_height' => $current_options['bar_height'],
|
256 |
+
'bar_border_color' => $current_options['bar_border_color'],
|
257 |
+
'bar_border_width' => $current_options['bar_border_width'],
|
258 |
+
'bar_border_style' => $current_options['bar_border_style'],
|
259 |
+
'sorting_archive_polls' => 'votes',
|
260 |
+
'sorting_archive_polls_rule' => 'asc',
|
261 |
+
'archive_url' => $current_options['archive_url'],
|
262 |
+
'archive_link_label' => $current_options['view_poll_archive_link_label'],
|
263 |
+
'show_poll_in_archive' => $current_options['show_in_archive'],
|
264 |
+
'poll_archive_order' => $current_options['archive_order'],
|
265 |
+
'archive_polls_per_page' => $current_options['archive_polls_per_page'],
|
266 |
+
'email_notifications_from_name' => $current_options['email_notifications_from_name'],
|
267 |
+
'email_notifications_from_email' => $current_options['email_notifications_from_email'],
|
268 |
+
'email_notifications_recipients' => $current_options['email_notifications_recipients'],
|
269 |
+
'email_notifications_subject' => $current_options['email_notifications_subject'],
|
270 |
+
'email_notifications_body' => '<p>A new vote was registered on %VOTE_DATE% for %POLL_NAME%</p>
|
271 |
|
272 |
<p>Vote Details:</p>
|
273 |
|
298 |
[/QUESTION]
|
299 |
|
300 |
<p><b>Vote ID:</b> <br />%VOTE_ID%</p>',
|
301 |
+
'schedule_reset_poll_stats' => $current_options['schedule_reset_poll_stats'],
|
302 |
+
'schedule_reset_poll_date' => current_time('mysql'),
|
303 |
+
'schedule_reset_poll_recurring_value' => $current_options['schedule_reset_poll_recurring_value'],
|
304 |
+
'schedule_reset_poll_recurring_unit' => $current_options['schedule_reset_poll_recurring_unit'],
|
305 |
+
'singular_answer_result_votes_number_label' => __yop_poll("vote"),
|
306 |
+
'plural_answer_result_votes_number_label' => __yop_poll("votes"),
|
307 |
+
'start_scheduler' => $current_options['start_scheduler'],
|
308 |
+
'use_the_same_template_for_widget' => 'yes',
|
309 |
+
'vote_permisions_facebook' => 'no',
|
310 |
|
311 |
+
'vote_permisions_facebook_label' => __yop_poll('Vote as Facebook User'),
|
312 |
|
313 |
+
'facebook_share_after_vote' => 'no',
|
314 |
|
315 |
+
'facebook_share_description' => __yop_poll('Just casted an YOP Poll vote on ') . get_bloginfo('name'),
|
316 |
|
317 |
+
'vote_permisions_google' => 'no',
|
318 |
|
319 |
+
'vote_permisions_google_label' => __yop_poll('Vote as G+ User'),
|
320 |
|
321 |
+
'show_google_share_button' => 'no',
|
322 |
+
'google_integration' => 'no',
|
323 |
+
'facebook_integration' => 'no',
|
324 |
+
'facebook_show_comments_widget' => "no"
|
325 |
// 'view_total_answers_label' => __yop_poll( 'Poll total answers: %POLL-TOTAL-ANSWERS%' ),
|
326 |
|
327 |
);
|
328 |
+
if ($current_options['blocking_voters'] == 'cookie-ip')
|
329 |
+
$new_options['blocking_voters'] = array("cookie", 'ip');
|
330 |
+
else {
|
331 |
+
if ($current_options['blocking_voters'] == 'username')
|
332 |
+
$new_options['blocking_voters'] = array('user_id');
|
333 |
}
|
334 |
+
list($g1, $d) = explode('-', $current_options['view_results_permissions']);
|
335 |
+
$new_options['view_results_permissions'] = array($g1, $d);
|
336 |
+
list($g1, $d) = explode('-', $current_options['view_results_link']);
|
337 |
+
$new_options['view_results_link'] = array($g1, $d);
|
338 |
+
update_option('yop_poll_options', $new_options);
|
339 |
+
update_option("yop_poll_version", YOP_POLL_VERSION);
|
340 |
YOP_POLL_Maintenance::activation_hook($default);
|
341 |
+
$wpdb->query('ALTER TABLE `' . $wpdb->yop_polls . '` CHANGE `ID` `ID` INT( 11 ) NOT NULL AUTO_INCREMENT ');
|
342 |
|
343 |
}
|
344 |
}
|
345 |
+
$installed_version = get_option("yop_poll_version");
|
346 |
|
347 |
+
if (version_compare($installed_version, '5.2', '<=')) {
|
348 |
ini_set('max_execution_time', 700);
|
349 |
+
ini_set("memory_limit", "512M");
|
350 |
+
$default_poll_options = get_option('yop_poll_options');
|
351 |
+
$default_poll_options['email_notifications_body'] = '<p>A new vote was registered on %VOTE_DATE% for %POLL_NAME%</p>
|
352 |
|
353 |
<p>Vote Details:</p>
|
354 |
|
379 |
[/QUESTION]
|
380 |
|
381 |
<p><b>Vote ID:</b> <br />%VOTE_ID%</p>';
|
382 |
+
update_option('yop_poll_options', $default_poll_options);
|
383 |
+
$templates = self::yop_poll_get_templates_new_version_from_db();
|
384 |
+
foreach ($templates as $template) {
|
385 |
+
$template['js'] = <<<NOWDOC
|
386 |
function stripBorder_%POLL-ID%(object) {
|
387 |
object.each(function() {
|
388 |
if( parseInt(jQuery(this).width() ) > 0) {
|
491 |
NOWDOC;
|
492 |
self::update_poll_template_in_database(($template));
|
493 |
}
|
494 |
+
$polls = self::yop_poll_get_polls_for_body_mail_update();
|
495 |
+
foreach ($polls as $poll) {
|
496 |
+
$current = new YOP_POLL_Poll_Model($poll['ID']);
|
497 |
+
$current->email_notifications_body = '<p>A new vote was registered on %VOTE_DATE% for %POLL_NAME%</p>
|
498 |
|
499 |
<p>Vote Details:</p>
|
500 |
|
528 |
$current->save();
|
529 |
|
530 |
}
|
531 |
+
update_option("yop_poll_version", YOP_POLL_VERSION);
|
532 |
}
|
533 |
+
$installed_version = get_option("yop_poll_version");
|
534 |
+
if (version_compare($installed_version, '5.3', '<=')) {
|
535 |
+
update_option("yop_poll_version", YOP_POLL_VERSION);
|
536 |
}
|
537 |
+
$installed_version = get_option("yop_poll_version");
|
538 |
+
if (version_compare($installed_version, '5.5', '<=')) {
|
539 |
+
update_option("yop_poll_version", YOP_POLL_VERSION);
|
540 |
}
|
541 |
+
$installed_version = get_option("yop_poll_version");
|
542 |
|
543 |
+
if (version_compare($installed_version, '5.6', '<=')) {
|
544 |
global $wpdb;
|
545 |
+
update_option("yop_poll_version", YOP_POLL_VERSION);
|
546 |
+
$default_poll_options = get_option('yop_poll_options');
|
547 |
+
$default_poll_options['show_results_in'] = "bar";
|
548 |
+
update_option('yop_poll_options', $default_poll_options);
|
549 |
|
550 |
+
$wpdb->query('ALTER TABLE `' . $wpdb->yop_poll_templates . '` ADD `after_vote_template_chart` text');
|
551 |
+
update_option("yop_poll_version", '5.7');
|
552 |
|
553 |
}
|
554 |
+
if (version_compare($installed_version, '5.7', '<=')) {
|
555 |
global $wpdb;
|
556 |
+
update_option("yop_poll_version", YOP_POLL_VERSION);
|
557 |
|
558 |
+
$templates = self::yop_poll_get_templates_new_version_from_db();
|
559 |
+
foreach ($templates as $template) {
|
560 |
+
$template['js'] = <<<NOWDOC
|
561 |
function stripBorder_%POLL-ID%(object) {
|
562 |
object.each(function() {
|
563 |
if( parseInt(jQuery(this).width() ) > 0) {
|
712 |
|
713 |
};
|
714 |
NOWDOC;
|
715 |
+
$template['after_vote_template_chart'] = <<<NOWDOC
|
716 |
[QUESTION_CONTAINER]
|
717 |
<div id = "yop-poll-question-container-%POLL-ID%-%QUESTION-ID%" class = "yop-poll-question-container-%POLL-ID%">
|
718 |
<div id = "yop-poll-question-%POLL-ID%-%QUESTION-ID%"
|
735 |
NOWDOC;
|
736 |
self::update_poll_template_in_database2($template);
|
737 |
}
|
738 |
+
update_option("yop_poll_version", '5.7.1');
|
739 |
|
740 |
}
|
741 |
+
if (version_compare($installed_version, '5.7.1', '<=')) {
|
742 |
global $wpdb;
|
743 |
+
update_option("yop_poll_version", '5.7.2');
|
744 |
}
|
745 |
+
if (version_compare($installed_version, '5.7.2', '<=')) {
|
746 |
global $wpdb;
|
747 |
+
update_option("yop_poll_version", '5.7.3');
|
748 |
}
|
749 |
+
if (version_compare($installed_version, '5.7.3', '<=')) {
|
750 |
global $wpdb;
|
751 |
+
update_option("yop_poll_version", '5.7.4');
|
752 |
+
}
|
753 |
+
if (version_compare($installed_version, '5.7.4', '<=')) {
|
754 |
+
global $wpdb;
|
755 |
+
update_option("yop_poll_version", '5.7.5');
|
756 |
+
}if (version_compare($installed_version, '5.7.5', '<=')) {
|
757 |
+
global $wpdb;
|
758 |
+
update_option("yop_poll_version", '5.7.6');
|
759 |
}
|
760 |
}
|
761 |
+
|
762 |
+
private static function update_poll_template_in_database2($template)
|
763 |
+
{
|
764 |
global $wpdb;
|
765 |
+
$sql = $wpdb->query($wpdb->prepare("
|
766 |
UPDATE " . $wpdb->yop_poll_templates . "
|
767 |
SET name = %s,
|
768 |
before_vote_template = %s,
|
775 |
last_modified = %s
|
776 |
WHERE
|
777 |
id = %d
|
778 |
+
", $template['name'], $template['before_vote_template'], $template['after_vote_template'], $template['after_vote_template_chart'], $template['before_start_date_template'], $template['after_end_date_template'], $template['css'], $template['js'], current_time('mysql'), $template['id']));
|
779 |
return $sql;
|
780 |
}
|
781 |
+
|
782 |
+
public function yop_poll_get_polls_for_body_mail_update()
|
783 |
+
{
|
784 |
global $wpdb;
|
785 |
+
$result = $wpdb->get_results(("
|
786 |
SELECT ID
|
787 |
+
FROM " . $wpdb->yop_polls . " ORDER BY ID ASC
|
788 |
+
"), ARRAY_A);
|
789 |
return $result;
|
790 |
}
|
791 |
+
|
792 |
+
private function install_default_options()
|
793 |
+
{
|
794 |
+
$default_poll_options = get_option('yop_poll_options');
|
795 |
|
796 |
$default_poll_options['is_default_answer'] = 'no';
|
797 |
+
$default_poll_options['poll_start_date'] = current_time('mysql');
|
798 |
+
$default_poll_options['poll_end_date'] = '01-01-2038 23:59:59';
|
799 |
|
800 |
+
update_option('yop_poll_options', $default_poll_options);
|
801 |
}
|
802 |
|
803 |
+
private function uninstall_default_options()
|
804 |
+
{
|
805 |
// delete_option( "yop_poll_version" );
|
806 |
// delete_option( "yop_poll_options" );
|
807 |
}
|
808 |
|
809 |
+
public function activate($networkwide)
|
810 |
+
{
|
811 |
+
if (!current_user_can('activate_plugins')) {
|
812 |
+
$error = new WP_Error ('Wordpress_version_error', __yop_poll('You need permissions to activate this plugin'), __yop_poll('Error: Wordpress Activation Permissions Problem'));
|
813 |
}
|
814 |
|
815 |
+
if (!version_compare($GLOBALS['wp_version'], YOP_POLL_WP_VERSION, '>=')) {
|
816 |
+
$error = new WP_Error ('Wordpress_version_error', sprintf(__yop_poll('You need at least Wordpress version %s to use this plugin'), YOP_POLL_WP_VERSION), __yop_poll('Error: Wordpress Version Problem'));
|
817 |
+
$error = new WP_Error ('Wordpress_version_error', sprintf(__yop_poll('You need at least Wordpress version %s to use this plugin'), YOP_POLL_WP_VERSION), __yop_poll('Error: Wordpress Version Problem'));
|
818 |
}
|
819 |
|
820 |
+
if (isset ($error) && is_wp_error($error)) {
|
821 |
+
wp_die($error->get_error_message(), $error->get_error_data());
|
822 |
}
|
823 |
|
824 |
|
825 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
826 |
+
require_once(YOP_POLL_INC . 'db_schema.php');
|
827 |
$this->install_default_options();
|
828 |
$capObj = YOP_POLL_Capabilities::get_instance();
|
829 |
$capObj->install_capabilities();
|
830 |
Yop_Poll_DbSchema::install_database();
|
831 |
}
|
832 |
|
833 |
+
public function deactivatedelete($networkwide)
|
834 |
+
{
|
835 |
+
require_once(YOP_POLL_INC . 'db_schema.php');
|
836 |
Yop_Poll_DbSchema::delete_database_tables();
|
837 |
$capObj = YOP_POLL_Capabilities::get_instance();
|
838 |
$capObj->uninstall_capabilities();
|
839 |
$this->uninstall_default_options();
|
840 |
}
|
841 |
|
842 |
+
function new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta)
|
843 |
+
{
|
844 |
+
if (!function_exists('is_plugin_active_for_network')) {
|
845 |
+
require_once(ABSPATH . '/wp-admin/includes/plugin.php');
|
846 |
}
|
847 |
+
if (is_plugin_active_for_network(YOP_POLL_SHORT_PLUGIN_FILE)) {
|
848 |
$old_blog = $GLOBALS['wpdb']->blogid;
|
849 |
+
switch_to_blog($blog_id);
|
850 |
+
yop_poll_create_table_names($GLOBALS['wpdb']->prefix);
|
851 |
+
$this->activate(null);
|
852 |
+
switch_to_blog($old_blog);
|
853 |
+
yop_poll_create_table_names($GLOBALS['wpdb']->prefix);
|
854 |
}
|
855 |
}
|
856 |
|
857 |
+
function delete_blog($blog_id)
|
858 |
+
{
|
859 |
$old_blog = $GLOBALS['wpdb']->blogid;
|
860 |
+
switch_to_blog($blog_id);
|
861 |
+
yop_poll_create_table_names($GLOBALS['wpdb']->prefix);
|
862 |
+
$this->deactivatedelete(null);
|
863 |
+
require_once(YOP_POLL_INC . 'db_schema.php');
|
864 |
// Yop_Poll_DbSchema::delete_database_tables();
|
865 |
$capObj = YOP_POLL_Capabilities::get_instance();
|
866 |
$capObj->uninstall_capabilities();
|
867 |
$this->uninstall_default_options();
|
868 |
+
switch_to_blog($old_blog);
|
869 |
+
yop_poll_create_table_names($GLOBALS['wpdb']->prefix);
|
870 |
}
|
871 |
|
872 |
+
function update()
|
873 |
+
{
|
874 |
}
|
875 |
|
876 |
+
public function activation_hook($default)
|
877 |
+
{
|
878 |
ini_set('max_execution_time', 700);
|
879 |
+
$current_options = get_option('yop_poll_options');
|
880 |
+
$polls = self::yop_poll_get_polls_from_db();
|
881 |
+
$answers = self::yop_poll_get_answers_from_db();
|
882 |
+
$logs = self::yop_poll_get_logs_from_db();
|
883 |
+
$bans = self::yop_poll_get_bans_from_db();
|
884 |
$custom_fields = self::yop_poll_get_custom_fields_from_db();
|
885 |
+
$custom_votes = self::yop_poll_get_custom_fields_votes_from_db();
|
886 |
+
$metas = self::yop_poll_get_polls_meta_from_db();
|
887 |
+
$answers_meta = self::yop_poll_get_answers_meta_from_db();
|
888 |
+
$templates = self::yop_poll_get_templates_from_db();
|
889 |
+
foreach ($templates as $template) {
|
890 |
+
$template['before_vote_template'] = "[QUESTION_CONTAINER]" . $template['before_vote_template'];
|
891 |
+
$template['before_vote_template'] = str_replace('%POLL-ANSWER-LABEL%', '%POLL-ANSWER-LABEL% [ANSWER_RESULT_CONTAINER]', $template['before_vote_template']);
|
892 |
+
$template['before_vote_template'] = str_replace('%POLL-TOTAL-ANSWERS%', '%POLL-TOTAL-ANSWERS-LABEL%', $template['before_vote_template']);
|
893 |
+
$template['before_vote_template'] = str_replace('%POLL-TOTAL-VOTES%', '%POLL-TOTAL-VOTES-LABEL%', $template['before_vote_template']);
|
894 |
+
$template['after_vote_template'] = str_replace('%POLL-TOTAL-VOTES%', '%POLL-TOTAL-VOTES-LABEL%', $template['after_vote_template']);
|
895 |
+
$template['after_vote_template'] = str_replace('%POLL-TOTAL-ANSWERS%', '%POLL-TOTAL-ANSWERS-LABEL%', $template['after_vote_template']);
|
896 |
+
$template['after_end_date_template'] = str_replace('%POLL-TOTAL-ANSWERS%', '%POLL-TOTAL-ANSWERS-LABEL%', $template['after_end_date_template']);
|
897 |
+
$template['after_end_date_template'] = str_replace('%POLL-TOTAL-VOTES%', '%POLL-TOTAL-VOTES-LABEL%', $template['after_end_date_template']);
|
898 |
+
$template['before_vote_template'] = preg_replace('/%POLL-ANSWER-RESULT-BAR%/', '%POLL-ANSWER-RESULT-BAR% [/ANSWER_RESULT_CONTAINER]', $template['before_vote_template'], 1);
|
899 |
$find = '[/ANSWER_RESULT_CONTAINER]';
|
900 |
$replace = '';
|
901 |
// $template['before_vote_template']= preg_replace(strrev("/$find/"),strrev($replace),strrev( $template['before_vote_template']),1);
|
902 |
+
$template['after_vote_template'] = "[QUESTION_CONTAINER]" . $template['after_vote_template'];
|
903 |
+
$template['after_end_date_template'] = "[QUESTION_CONTAINER]" . $template['after_end_date_template'];
|
904 |
/* if(strpos($template['before_vote_template'],"[CAPTCHA_CONTAINER]"))
|
905 |
$template['before_vote_template']=str_replace('[CAPTCHA_CONTAINER]','[/QUESTION_CONTAINER][CAPTCHA_CONTAINER]',$template['before_vote_template']);
|
906 |
else{
|
907 |
$template['before_vote_template']=str_replace('<div id="yop-poll-vote-%POLL-ID%" class="yop-poll-footer">','[/QUESTION_CONTAINER]<div id="yop-poll-vote-%POLL-ID%" class="yop-poll-footer">',$template['before_vote_template']);
|
908 |
} */
|
909 |
+
$template['before_vote_template'] = $template['before_vote_template'] . '[/QUESTION_CONTAINER]';
|
910 |
+
if (strpos($template['before_vote_template'], "%POLL-QUESTION%") && strpos($template['before_vote_template'], '%POLL-NAME%')) {
|
911 |
+
$template['before_vote_template'] = str_replace('%POLL-QUESTION%', '', $template['before_vote_template']);
|
912 |
+
$template['before_vote_template'] = str_replace('%POLL-NAME%', '%POLL-QUESTION%', $template['before_vote_template']);
|
913 |
}
|
914 |
+
if (strpos($template['after_vote_template'], "%POLL-QUESTION%") && strpos($template['after_vote_template'], '%POLL-NAME%')) {
|
915 |
+
$template['after_vote_template'] = str_replace('%POLL-QUESTION%', '', $template['after_vote_template']);
|
916 |
+
$template['after_vote_template'] = str_replace('%POLL-NAME%', '%POLL-QUESTION%', $template['after_vote_template']);
|
917 |
}
|
918 |
+
$template['after_vote_template'] = $template['after_vote_template'] . '[/QUESTION_CONTAINER]';
|
919 |
+
$template['after_end_date_template'] = $template['after_end_date_template'] . '[/QUESTION_CONTAINER]';
|
920 |
+
$template['js'] = <<<NOWDOC
|
921 |
function stripBorder_%POLL-ID%(object) {
|
922 |
object.each(function() {
|
923 |
if( parseInt(jQuery(this).width() ) > 0) {
|
1073 |
};
|
1074 |
|
1075 |
NOWDOC;
|
1076 |
+
$template['js'] = addslashes($template['js']);
|
1077 |
+
$templates_ids[$template['id']] = self::insert_template_in_databease(($template));
|
1078 |
}
|
1079 |
|
1080 |
+
foreach ($polls as $poll) {
|
1081 |
|
1082 |
+
foreach ($answers as $answer) {
|
1083 |
+
if ($answer['poll_id'] == $poll['id']) {
|
1084 |
$answers_ordonate[$poll['id']][] = (array)$answer;
|
1085 |
}
|
1086 |
+
if ($answer['poll_id'] > $poll['id']) {
|
1087 |
break;
|
1088 |
}
|
1089 |
|
1090 |
+
foreach ($logs as $log) {
|
1091 |
+
if ($log['poll_id'] == $poll['id'] && $log['answer_id'] == $answer['id']) {
|
1092 |
+
$logs_ordonate[$poll['id']][] = (array)$log;
|
1093 |
$logs_ordonate_details[$log['id']][] = $answer['answer'];
|
1094 |
}
|
1095 |
}
|
1096 |
+
foreach ($answers_meta as $answer_meta) {
|
1097 |
+
if ($answer_meta['yop_poll_answer_id'] == $answer['id']) {
|
1098 |
$answer_meta_ordonate[$answer['id']][] = (array)$answer_meta;
|
1099 |
}
|
1100 |
}
|
1101 |
}
|
1102 |
|
1103 |
+
foreach ($bans as $ban) {
|
1104 |
+
if ($ban['poll_id'] == $poll['id']) {
|
1105 |
$bans_ordonate[$poll['id']][] = (array)$ban;
|
1106 |
}
|
1107 |
+
if ($ban['poll_id'] > $poll['id']) {
|
1108 |
break;
|
1109 |
}
|
1110 |
}
|
1111 |
|
1112 |
+
foreach ($metas as $meta) {
|
1113 |
+
if ($meta['yop_poll_id'] == $poll['id']) {
|
1114 |
$metas_ordonate[$poll['id']][] = (array)$meta;
|
1115 |
}
|
1116 |
+
if ($meta['yop_poll_id'] > $poll['id']) {
|
1117 |
break;
|
1118 |
}
|
1119 |
}
|
1120 |
|
1121 |
+
foreach ($custom_fields as $custom_field) {
|
1122 |
+
if ($custom_field['poll_id'] == $poll['id']) {
|
1123 |
$custom_fields_ordonate[$poll['id']][] = (array)$custom_field;
|
1124 |
+
if ($custom_field['poll_id'] > $poll['id']) {
|
1125 |
break;
|
1126 |
}
|
1127 |
|
1128 |
+
foreach ($custom_votes as $custom_vote) {
|
1129 |
+
if ($custom_field['id'] == $custom_vote['custom_field_id']) {
|
1130 |
$custom_votes_fields_ordonate[$custom_field['id']][] = (array)$custom_vote;
|
1131 |
}
|
1132 |
}
|
1135 |
}
|
1136 |
|
1137 |
|
1138 |
+
foreach ($polls as $poll) {
|
1139 |
+
$current_poll = new YOP_POLL_Poll_Model();
|
1140 |
+
$current_poll->poll_author = $poll['poll_author'];
|
1141 |
+
$current_poll->ID = $poll['id'];
|
1142 |
+
$current_poll->poll_title = $poll['name'];
|
1143 |
+
$current_poll->poll_name = $poll['name'];
|
1144 |
+
$current_poll->poll_date = $poll['date_added'];
|
1145 |
$current_poll->poll_modified = $poll['last_modified'];
|
1146 |
+
$current_poll->poll_status = $poll['status'];
|
1147 |
+
$current_poll->poll_type = "poll";
|
1148 |
+
$current_poll->poll_status = $poll['status'];
|
1149 |
+
$current_poll->email_notifications_body = '<p>A new vote was registered on %VOTE_DATE% for %POLL_NAME%</p>
|
1150 |
|
1151 |
<p>Vote Details:</p>
|
1152 |
|
1177 |
[/QUESTION]
|
1178 |
|
1179 |
<p><b>Vote ID:</b> <br />%VOTE_ID%</p>';
|
1180 |
+
if ($poll['end_date'] <= "2038-01-18 23:59:59") {
|
|
|
|
|
1181 |
|
1182 |
+
$current_poll->poll_end_date = convert_date($poll['end_date'], 'd-m-Y H:i:s', 1);
|
1183 |
|
1184 |
+
} else {
|
1185 |
|
1186 |
$current_poll->poll_end_date = "01-01-2038 23:59:59";
|
1187 |
|
1188 |
}
|
1189 |
|
1190 |
+
if ($poll['start_date'] <= "2038-01-18 23:59:59") {
|
1191 |
|
1192 |
+
$current_poll->poll_start_date = convert_date($poll['start_date'], 'd-m-Y H:i:s', 1);
|
1193 |
|
1194 |
+
} else {
|
|
|
|
|
1195 |
|
1196 |
$current_poll->poll_start_date = "01-01-2038 23:59:59";
|
1197 |
|
1198 |
}
|
1199 |
$current_poll->poll_total_votes = $poll['total_votes'];
|
1200 |
+
$question = new YOP_POLL_Question_Model();
|
1201 |
+
$question->type = "text";
|
1202 |
+
$question->question = $poll['question'];
|
1203 |
+
$question->question_date = $current_poll->poll_date;
|
1204 |
+
$question->question_author = $current_poll->poll_author;
|
1205 |
+
$question->question_modified = $current_poll->poll_modified;
|
1206 |
+
$question->question_status = $current_poll->poll_status;
|
1207 |
+
$question->poll_order = 1;
|
1208 |
+
$i = 0;
|
1209 |
+
|
1210 |
+
|
1211 |
+
foreach ($answers_ordonate[$poll['id']] as $answer_ordonate) {
|
1212 |
+
|
1213 |
+
if ($answer_ordonate['type'] == "other") {
|
1214 |
+
$current_poll->allow_other_answers = 'yes';
|
1215 |
+
$question->allow_other_answers = 'yes';
|
|
|
1216 |
}
|
1217 |
}
|
1218 |
+
$q[] = $question;
|
1219 |
// yop_poll_dump($current_poll);
|
1220 |
$current_poll->questions = $q;
|
1221 |
+
$current_poll->auto_generate_poll_page = "no";
|
1222 |
+
$current_poll_id = $current_poll->insert();
|
1223 |
+
$current_poll_id = $current_poll->ID;
|
1224 |
// yop_poll_dump($current_poll->save())
|
1225 |
+
$no_modif = 0;
|
1226 |
+
$no_modif2 = 0;
|
1227 |
+
$current_poll_meta = $current_options;
|
1228 |
+
if (isset($metas_ordonate[$poll['id']])) {
|
1229 |
+
$poll_option = maybe_unserialize($metas_ordonate[$poll['id']][0]['meta_value']);
|
1230 |
+
foreach ($current_options as $key => $value) {
|
1231 |
+
if (isset($poll_option[$key])) {
|
1232 |
|
1233 |
+
if ($key == 'view_results_permissions') {
|
1234 |
|
1235 |
+
list($g1, $d) = explode('-', $poll_option[$key]);
|
1236 |
+
if ($g1 == "quest") {
|
1237 |
+
$g1 = "guest";
|
1238 |
|
1239 |
}
|
1240 |
|
1241 |
+
$current_poll_meta[$key] = array($g1, $d);
|
1242 |
+
$no_modif = 1;
|
1243 |
|
1244 |
+
} else
|
1245 |
+
if ($key == 'vote_permisions') {
|
1246 |
+
list($g1, $d) = explode('-', $poll_option['vote_permisions']);
|
1247 |
+
if ($g1 == "quest") {
|
1248 |
+
$g1 = "guest";
|
|
|
1249 |
|
1250 |
}
|
1251 |
+
$no_modif2 = 1;
|
1252 |
+
$current_poll_meta[$key] = array($g1, $d);
|
1253 |
+
} else
|
|
|
1254 |
$current_poll_meta[$key] = $poll_option[$key];
|
1255 |
|
1256 |
|
1257 |
} else
|
1258 |
+
$current_poll_meta[$key] = $default[$key];
|
1259 |
}
|
1260 |
}
|
1261 |
+
$current_poll_meta['view_results'] = array($poll_option['view_results']);
|
1262 |
$current_poll_meta['sorting_results'] = $default['sorting_answers'];
|
1263 |
+
if (!isset($poll_option['view_results_link'])) {
|
1264 |
+
$current_poll_meta['view_results_link'] = "yes";
|
1265 |
+
} else
|
1266 |
+
$current_poll_meta['view_results_link'] = $poll_option['view_results_link'];
|
1267 |
+
|
1268 |
+
if ($poll_option['view_results'] == 'custom-date')
|
1269 |
+
$current_poll_meta['view_results_start_date'] = $poll_option['view_results_start_date'];
|
1270 |
+
if (empty($current_poll_meta['view_results'][0])) {
|
|
|
1271 |
$current_poll_meta['view_results'] = array('after');
|
1272 |
}
|
1273 |
+
if ($no_modif == 0 || empty($current_poll_meta['view_results'])) {
|
1274 |
+
$current_poll_meta['view_results_permissions'] = array('guest', 'registered');
|
1275 |
|
1276 |
}
|
1277 |
|
1278 |
+
if ($no_modif2 == 0 || empty($current_poll_meta['vote_permisions'])) {
|
1279 |
+
$current_poll_meta['vote_permisions'] = array('guest', 'registered');
|
1280 |
}
|
1281 |
|
1282 |
+
if ($poll_option['blocking_voters'] == 'cookie-ip')
|
1283 |
+
$current_poll_meta['blocking_voters'] = array("cookie", 'ip');
|
1284 |
else {
|
1285 |
+
if ($poll_option['blocking_voters'] == 'username')
|
1286 |
+
$current_poll_meta['blocking_voters'] = array("user_id");
|
1287 |
else
|
1288 |
+
$current_poll_meta['blocking_voters'] = array('dont-block');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1289 |
}
|
1290 |
+
$current_poll_meta['facebook_share_after_vote'] = "no";
|
1291 |
+
$current_poll_meta['show_google_share_button'] = "no";
|
1292 |
+
$current_poll_meta['facebook_show_comments_widget'] = "no";
|
1293 |
+
$current_poll_meta['facebook_share_description'] = __yop_poll('Just casted an YOP Poll vote on ') . get_bloginfo('name');
|
1294 |
+
if (isset($poll_option['show_in_archive']))
|
1295 |
+
$current_poll_meta['show_poll_in_archive'] = $poll_option['show_in_archive'];
|
1296 |
+
if (isset($poll_option['schedule_reset_poll_date']))
|
1297 |
+
$current_poll_meta['schedule_reset_poll_date'] = $poll_option['schedule_reset_poll_date'];
|
1298 |
+
if (isset($poll_option['template'])) {
|
1299 |
+
$current_poll_meta['template'] = $templates_ids[$poll_option['template']];
|
1300 |
+
} else $current_poll_meta['template'] = 1;
|
1301 |
+
if (isset($poll_option['widget_template'])) {
|
1302 |
+
$current_poll_meta['widget_template'] = $templates_ids[$poll_option['widget_template']];
|
1303 |
+
} else $current_poll_meta['widget_template'] = 1;
|
1304 |
+
if (isset($poll_option['widget_template']) && isset($poll_option['template']) && $poll_option['template'] != $poll_option['widget_template']) {
|
1305 |
+
$current_poll_meta['use_the_same_template_for_widget'] = "no";
|
1306 |
}
|
1307 |
+
if (isset($poll_option['view_total_answers_label'])) {
|
1308 |
+
$current_poll_meta['view_total_answers_label'] = $default['view_total_answers_label'];
|
1309 |
}
|
1310 |
+
if (isset($poll_option['answer_result_label'])) {
|
1311 |
+
$current_poll_meta['answer_result_label'] = $default['answer_result_label'];
|
1312 |
}
|
1313 |
+
if ($current_poll_meta['vote_permisions_anonymous'] == "no" && $current_poll_meta['vote_permisions_wordpress'] == "no") {
|
1314 |
+
$current_poll_meta['vote_permisions_anonymous'] = "yes";
|
1315 |
}
|
1316 |
+
update_yop_poll_question_meta($current_poll_id, 'options', $current_poll_meta);
|
1317 |
+
update_yop_poll_meta($current_poll_id, 'options', $current_poll_meta);
|
1318 |
+
if ($poll['show_in_archive'] == "yes") {
|
1319 |
+
self::save_poll_order($current_poll_id, $poll['archive_order']);
|
1320 |
}
|
1321 |
|
1322 |
+
if ($default['sorting_answers'] == "votes") {
|
1323 |
+
$answers_ordonate[$poll['id']] = self::get_answers_order_by_votes($poll['id'], $default['sorting_answers_direction']);
|
1324 |
+
}
|
1325 |
+
if ($default['sorting_answers'] == "alphabetical") {
|
1326 |
+
$answers_ordonate[$poll['id']] = self::get_answers_order_by_alph($poll['id'], $default['sorting_answers_direction']);
|
1327 |
}
|
1328 |
+
foreach ($answers_ordonate[$poll['id']] as $answer_ordonate) {
|
1329 |
+
$ans = new YOP_POLL_Answer_Model();
|
1330 |
+
$ans->answer = $answer_ordonate['answer'];
|
1331 |
+
$ans->answer_author = $current_poll->poll_author;
|
1332 |
+
$ans->answer_date = $current_poll->poll_date;
|
1333 |
$ans->answer_modified = $poll['last_modified'];
|
1334 |
+
if ($answer_ordonate['type'] != "other") {
|
1335 |
$ans->type = "text";
|
1336 |
+
} else {
|
1337 |
+
$current_poll->allow_other_answers = 'yes';
|
1338 |
+
$question->allow_other_answers = 'yes';
|
|
|
1339 |
$ans->type = "other";
|
1340 |
}
|
1341 |
+
$ans->answer_status = $answer['status'];
|
1342 |
+
$ans->votes = $answer_ordonate['votes'];
|
1343 |
+
$ans->question_order = $i++;
|
1344 |
|
1345 |
+
if ($answer_ordonate['type'] != "other") {
|
1346 |
$answersa[] = $ans;
|
1347 |
+
if (isset($answer_meta_ordonate[$answer_ordonate['id']])) {
|
1348 |
+
$answer_option = maybe_unserialize($answer_meta_ordonate[$answer_ordonate['id']][0]['meta_value']);
|
1349 |
$answer_options = $ans->options;
|
1350 |
+
foreach ($ans->options as $key => &$value) {
|
1351 |
+
if (isset($answer_option[$key])) {
|
1352 |
$ans->$key = $answer_option[$key];
|
1353 |
}
|
1354 |
|
1356 |
$ans->options = $answer_options;
|
1357 |
}
|
1358 |
|
1359 |
+
$question->addAnswer($ans);
|
1360 |
|
1361 |
$question->save_answers();
|
1362 |
$answersids[$answer_ordonate['id']] = $ans->ID;
|
1363 |
}
|
1364 |
|
1365 |
}
|
1366 |
+
if (!empty($custom_fields_ordonate[$poll['id']]))
|
1367 |
+
foreach ($custom_fields_ordonate[$poll['id']] as $custom_ordonate) {
|
1368 |
+
$oldid = $custom_ordonate['id'];
|
1369 |
+
// $question = $current_poll->questions;
|
1370 |
+
$custom_ordonate['question_id'] = $current_poll_id;
|
1371 |
+
$custom_ordonate['poll_id'] = $current_poll_id;
|
1372 |
+
$newid = insert_custom_field_in_db($custom_ordonate);
|
1373 |
+
foreach ($custom_votes_fields_ordonate[$oldid] as $votes) {
|
1374 |
+
$votes['custom_field_id'] = $newid;
|
1375 |
+
$votes['question_id'] = $current_poll_id;
|
1376 |
+
$votes['poll_id'] = $current_poll_id;
|
1377 |
+
$votes['id'] = insert_votes_custom_in_db($votes);
|
1378 |
+
$custom_field_vote[$poll['id']][] = $votes;
|
1379 |
+
}
|
1380 |
}
|
|
|
1381 |
|
1382 |
+
if (!empty($logs_ordonate[$poll['id']]))
|
1383 |
+
foreach ($logs_ordonate[$poll['id']] as $log_ordonate) {
|
1384 |
+
$log['poll_id'] = $current_poll_id;
|
1385 |
+
$log['vote_id'] = $log_ordonate['vote_id'];
|
1386 |
+
$log['ip'] = $log_ordonate['ip'];
|
1387 |
+
$log['user_id'] = $log_ordonate['user_id'];
|
1388 |
+
$log['user_type'] = $log_ordonate['user_type'];
|
1389 |
+
$log['vote_date'] = $log_ordonate['vote_date'];
|
1390 |
+
$log['tr_id'] = $log_ordonate['tr_id'];
|
1391 |
+
$vote_details[1]["q-" . $current_poll_id]['question'] = $poll['question'];
|
1392 |
+
$vote_details[1]["q-" . $current_poll_id]['id'] = $current_poll_id;
|
1393 |
+
$vote_details[1]["q-" . $current_poll_id]['a'][] = $answersids[$log_ordonate['answer_id']];
|
1394 |
+
if ($log_ordonate['other_answer_value'] != "" && isset($log_ordonate['other_answer_value'])) {
|
1395 |
+
$ans = new YOP_POLL_Answer_Model();
|
1396 |
+
$ans->answer = $answer_ordonate['answer'];
|
1397 |
+
$ans->answer_author = $current_poll->poll_author;
|
1398 |
+
$ans->answer_date = $current_poll->poll_date;
|
1399 |
+
$ans->answer_modified = $poll['last_modified'];
|
1400 |
+
$ans->answer = $log_ordonate['other_answer_value'];
|
1401 |
+
$ans->answer_status = 'active';
|
1402 |
+
$ans->votes = 1;
|
1403 |
+
$ans->type = 'other';
|
1404 |
+
$ans->question_order = $i++;
|
1405 |
+
$question->addAnswer($ans);
|
1406 |
+
$question->save_answers();
|
|
|
|
|
|
|
|
|
|
|
1407 |
}
|
1408 |
+
if (!empty($custom_field_vote[$poll['id']]))
|
1409 |
+
foreach ($custom_field_vote[$poll['id']] as $vote) {
|
1410 |
+
if ($vote['vote_id'] == $log_ordonate['vote_id']) {
|
1411 |
+
$vote_details[1]["q-" . $current_poll_id]['cf'][] = $vote['id'];
|
1412 |
+
}
|
1413 |
|
1414 |
+
}
|
1415 |
+
foreach ($logs_ordonate_details[$log_ordonate['id']] as $a) {
|
1416 |
+
$vote_details[1]["q-" . $current_poll_id]['answers'][] = $a;
|
1417 |
+
$log['vote_details'] = json_encode($vote_details[1]);
|
1418 |
+
$log['message'] = "Succes";
|
1419 |
+
insert_result_in_db($log);
|
1420 |
+
insert_log_in_db($log);
|
1421 |
+
unset($vote_details[1]["q-" . $current_poll_id]['answers']);
|
1422 |
+
}
|
1423 |
+
unset($vote_details);
|
1424 |
}
|
1425 |
+
if (!empty($bans_ordonate[$poll['id']]))
|
1426 |
+
foreach ($bans_ordonate[$poll['id']] as $ban_ordonate) {
|
1427 |
+
$ban = $ban_ordonate;
|
1428 |
+
$ban['poll_id'] = $current_poll_id;
|
1429 |
+
self::insert_ban_in_db($ban);
|
|
|
|
|
1430 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1431 |
|
1432 |
|
1433 |
}
|
1434 |
|
1435 |
}
|
1436 |
|
1437 |
+
public function insert_template_in_databease($template)
|
1438 |
+
{
|
1439 |
global $wpdb;
|
1440 |
+
$sql = $wpdb->query($wpdb->prepare("
|
1441 |
INSERT INTO " . $wpdb->yop_poll_templates . "
|
1442 |
SET
|
1443 |
template_author = %d,
|
1451 |
date_added = %s,
|
1452 |
last_modified = %s,
|
1453 |
status = %s
|
1454 |
+
", $template['template_author'], $template['name'], $template['before_vote_template'], $template['after_vote_template'], $template['before_start_date_template'], $template['after_end_date_template'], $template['css'], $template['js'], current_time('mysql'), current_time('mysql'), $template['status']));
|
1455 |
return $GLOBALS['wpdb']->insert_id;
|
1456 |
}
|
1457 |
+
|
1458 |
+
private static function update_poll_template_in_database($template)
|
1459 |
+
{
|
1460 |
global $wpdb;
|
1461 |
+
$sql = $wpdb->query($wpdb->prepare("
|
1462 |
UPDATE " . $wpdb->yop_poll_templates . "
|
1463 |
SET name = %s,
|
1464 |
before_vote_template = %s,
|
1470 |
last_modified = %s
|
1471 |
WHERE
|
1472 |
id = %d
|
1473 |
+
", $template['name'], $template['before_vote_template'], $template['after_vote_template'], $template['before_start_date_template'], $template['after_end_date_template'], $template['css'], $template['js'], current_time('mysql'), $template['id']));
|
1474 |
return $sql;
|
1475 |
}
|
1476 |
+
|
1477 |
+
public function yop_poll_get_polls_from_db()
|
1478 |
+
{
|
1479 |
global $wpdb;
|
1480 |
+
$result = $wpdb->get_results(("
|
1481 |
SELECT *
|
1482 |
FROM " . $wpdb->prefix . "yop_polls ORDER BY id ASC
|
1483 |
+
"), ARRAY_A);
|
1484 |
return $result;
|
1485 |
|
1486 |
}
|
1487 |
|
1488 |
+
public function yop_poll_get_polls_meta_from_db()
|
1489 |
+
{
|
1490 |
global $wpdb;
|
1491 |
+
$result = $wpdb->get_results(("
|
1492 |
SELECT *
|
1493 |
FROM " . $wpdb->prefix . "yop_pollmeta ORDER BY yop_poll_id ASC
|
1494 |
+
"), ARRAY_A);
|
1495 |
return $result;
|
1496 |
|
1497 |
}
|
1498 |
|
1499 |
+
public function yop_poll_get_answers_meta_from_db()
|
1500 |
+
{
|
1501 |
global $wpdb;
|
1502 |
|
1503 |
+
$result = $wpdb->get_results(("
|
1504 |
SELECT *
|
1505 |
FROM " . $wpdb->prefix . "yop_poll_answermeta
|
1506 |
+
"), ARRAY_A);
|
1507 |
return $result;
|
1508 |
|
1509 |
}
|
1510 |
|
1511 |
+
public function yop_poll_get_templates_from_db()
|
1512 |
+
{
|
1513 |
global $wpdb;
|
1514 |
+
$result = $wpdb->get_results(("
|
1515 |
SELECT *
|
1516 |
FROM " . $wpdb->prefix . "yop_poll_templates
|
1517 |
+
"), ARRAY_A);
|
1518 |
return $result;
|
1519 |
}
|
1520 |
+
|
1521 |
+
public function yop_poll_get_templates_new_version_from_db()
|
1522 |
+
{
|
1523 |
global $wpdb;
|
1524 |
+
$result = $wpdb->get_results(("
|
1525 |
SELECT *
|
1526 |
FROM " . $wpdb->yop_poll_templates
|
1527 |
+
), ARRAY_A);
|
1528 |
return $result;
|
1529 |
}
|
1530 |
|
1531 |
+
public function yop_poll_get_custom_fields_from_db()
|
1532 |
+
{
|
1533 |
global $wpdb;
|
1534 |
+
$result = $wpdb->get_results(("
|
1535 |
SELECT *
|
1536 |
FROM " . $wpdb->prefix . "yop_poll_custom_fields ORDER BY poll_id ASC
|
1537 |
+
"), ARRAY_A);
|
1538 |
return $result;
|
1539 |
}
|
1540 |
|
1541 |
+
public function yop_poll_get_custom_fields_votes_from_db()
|
1542 |
+
{
|
1543 |
global $wpdb;
|
1544 |
+
$result = $wpdb->get_results(("
|
1545 |
SELECT *
|
1546 |
FROM " . $wpdb->prefix . "yop_poll_votes_custom_fields
|
1547 |
+
"), ARRAY_A);
|
1548 |
return $result;
|
1549 |
}
|
1550 |
|
1551 |
+
public function yop_poll_get_bans_from_db()
|
1552 |
+
{
|
1553 |
global $wpdb;
|
1554 |
+
$result = $wpdb->get_results(("
|
1555 |
SELECT *
|
1556 |
FROM " . $wpdb->prefix . "yop_poll_bans ORDER BY poll_id ASC
|
1557 |
+
"), ARRAY_A);
|
1558 |
return $result;
|
1559 |
}
|
1560 |
+
|
1561 |
+
public function yop_poll_get_answers_from_db()
|
1562 |
+
{
|
1563 |
global $wpdb;
|
1564 |
+
$result = $wpdb->get_results(("
|
1565 |
SELECT *
|
1566 |
FROM " . $wpdb->prefix . "yop_poll_answers ORDER BY poll_id ASC
|
1567 |
+
"), ARRAY_A);
|
1568 |
return $result;
|
1569 |
}
|
1570 |
+
|
1571 |
+
public function get_answers_order_by_votes($poll_id, $dir)
|
1572 |
+
{
|
1573 |
global $wpdb;
|
1574 |
+
$result = $wpdb->get_results($wpdb->prepare("
|
1575 |
SELECT *
|
1576 |
FROM " . $wpdb->prefix . "yop_poll_answers WHERE poll_id=%d ORDER BY votes $dir
|
1577 |
+
", $poll_id), ARRAY_A);
|
1578 |
return $result;
|
1579 |
}
|
1580 |
|
1581 |
+
public function get_answers_order_by_alph($poll_id, $dir)
|
1582 |
+
{
|
1583 |
global $wpdb;
|
1584 |
+
$result = $wpdb->get_results($wpdb->prepare("
|
1585 |
SELECT *
|
1586 |
FROM " . $wpdb->prefix . "yop_poll_answers WHERE poll_id=%d ORDER BY answer $dir
|
1587 |
+
", $poll_id), ARRAY_A);
|
1588 |
return $result;
|
1589 |
}
|
1590 |
|
1591 |
+
public function yop_poll_get_logs_from_db()
|
1592 |
+
{
|
1593 |
global $wpdb;
|
1594 |
+
$result = $wpdb->get_results(("
|
1595 |
SELECT *
|
1596 |
FROM " . $wpdb->prefix . "yop_poll_logs
|
1597 |
+
"), ARRAY_A);
|
1598 |
return $result;
|
1599 |
}
|
1600 |
|
1601 |
+
private static function insert_ban_in_db($ban)
|
1602 |
+
{
|
1603 |
global $wpdb;
|
1604 |
+
$sql = $wpdb->query($wpdb->prepare("
|
1605 |
INSERT INTO $wpdb->yop_poll_bans
|
1606 |
( poll_id,type,value,period ,unit)
|
1607 |
VALUES(%d,%s,%s,%d,%s)
|
1608 |
+
", $ban['poll_id'], $ban['type'], $ban['value'], intval($ban['period']), $ban['unit']));
|
1609 |
+
return $wpdb->get_results($sql);
|
1610 |
}
|
1611 |
+
|
1612 |
+
private function save_poll_order($poll, $poll_order)
|
1613 |
+
{
|
1614 |
+
$poll_archive_order = get_option('yop_poll_archive_order', array());
|
1615 |
+
if ($poll_archive_order == "") {
|
1616 |
$poll_archive_order = array();
|
|
|
|
|
1617 |
}
|
1618 |
+
if (trim($poll_order) <= 0) {
|
1619 |
+
$poll_order = 1;
|
|
|
1620 |
}
|
1621 |
+
$key = array_search($poll, $poll_archive_order);
|
1622 |
+
if ($key !== false) {
|
1623 |
+
unset($poll_archive_order[$key]);
|
1624 |
}
|
1625 |
+
if ($poll_order > count($poll_archive_order)) {
|
1626 |
+
array_push($poll_archive_order, $poll);
|
1627 |
+
} else {
|
1628 |
+
array_splice($poll_archive_order, trim($poll_order) - 1, 0, array($poll));
|
1629 |
}
|
1630 |
+
update_option('yop_poll_archive_order', $poll_archive_order);
|
1631 |
}
|
1632 |
|
1633 |
}
|
inc/poll_admin.php
CHANGED
@@ -1046,6 +1046,7 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
|
|
1046 |
$question->ID = 0;
|
1047 |
foreach( $question->answers as $answer ) {
|
1048 |
$answer->ID = 0;
|
|
|
1049 |
}
|
1050 |
if(isset($question->custom_fields))
|
1051 |
foreach($question->custom_fields as $custom){
|
@@ -1054,8 +1055,8 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
|
|
1054 |
$custom->question_id=0;
|
1055 |
}
|
1056 |
}
|
1057 |
-
|
1058 |
-
$id_poll=$poll_clone->save();
|
1059 |
self::save_poll_order($poll_clone,$poll_clone->poll_archive_order);
|
1060 |
update_yop_poll_meta( $id_poll, 'options', $meta );
|
1061 |
|
1046 |
$question->ID = 0;
|
1047 |
foreach( $question->answers as $answer ) {
|
1048 |
$answer->ID = 0;
|
1049 |
+
$answer->votes = 0;
|
1050 |
}
|
1051 |
if(isset($question->custom_fields))
|
1052 |
foreach($question->custom_fields as $custom){
|
1055 |
$custom->question_id=0;
|
1056 |
}
|
1057 |
}
|
1058 |
+
$is_clone=true;
|
1059 |
+
$id_poll=$poll_clone->save($is_clone);
|
1060 |
self::save_poll_order($poll_clone,$poll_clone->poll_archive_order);
|
1061 |
update_yop_poll_meta( $id_poll, 'options', $meta );
|
1062 |
|
inc/public-admin.php
CHANGED
@@ -159,15 +159,15 @@
|
|
159 |
|
160 |
$args = array(
|
161 |
'base' => remove_query_arg( 'yop_poll_page', $_SERVER['REQUEST_URI'] ) . '%_%',
|
162 |
-
'format' => '
|
163 |
'total' => $total_per_page,
|
164 |
'current' => max( 1, $yop_poll_page ),
|
165 |
'prev_next' => true,
|
166 |
'prev_text' => __( '« Previous', 'yop_poll' ),
|
167 |
'next_text' => __( 'Next »', 'yop_poll' )
|
168 |
);
|
169 |
-
$temp = "";
|
170 |
|
|
|
171 |
if($ok==1){
|
172 |
for( $i = ( $args['current'] - 1 ) * $per_page; $i <= ( $args['current'] - 1 ) * $per_page + $per_page - 1; $i ++ ) {
|
173 |
if(isset($archives[$i]['ID']))
|
159 |
|
160 |
$args = array(
|
161 |
'base' => remove_query_arg( 'yop_poll_page', $_SERVER['REQUEST_URI'] ) . '%_%',
|
162 |
+
'format' => '&yop_poll_page=%#%',
|
163 |
'total' => $total_per_page,
|
164 |
'current' => max( 1, $yop_poll_page ),
|
165 |
'prev_next' => true,
|
166 |
'prev_text' => __( '« Previous', 'yop_poll' ),
|
167 |
'next_text' => __( 'Next »', 'yop_poll' )
|
168 |
);
|
|
|
169 |
|
170 |
+
$temp = "<style> .yop-poll-container{display:block !important;}.yop-poll-footer{display: inline-block;margin: auto;text-align: center;width: 100%;}</style>";
|
171 |
if($ok==1){
|
172 |
for( $i = ( $args['current'] - 1 ) * $per_page; $i <= ( $args['current'] - 1 ) * $per_page + $per_page - 1; $i ++ ) {
|
173 |
if(isset($archives[$i]['ID']))
|
js/yop-poll-general-options.js
CHANGED
@@ -314,7 +314,7 @@ jQuery( document ).ready( function() {
|
|
314 |
jQuery('#yop-poll-email-notifications-body').textcomplete([
|
315 |
|
316 |
{ // tech companies
|
317 |
-
words: ['%VOTE_DATE%', '%POLL_NAME%', '[ QUESTION ] ','[/QUESTION]', '[ ANSWERS ]', ' %ANSWER_VALUE%', '[/ANSWERS]','[ CUSTOM_FIELDS ]','%CUSTOM_FIELD_NAME%','%CUSTOM_FIELD_VALUE%','[/CUSTOM_FIELDS]'],
|
318 |
match: /(\[|%)(\w*)$/,
|
319 |
search: function (term, callback) {
|
320 |
callback(jQuery.map(this.words, function (word) {
|
314 |
jQuery('#yop-poll-email-notifications-body').textcomplete([
|
315 |
|
316 |
{ // tech companies
|
317 |
+
words: ['%VOTE_DATE%', '%POLL_NAME%','%POLL_TOTAL_VOTES%','%WP_USERNAME%','%WP_FIRST_NAME%','%WP_LAST_NAME%', '[ QUESTION ] ','[/QUESTION]', '[ ANSWERS ]', ' %ANSWER_VALUE%', '[/ANSWERS]','[ CUSTOM_FIELDS ]','%CUSTOM_FIELD_NAME%','%CUSTOM_FIELD_VALUE%','[/CUSTOM_FIELDS]'],
|
318 |
match: /(\[|%)(\w*)$/,
|
319 |
search: function (term, callback) {
|
320 |
callback(jQuery.map(this.words, function (word) {
|
lib/Twig/AutoloaderYOP.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of Twig.
|
5 |
+
*
|
6 |
+
* (c) 2009 Fabien Potencier
|
7 |
+
*
|
8 |
+
* For the full copyright and license information, please view the LICENSE
|
9 |
+
* file that was distributed with this source code.
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Autoloads Twig classes.
|
14 |
+
*
|
15 |
+
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
+
*/
|
17 |
+
class Yop_Twig_Autoloader
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Registers Twig_Autoloader as an SPL autoloader.
|
21 |
+
*
|
22 |
+
* @param Boolean $prepend Whether to prepend the autoloader or not.
|
23 |
+
*/
|
24 |
+
public static function register($prepend = false)
|
25 |
+
{
|
26 |
+
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
27 |
+
spl_autoload_register(array(new self, 'autoload'), true, $prepend);
|
28 |
+
} else {
|
29 |
+
spl_autoload_register(array(new self, 'autoload'));
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Handles autoloading of classes.
|
35 |
+
*
|
36 |
+
* @param string $class A class name.
|
37 |
+
*/
|
38 |
+
public static function autoload($class)
|
39 |
+
{
|
40 |
+
if (0 !== strpos($class, 'Twig')) {
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
|
44 |
+
if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) {
|
45 |
+
require $file;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
models/abstract_model.php
CHANGED
@@ -1,44 +1,36 @@
|
|
1 |
<?php
|
2 |
-
abstract class YOP_POLL_Abstract_Model {
|
3 |
|
|
|
|
|
4 |
|
5 |
|
6 |
protected $data = null;
|
7 |
|
8 |
|
9 |
-
|
10 |
protected $options = null;
|
11 |
|
12 |
|
13 |
-
|
14 |
protected $questions = null;
|
15 |
|
16 |
|
17 |
-
|
18 |
protected $ID = null;
|
19 |
|
20 |
|
21 |
-
|
22 |
protected $unique_id = null;
|
23 |
|
24 |
|
25 |
-
|
26 |
protected $vote = false;
|
27 |
|
28 |
|
29 |
-
|
30 |
protected $type = 'quiz';
|
31 |
|
32 |
|
33 |
-
|
34 |
protected $error = "";
|
35 |
|
36 |
|
37 |
-
|
38 |
protected $success = "";
|
39 |
|
40 |
|
41 |
-
|
42 |
private $default_fields = array(
|
43 |
|
44 |
'ID',
|
@@ -70,165 +62,156 @@ abstract class YOP_POLL_Abstract_Model {
|
|
70 |
);
|
71 |
|
72 |
|
|
|
|
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
$this->init( $id->data, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule );
|
79 |
|
80 |
return;
|
81 |
|
82 |
-
}
|
83 |
-
|
84 |
-
elseif( is_object( $id ) ) {
|
85 |
|
86 |
-
$this->init(
|
87 |
|
88 |
return;
|
89 |
|
90 |
}
|
91 |
|
92 |
|
93 |
-
|
94 |
-
if( ! empty( $id ) && ! is_numeric( $id ) ) {
|
95 |
|
96 |
$id = 0;
|
97 |
|
98 |
}
|
99 |
|
100 |
-
if($id=="-3"){
|
101 |
|
102 |
|
103 |
-
$filters
|
104 |
$filters[] = array(
|
105 |
-
'field'
|
106 |
-
'value'
|
107 |
'operator' => '='
|
108 |
);
|
109 |
|
110 |
|
111 |
$filters[] = array(
|
112 |
-
'field'
|
113 |
-
'value'
|
114 |
'operator' => '<='
|
115 |
);
|
116 |
$args = array(
|
117 |
'return_fields' => 'ID ',
|
118 |
-
'filters'
|
119 |
-
'search'
|
120 |
-
|
121 |
-
|
122 |
-
'orderby' => "poll_start_date",
|
123 |
-
'order' => 'DESC'
|
124 |
);
|
125 |
|
126 |
-
$total_polls = Yop_Poll_Model::get_polls_filter_search(
|
127 |
-
$ok=0;
|
128 |
$current_date = yop_poll_get_mysql_curent_date();
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
136 |
}
|
137 |
-
}
|
138 |
-
|
139 |
-
else
|
140 |
-
$id=rand ( 1 , count($total_polls));
|
141 |
}
|
142 |
-
if($id=="-2"){
|
143 |
|
144 |
|
145 |
-
$filters
|
146 |
$filters[] = array(
|
147 |
-
'field'
|
148 |
-
'value'
|
149 |
'operator' => '='
|
150 |
);
|
151 |
|
152 |
$filters[] = array(
|
153 |
-
'field'
|
154 |
-
'value'
|
155 |
'operator' => '<='
|
156 |
);
|
157 |
|
158 |
$args = array(
|
159 |
'return_fields' => 'ID ',
|
160 |
-
'filters'
|
161 |
-
'search'
|
162 |
-
|
163 |
-
|
164 |
-
'orderby' => "poll_date",
|
165 |
-
'order' => 'ASC'
|
166 |
);
|
167 |
|
168 |
-
$total_polls = Yop_Poll_Model::get_polls_filter_search(
|
169 |
-
$id
|
170 |
}
|
171 |
-
if($id=="-1"){
|
172 |
|
173 |
|
174 |
-
$poll = self::get_current_active_poll(
|
175 |
-
$id
|
176 |
}
|
177 |
|
178 |
|
179 |
-
$data = self::get_data_by(
|
180 |
|
181 |
-
if(
|
182 |
|
183 |
-
$this->init(
|
184 |
|
185 |
-
}
|
186 |
-
|
187 |
-
else {
|
188 |
|
189 |
$this->default_init();
|
190 |
|
191 |
}
|
192 |
|
193 |
|
|
|
194 |
|
195 |
-
$this->
|
196 |
-
|
197 |
-
$this->poll_end_date = convert_date( $this->poll_end_date, "Y-m-d H:i:s" );
|
198 |
|
199 |
}
|
200 |
|
201 |
-
public static function get_current_active_poll(
|
|
|
202 |
global $wpdb;
|
203 |
$current_date = self::get_mysql_curent_date();
|
204 |
-
return $wpdb->get_row(
|
205 |
SELECT * FROM " . $wpdb->yop_polls . "
|
206 |
WHERE
|
207 |
%s >= poll_start_date AND
|
208 |
%s <= poll_end_date
|
209 |
ORDER BY
|
210 |
poll_date ASC
|
211 |
-
", $current_date, $current_date
|
212 |
}
|
213 |
|
214 |
|
215 |
-
function init(
|
|
|
216 |
|
217 |
$this->data = $data;
|
218 |
|
219 |
-
$this->ID
|
220 |
|
221 |
$this->init_options();
|
222 |
|
223 |
-
if(
|
224 |
|
225 |
-
switch(
|
226 |
|
227 |
case "database":
|
228 |
|
229 |
{
|
230 |
|
231 |
-
$answer_sort
|
232 |
|
233 |
$answer_sort_rule = $this->sorting_results_direction;
|
234 |
|
@@ -240,7 +223,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
240 |
|
241 |
{
|
242 |
|
243 |
-
$answer_sort
|
244 |
|
245 |
$answer_sort_rule = $this->sorting_results_direction;
|
246 |
|
@@ -252,7 +235,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
252 |
|
253 |
{
|
254 |
|
255 |
-
$answer_sort
|
256 |
|
257 |
$answer_sort_rule = $this->sorting_results_direction;
|
258 |
|
@@ -264,7 +247,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
264 |
|
265 |
{
|
266 |
|
267 |
-
$answer_sort
|
268 |
|
269 |
$answer_sort_rule = "ASC";
|
270 |
|
@@ -278,15 +261,15 @@ abstract class YOP_POLL_Abstract_Model {
|
|
278 |
|
279 |
$this->questions = array();
|
280 |
|
281 |
-
$questions_ids
|
282 |
|
283 |
-
if(
|
284 |
|
285 |
-
foreach(
|
286 |
|
287 |
-
$new_question = new YOP_POLL_Question_Model(
|
288 |
|
289 |
-
if(
|
290 |
|
291 |
$this->questions[] = $new_question;
|
292 |
|
@@ -299,50 +282,48 @@ abstract class YOP_POLL_Abstract_Model {
|
|
299 |
}
|
300 |
|
301 |
|
302 |
-
|
303 |
-
|
304 |
|
305 |
$this->data = new stdClass();
|
306 |
|
307 |
-
$this->ID
|
308 |
|
309 |
$this->init_options();
|
310 |
|
311 |
-
$this->questions
|
312 |
|
313 |
$this->data->poll_start_date = $this->options['poll_start_date'];
|
314 |
|
315 |
-
$this->data->poll_end_date
|
316 |
|
317 |
}
|
318 |
|
319 |
|
|
|
|
|
320 |
|
321 |
-
|
322 |
-
|
323 |
-
$this->options = array();
|
324 |
|
325 |
$poll_default_options = yop_poll_poll_default_options();
|
326 |
|
327 |
|
|
|
328 |
|
329 |
-
$
|
330 |
|
331 |
-
|
332 |
-
|
333 |
-
if( $key !== false ) {
|
334 |
|
335 |
$this->options['poll_archive_order'] = $key + 1;
|
336 |
|
337 |
}
|
338 |
|
339 |
|
|
|
340 |
|
341 |
-
|
342 |
-
|
343 |
-
foreach( $poll_default_options as $option_name => $option_value ) {
|
344 |
|
345 |
-
$this->options[$option_name] = $this->get_option(
|
346 |
|
347 |
}
|
348 |
|
@@ -351,66 +332,61 @@ abstract class YOP_POLL_Abstract_Model {
|
|
351 |
}
|
352 |
|
353 |
|
|
|
|
|
354 |
|
355 |
-
|
356 |
-
|
357 |
-
$this->data = null;
|
358 |
|
359 |
-
$this->ID
|
360 |
|
361 |
$this->questions = null;
|
362 |
|
363 |
-
$this->options
|
364 |
|
365 |
$this->unique_id = null;
|
366 |
|
367 |
-
$this->error
|
368 |
-
|
369 |
-
$this->success = null;
|
370 |
|
|
|
371 |
|
372 |
|
373 |
}
|
374 |
|
375 |
|
|
|
|
|
376 |
|
377 |
-
|
378 |
-
|
379 |
-
if( 'id' == $field ) {
|
380 |
|
381 |
-
if(
|
382 |
|
383 |
return false;
|
384 |
|
385 |
}
|
386 |
|
387 |
-
$value = intval(
|
388 |
|
389 |
-
if(
|
390 |
|
391 |
return false;
|
392 |
|
393 |
}
|
394 |
|
395 |
-
}
|
396 |
-
|
397 |
-
else {
|
398 |
|
399 |
-
$value = trim(
|
400 |
|
401 |
}
|
402 |
|
403 |
|
404 |
-
|
405 |
-
if( ! $value ) {
|
406 |
|
407 |
return false;
|
408 |
|
409 |
}
|
410 |
|
411 |
|
412 |
-
|
413 |
-
switch( $field ) {
|
414 |
|
415 |
case 'id':
|
416 |
|
@@ -435,10 +411,9 @@ abstract class YOP_POLL_Abstract_Model {
|
|
435 |
}
|
436 |
|
437 |
|
|
|
438 |
|
439 |
-
|
440 |
-
|
441 |
-
if( $model = wp_cache_get( $model_id, 'yop_poll_model' ) ) {
|
442 |
|
443 |
return $model;
|
444 |
|
@@ -447,17 +422,14 @@ abstract class YOP_POLL_Abstract_Model {
|
|
447 |
}
|
448 |
|
449 |
|
450 |
-
|
451 |
-
if( ! $model = $GLOBALS['wpdb']->get_row( $GLOBALS['wpdb']->prepare( "SELECT * FROM {$GLOBALS['wpdb']->yop_polls} WHERE $db_field = %s", $value ) ) ) {
|
452 |
|
453 |
return false;
|
454 |
|
455 |
}
|
456 |
|
457 |
|
458 |
-
|
459 |
-
wp_cache_add( $model_id, $model, 'yop_poll_model' );
|
460 |
-
|
461 |
|
462 |
|
463 |
return $model;
|
@@ -465,28 +437,26 @@ abstract class YOP_POLL_Abstract_Model {
|
|
465 |
}
|
466 |
|
467 |
|
|
|
|
|
468 |
|
469 |
-
|
470 |
-
|
471 |
-
$value = trim( $value );
|
472 |
|
473 |
|
474 |
-
|
475 |
-
if( ! $value ) {
|
476 |
|
477 |
return false;
|
478 |
|
479 |
}
|
480 |
|
481 |
-
if(
|
482 |
|
483 |
return false;
|
484 |
|
485 |
}
|
486 |
|
487 |
|
488 |
-
|
489 |
-
switch( $field ) {
|
490 |
|
491 |
case 'name':
|
492 |
|
@@ -503,184 +473,168 @@ abstract class YOP_POLL_Abstract_Model {
|
|
503 |
}
|
504 |
|
505 |
|
506 |
-
|
507 |
-
if( ! $model = $GLOBALS['wpdb']->get_row( $GLOBALS['wpdb']->prepare( "SELECT * FROM {$GLOBALS['wpdb']->yop_polls} WHERE $db_field = %s AND ID != %d", $value, $current_model_id ) ) ) {
|
508 |
|
509 |
return false;
|
510 |
|
511 |
}
|
512 |
|
513 |
|
514 |
-
|
515 |
return $model;
|
516 |
|
517 |
}
|
518 |
|
519 |
|
|
|
|
|
520 |
|
521 |
-
|
522 |
-
|
523 |
-
if( 'id' == strtolower( $key ) ) {
|
524 |
|
525 |
$key = 'ID';
|
526 |
|
527 |
}
|
528 |
|
529 |
-
if(
|
530 |
|
531 |
$key = 'type';
|
532 |
|
533 |
}
|
534 |
|
535 |
|
536 |
-
|
537 |
-
if( isset( $this->$key ) ) {
|
538 |
|
539 |
return true;
|
540 |
|
541 |
}
|
542 |
|
543 |
-
if(
|
544 |
|
545 |
return true;
|
546 |
|
547 |
}
|
548 |
|
549 |
|
550 |
-
|
551 |
-
return $this->isset_option( $key );
|
552 |
|
553 |
}
|
554 |
|
555 |
|
556 |
-
|
557 |
-
|
558 |
|
559 |
|
560 |
-
|
561 |
-
if( isset( $this->options[$key] ) ) {
|
562 |
|
563 |
return true;
|
564 |
|
565 |
}
|
566 |
|
567 |
|
|
|
568 |
|
569 |
-
|
570 |
-
|
571 |
-
if( isset( $poll_options[$key] ) ) {
|
572 |
|
573 |
return true;
|
574 |
|
575 |
}
|
576 |
|
577 |
|
578 |
-
|
579 |
return false;
|
580 |
|
581 |
}
|
582 |
|
583 |
|
584 |
-
|
585 |
-
|
586 |
|
587 |
$value = null;
|
588 |
|
589 |
-
if(
|
590 |
|
591 |
return $this->ID;
|
592 |
|
593 |
}
|
594 |
|
595 |
-
if(
|
596 |
|
597 |
return $this->type;
|
598 |
|
599 |
}
|
600 |
|
601 |
-
if(
|
602 |
|
603 |
return $this->questions;
|
604 |
|
605 |
}
|
606 |
|
607 |
-
if(
|
608 |
|
609 |
return $this->unique_id;
|
610 |
|
611 |
}
|
612 |
|
613 |
-
if(
|
614 |
|
615 |
return $this->error;
|
616 |
|
617 |
}
|
618 |
|
619 |
-
if(
|
620 |
|
621 |
return $this->success;
|
622 |
|
623 |
}
|
624 |
|
625 |
-
if(
|
626 |
|
627 |
return $this->vote;
|
628 |
|
629 |
}
|
630 |
|
631 |
|
632 |
-
|
633 |
-
if( isset( $this->data->$key ) ) {
|
634 |
|
635 |
$value = $this->data->$key;
|
636 |
|
637 |
-
}
|
638 |
-
|
639 |
-
elseif( in_array( $key, $this->default_fields ) ) {
|
640 |
|
641 |
$value = $this->data->$key;
|
642 |
|
643 |
-
}
|
644 |
|
645 |
-
|
646 |
-
|
647 |
-
$value = $this->get_option( $key );
|
648 |
|
649 |
}
|
650 |
|
651 |
|
652 |
-
|
653 |
return $value;
|
654 |
|
655 |
}
|
656 |
|
657 |
|
658 |
-
|
659 |
-
|
660 |
|
661 |
|
662 |
-
|
663 |
-
if( isset( $this->options[$key] ) ) {
|
664 |
|
665 |
return $this->options[$key];
|
666 |
|
667 |
}
|
668 |
|
669 |
|
|
|
670 |
|
671 |
-
|
672 |
-
|
673 |
-
if( isset( $poll_options[$key] ) ) {
|
674 |
|
675 |
return $poll_options[$key];
|
676 |
|
677 |
}
|
678 |
|
679 |
|
|
|
680 |
|
681 |
-
$default_options
|
682 |
-
|
683 |
-
if( isset( $default_options[$key] ) ) {
|
684 |
|
685 |
return $default_options[$key];
|
686 |
|
@@ -691,12 +645,12 @@ abstract class YOP_POLL_Abstract_Model {
|
|
691 |
}
|
692 |
|
693 |
|
|
|
|
|
694 |
|
695 |
-
|
696 |
|
697 |
-
|
698 |
-
|
699 |
-
$this->ID = $value;
|
700 |
|
701 |
$this->data->ID = $value;
|
702 |
|
@@ -704,7 +658,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
704 |
|
705 |
}
|
706 |
|
707 |
-
if(
|
708 |
|
709 |
$this->type = $value;
|
710 |
|
@@ -712,7 +666,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
712 |
|
713 |
}
|
714 |
|
715 |
-
if(
|
716 |
|
717 |
$this->questions = $value;
|
718 |
|
@@ -720,7 +674,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
720 |
|
721 |
}
|
722 |
|
723 |
-
if(
|
724 |
|
725 |
$this->unique_id = $value;
|
726 |
|
@@ -728,7 +682,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
728 |
|
729 |
}
|
730 |
|
731 |
-
if(
|
732 |
|
733 |
$this->error = $value;
|
734 |
|
@@ -736,7 +690,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
736 |
|
737 |
}
|
738 |
|
739 |
-
if(
|
740 |
|
741 |
$this->success = $value;
|
742 |
|
@@ -744,7 +698,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
744 |
|
745 |
}
|
746 |
|
747 |
-
if(
|
748 |
|
749 |
$this->vote = $value;
|
750 |
|
@@ -753,68 +707,65 @@ abstract class YOP_POLL_Abstract_Model {
|
|
753 |
}
|
754 |
|
755 |
|
756 |
-
|
757 |
-
if( in_array( $key, $this->default_fields ) ) //this is not an option
|
758 |
|
759 |
{
|
760 |
|
761 |
$this->data->$key = $value;
|
762 |
|
763 |
-
}
|
764 |
-
|
765 |
-
else {
|
766 |
|
767 |
-
$this->_set_option(
|
768 |
|
769 |
}
|
770 |
|
771 |
}
|
772 |
|
773 |
|
774 |
-
|
775 |
-
|
776 |
|
777 |
$this->options[$key] = $value;
|
778 |
|
779 |
}
|
780 |
|
781 |
|
|
|
|
|
782 |
|
783 |
-
|
784 |
-
|
785 |
-
return ! empty( $this->ID );
|
786 |
|
787 |
}
|
788 |
|
789 |
|
|
|
|
|
790 |
|
791 |
-
|
792 |
-
|
793 |
-
return $this->__get( $key );
|
794 |
|
795 |
}
|
796 |
|
797 |
|
|
|
|
|
798 |
|
799 |
-
|
800 |
-
|
801 |
-
return $this->__isset( $key );
|
802 |
|
803 |
}
|
804 |
|
805 |
|
|
|
|
|
806 |
|
807 |
-
|
808 |
-
|
809 |
-
return get_object_vars( $this->data );
|
810 |
|
811 |
}
|
812 |
|
813 |
|
|
|
|
|
814 |
|
815 |
-
|
816 |
-
|
817 |
-
if( ! $questions = $GLOBALS['wpdb']->get_col( $GLOBALS['wpdb']->prepare( "SELECT ID FROM {$GLOBALS['wpdb']->yop_poll_questions} WHERE poll_id = %s ORDER BY {$question_sort} {$question_sort_rule}", $this->id ) ) ) {
|
818 |
|
819 |
return false;
|
820 |
|
@@ -825,16 +776,13 @@ abstract class YOP_POLL_Abstract_Model {
|
|
825 |
}
|
826 |
|
827 |
|
|
|
|
|
|
|
828 |
|
829 |
-
|
830 |
|
831 |
-
|
832 |
-
|
833 |
-
return $this->insert();
|
834 |
-
|
835 |
-
}
|
836 |
-
|
837 |
-
else {
|
838 |
|
839 |
return $this->update();
|
840 |
|
@@ -843,97 +791,96 @@ abstract class YOP_POLL_Abstract_Model {
|
|
843 |
}
|
844 |
|
845 |
|
|
|
|
|
846 |
|
847 |
-
|
848 |
|
849 |
-
$
|
850 |
|
851 |
-
|
852 |
|
853 |
-
|
|
|
|
|
|
|
|
|
|
|
854 |
|
855 |
-
if($option_name=="view_results_start_date"||$option_name=="schedule_reset_poll_date"){
|
856 |
-
$options1 = get_option('yop_poll_options' );
|
857 |
-
if($options1['date_format']=="US"){
|
858 |
-
$original1=explode(' ',$option_value);
|
859 |
-
$original=explode('-',$original1[0]);
|
860 |
-
$option_value=$original[1].'-'.$original[0].'-'.$original[2].' '.$original1[1];
|
861 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
862 |
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
$original=explode(' ',$option_value);
|
869 |
-
$original=explode('-',$original[0]);
|
870 |
-
|
871 |
-
if($original[2]>12){
|
872 |
-
$poll_options[$option_name]=convert_date( $option_value, 'Y-m-d H:i:s',1 );
|
873 |
-
}
|
874 |
-
else
|
875 |
-
$poll_options[$option_name]=convert_date( $option_value, 'Y-d-m H:i:s',1 );
|
876 |
-
}
|
877 |
-
else
|
878 |
|
879 |
|
880 |
-
|
881 |
|
882 |
}
|
883 |
|
884 |
}
|
885 |
|
886 |
-
update_yop_poll_meta(
|
887 |
|
888 |
}
|
889 |
|
890 |
|
891 |
-
|
892 |
-
|
893 |
-
$options
|
894 |
-
if($options['date_format']=="US"){
|
895 |
-
$original1=explode(' '
|
896 |
-
$original=explode('-'
|
897 |
-
$this->poll_start_date
|
898 |
-
$original1=explode(' '
|
899 |
-
$original=explode('-'
|
900 |
-
$this->poll_end_date
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
909 |
else
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
$
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
$
|
931 |
-
|
932 |
-
if(isset($this->ID)){
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
$GLOBALS['wpdb']->query( $GLOBALS['wpdb']->prepare( "
|
937 |
|
938 |
INSERT INTO " . $GLOBALS['wpdb']->yop_polls . "
|
939 |
|
@@ -959,13 +906,12 @@ abstract class YOP_POLL_Abstract_Model {
|
|
959 |
|
960 |
poll_total_votes = %d
|
961 |
|
962 |
-
"
|
963 |
|
964 |
$this->id = $GLOBALS['wpdb']->insert_id;
|
965 |
|
966 |
-
}
|
967 |
-
|
968 |
-
$GLOBALS['wpdb']->query( $GLOBALS['wpdb']->prepare( "
|
969 |
|
970 |
INSERT INTO " . $GLOBALS['wpdb']->yop_polls . "
|
971 |
|
@@ -990,48 +936,44 @@ abstract class YOP_POLL_Abstract_Model {
|
|
990 |
|
991 |
poll_total_votes = %d
|
992 |
|
993 |
-
", $this->poll_title, $this->poll_name, $this->poll_author, $this->poll_date, $this->poll_status, $this->poll_modified, $this->type,
|
994 |
|
995 |
$this->id = $GLOBALS['wpdb']->insert_id;
|
996 |
}
|
997 |
|
998 |
|
|
|
999 |
|
|
|
1000 |
|
1001 |
-
if( intval( $this->id ) > 0 ) {
|
1002 |
|
1003 |
-
|
1004 |
|
|
|
1005 |
|
1006 |
-
|
1007 |
|
1008 |
-
$_p
|
1009 |
|
1010 |
-
$_p['
|
1011 |
|
1012 |
-
$_p['
|
1013 |
-
|
1014 |
-
$_p['post_status'] = 'publish';
|
1015 |
-
|
1016 |
-
$_p['post_type'] = 'page';
|
1017 |
|
1018 |
$_p['comment_status'] = 'open';
|
1019 |
|
1020 |
-
$_p['ping_status']
|
1021 |
-
|
1022 |
-
$_p['post_category'] = array( 1 ); // the default 'Uncategorised'
|
1023 |
|
|
|
1024 |
|
1025 |
|
1026 |
-
$poll_page_id = wp_insert_post(
|
1027 |
|
1028 |
|
1029 |
-
|
1030 |
-
$this->poll_page_url = get_permalink( $poll_page_id );
|
1031 |
|
1032 |
$this->has_auto_generate_poll_page = 'yes';
|
1033 |
|
1034 |
-
$this->auto_generate_poll_page
|
1035 |
|
1036 |
}
|
1037 |
|
@@ -1048,49 +990,45 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1048 |
}
|
1049 |
|
1050 |
|
1051 |
-
|
1052 |
-
|
1053 |
-
$options
|
1054 |
-
if($options['date_format']=="US"){
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
$original1=explode(' '
|
1059 |
-
$original=explode('-'
|
1060 |
-
$this->poll_end_date
|
1061 |
|
1062 |
}
|
1063 |
-
|
1064 |
-
|
1065 |
-
$this->poll_end_date=convert_date( $this->poll_end_date, 'Y-m-d H:i:s' );
|
1066 |
else {
|
1067 |
-
if(
|
1068 |
-
$this->poll_end_date=convert_date(
|
1069 |
else
|
1070 |
-
$this->poll_end_date=convert_date(
|
1071 |
-
}
|
1072 |
-
if (convert_date( $this->poll_start_date, 'Y-m-d H:i:s',1 )=='1970-01-01 00:00:00')
|
1073 |
-
$this->poll_start_date=convert_date( $this->poll_start_date, 'Y-m-d H:i:s' );
|
1074 |
-
else
|
1075 |
-
$this->poll_start_date=convert_date( $this->poll_start_date, 'Y-m-d H:i:s',1 );
|
1076 |
-
// if( $this->poll_end_date=)
|
1077 |
-
$original=explode(' ',$this->poll_start_date);
|
1078 |
-
$original=explode('-',$original[0]);
|
1079 |
-
if($original[2]>12){
|
1080 |
-
$this->poll_start_date=convert_date( $this->poll_start_date, 'Y-m-d H:i:s',1 );
|
1081 |
-
}
|
1082 |
-
else
|
1083 |
-
$this->poll_start_date=convert_date( $this->poll_start_date, 'Y-d-m H:i:s',1 );
|
1084 |
-
$original=explode(' ',$this->poll_end_date);
|
1085 |
-
$original=explode('-',$original[0]);
|
1086 |
-
|
1087 |
-
if($original[2]>12){
|
1088 |
-
$this->poll_end_date=convert_date( $this->poll_end_date, 'Y-m-d H:i:s',1 );
|
1089 |
}
|
|
|
|
|
1090 |
else
|
1091 |
-
$this->
|
1092 |
-
|
1093 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1094 |
|
1095 |
UPDATE " . $GLOBALS['wpdb']->yop_polls . "
|
1096 |
|
@@ -1112,36 +1050,34 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1112 |
|
1113 |
ID = %d
|
1114 |
|
1115 |
-
", $this->poll_title, $this->poll_name, $this->poll_status, $this->poll_modified,
|
1116 |
-
if(
|
1117 |
|
1118 |
-
$_p
|
1119 |
|
1120 |
-
$_p['post_title']
|
1121 |
|
1122 |
-
$_p['post_content']
|
1123 |
|
1124 |
-
$_p['post_status']
|
1125 |
|
1126 |
-
$_p['post_type']
|
1127 |
|
1128 |
$_p['comment_status'] = 'open';
|
1129 |
|
1130 |
-
$_p['ping_status']
|
1131 |
|
1132 |
-
$_p['post_category']
|
1133 |
|
1134 |
|
|
|
1135 |
|
1136 |
-
$poll_page_id = wp_insert_post( $_p );
|
1137 |
|
1138 |
-
|
1139 |
-
|
1140 |
-
$this->poll_page_url = get_permalink( $poll_page_id );
|
1141 |
|
1142 |
$this->has_auto_generate_poll_page = 'yes';
|
1143 |
|
1144 |
-
$this->auto_generate_poll_page
|
1145 |
|
1146 |
}
|
1147 |
|
@@ -1149,17 +1085,17 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1149 |
|
1150 |
$this->save_questions();
|
1151 |
|
1152 |
-
wp_cache_delete(
|
1153 |
|
1154 |
return true;
|
1155 |
|
1156 |
}
|
1157 |
|
1158 |
|
|
|
|
|
1159 |
|
1160 |
-
|
1161 |
-
|
1162 |
-
$GLOBALS['wpdb']->query( $GLOBALS['wpdb']->prepare( "
|
1163 |
|
1164 |
UPDATE " . $GLOBALS['wpdb']->yop_polls . "
|
1165 |
|
@@ -1171,23 +1107,22 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1171 |
|
1172 |
ID= %d
|
1173 |
|
1174 |
-
", $this->poll_total_votes, $this->id
|
1175 |
|
1176 |
|
1177 |
-
|
1178 |
-
wp_cache_delete( $this->id, 'yop_poll_model' );
|
1179 |
|
1180 |
return true;
|
1181 |
|
1182 |
}
|
1183 |
|
1184 |
|
|
|
|
|
1185 |
|
1186 |
-
|
1187 |
-
|
1188 |
-
if( count( $this->questions ) > 0 ) {
|
1189 |
|
1190 |
-
foreach(
|
1191 |
|
1192 |
$question->delete();
|
1193 |
|
@@ -1195,32 +1130,32 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1195 |
|
1196 |
}
|
1197 |
|
1198 |
-
delete_yop_poll_meta(
|
1199 |
|
1200 |
-
$GLOBALS['wpdb']->query(
|
1201 |
|
1202 |
DELETE FROM " . $GLOBALS['wpdb']->yop_polls . "
|
1203 |
|
1204 |
WHERE ID = %d
|
1205 |
|
1206 |
-
", $this->id
|
1207 |
|
1208 |
-
wp_cache_delete(
|
1209 |
|
1210 |
$this->_unset();
|
1211 |
|
1212 |
}
|
1213 |
|
1214 |
|
1215 |
-
|
1216 |
-
|
1217 |
|
1218 |
|
1219 |
$current_questions_ids = array();
|
1220 |
|
1221 |
-
if(
|
1222 |
|
1223 |
-
foreach(
|
1224 |
|
1225 |
$question->poll_id = $this->id;
|
1226 |
|
@@ -1232,27 +1167,27 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1232 |
|
1233 |
}
|
1234 |
|
1235 |
-
$this->remove_deleted_questions(
|
1236 |
|
1237 |
}
|
1238 |
|
1239 |
|
|
|
|
|
1240 |
|
1241 |
-
|
1242 |
-
|
1243 |
-
if( count( $current_questions_ids ) == 0 ) {
|
1244 |
|
1245 |
$current_questions_ids[] = 0;
|
1246 |
|
1247 |
}
|
1248 |
|
1249 |
-
$questions_for_delete = $GLOBALS['wpdb']->get_col(
|
1250 |
|
1251 |
-
if(
|
1252 |
|
1253 |
-
foreach(
|
1254 |
|
1255 |
-
$question = new YOP_POLL_Question_Model(
|
1256 |
|
1257 |
$question->delete();
|
1258 |
|
@@ -1263,24 +1198,22 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1263 |
}
|
1264 |
|
1265 |
|
1266 |
-
|
1267 |
-
|
1268 |
|
1269 |
global $wpdb;
|
1270 |
|
1271 |
-
if(
|
1272 |
|
1273 |
-
$request = $wpdb->prepare(
|
1274 |
|
1275 |
-
}
|
1276 |
-
|
1277 |
-
else {
|
1278 |
|
1279 |
-
$request = $wpdb->prepare(
|
1280 |
|
1281 |
}
|
1282 |
|
1283 |
-
$result = $wpdb->get_row(
|
1284 |
|
1285 |
SELECT *
|
1286 |
|
@@ -1290,69 +1223,69 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1290 |
|
1291 |
LIMIT 0,1
|
1292 |
|
1293 |
-
", ARRAY_A
|
1294 |
|
1295 |
return $result;
|
1296 |
|
1297 |
}
|
1298 |
|
1299 |
|
|
|
|
|
1300 |
|
1301 |
-
|
1302 |
-
|
1303 |
-
return current_time( 'mysql' );
|
1304 |
|
1305 |
}
|
1306 |
|
1307 |
|
1308 |
-
|
1309 |
-
|
1310 |
|
1311 |
global $wpdb;
|
1312 |
|
1313 |
-
return $wpdb->get_var(
|
1314 |
|
1315 |
}
|
1316 |
|
1317 |
|
1318 |
-
|
1319 |
-
|
1320 |
-
if(
|
1321 |
|
1322 |
return true;
|
1323 |
|
1324 |
}
|
1325 |
|
1326 |
|
1327 |
-
if(
|
1328 |
|
1329 |
$is_voted = false;
|
1330 |
|
1331 |
-
if(
|
1332 |
|
1333 |
return false;
|
1334 |
|
1335 |
}
|
1336 |
|
1337 |
-
if(
|
1338 |
|
1339 |
$is_voted = $is_voted || $this->is_voted_ip();
|
1340 |
|
1341 |
}
|
1342 |
|
1343 |
-
if(
|
1344 |
|
1345 |
|
1346 |
$is_voted = $is_voted || $this->is_voted_cookie();
|
1347 |
|
1348 |
}
|
1349 |
|
1350 |
-
if(
|
1351 |
|
1352 |
-
$is_voted = $is_voted || $this->is_voted_username(
|
1353 |
}
|
1354 |
|
1355 |
-
if(
|
1356 |
|
1357 |
}
|
1358 |
|
@@ -1365,47 +1298,46 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1365 |
}
|
1366 |
|
1367 |
|
1368 |
-
private function is_ban(
|
|
|
1369 |
|
1370 |
global $wpdb, $current_user;
|
1371 |
|
1372 |
|
1373 |
-
|
1374 |
$username = $current_user->data->user_login;
|
1375 |
|
1376 |
-
$email
|
1377 |
-
|
1378 |
|
1379 |
|
1380 |
-
if(
|
1381 |
|
1382 |
$username = $facebook_user_details['username'];
|
1383 |
|
1384 |
-
$email
|
1385 |
|
1386 |
}
|
1387 |
|
1388 |
-
if(
|
1389 |
|
1390 |
$username = $google_user_details['displayName'];
|
1391 |
|
1392 |
-
$id
|
1393 |
|
1394 |
-
$email
|
1395 |
|
1396 |
}
|
1397 |
|
1398 |
-
if(
|
1399 |
|
1400 |
$username = '';
|
1401 |
|
1402 |
-
$email
|
1403 |
|
1404 |
}
|
1405 |
|
1406 |
-
$ip
|
1407 |
|
1408 |
-
$sql = $wpdb->prepare(
|
1409 |
|
1410 |
SELECT id
|
1411 |
|
@@ -1427,23 +1359,23 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1427 |
|
1428 |
LIMIT 0,1
|
1429 |
|
1430 |
-
", $this->ID, $ip, $username, $email, $id
|
1431 |
|
1432 |
-
return $wpdb->get_var(
|
1433 |
|
1434 |
}
|
1435 |
|
1436 |
|
1437 |
-
|
1438 |
-
|
1439 |
|
1440 |
global $wpdb;
|
1441 |
|
1442 |
$unit = 'DAY';
|
1443 |
|
1444 |
-
if(
|
1445 |
|
1446 |
-
switch(
|
1447 |
|
1448 |
case 'seconds' :
|
1449 |
|
@@ -1475,15 +1407,15 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1475 |
|
1476 |
$value = 30;
|
1477 |
|
1478 |
-
if(
|
1479 |
|
1480 |
$value = $this->blocking_voters_interval_value;
|
1481 |
|
1482 |
}
|
1483 |
|
1484 |
-
$ip
|
1485 |
|
1486 |
-
$log_id = $wpdb->get_var(
|
1487 |
|
1488 |
SELECT id
|
1489 |
|
@@ -1495,8 +1427,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1495 |
|
1496 |
vote_date >= DATE_ADD( %s, INTERVAL -%d " . $unit . ")
|
1497 |
|
1498 |
-
", $this->ID, $ip, current_time(
|
1499 |
-
|
1500 |
|
1501 |
|
1502 |
return $log_id;
|
@@ -1504,10 +1435,10 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1504 |
}
|
1505 |
|
1506 |
|
|
|
|
|
1507 |
|
1508 |
-
|
1509 |
-
|
1510 |
-
if( isset( $_COOKIE['yop_poll_voted_' . $this->ID] ) ) {
|
1511 |
|
1512 |
return true;
|
1513 |
|
@@ -1518,26 +1449,25 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1518 |
}
|
1519 |
|
1520 |
|
1521 |
-
|
1522 |
-
|
1523 |
|
1524 |
global $current_user;
|
1525 |
|
1526 |
-
if(
|
1527 |
|
1528 |
return false;
|
1529 |
|
1530 |
}
|
1531 |
|
1532 |
-
if(
|
1533 |
|
1534 |
|
1535 |
-
if(
|
1536 |
|
1537 |
-
if(
|
1538 |
-
|
1539 |
-
if( $current_user->ID > 0 ) {
|
1540 |
|
|
|
1541 |
|
1542 |
|
1543 |
return true;
|
@@ -1546,13 +1476,10 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1546 |
|
1547 |
}
|
1548 |
|
1549 |
-
if(
|
1550 |
-
|
1551 |
|
1552 |
|
1553 |
-
|
1554 |
-
|
1555 |
-
return true;
|
1556 |
|
1557 |
|
1558 |
}
|
@@ -1561,12 +1488,11 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1561 |
return false;
|
1562 |
|
1563 |
}
|
1564 |
-
if(
|
1565 |
-
|
1566 |
-
if( $vote_type == "wordpress" && $this->vote_permisions_wordpress=="yes" ) {
|
1567 |
|
1568 |
-
|
1569 |
|
|
|
1570 |
|
1571 |
|
1572 |
return false;
|
@@ -1575,24 +1501,20 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1575 |
|
1576 |
}
|
1577 |
|
1578 |
-
if(
|
1579 |
-
|
1580 |
|
1581 |
|
1582 |
return false;
|
1583 |
|
1584 |
}
|
1585 |
|
1586 |
-
if(
|
1587 |
|
1588 |
return false;
|
1589 |
|
1590 |
}
|
1591 |
|
1592 |
-
if(
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
|
1597 |
|
1598 |
return false;
|
@@ -1605,27 +1527,26 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1605 |
}
|
1606 |
|
1607 |
|
1608 |
-
|
1609 |
//registered only
|
1610 |
|
1611 |
-
if(
|
1612 |
|
1613 |
-
if(
|
1614 |
|
1615 |
return true;
|
1616 |
|
1617 |
}
|
1618 |
|
1619 |
-
if(
|
1620 |
return true;
|
1621 |
|
1622 |
}
|
1623 |
|
1624 |
-
if(
|
1625 |
|
1626 |
-
if(
|
1627 |
|
1628 |
-
if(
|
1629 |
|
1630 |
return true;
|
1631 |
|
@@ -1639,11 +1560,11 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1639 |
|
1640 |
}
|
1641 |
|
1642 |
-
if(
|
1643 |
|
1644 |
-
if(
|
1645 |
|
1646 |
-
if(
|
1647 |
|
1648 |
return true;
|
1649 |
|
@@ -1670,16 +1591,15 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1670 |
}
|
1671 |
|
1672 |
|
1673 |
-
|
1674 |
-
|
1675 |
|
1676 |
$expire_cookie = 0;
|
1677 |
|
1678 |
-
$value
|
1679 |
-
|
1680 |
|
1681 |
|
1682 |
-
if(
|
1683 |
|
1684 |
$value = $this->blocking_voters_interval_value;
|
1685 |
|
@@ -1687,15 +1607,14 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1687 |
|
1688 |
$unit = 'days';
|
1689 |
|
1690 |
-
if(
|
1691 |
|
1692 |
$unit = $this->blocking_voters_interval_unit;
|
1693 |
|
1694 |
}
|
1695 |
|
1696 |
|
1697 |
-
|
1698 |
-
switch( $unit ) {
|
1699 |
|
1700 |
case 'seconds' :
|
1701 |
|
@@ -1705,67 +1624,65 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1705 |
|
1706 |
case 'minutes' :
|
1707 |
|
1708 |
-
$expire_cookie = time() + (
|
1709 |
|
1710 |
break;
|
1711 |
|
1712 |
case 'hours' :
|
1713 |
|
1714 |
-
$expire_cookie = time() + (
|
1715 |
|
1716 |
break;
|
1717 |
|
1718 |
case 'days' :
|
1719 |
|
1720 |
-
$expire_cookie = time() + (
|
1721 |
|
1722 |
break;
|
1723 |
|
1724 |
}
|
1725 |
|
1726 |
-
setcookie(
|
1727 |
|
1728 |
-
setcookie(
|
1729 |
|
1730 |
-
if(
|
1731 |
|
1732 |
-
setcookie(
|
1733 |
|
1734 |
}
|
1735 |
|
1736 |
-
if(
|
1737 |
|
1738 |
-
setcookie(
|
1739 |
|
1740 |
}
|
1741 |
|
1742 |
}
|
1743 |
|
1744 |
|
1745 |
-
|
1746 |
-
|
1747 |
|
1748 |
global $current_user, $wpdb;
|
1749 |
|
1750 |
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
if(isset($_COOKIE['yop_poll_vote_facebook_user_' . $this->poll['id']]))
|
1756 |
$facebook_user_details['id'] = $_COOKIE['yop_poll_vote_facebook_user_' . $this->poll['id']];
|
1757 |
-
if(isset($_COOKIE['yop_poll_vote_google_user_' . $this->poll['id']]))
|
1758 |
-
$google_user_details['id']
|
1759 |
|
1760 |
}
|
1761 |
|
1762 |
|
1763 |
-
|
1764 |
$unit = 'DAY';
|
1765 |
|
1766 |
-
if(
|
1767 |
|
1768 |
-
switch(
|
1769 |
|
1770 |
case 'seconds' :
|
1771 |
|
@@ -1797,9 +1714,9 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1797 |
|
1798 |
//user is guest
|
1799 |
|
1800 |
-
if(
|
1801 |
|
1802 |
-
if(
|
1803 |
|
1804 |
return $this->is_voted_ip();
|
1805 |
|
@@ -1808,26 +1725,24 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1808 |
}
|
1809 |
|
1810 |
|
1811 |
-
|
1812 |
$value = 30;
|
1813 |
|
1814 |
-
if(
|
1815 |
|
1816 |
$value = $this->options['blocking_voters_interval_value'];
|
1817 |
|
1818 |
}
|
1819 |
|
1820 |
-
$ip
|
1821 |
|
1822 |
$user_id = $current_user->ID;
|
1823 |
|
1824 |
|
1825 |
-
|
1826 |
-
if( 'facebook' == $vote_type ) {
|
1827 |
|
1828 |
$user_id = $facebook_user_details['id'];
|
1829 |
|
1830 |
-
if(
|
1831 |
|
1832 |
return false;
|
1833 |
|
@@ -1835,11 +1750,11 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1835 |
|
1836 |
}
|
1837 |
|
1838 |
-
if(
|
1839 |
|
1840 |
$user_id = $google_user_details['id'];
|
1841 |
|
1842 |
-
if(
|
1843 |
|
1844 |
return false;
|
1845 |
|
@@ -1848,8 +1763,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1848 |
}
|
1849 |
|
1850 |
|
1851 |
-
|
1852 |
-
$sql= $wpdb->prepare( "
|
1853 |
SELECT * FROM " . $wpdb->yop_poll_results . "
|
1854 |
|
1855 |
WHERE poll_id = %d AND
|
@@ -1858,21 +1772,22 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1858 |
|
1859 |
vote_date >= DATE_SUB( NOW(), INTERVAL %d " . $unit . ")
|
1860 |
|
1861 |
-
LIMIT 1", $this->ID, $user_id, $value
|
1862 |
-
$result = $wpdb->get_results($sql,ARRAY_A
|
1863 |
|
1864 |
-
if(isset($result[0]['vote_date']))
|
1865 |
return true;
|
1866 |
else
|
1867 |
return false;
|
1868 |
|
1869 |
}
|
1870 |
|
1871 |
-
protected function get_voter_number_of_votes(
|
|
|
1872 |
|
1873 |
global $wpdb;
|
1874 |
|
1875 |
-
$result = $wpdb->get_results(
|
1876 |
|
1877 |
SELECT *
|
1878 |
|
@@ -1886,64 +1801,61 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1886 |
|
1887 |
user_type = %s GROUP BY vote_id
|
1888 |
|
1889 |
-
", $voter['poll_id'], $voter['user_id'], $voter['user_type']
|
1890 |
-
|
1891 |
-
return count( $result );
|
1892 |
|
|
|
1893 |
|
1894 |
|
1895 |
}
|
1896 |
|
1897 |
|
|
|
|
|
1898 |
|
1899 |
-
|
1900 |
|
1901 |
-
$
|
1902 |
-
|
1903 |
-
$votes = explode( ";", $details[1] );
|
1904 |
|
1905 |
return (int)$votes[0];
|
1906 |
|
1907 |
}
|
1908 |
|
1909 |
|
1910 |
-
|
1911 |
-
|
1912 |
-
$original_date=convert_date(
|
1913 |
-
$original_date=str_replace('-', '/', $original_date);
|
1914 |
-
return date_i18n(
|
1915 |
|
1916 |
}
|
1917 |
|
1918 |
|
|
|
|
|
1919 |
|
1920 |
-
|
1921 |
-
|
1922 |
-
$poll_options = get_yop_poll_meta( $voter['poll_id'], "options", true );
|
1923 |
///yop_poll_dump($cookie);
|
1924 |
-
if(
|
1925 |
-
if(
|
1926 |
|
1927 |
-
if(
|
1928 |
|
1929 |
return false;
|
1930 |
|
1931 |
}
|
1932 |
}
|
1933 |
|
1934 |
-
}
|
1935 |
-
|
1936 |
-
else if( $voter['user_id'] > 0 ) {
|
1937 |
|
1938 |
-
if(
|
1939 |
|
1940 |
-
if(
|
1941 |
|
1942 |
return false;
|
1943 |
|
1944 |
}
|
1945 |
|
1946 |
-
if(
|
1947 |
|
1948 |
return false;
|
1949 |
|
@@ -1951,9 +1863,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1951 |
|
1952 |
}
|
1953 |
|
1954 |
-
}
|
1955 |
-
|
1956 |
-
else {
|
1957 |
|
1958 |
return false;
|
1959 |
|
@@ -1964,48 +1874,44 @@ abstract class YOP_POLL_Abstract_Model {
|
|
1964 |
}
|
1965 |
|
1966 |
|
1967 |
-
|
1968 |
-
|
1969 |
|
1970 |
//$options = get_option( 'yop_poll_options' );
|
1971 |
|
1972 |
|
1973 |
-
|
1974 |
$headers = 'From: ' . $this->email_notifications_from_name . ' <' . $this->email_notifications_from_email . '>';
|
1975 |
|
1976 |
-
$subject = str_replace(
|
1977 |
-
|
1978 |
|
1979 |
|
1980 |
-
$body
|
1981 |
|
1982 |
$regex = '/\[(\[?)(QUESTION)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
1983 |
|
1984 |
-
$q
|
1985 |
|
1986 |
-
$body
|
1987 |
|
1988 |
$template = '';
|
1989 |
|
1990 |
-
foreach(
|
1991 |
-
|
1992 |
-
$temp_question_body = str_ireplace(
|
1993 |
-
|
1994 |
|
1995 |
|
1996 |
$regex = '/\[(\[?)(ANSWERS)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
1997 |
|
1998 |
|
|
|
1999 |
|
2000 |
-
$
|
2001 |
-
|
2002 |
-
$temp_question_body = preg_replace_callback( $regex, function ( $m ) use ( $answers ) {
|
2003 |
|
2004 |
$temp = "";
|
2005 |
|
2006 |
-
foreach(
|
2007 |
|
2008 |
-
$temp_answer_body = str_ireplace(
|
2009 |
|
2010 |
$temp .= $temp_answer_body;
|
2011 |
|
@@ -2013,27 +1919,25 @@ abstract class YOP_POLL_Abstract_Model {
|
|
2013 |
|
2014 |
return $temp;
|
2015 |
|
2016 |
-
}, $temp_question_body
|
2017 |
-
|
2018 |
|
2019 |
|
2020 |
$regex = '/\[(\[?)(CUSTOM_FIELDS)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
2021 |
|
2022 |
|
|
|
2023 |
|
2024 |
-
$
|
2025 |
-
|
2026 |
-
$temp_question_body = preg_replace_callback( $regex, function ( $m ) use ( $custom_fields ) {
|
2027 |
|
2028 |
$temp = "";
|
2029 |
|
2030 |
-
if(
|
2031 |
|
2032 |
-
foreach(
|
2033 |
|
2034 |
-
$temp_cf_body = str_ireplace(
|
2035 |
|
2036 |
-
$temp_cf_body = str_ireplace(
|
2037 |
|
2038 |
$temp .= $temp_cf_body;
|
2039 |
|
@@ -2041,7 +1945,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
2041 |
|
2042 |
}
|
2043 |
|
2044 |
-
if(
|
2045 |
|
2046 |
$temp = "No custom fields defined";
|
2047 |
|
@@ -2049,7 +1953,7 @@ abstract class YOP_POLL_Abstract_Model {
|
|
2049 |
|
2050 |
return $temp;
|
2051 |
|
2052 |
-
}, $temp_question_body
|
2053 |
|
2054 |
$template .= $temp_question_body;
|
2055 |
|
@@ -2057,45 +1961,51 @@ abstract class YOP_POLL_Abstract_Model {
|
|
2057 |
|
2058 |
return $template;
|
2059 |
|
2060 |
-
}, $body
|
2061 |
|
|
|
2062 |
|
|
|
2063 |
|
|
|
2064 |
|
|
|
2065 |
|
2066 |
-
$body = str_replace( '%
|
2067 |
|
2068 |
-
$body = str_replace( '%
|
2069 |
|
2070 |
-
$body = str_replace( '%
|
2071 |
|
|
|
2072 |
|
|
|
2073 |
|
2074 |
-
add_filter( 'wp_mail_content_type', 'yop_poll_set_html_content_type' );
|
2075 |
|
2076 |
-
|
2077 |
|
|
|
2078 |
|
2079 |
|
2080 |
-
remove_filter(
|
2081 |
|
2082 |
}
|
2083 |
|
2084 |
|
2085 |
-
|
2086 |
-
|
2087 |
|
2088 |
global $message;
|
2089 |
|
2090 |
-
$current_poll
|
2091 |
|
2092 |
-
$message
|
2093 |
|
2094 |
$current_poll->poll_total_votes = 0;
|
2095 |
|
2096 |
-
foreach(
|
2097 |
|
2098 |
-
foreach(
|
2099 |
|
2100 |
$answer->votes = 0;
|
2101 |
|
@@ -2110,41 +2020,36 @@ abstract class YOP_POLL_Abstract_Model {
|
|
2110 |
}
|
2111 |
|
2112 |
|
2113 |
-
|
2114 |
-
|
2115 |
|
2116 |
global $wpdb;
|
2117 |
|
2118 |
$response['success'] = "";
|
2119 |
|
2120 |
-
$response['error']
|
2121 |
-
|
2122 |
|
2123 |
|
2124 |
-
$sql = $wpdb->query(
|
2125 |
|
2126 |
DELETE FROM $wpdb->yop_poll_results
|
2127 |
|
2128 |
WHERE poll_id = %d
|
2129 |
|
2130 |
-
", $poll_id
|
2131 |
|
2132 |
-
if(
|
2133 |
|
2134 |
-
$response['success'] = __yop_poll(
|
2135 |
|
2136 |
|
|
|
2137 |
|
2138 |
-
|
2139 |
-
|
2140 |
-
else {
|
2141 |
-
|
2142 |
-
$response['error'] = __yop_poll( 'Could not delete result from database! Please try again!' );
|
2143 |
|
2144 |
}
|
2145 |
|
2146 |
|
2147 |
-
|
2148 |
return $response;
|
2149 |
|
2150 |
}
|
1 |
<?php
|
|
|
2 |
|
3 |
+
abstract class YOP_POLL_Abstract_Model
|
4 |
+
{
|
5 |
|
6 |
|
7 |
protected $data = null;
|
8 |
|
9 |
|
|
|
10 |
protected $options = null;
|
11 |
|
12 |
|
|
|
13 |
protected $questions = null;
|
14 |
|
15 |
|
|
|
16 |
protected $ID = null;
|
17 |
|
18 |
|
|
|
19 |
protected $unique_id = null;
|
20 |
|
21 |
|
|
|
22 |
protected $vote = false;
|
23 |
|
24 |
|
|
|
25 |
protected $type = 'quiz';
|
26 |
|
27 |
|
|
|
28 |
protected $error = "";
|
29 |
|
30 |
|
|
|
31 |
protected $success = "";
|
32 |
|
33 |
|
|
|
34 |
private $default_fields = array(
|
35 |
|
36 |
'ID',
|
62 |
);
|
63 |
|
64 |
|
65 |
+
function __construct($id = 0, $is_view_results = "no", $question_sort = "poll_order", $question_sort_rule = "ASC", $answer_sort = "question_order", $answer_sort_rule = "ASC")
|
66 |
+
{
|
67 |
|
68 |
+
if ($id instanceof YOP_POLL_Abstract_Model) {
|
69 |
|
70 |
+
$this->init($id->data, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule);
|
|
|
|
|
71 |
|
72 |
return;
|
73 |
|
74 |
+
} elseif (is_object($id)) {
|
|
|
|
|
75 |
|
76 |
+
$this->init($id, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule);
|
77 |
|
78 |
return;
|
79 |
|
80 |
}
|
81 |
|
82 |
|
83 |
+
if (!empty($id) && !is_numeric($id)) {
|
|
|
84 |
|
85 |
$id = 0;
|
86 |
|
87 |
}
|
88 |
|
89 |
+
if ($id == "-3") {
|
90 |
|
91 |
|
92 |
+
$filters = array();
|
93 |
$filters[] = array(
|
94 |
+
'field' => 'poll_type',
|
95 |
+
'value' => 'poll',
|
96 |
'operator' => '='
|
97 |
);
|
98 |
|
99 |
|
100 |
$filters[] = array(
|
101 |
+
'field' => 'poll_start_date',
|
102 |
+
'value' => current_time('mysql'),
|
103 |
'operator' => '<='
|
104 |
);
|
105 |
$args = array(
|
106 |
'return_fields' => 'ID ',
|
107 |
+
'filters' => $filters,
|
108 |
+
'search' => array(),
|
109 |
+
'orderby' => "poll_start_date",
|
110 |
+
'order' => 'DESC'
|
|
|
|
|
111 |
);
|
112 |
|
113 |
+
$total_polls = Yop_Poll_Model::get_polls_filter_search($args);
|
114 |
+
$ok = 0;
|
115 |
$current_date = yop_poll_get_mysql_curent_date();
|
116 |
|
117 |
+
if (count($total_polls) > 1) {
|
118 |
+
while ($ok == 0) {
|
119 |
+
$id = rand(1, count($total_polls));
|
120 |
+
$poll = new YOP_POLL_Poll_Model($id);
|
121 |
+
if ($current_date <= convert_date($poll->poll_end_date, 'Y-m-d H:i:s')) {
|
122 |
+
$ok = 1;
|
123 |
+
}
|
124 |
}
|
125 |
+
} else
|
126 |
+
$id = rand(1, count($total_polls));
|
|
|
|
|
127 |
}
|
128 |
+
if ($id == "-2") {
|
129 |
|
130 |
|
131 |
+
$filters = array();
|
132 |
$filters[] = array(
|
133 |
+
'field' => 'poll_type',
|
134 |
+
'value' => 'poll',
|
135 |
'operator' => '='
|
136 |
);
|
137 |
|
138 |
$filters[] = array(
|
139 |
+
'field' => 'poll_start_date',
|
140 |
+
'value' => current_time('mysql'),
|
141 |
'operator' => '<='
|
142 |
);
|
143 |
|
144 |
$args = array(
|
145 |
'return_fields' => 'ID ',
|
146 |
+
'filters' => $filters,
|
147 |
+
'search' => array(),
|
148 |
+
'orderby' => "poll_date",
|
149 |
+
'order' => 'ASC'
|
|
|
|
|
150 |
);
|
151 |
|
152 |
+
$total_polls = Yop_Poll_Model::get_polls_filter_search($args);
|
153 |
+
$id = $total_polls[count($total_polls) - 1]['ID'];
|
154 |
}
|
155 |
+
if ($id == "-1") {
|
156 |
|
157 |
|
158 |
+
$poll = self::get_current_active_poll();
|
159 |
+
$id = $poll['ID'];
|
160 |
}
|
161 |
|
162 |
|
163 |
+
$data = self::get_data_by('id', $id);
|
164 |
|
165 |
+
if ($data) {
|
166 |
|
167 |
+
$this->init($data, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule);
|
168 |
|
169 |
+
} else {
|
|
|
|
|
170 |
|
171 |
$this->default_init();
|
172 |
|
173 |
}
|
174 |
|
175 |
|
176 |
+
$this->poll_start_date = convert_date($this->poll_start_date, "Y-m-d H:i:s");
|
177 |
|
178 |
+
$this->poll_end_date = convert_date($this->poll_end_date, "Y-m-d H:i:s");
|
|
|
|
|
179 |
|
180 |
}
|
181 |
|
182 |
+
public static function get_current_active_poll($offset = 0)
|
183 |
+
{
|
184 |
global $wpdb;
|
185 |
$current_date = self::get_mysql_curent_date();
|
186 |
+
return $wpdb->get_row($wpdb->prepare("
|
187 |
SELECT * FROM " . $wpdb->yop_polls . "
|
188 |
WHERE
|
189 |
%s >= poll_start_date AND
|
190 |
%s <= poll_end_date
|
191 |
ORDER BY
|
192 |
poll_date ASC
|
193 |
+
", $current_date, $current_date), ARRAY_A, $offset);
|
194 |
}
|
195 |
|
196 |
|
197 |
+
function init($data, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule)
|
198 |
+
{
|
199 |
|
200 |
$this->data = $data;
|
201 |
|
202 |
+
$this->ID = (int)$data->ID;
|
203 |
|
204 |
$this->init_options();
|
205 |
|
206 |
+
if ('yes' == $is_view_results) {
|
207 |
|
208 |
+
switch ($this->sorting_results) {
|
209 |
|
210 |
case "database":
|
211 |
|
212 |
{
|
213 |
|
214 |
+
$answer_sort = 'ID';
|
215 |
|
216 |
$answer_sort_rule = $this->sorting_results_direction;
|
217 |
|
223 |
|
224 |
{
|
225 |
|
226 |
+
$answer_sort = 'answer';
|
227 |
|
228 |
$answer_sort_rule = $this->sorting_results_direction;
|
229 |
|
235 |
|
236 |
{
|
237 |
|
238 |
+
$answer_sort = 'votes';
|
239 |
|
240 |
$answer_sort_rule = $this->sorting_results_direction;
|
241 |
|
247 |
|
248 |
{
|
249 |
|
250 |
+
$answer_sort = "question_order";
|
251 |
|
252 |
$answer_sort_rule = "ASC";
|
253 |
|
261 |
|
262 |
$this->questions = array();
|
263 |
|
264 |
+
$questions_ids = $this->load_questions_ids($question_sort, $question_sort_rule);
|
265 |
|
266 |
+
if ($questions_ids && count($questions_ids) > 0) {
|
267 |
|
268 |
+
foreach ($questions_ids as $question_id) {
|
269 |
|
270 |
+
$new_question = new YOP_POLL_Question_Model($question_id, $answer_sort, $answer_sort_rule);
|
271 |
|
272 |
+
if ($new_question) {
|
273 |
|
274 |
$this->questions[] = $new_question;
|
275 |
|
282 |
}
|
283 |
|
284 |
|
285 |
+
function default_init()
|
286 |
+
{
|
287 |
|
288 |
$this->data = new stdClass();
|
289 |
|
290 |
+
$this->ID = null;
|
291 |
|
292 |
$this->init_options();
|
293 |
|
294 |
+
$this->questions = array();
|
295 |
|
296 |
$this->data->poll_start_date = $this->options['poll_start_date'];
|
297 |
|
298 |
+
$this->data->poll_end_date = $this->options['poll_end_date'];
|
299 |
|
300 |
}
|
301 |
|
302 |
|
303 |
+
function init_options()
|
304 |
+
{
|
305 |
|
306 |
+
$this->options = array();
|
|
|
|
|
307 |
|
308 |
$poll_default_options = yop_poll_poll_default_options();
|
309 |
|
310 |
|
311 |
+
$poll_archive_order = get_option('yop_poll_archive_order', array());
|
312 |
|
313 |
+
$key = array_search($this->ID, $poll_archive_order);
|
314 |
|
315 |
+
if ($key !== false) {
|
|
|
|
|
316 |
|
317 |
$this->options['poll_archive_order'] = $key + 1;
|
318 |
|
319 |
}
|
320 |
|
321 |
|
322 |
+
if ($poll_default_options && count($poll_default_options) > 0) {
|
323 |
|
324 |
+
foreach ($poll_default_options as $option_name => $option_value) {
|
|
|
|
|
325 |
|
326 |
+
$this->options[$option_name] = $this->get_option($option_name);
|
327 |
|
328 |
}
|
329 |
|
332 |
}
|
333 |
|
334 |
|
335 |
+
function _unset()
|
336 |
+
{
|
337 |
|
338 |
+
$this->data = null;
|
|
|
|
|
339 |
|
340 |
+
$this->ID = null;
|
341 |
|
342 |
$this->questions = null;
|
343 |
|
344 |
+
$this->options = null;
|
345 |
|
346 |
$this->unique_id = null;
|
347 |
|
348 |
+
$this->error = null;
|
|
|
|
|
349 |
|
350 |
+
$this->success = null;
|
351 |
|
352 |
|
353 |
}
|
354 |
|
355 |
|
356 |
+
static function get_data_by($field, $value)
|
357 |
+
{
|
358 |
|
359 |
+
if ('id' == $field) {
|
|
|
|
|
360 |
|
361 |
+
if (!is_numeric($value)) {
|
362 |
|
363 |
return false;
|
364 |
|
365 |
}
|
366 |
|
367 |
+
$value = intval($value);
|
368 |
|
369 |
+
if ($value < 1) {
|
370 |
|
371 |
return false;
|
372 |
|
373 |
}
|
374 |
|
375 |
+
} else {
|
|
|
|
|
376 |
|
377 |
+
$value = trim($value);
|
378 |
|
379 |
}
|
380 |
|
381 |
|
382 |
+
if (!$value) {
|
|
|
383 |
|
384 |
return false;
|
385 |
|
386 |
}
|
387 |
|
388 |
|
389 |
+
switch ($field) {
|
|
|
390 |
|
391 |
case 'id':
|
392 |
|
411 |
}
|
412 |
|
413 |
|
414 |
+
if (false !== $model_id) {
|
415 |
|
416 |
+
if ($model = wp_cache_get($model_id, 'yop_poll_model')) {
|
|
|
|
|
417 |
|
418 |
return $model;
|
419 |
|
422 |
}
|
423 |
|
424 |
|
425 |
+
if (!$model = $GLOBALS['wpdb']->get_row($GLOBALS['wpdb']->prepare("SELECT * FROM {$GLOBALS['wpdb']->yop_polls} WHERE $db_field = %s", $value))) {
|
|
|
426 |
|
427 |
return false;
|
428 |
|
429 |
}
|
430 |
|
431 |
|
432 |
+
wp_cache_add($model_id, $model, 'yop_poll_model');
|
|
|
|
|
433 |
|
434 |
|
435 |
return $model;
|
437 |
}
|
438 |
|
439 |
|
440 |
+
static function get_other_model_data_by($field, $value, $current_model_id)
|
441 |
+
{
|
442 |
|
443 |
+
$value = trim($value);
|
|
|
|
|
444 |
|
445 |
|
446 |
+
if (!$value) {
|
|
|
447 |
|
448 |
return false;
|
449 |
|
450 |
}
|
451 |
|
452 |
+
if (intval($current_model_id) <= 0) {
|
453 |
|
454 |
return false;
|
455 |
|
456 |
}
|
457 |
|
458 |
|
459 |
+
switch ($field) {
|
|
|
460 |
|
461 |
case 'name':
|
462 |
|
473 |
}
|
474 |
|
475 |
|
476 |
+
if (!$model = $GLOBALS['wpdb']->get_row($GLOBALS['wpdb']->prepare("SELECT * FROM {$GLOBALS['wpdb']->yop_polls} WHERE $db_field = %s AND ID != %d", $value, $current_model_id))) {
|
|
|
477 |
|
478 |
return false;
|
479 |
|
480 |
}
|
481 |
|
482 |
|
|
|
483 |
return $model;
|
484 |
|
485 |
}
|
486 |
|
487 |
|
488 |
+
function __isset($key)
|
489 |
+
{
|
490 |
|
491 |
+
if ('id' == strtolower($key)) {
|
|
|
|
|
492 |
|
493 |
$key = 'ID';
|
494 |
|
495 |
}
|
496 |
|
497 |
+
if ('type' == $key) {
|
498 |
|
499 |
$key = 'type';
|
500 |
|
501 |
}
|
502 |
|
503 |
|
504 |
+
if (isset($this->$key)) {
|
|
|
505 |
|
506 |
return true;
|
507 |
|
508 |
}
|
509 |
|
510 |
+
if (isset($this->data->$key)) {
|
511 |
|
512 |
return true;
|
513 |
|
514 |
}
|
515 |
|
516 |
|
517 |
+
return $this->isset_option($key);
|
|
|
518 |
|
519 |
}
|
520 |
|
521 |
|
522 |
+
function isset_option($key)
|
523 |
+
{
|
524 |
|
525 |
|
526 |
+
if (isset($this->options[$key])) {
|
|
|
527 |
|
528 |
return true;
|
529 |
|
530 |
}
|
531 |
|
532 |
|
533 |
+
$poll_options = get_yop_poll_meta($this->ID, 'options', true);
|
534 |
|
535 |
+
if (isset($poll_options[$key])) {
|
|
|
|
|
536 |
|
537 |
return true;
|
538 |
|
539 |
}
|
540 |
|
541 |
|
|
|
542 |
return false;
|
543 |
|
544 |
}
|
545 |
|
546 |
|
547 |
+
function __get($key)
|
548 |
+
{
|
549 |
|
550 |
$value = null;
|
551 |
|
552 |
+
if ('id' == strtolower($key)) {
|
553 |
|
554 |
return $this->ID;
|
555 |
|
556 |
}
|
557 |
|
558 |
+
if ('type' == $key) {
|
559 |
|
560 |
return $this->type;
|
561 |
|
562 |
}
|
563 |
|
564 |
+
if ('questions' == $key) {
|
565 |
|
566 |
return $this->questions;
|
567 |
|
568 |
}
|
569 |
|
570 |
+
if ('unique_id' == $key) {
|
571 |
|
572 |
return $this->unique_id;
|
573 |
|
574 |
}
|
575 |
|
576 |
+
if ('error' == $key) {
|
577 |
|
578 |
return $this->error;
|
579 |
|
580 |
}
|
581 |
|
582 |
+
if ('success' == $key) {
|
583 |
|
584 |
return $this->success;
|
585 |
|
586 |
}
|
587 |
|
588 |
+
if ('vote' == $key) {
|
589 |
|
590 |
return $this->vote;
|
591 |
|
592 |
}
|
593 |
|
594 |
|
595 |
+
if (isset($this->data->$key)) {
|
|
|
596 |
|
597 |
$value = $this->data->$key;
|
598 |
|
599 |
+
} elseif (in_array($key, $this->default_fields)) {
|
|
|
|
|
600 |
|
601 |
$value = $this->data->$key;
|
602 |
|
603 |
+
} else {
|
604 |
|
605 |
+
$value = $this->get_option($key);
|
|
|
|
|
606 |
|
607 |
}
|
608 |
|
609 |
|
|
|
610 |
return $value;
|
611 |
|
612 |
}
|
613 |
|
614 |
|
615 |
+
function get_option($key)
|
616 |
+
{
|
617 |
|
618 |
|
619 |
+
if (isset($this->options[$key])) {
|
|
|
620 |
|
621 |
return $this->options[$key];
|
622 |
|
623 |
}
|
624 |
|
625 |
|
626 |
+
$poll_options = get_yop_poll_meta($this->ID, 'options', true);
|
627 |
|
628 |
+
if (isset($poll_options[$key])) {
|
|
|
|
|
629 |
|
630 |
return $poll_options[$key];
|
631 |
|
632 |
}
|
633 |
|
634 |
|
635 |
+
$default_options = get_option('yop_poll_options');
|
636 |
|
637 |
+
if (isset($default_options[$key])) {
|
|
|
|
|
638 |
|
639 |
return $default_options[$key];
|
640 |
|
645 |
}
|
646 |
|
647 |
|
648 |
+
function __set($key, $value)
|
649 |
+
{
|
650 |
|
651 |
+
if ('id' == strtolower($key)) {
|
652 |
|
653 |
+
$this->ID = $value;
|
|
|
|
|
654 |
|
655 |
$this->data->ID = $value;
|
656 |
|
658 |
|
659 |
}
|
660 |
|
661 |
+
if ('type' == $key) {
|
662 |
|
663 |
$this->type = $value;
|
664 |
|
666 |
|
667 |
}
|
668 |
|
669 |
+
if ('questions' == $key) {
|
670 |
|
671 |
$this->questions = $value;
|
672 |
|
674 |
|
675 |
}
|
676 |
|
677 |
+
if ('unique_id' == $key) {
|
678 |
|
679 |
$this->unique_id = $value;
|
680 |
|
682 |
|
683 |
}
|
684 |
|
685 |
+
if ('error' == $key) {
|
686 |
|
687 |
$this->error = $value;
|
688 |
|
690 |
|
691 |
}
|
692 |
|
693 |
+
if ('success' == $key) {
|
694 |
|
695 |
$this->success = $value;
|
696 |
|
698 |
|
699 |
}
|
700 |
|
701 |
+
if ('vote' == $key) {
|
702 |
|
703 |
$this->vote = $value;
|
704 |
|
707 |
}
|
708 |
|
709 |
|
710 |
+
if (in_array($key, $this->default_fields)) //this is not an option
|
|
|
711 |
|
712 |
{
|
713 |
|
714 |
$this->data->$key = $value;
|
715 |
|
716 |
+
} else {
|
|
|
|
|
717 |
|
718 |
+
$this->_set_option($key, $value);
|
719 |
|
720 |
}
|
721 |
|
722 |
}
|
723 |
|
724 |
|
725 |
+
function _set_option($key, $value)
|
726 |
+
{
|
727 |
|
728 |
$this->options[$key] = $value;
|
729 |
|
730 |
}
|
731 |
|
732 |
|
733 |
+
function exists()
|
734 |
+
{
|
735 |
|
736 |
+
return !empty($this->ID);
|
|
|
|
|
737 |
|
738 |
}
|
739 |
|
740 |
|
741 |
+
function get($key)
|
742 |
+
{
|
743 |
|
744 |
+
return $this->__get($key);
|
|
|
|
|
745 |
|
746 |
}
|
747 |
|
748 |
|
749 |
+
function has_prop($key)
|
750 |
+
{
|
751 |
|
752 |
+
return $this->__isset($key);
|
|
|
|
|
753 |
|
754 |
}
|
755 |
|
756 |
|
757 |
+
function to_array()
|
758 |
+
{
|
759 |
|
760 |
+
return get_object_vars($this->data);
|
|
|
|
|
761 |
|
762 |
}
|
763 |
|
764 |
|
765 |
+
function load_questions_ids($question_sort, $question_sort_rule)
|
766 |
+
{
|
767 |
|
768 |
+
if (!$questions = $GLOBALS['wpdb']->get_col($GLOBALS['wpdb']->prepare("SELECT ID FROM {$GLOBALS['wpdb']->yop_poll_questions} WHERE poll_id = %s ORDER BY {$question_sort} {$question_sort_rule}", $this->id))) {
|
|
|
|
|
769 |
|
770 |
return false;
|
771 |
|
776 |
}
|
777 |
|
778 |
|
779 |
+
function save($is_clone = false)
|
780 |
+
{
|
781 |
+
if (!$this->exists()) {
|
782 |
|
783 |
+
return $this->insert($is_clone);
|
784 |
|
785 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
786 |
|
787 |
return $this->update();
|
788 |
|
791 |
}
|
792 |
|
793 |
|
794 |
+
function save_options()
|
795 |
+
{
|
796 |
|
797 |
+
$poll_options = get_yop_poll_meta($this->ID, 'options', true);
|
798 |
|
799 |
+
if ($this->options && count($this->options) > 0) {
|
800 |
|
801 |
+
foreach ($this->options as $option_name => $option_value) {
|
802 |
|
803 |
+
if ($option_name == "view_results_start_date" || $option_name == "schedule_reset_poll_date") {
|
804 |
+
$options1 = get_option('yop_poll_options');
|
805 |
+
if ($options1['date_format'] == "US") {
|
806 |
+
$original1 = explode(' ', $option_value);
|
807 |
+
$original = explode('-', $original1[0]);
|
808 |
+
$option_value = $original[1] . '-' . $original[0] . '-' . $original[2] . ' ' . $original1[1];
|
809 |
|
|
|
|
|
|
|
|
|
|
|
|
|
810 |
|
811 |
+
}
|
812 |
+
if (convert_date($option_value, 'Y-m-d H:i:s', 1) == '1970-01-01 00:00:00')
|
813 |
+
$option_value = convert_date($option_value, 'Y-m-d H:i:s');
|
814 |
+
else
|
815 |
+
$option_value = convert_date($option_value, 'Y-m-d H:i:s', 1);
|
816 |
+
$original = explode(' ', $option_value);
|
817 |
+
$original = explode('-', $original[0]);
|
818 |
|
819 |
+
if ($original[2] > 12) {
|
820 |
+
$poll_options[$option_name] = convert_date($option_value, 'Y-m-d H:i:s', 1);
|
821 |
+
} else
|
822 |
+
$poll_options[$option_name] = convert_date($option_value, 'Y-d-m H:i:s', 1);
|
823 |
+
} else
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
824 |
|
825 |
|
826 |
+
$poll_options[$option_name] = $option_value;
|
827 |
|
828 |
}
|
829 |
|
830 |
}
|
831 |
|
832 |
+
update_yop_poll_meta($this->id, 'options', $poll_options);
|
833 |
|
834 |
}
|
835 |
|
836 |
|
837 |
+
function insert($is_clone = false)
|
838 |
+
{
|
839 |
+
$options = get_option('yop_poll_options');
|
840 |
+
if ($options['date_format'] == "US") {
|
841 |
+
$original1 = explode(' ', $this->poll_start_date);
|
842 |
+
$original = explode('-', $original1[0]);
|
843 |
+
$this->poll_start_date = $original[0] . '-' . $original[1] . '-' . $original[2] . ' ' . $original1[1];
|
844 |
+
$original1 = explode(' ', $this->poll_end_date);
|
845 |
+
$original = explode('-', $original1[0]);
|
846 |
+
$this->poll_end_date = $original[0] . '-' . $original[1] . '-' . $original[2] . ' ' . $original1[1];
|
847 |
+
}
|
848 |
+
if ($this->poll_end_date == "01-01-2038 23:59:59")
|
849 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s');
|
850 |
+
else {
|
851 |
+
if (convert_date($this->poll_end_date, 'Y-m-d H:i:s', 1) == '1970-01-01 00:00:00')
|
852 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s');
|
853 |
+
else
|
854 |
+
if ($options['date_format'] == "US")
|
855 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s', 1);
|
856 |
+
else
|
857 |
+
if(!$is_clone)
|
858 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-d-m H:i:s', 1);
|
859 |
+
}
|
860 |
+
if (convert_date($this->poll_start_date, 'Y-m-d H:i:s', 1) == '1970-01-01 00:00:00')
|
861 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-m-d H:i:s');
|
862 |
else
|
863 |
+
if ($options['date_format'] == "US")
|
864 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-m-d H:i:s', 1);
|
865 |
+
else
|
866 |
+
if(!$is_clone)
|
867 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-d-m H:i:s', 1);
|
868 |
+
$original = explode(' ', $this->poll_start_date);
|
869 |
+
$original = explode('-', $original[0]);
|
870 |
+
if ($original[2] > 12) {
|
871 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-m-d H:i:s', 1);
|
872 |
+
} else
|
873 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-m-d H:i:s', 1);
|
874 |
+
$original = explode(' ', $this->poll_end_date);
|
875 |
+
$original = explode('-', $original[0]);
|
876 |
+
if ($original[2] > 12) {
|
877 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s', 1);
|
878 |
+
} else
|
879 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s', 1);
|
880 |
+
if (isset($this->ID)) {
|
881 |
+
|
882 |
+
|
883 |
+
$GLOBALS['wpdb']->query($GLOBALS['wpdb']->prepare("
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
|
885 |
INSERT INTO " . $GLOBALS['wpdb']->yop_polls . "
|
886 |
|
906 |
|
907 |
poll_total_votes = %d
|
908 |
|
909 |
+
", $this->ID, $this->poll_title, $this->poll_name, $this->poll_author, $this->poll_date, $this->poll_status, $this->poll_modified, $this->type, $this->poll_start_date, $this->poll_end_date, $this->poll_total_votes));
|
910 |
|
911 |
$this->id = $GLOBALS['wpdb']->insert_id;
|
912 |
|
913 |
+
} else {
|
914 |
+
$GLOBALS['wpdb']->query($GLOBALS['wpdb']->prepare("
|
|
|
915 |
|
916 |
INSERT INTO " . $GLOBALS['wpdb']->yop_polls . "
|
917 |
|
936 |
|
937 |
poll_total_votes = %d
|
938 |
|
939 |
+
", $this->poll_title, $this->poll_name, $this->poll_author, $this->poll_date, $this->poll_status, $this->poll_modified, $this->type, $this->poll_start_date, $this->poll_end_date, $this->poll_total_votes));
|
940 |
|
941 |
$this->id = $GLOBALS['wpdb']->insert_id;
|
942 |
}
|
943 |
|
944 |
|
945 |
+
if (intval($this->id) > 0) {
|
946 |
|
947 |
+
wp_cache_delete($this->id, 'yop_poll_model');
|
948 |
|
|
|
949 |
|
950 |
+
if (isset($this->auto_generate_poll_page) && "yes" == $this->auto_generate_poll_page && "yes" != $this->has_auto_generate_poll_page) {
|
951 |
|
952 |
+
$_p = array();
|
953 |
|
954 |
+
$_p['post_title'] = $this->poll_title;
|
955 |
|
956 |
+
$_p['post_content'] = "[yop_poll id='" . $this->ID . "']";
|
957 |
|
958 |
+
$_p['post_status'] = 'publish';
|
959 |
|
960 |
+
$_p['post_type'] = 'page';
|
|
|
|
|
|
|
|
|
961 |
|
962 |
$_p['comment_status'] = 'open';
|
963 |
|
964 |
+
$_p['ping_status'] = 'open';
|
|
|
|
|
965 |
|
966 |
+
$_p['post_category'] = array(1); // the default 'Uncategorised'
|
967 |
|
968 |
|
969 |
+
$poll_page_id = wp_insert_post($_p);
|
970 |
|
971 |
|
972 |
+
$this->poll_page_url = get_permalink($poll_page_id);
|
|
|
973 |
|
974 |
$this->has_auto_generate_poll_page = 'yes';
|
975 |
|
976 |
+
$this->auto_generate_poll_page = 'no';
|
977 |
|
978 |
}
|
979 |
|
990 |
}
|
991 |
|
992 |
|
993 |
+
function update()
|
994 |
+
{
|
995 |
+
$options = get_option('yop_poll_options');
|
996 |
+
if ($options['date_format'] == "US") {
|
997 |
+
$original1 = explode(' ', $this->poll_start_date);
|
998 |
+
$original = explode('-', $original1[0]);
|
999 |
+
$this->poll_start_date = $original[1] . '-' . $original[0] . '-' . $original[2] . ' ' . $original1[1];
|
1000 |
+
$original1 = explode(' ', $this->poll_end_date);
|
1001 |
+
$original = explode('-', $original1[0]);
|
1002 |
+
$this->poll_end_date = $original[1] . '-' . $original[0] . '-' . $original[2] . ' ' . $original1[1];
|
1003 |
|
1004 |
}
|
1005 |
+
if ($this->poll_end_date == "01-01-2038 23:59:59")
|
1006 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s');
|
|
|
1007 |
else {
|
1008 |
+
if (convert_date($this->poll_end_date, 'Y-m-d H:i:s', 1) == '1970-01-01 00:00:00')
|
1009 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s');
|
1010 |
else
|
1011 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s', 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1012 |
}
|
1013 |
+
if (convert_date($this->poll_start_date, 'Y-m-d H:i:s', 1) == '1970-01-01 00:00:00')
|
1014 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-m-d H:i:s');
|
1015 |
else
|
1016 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-m-d H:i:s', 1);
|
1017 |
+
|
1018 |
+
$original = explode(' ', $this->poll_start_date);
|
1019 |
+
$original = explode('-', $original[0]);
|
1020 |
+
if ($original[2] > 12) {
|
1021 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-m-d H:i:s', 1);
|
1022 |
+
} else
|
1023 |
+
$this->poll_start_date = convert_date($this->poll_start_date, 'Y-d-m H:i:s', 1);
|
1024 |
+
$original = explode(' ', $this->poll_end_date);
|
1025 |
+
$original = explode('-', $original[0]);
|
1026 |
+
|
1027 |
+
if ($original[2] > 12) {
|
1028 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-m-d H:i:s', 1);
|
1029 |
+
} else
|
1030 |
+
$this->poll_end_date = convert_date($this->poll_end_date, 'Y-d-m H:i:s', 1);
|
1031 |
+
$GLOBALS['wpdb']->query($GLOBALS['wpdb']->prepare("
|
1032 |
|
1033 |
UPDATE " . $GLOBALS['wpdb']->yop_polls . "
|
1034 |
|
1050 |
|
1051 |
ID = %d
|
1052 |
|
1053 |
+
", $this->poll_title, $this->poll_name, $this->poll_status, $this->poll_modified, $this->poll_start_date, $this->poll_end_date, $this->id));
|
1054 |
+
if (isset($this->auto_generate_poll_page) && "yes" == $this->auto_generate_poll_page && "yes" != $this->has_auto_generate_poll_page) {
|
1055 |
|
1056 |
+
$_p = array();
|
1057 |
|
1058 |
+
$_p['post_title'] = $this->poll_title;
|
1059 |
|
1060 |
+
$_p['post_content'] = "[yop_poll id='" . $this->ID . "']";
|
1061 |
|
1062 |
+
$_p['post_status'] = 'publish';
|
1063 |
|
1064 |
+
$_p['post_type'] = 'page';
|
1065 |
|
1066 |
$_p['comment_status'] = 'open';
|
1067 |
|
1068 |
+
$_p['ping_status'] = 'open';
|
1069 |
|
1070 |
+
$_p['post_category'] = array(1); // the default 'Uncategorised'
|
1071 |
|
1072 |
|
1073 |
+
$poll_page_id = wp_insert_post($_p);
|
1074 |
|
|
|
1075 |
|
1076 |
+
$this->poll_page_url = get_permalink($poll_page_id);
|
|
|
|
|
1077 |
|
1078 |
$this->has_auto_generate_poll_page = 'yes';
|
1079 |
|
1080 |
+
$this->auto_generate_poll_page = 'no';
|
1081 |
|
1082 |
}
|
1083 |
|
1085 |
|
1086 |
$this->save_questions();
|
1087 |
|
1088 |
+
wp_cache_delete($this->id, 'yop_poll_model');
|
1089 |
|
1090 |
return true;
|
1091 |
|
1092 |
}
|
1093 |
|
1094 |
|
1095 |
+
function update_no_votes()
|
1096 |
+
{
|
1097 |
|
1098 |
+
$GLOBALS['wpdb']->query($GLOBALS['wpdb']->prepare("
|
|
|
|
|
1099 |
|
1100 |
UPDATE " . $GLOBALS['wpdb']->yop_polls . "
|
1101 |
|
1107 |
|
1108 |
ID= %d
|
1109 |
|
1110 |
+
", $this->poll_total_votes, $this->id));
|
1111 |
|
1112 |
|
1113 |
+
wp_cache_delete($this->id, 'yop_poll_model');
|
|
|
1114 |
|
1115 |
return true;
|
1116 |
|
1117 |
}
|
1118 |
|
1119 |
|
1120 |
+
function delete()
|
1121 |
+
{
|
1122 |
|
1123 |
+
if (count($this->questions) > 0) {
|
|
|
|
|
1124 |
|
1125 |
+
foreach ($this->questions as $question) {
|
1126 |
|
1127 |
$question->delete();
|
1128 |
|
1130 |
|
1131 |
}
|
1132 |
|
1133 |
+
delete_yop_poll_meta($this->id, 'options');
|
1134 |
|
1135 |
+
$GLOBALS['wpdb']->query($GLOBALS['wpdb']->prepare("
|
1136 |
|
1137 |
DELETE FROM " . $GLOBALS['wpdb']->yop_polls . "
|
1138 |
|
1139 |
WHERE ID = %d
|
1140 |
|
1141 |
+
", $this->id));
|
1142 |
|
1143 |
+
wp_cache_delete($this->id, 'yop_poll_model');
|
1144 |
|
1145 |
$this->_unset();
|
1146 |
|
1147 |
}
|
1148 |
|
1149 |
|
1150 |
+
function save_questions()
|
1151 |
+
{
|
1152 |
|
1153 |
|
1154 |
$current_questions_ids = array();
|
1155 |
|
1156 |
+
if (is_array($this->questions) && count($this->questions) > 0) {
|
1157 |
|
1158 |
+
foreach ($this->questions as $question) {
|
1159 |
|
1160 |
$question->poll_id = $this->id;
|
1161 |
|
1167 |
|
1168 |
}
|
1169 |
|
1170 |
+
$this->remove_deleted_questions($current_questions_ids);
|
1171 |
|
1172 |
}
|
1173 |
|
1174 |
|
1175 |
+
function remove_deleted_questions($current_questions_ids = array())
|
1176 |
+
{
|
1177 |
|
1178 |
+
if (count($current_questions_ids) == 0) {
|
|
|
|
|
1179 |
|
1180 |
$current_questions_ids[] = 0;
|
1181 |
|
1182 |
}
|
1183 |
|
1184 |
+
$questions_for_delete = $GLOBALS['wpdb']->get_col($GLOBALS['wpdb']->prepare(" SELECT ID FROM " . $GLOBALS['wpdb']->yop_poll_questions . " WHERE ID NOT IN ( " . implode(',', $current_questions_ids) . " ) AND poll_id = %d ", $this->id));
|
1185 |
|
1186 |
+
if ($questions_for_delete) {
|
1187 |
|
1188 |
+
foreach ($questions_for_delete as $question_id) {
|
1189 |
|
1190 |
+
$question = new YOP_POLL_Question_Model($question_id);
|
1191 |
|
1192 |
$question->delete();
|
1193 |
|
1198 |
}
|
1199 |
|
1200 |
|
1201 |
+
protected static function get_poll_template_from_database($id = 0)
|
1202 |
+
{
|
1203 |
|
1204 |
global $wpdb;
|
1205 |
|
1206 |
+
if (!$id) {
|
1207 |
|
1208 |
+
$request = $wpdb->prepare("status = %s ", "default");
|
1209 |
|
1210 |
+
} else {
|
|
|
|
|
1211 |
|
1212 |
+
$request = $wpdb->prepare("id = %d ", $id);
|
1213 |
|
1214 |
}
|
1215 |
|
1216 |
+
$result = $wpdb->get_row("
|
1217 |
|
1218 |
SELECT *
|
1219 |
|
1223 |
|
1224 |
LIMIT 0,1
|
1225 |
|
1226 |
+
", ARRAY_A);
|
1227 |
|
1228 |
return $result;
|
1229 |
|
1230 |
}
|
1231 |
|
1232 |
|
1233 |
+
public static function get_mysql_curent_date()
|
1234 |
+
{
|
1235 |
|
1236 |
+
return current_time('mysql');
|
|
|
|
|
1237 |
|
1238 |
}
|
1239 |
|
1240 |
|
1241 |
+
public static function get_mysql_custom_date($interval_value = 0, $interval_unit = 'DAY')
|
1242 |
+
{
|
1243 |
|
1244 |
global $wpdb;
|
1245 |
|
1246 |
+
return $wpdb->get_var($wpdb->prepare("SELECT %s + INTERVAL %d " . esc_sql($interval_unit), current_time('mysql'), $interval_value));
|
1247 |
|
1248 |
}
|
1249 |
|
1250 |
|
1251 |
+
protected function is_voted($vote_type = 'default', $facebook_user_details = null, $from_register = null, $SuperCookie = null, $google_user_details = null)
|
1252 |
+
{
|
1253 |
+
if ($this->vote) {
|
1254 |
|
1255 |
return true;
|
1256 |
|
1257 |
}
|
1258 |
|
1259 |
|
1260 |
+
if (isset($this->blocking_voters)) {
|
1261 |
|
1262 |
$is_voted = false;
|
1263 |
|
1264 |
+
if (in_array('dont-block', $this->blocking_voters)) {
|
1265 |
|
1266 |
return false;
|
1267 |
|
1268 |
}
|
1269 |
|
1270 |
+
if (in_array("ip", $this->blocking_voters)) {
|
1271 |
|
1272 |
$is_voted = $is_voted || $this->is_voted_ip();
|
1273 |
|
1274 |
}
|
1275 |
|
1276 |
+
if (in_array("cookie", $this->blocking_voters)) {
|
1277 |
|
1278 |
|
1279 |
$is_voted = $is_voted || $this->is_voted_cookie();
|
1280 |
|
1281 |
}
|
1282 |
|
1283 |
+
if (in_array("user_id", $this->blocking_voters)) {
|
1284 |
|
1285 |
+
$is_voted = $is_voted || $this->is_voted_username($vote_type = 'default', $facebook_user_details = null, $google_user_details, $from_register);
|
1286 |
}
|
1287 |
|
1288 |
+
if (in_array("supercookie", $this->blocking_voters)) {
|
1289 |
|
1290 |
}
|
1291 |
|
1298 |
}
|
1299 |
|
1300 |
|
1301 |
+
private function is_ban($vote_type = 'default', $facebook_user_details = null, $google_user_details = null)
|
1302 |
+
{
|
1303 |
|
1304 |
global $wpdb, $current_user;
|
1305 |
|
1306 |
|
|
|
1307 |
$username = $current_user->data->user_login;
|
1308 |
|
1309 |
+
$email = $current_user->data->user_email;
|
|
|
1310 |
|
1311 |
|
1312 |
+
if ('facebook' == $vote_type) {
|
1313 |
|
1314 |
$username = $facebook_user_details['username'];
|
1315 |
|
1316 |
+
$email = $facebook_user_details['email'];
|
1317 |
|
1318 |
}
|
1319 |
|
1320 |
+
if ('google' == $vote_type) {
|
1321 |
|
1322 |
$username = $google_user_details['displayName'];
|
1323 |
|
1324 |
+
$id = $google_user_details['id'];
|
1325 |
|
1326 |
+
$email = '';
|
1327 |
|
1328 |
}
|
1329 |
|
1330 |
+
if ('anonymous' == $vote_type) {
|
1331 |
|
1332 |
$username = '';
|
1333 |
|
1334 |
+
$email = '';
|
1335 |
|
1336 |
}
|
1337 |
|
1338 |
+
$ip = yop_poll_get_ip();
|
1339 |
|
1340 |
+
$sql = $wpdb->prepare("
|
1341 |
|
1342 |
SELECT id
|
1343 |
|
1359 |
|
1360 |
LIMIT 0,1
|
1361 |
|
1362 |
+
", $this->ID, $ip, $username, $email, $id);
|
1363 |
|
1364 |
+
return $wpdb->get_var($sql);
|
1365 |
|
1366 |
}
|
1367 |
|
1368 |
|
1369 |
+
private function is_voted_ip()
|
1370 |
+
{
|
1371 |
|
1372 |
global $wpdb;
|
1373 |
|
1374 |
$unit = 'DAY';
|
1375 |
|
1376 |
+
if (isset($this->blocking_voters_interval_unit)) {
|
1377 |
|
1378 |
+
switch ($this->blocking_voters_interval_unit) {
|
1379 |
|
1380 |
case 'seconds' :
|
1381 |
|
1407 |
|
1408 |
$value = 30;
|
1409 |
|
1410 |
+
if (isset($this->blocking_voters_interval_value)) {
|
1411 |
|
1412 |
$value = $this->blocking_voters_interval_value;
|
1413 |
|
1414 |
}
|
1415 |
|
1416 |
+
$ip = yop_poll_get_ip();
|
1417 |
|
1418 |
+
$log_id = $wpdb->get_var($wpdb->prepare("
|
1419 |
|
1420 |
SELECT id
|
1421 |
|
1427 |
|
1428 |
vote_date >= DATE_ADD( %s, INTERVAL -%d " . $unit . ")
|
1429 |
|
1430 |
+
", $this->ID, $ip, current_time('mysql'), $value));
|
|
|
1431 |
|
1432 |
|
1433 |
return $log_id;
|
1435 |
}
|
1436 |
|
1437 |
|
1438 |
+
private function is_voted_cookie()
|
1439 |
+
{
|
1440 |
|
1441 |
+
if (isset($_COOKIE['yop_poll_voted_' . $this->ID])) {
|
|
|
|
|
1442 |
|
1443 |
return true;
|
1444 |
|
1449 |
}
|
1450 |
|
1451 |
|
1452 |
+
protected function is_allowed_to_vote($vote_type = 'default', $facebook_user_details = null, $google_user_details = null)
|
1453 |
+
{
|
1454 |
|
1455 |
global $current_user;
|
1456 |
|
1457 |
+
if (self::is_ban($vote_type, $facebook_user_details, $google_user_details)) {
|
1458 |
|
1459 |
return false;
|
1460 |
|
1461 |
}
|
1462 |
|
1463 |
+
if (isset($this->vote_permisions)) {
|
1464 |
|
1465 |
|
1466 |
+
if (in_array('guest', $this->vote_permisions) && in_array('registered', $this->vote_permisions)) {
|
1467 |
|
1468 |
+
if ($vote_type == "wordpress" && $this->vote_permisions_wordpress == "yes") {
|
|
|
|
|
1469 |
|
1470 |
+
if ($current_user->ID > 0) {
|
1471 |
|
1472 |
|
1473 |
return true;
|
1476 |
|
1477 |
}
|
1478 |
|
1479 |
+
if ($vote_type == "anonymous" && $this->vote_permisions_anonymous == "yes") {
|
|
|
1480 |
|
1481 |
|
1482 |
+
return true;
|
|
|
|
|
1483 |
|
1484 |
|
1485 |
}
|
1488 |
return false;
|
1489 |
|
1490 |
}
|
1491 |
+
if (in_array('guest', $this->vote_permisions) && !in_array('registered', $this->vote_permisions)) {
|
|
|
|
|
1492 |
|
1493 |
+
if ($vote_type == "wordpress" && $this->vote_permisions_wordpress == "yes") {
|
1494 |
|
1495 |
+
if ($current_user->ID > 0) {
|
1496 |
|
1497 |
|
1498 |
return false;
|
1501 |
|
1502 |
}
|
1503 |
|
1504 |
+
if ('facebook' == $vote_type) {
|
|
|
1505 |
|
1506 |
|
1507 |
return false;
|
1508 |
|
1509 |
}
|
1510 |
|
1511 |
+
if ('google' == $vote_type) {
|
1512 |
|
1513 |
return false;
|
1514 |
|
1515 |
}
|
1516 |
|
1517 |
+
if ($vote_type == "anonymous" && $this->vote_permisions_anonymous != "yes") {
|
|
|
|
|
|
|
1518 |
|
1519 |
|
1520 |
return false;
|
1527 |
}
|
1528 |
|
1529 |
|
|
|
1530 |
//registered only
|
1531 |
|
1532 |
+
if (in_array('registered', $this->vote_permisions) && !in_array('guest', $this->vote_permisions)) {
|
1533 |
|
1534 |
+
if ('anonymous' == $vote_type) {
|
1535 |
|
1536 |
return true;
|
1537 |
|
1538 |
}
|
1539 |
|
1540 |
+
if ($current_user->ID > 0 && "wordpress" == $vote_type && $this->vote_permisions_wordpress == "yes") {
|
1541 |
return true;
|
1542 |
|
1543 |
}
|
1544 |
|
1545 |
+
if ('facebook' == $vote_type) {
|
1546 |
|
1547 |
+
if ($facebook_user_details) {
|
1548 |
|
1549 |
+
if ($facebook_user_details['id'] != '') {
|
1550 |
|
1551 |
return true;
|
1552 |
|
1560 |
|
1561 |
}
|
1562 |
|
1563 |
+
if ('google' == $vote_type) {
|
1564 |
|
1565 |
+
if ($google_user_details) {
|
1566 |
|
1567 |
+
if ($google_user_details['id'] != '') {
|
1568 |
|
1569 |
return true;
|
1570 |
|
1591 |
}
|
1592 |
|
1593 |
|
1594 |
+
protected function set_vote_cookie($vote_details = array(), $vote_type = 'default', $facebook_user_details = null, $google_user_details = null)
|
1595 |
+
{
|
1596 |
|
1597 |
$expire_cookie = 0;
|
1598 |
|
1599 |
+
$value = 30;
|
|
|
1600 |
|
1601 |
|
1602 |
+
if (isset($this->blocking_voters_interval_value)) {
|
1603 |
|
1604 |
$value = $this->blocking_voters_interval_value;
|
1605 |
|
1607 |
|
1608 |
$unit = 'days';
|
1609 |
|
1610 |
+
if (isset($this->blocking_voters_interval_unit)) {
|
1611 |
|
1612 |
$unit = $this->blocking_voters_interval_unit;
|
1613 |
|
1614 |
}
|
1615 |
|
1616 |
|
1617 |
+
switch ($unit) {
|
|
|
1618 |
|
1619 |
case 'seconds' :
|
1620 |
|
1624 |
|
1625 |
case 'minutes' :
|
1626 |
|
1627 |
+
$expire_cookie = time() + (60 * $value);
|
1628 |
|
1629 |
break;
|
1630 |
|
1631 |
case 'hours' :
|
1632 |
|
1633 |
+
$expire_cookie = time() + (60 * 60 * $value);
|
1634 |
|
1635 |
break;
|
1636 |
|
1637 |
case 'days' :
|
1638 |
|
1639 |
+
$expire_cookie = time() + (60 * 60 * 24 * $value);
|
1640 |
|
1641 |
break;
|
1642 |
|
1643 |
}
|
1644 |
|
1645 |
+
setcookie('yop_poll_voted_' . $this->ID, $vote_details, $expire_cookie, COOKIEPATH, COOKIE_DOMAIN, false);
|
1646 |
|
1647 |
+
setcookie('yop_poll_vote_type_' . $this->ID, $vote_type, $expire_cookie, COOKIEPATH, COOKIE_DOMAIN, false);
|
1648 |
|
1649 |
+
if ('facebook' == $vote_type) {
|
1650 |
|
1651 |
+
setcookie('yop_poll_vote_facebook_user_' . $this->ID, $facebook_user_details['id'], $expire_cookie, COOKIEPATH, COOKIE_DOMAIN, false);
|
1652 |
|
1653 |
}
|
1654 |
|
1655 |
+
if ('google' == $vote_type) {
|
1656 |
|
1657 |
+
setcookie('yop_poll_vote_google_user_' . $this->ID, $google_user_details['id'], $expire_cookie, COOKIEPATH, COOKIE_DOMAIN, false);
|
1658 |
|
1659 |
}
|
1660 |
|
1661 |
}
|
1662 |
|
1663 |
|
1664 |
+
private function is_voted_username($vote_type = 'default', $facebook_user_details = null, $google_user_details, $from_register = null)
|
1665 |
+
{
|
1666 |
|
1667 |
global $current_user, $wpdb;
|
1668 |
|
1669 |
|
1670 |
+
if (!$from_register) {
|
1671 |
+
if (isset($_COOKIE['yop_poll_vote_type_' . $this->poll['id']]))
|
1672 |
+
$vote_type = in_array($_COOKIE['yop_poll_vote_type_' . $this->poll['id']], array("anonymous")) ? $_COOKIE['yop_poll_vote_type_' . $this->poll['id']] : 'default';
|
1673 |
+
if (isset($_COOKIE['yop_poll_vote_facebook_user_' . $this->poll['id']]))
|
|
|
1674 |
$facebook_user_details['id'] = $_COOKIE['yop_poll_vote_facebook_user_' . $this->poll['id']];
|
1675 |
+
if (isset($_COOKIE['yop_poll_vote_google_user_' . $this->poll['id']]))
|
1676 |
+
$google_user_details['id'] = $_COOKIE['yop_poll_vote_google_user_' . $this->poll['id']];
|
1677 |
|
1678 |
}
|
1679 |
|
1680 |
|
|
|
1681 |
$unit = 'DAY';
|
1682 |
|
1683 |
+
if (isset($this->options['blocking_voters_interval_unit'])) {
|
1684 |
|
1685 |
+
switch ($this->options['blocking_voters_interval_unit']) {
|
1686 |
|
1687 |
case 'seconds' :
|
1688 |
|
1714 |
|
1715 |
//user is guest
|
1716 |
|
1717 |
+
if ('default' == $vote_type || 'anonymous' == $vote_type) {
|
1718 |
|
1719 |
+
if (!is_user_logged_in()) {
|
1720 |
|
1721 |
return $this->is_voted_ip();
|
1722 |
|
1725 |
}
|
1726 |
|
1727 |
|
|
|
1728 |
$value = 30;
|
1729 |
|
1730 |
+
if (isset($this->options['blocking_voters_interval_value'])) {
|
1731 |
|
1732 |
$value = $this->options['blocking_voters_interval_value'];
|
1733 |
|
1734 |
}
|
1735 |
|
1736 |
+
$ip = yop_poll_get_ip();
|
1737 |
|
1738 |
$user_id = $current_user->ID;
|
1739 |
|
1740 |
|
1741 |
+
if ('facebook' == $vote_type) {
|
|
|
1742 |
|
1743 |
$user_id = $facebook_user_details['id'];
|
1744 |
|
1745 |
+
if (!$user_id) {
|
1746 |
|
1747 |
return false;
|
1748 |
|
1750 |
|
1751 |
}
|
1752 |
|
1753 |
+
if ('google' == $vote_type) {
|
1754 |
|
1755 |
$user_id = $google_user_details['id'];
|
1756 |
|
1757 |
+
if (!$user_id) {
|
1758 |
|
1759 |
return false;
|
1760 |
|
1763 |
}
|
1764 |
|
1765 |
|
1766 |
+
$sql = $wpdb->prepare("
|
|
|
1767 |
SELECT * FROM " . $wpdb->yop_poll_results . "
|
1768 |
|
1769 |
WHERE poll_id = %d AND
|
1772 |
|
1773 |
vote_date >= DATE_SUB( NOW(), INTERVAL %d " . $unit . ")
|
1774 |
|
1775 |
+
LIMIT 1", $this->ID, $user_id, $value);
|
1776 |
+
$result = $wpdb->get_results($sql, ARRAY_A);
|
1777 |
|
1778 |
+
if (isset($result[0]['vote_date']))
|
1779 |
return true;
|
1780 |
else
|
1781 |
return false;
|
1782 |
|
1783 |
}
|
1784 |
|
1785 |
+
protected function get_voter_number_of_votes($voter)
|
1786 |
+
{
|
1787 |
|
1788 |
global $wpdb;
|
1789 |
|
1790 |
+
$result = $wpdb->get_results($wpdb->prepare("
|
1791 |
|
1792 |
SELECT *
|
1793 |
|
1801 |
|
1802 |
user_type = %s GROUP BY vote_id
|
1803 |
|
1804 |
+
", $voter['poll_id'], $voter['user_id'], $voter['user_type']));
|
|
|
|
|
1805 |
|
1806 |
+
return count($result);
|
1807 |
|
1808 |
|
1809 |
}
|
1810 |
|
1811 |
|
1812 |
+
protected function get_votes_number_from_supercookie($cookie)
|
1813 |
+
{
|
1814 |
|
1815 |
+
$details = explode("=", $cookie);
|
1816 |
|
1817 |
+
$votes = explode(";", $details[1]);
|
|
|
|
|
1818 |
|
1819 |
return (int)$votes[0];
|
1820 |
|
1821 |
}
|
1822 |
|
1823 |
|
1824 |
+
public static function convert_date($original_date, $new_format = '')
|
1825 |
+
{
|
1826 |
+
$original_date = convert_date($original_date, 'Y-m-d H:i:s');
|
1827 |
+
$original_date = str_replace('-', '/', $original_date);
|
1828 |
+
return date_i18n($new_format, strtotime($original_date));
|
1829 |
|
1830 |
}
|
1831 |
|
1832 |
|
1833 |
+
protected function user_have_votes_to_vote($voter, $cookie)
|
1834 |
+
{
|
1835 |
|
1836 |
+
$poll_options = get_yop_poll_meta($voter['poll_id'], "options", true);
|
|
|
|
|
1837 |
///yop_poll_dump($cookie);
|
1838 |
+
if ($voter['user_type'] == "anonymous") {
|
1839 |
+
if ('yes' == $poll_options['limit_number_of_votes_per_user']) {
|
1840 |
|
1841 |
+
if ($this->get_votes_number_from_supercookie($cookie) >= $poll_options['number_of_votes_per_user']) {
|
1842 |
|
1843 |
return false;
|
1844 |
|
1845 |
}
|
1846 |
}
|
1847 |
|
1848 |
+
} else if ($voter['user_id'] > 0) {
|
|
|
|
|
1849 |
|
1850 |
+
if ('yes' == $poll_options['limit_number_of_votes_per_user']) {
|
1851 |
|
1852 |
+
if ($this->get_voter_number_of_votes($voter) >= $poll_options['number_of_votes_per_user']) {
|
1853 |
|
1854 |
return false;
|
1855 |
|
1856 |
}
|
1857 |
|
1858 |
+
if ($this->get_votes_number_from_supercookie($cookie) >= $poll_options['number_of_votes_per_user'] && in_array("cookie", $this->blocking_voters)) {
|
1859 |
|
1860 |
return false;
|
1861 |
|
1863 |
|
1864 |
}
|
1865 |
|
1866 |
+
} else {
|
|
|
|
|
1867 |
|
1868 |
return false;
|
1869 |
|
1874 |
}
|
1875 |
|
1876 |
|
1877 |
+
protected function sendMail($mail_notifications_answers, $mail_notifications_custom_fields, $vote_id)
|
1878 |
+
{
|
1879 |
|
1880 |
//$options = get_option( 'yop_poll_options' );
|
1881 |
|
1882 |
|
|
|
1883 |
$headers = 'From: ' . $this->email_notifications_from_name . ' <' . $this->email_notifications_from_email . '>';
|
1884 |
|
1885 |
+
$subject = str_replace('[POLL_NAME]', $this->poll_title, $this->email_notifications_subject);
|
|
|
1886 |
|
1887 |
|
1888 |
+
$body = stripslashes_deep($this->email_notifications_body);
|
1889 |
|
1890 |
$regex = '/\[(\[?)(QUESTION)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
1891 |
|
1892 |
+
$q = $this->questions;
|
1893 |
|
1894 |
+
$body = preg_replace_callback($regex, function ($m) use ($q, $mail_notifications_answers, $mail_notifications_custom_fields) {
|
1895 |
|
1896 |
$template = '';
|
1897 |
|
1898 |
+
foreach ($q as $question) {
|
1899 |
+
//yop_poll_dump($m[5]);
|
1900 |
+
$temp_question_body = str_ireplace("%QUESTION_TEXT%", $question->question, $m[5]);
|
|
|
1901 |
|
1902 |
|
1903 |
$regex = '/\[(\[?)(ANSWERS)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
1904 |
|
1905 |
|
1906 |
+
$answers = $mail_notifications_answers[$question->ID];
|
1907 |
|
1908 |
+
$temp_question_body = preg_replace_callback($regex, function ($m) use ($answers) {
|
|
|
|
|
1909 |
|
1910 |
$temp = "";
|
1911 |
|
1912 |
+
foreach ($answers as $a) {
|
1913 |
|
1914 |
+
$temp_answer_body = str_ireplace("%ANSWER_VALUE%", $a, $m[5]);
|
1915 |
|
1916 |
$temp .= $temp_answer_body;
|
1917 |
|
1919 |
|
1920 |
return $temp;
|
1921 |
|
1922 |
+
}, $temp_question_body);
|
|
|
1923 |
|
1924 |
|
1925 |
$regex = '/\[(\[?)(CUSTOM_FIELDS)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
1926 |
|
1927 |
|
1928 |
+
$custom_fields = $mail_notifications_custom_fields[$question->ID];
|
1929 |
|
1930 |
+
$temp_question_body = preg_replace_callback($regex, function ($m) use ($custom_fields) {
|
|
|
|
|
1931 |
|
1932 |
$temp = "";
|
1933 |
|
1934 |
+
if (count($custom_fields) > 0) {
|
1935 |
|
1936 |
+
foreach ($custom_fields as $key => $value) {
|
1937 |
|
1938 |
+
$temp_cf_body = str_ireplace("%CUSTOM_FIELD_NAME%", $key, $m[5]);
|
1939 |
|
1940 |
+
$temp_cf_body = str_ireplace("%CUSTOM_FIELD_VALUE%", $value, $temp_cf_body);
|
1941 |
|
1942 |
$temp .= $temp_cf_body;
|
1943 |
|
1945 |
|
1946 |
}
|
1947 |
|
1948 |
+
if ("" == $temp) {
|
1949 |
|
1950 |
$temp = "No custom fields defined";
|
1951 |
|
1953 |
|
1954 |
return $temp;
|
1955 |
|
1956 |
+
}, $temp_question_body);
|
1957 |
|
1958 |
$template .= $temp_question_body;
|
1959 |
|
1961 |
|
1962 |
return $template;
|
1963 |
|
1964 |
+
}, $body);
|
1965 |
|
1966 |
+
global $current_user;
|
1967 |
|
1968 |
+
get_currentuserinfo();
|
1969 |
|
1970 |
+
$body = str_replace('%POLL_NAME%', $this->poll_title, $body);
|
1971 |
|
1972 |
+
$body = str_replace('%VOTE_ID%', $vote_id, $body);
|
1973 |
|
1974 |
+
$body = str_replace( '%WP_USERNAME%', $current_user->user_login , $body );
|
1975 |
|
1976 |
+
$body = str_replace( '%WP_FIRST_NAME%', $current_user->user_firstname , $body );
|
1977 |
|
1978 |
+
$body = str_replace( '%POLL_TOTAL_VOTES%', $this->poll_total_votes , $body );
|
1979 |
|
1980 |
+
$body = str_replace( '%WP_LAST_NAME%', $current_user->user_lastname , $body );
|
1981 |
|
1982 |
+
$body = str_replace('%VOTE_DATE%', current_time('mysql'), $body);
|
1983 |
|
|
|
1984 |
|
1985 |
+
add_filter('wp_mail_content_type', 'yop_poll_set_html_content_type');
|
1986 |
|
1987 |
+
wp_mail($this->email_notifications_recipients, $subject, $body, $headers);
|
1988 |
|
1989 |
|
1990 |
+
remove_filter('wp_mail_content_type', 'yop_poll_set_html_content_type');
|
1991 |
|
1992 |
}
|
1993 |
|
1994 |
|
1995 |
+
public static function reset_poll_stats_from_database($poll_id)
|
1996 |
+
{
|
1997 |
|
1998 |
global $message;
|
1999 |
|
2000 |
+
$current_poll = new YOP_POLL_Poll_Model($poll_id);
|
2001 |
|
2002 |
+
$message = self::delete_result_from_db_by_poll_id($poll_id);
|
2003 |
|
2004 |
$current_poll->poll_total_votes = 0;
|
2005 |
|
2006 |
+
foreach ($current_poll->questions as &$question) {
|
2007 |
|
2008 |
+
foreach ($question->answers as &$answer) {
|
2009 |
|
2010 |
$answer->votes = 0;
|
2011 |
|
2020 |
}
|
2021 |
|
2022 |
|
2023 |
+
private static function delete_result_from_db_by_poll_id($poll_id)
|
2024 |
+
{
|
2025 |
|
2026 |
global $wpdb;
|
2027 |
|
2028 |
$response['success'] = "";
|
2029 |
|
2030 |
+
$response['error'] = "";
|
|
|
2031 |
|
2032 |
|
2033 |
+
$sql = $wpdb->query($wpdb->prepare("
|
2034 |
|
2035 |
DELETE FROM $wpdb->yop_poll_results
|
2036 |
|
2037 |
WHERE poll_id = %d
|
2038 |
|
2039 |
+
", $poll_id));
|
2040 |
|
2041 |
+
if ($sql) {
|
2042 |
|
2043 |
+
$response['success'] = __yop_poll('Result deleted');
|
2044 |
|
2045 |
|
2046 |
+
} else {
|
2047 |
|
2048 |
+
$response['error'] = __yop_poll('Could not delete result from database! Please try again!');
|
|
|
|
|
|
|
|
|
2049 |
|
2050 |
}
|
2051 |
|
2052 |
|
|
|
2053 |
return $response;
|
2054 |
|
2055 |
}
|
models/poll_model.php
CHANGED
@@ -1,108 +1,111 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model
|
|
|
4 |
|
5 |
protected $type = 'poll';
|
6 |
|
7 |
-
function __construct(
|
|
|
8 |
|
9 |
-
parent::__construct(
|
10 |
|
11 |
}
|
12 |
|
13 |
-
public static function return_template_preview_html(
|
|
|
14 |
|
15 |
-
if(
|
16 |
return "";
|
17 |
-
}
|
18 |
-
|
19 |
-
$
|
20 |
-
$
|
21 |
-
$
|
22 |
-
$template
|
23 |
-
$template = stripslashes_deep( $template );
|
24 |
|
25 |
-
$template = str_ireplace(
|
26 |
-
$template = str_ireplace(
|
27 |
|
28 |
-
$question
|
29 |
|
30 |
-
$question->question
|
31 |
$question->allow_multiple_answers = "no";
|
32 |
-
$question->allow_other_answers
|
33 |
|
34 |
-
for(
|
35 |
-
$a
|
36 |
-
$j
|
37 |
-
$a->ID
|
38 |
$a->answer = "Answer {$j}";
|
39 |
|
40 |
-
$question->addAnswer(
|
41 |
-
unset(
|
42 |
}
|
43 |
-
|
44 |
-
$t
|
45 |
$pattern = '\[(\[?)(QUESTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
46 |
-
preg_match(
|
47 |
$m = $m[5];
|
48 |
|
49 |
-
$m = str_ireplace(
|
50 |
|
51 |
$pattern = '/\[(\[?)(ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
52 |
-
preg_match(
|
53 |
$m1 = $m1[5];
|
54 |
|
55 |
$ts = "";
|
56 |
|
57 |
/** Start Answer Description replace */
|
58 |
$pattern = '\[(\[?)(ANSWER_DESCRIPTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
59 |
-
$m1
|
60 |
/** End Answer Description replace */
|
61 |
|
62 |
/** Start Answer Result replace */
|
63 |
$pattern = '\[(\[?)(ANSWER_RESULT_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
64 |
-
$m1
|
65 |
/** End Answer Result replace */
|
66 |
|
67 |
-
foreach(
|
68 |
-
$temps = str_ireplace(
|
69 |
-
$temps = str_ireplace(
|
70 |
$ts .= $temps;
|
71 |
}
|
72 |
|
73 |
$pattern = '/\[(\[?)(ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
74 |
-
$m
|
75 |
|
76 |
-
$pattern
|
77 |
-
$template = preg_replace(
|
78 |
|
79 |
-
$pattern
|
80 |
'/\[(\[?)(OTHER_ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/',
|
81 |
'/\[(\[?)(CUSTOM_FIELD_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/',
|
82 |
'/\[(\[?)(ANSWER_RESULT_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/',
|
83 |
'/\[(\[?)(CAPTCHA_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/'
|
84 |
);
|
85 |
-
$template = preg_replace(
|
86 |
-
$template = preg_replace(
|
87 |
-
$template = str_ireplace(
|
88 |
-
$template = self::strip_all_tags(
|
89 |
-
|
90 |
-
$t = '<style type="text/css">' . $poll->return_poll_css(
|
91 |
-
"location"
|
92 |
-
'preview'
|
93 |
'template_id' => $uID,
|
94 |
-
'loc'
|
95 |
-
)
|
96 |
$t .= '<div id="yop-poll-container-preview-' . $uID . '" class="yop-poll-container" style="position: relative; z-index: 1;">';
|
97 |
$t .= '' . $template . '</div>';
|
98 |
|
99 |
-
$qID = uniqid(
|
100 |
-
$t
|
101 |
return $t;
|
102 |
}
|
103 |
}
|
104 |
|
105 |
-
private static function strip_all_tags(
|
|
|
106 |
|
107 |
$tags = array(
|
108 |
'%CAPTCHA-PLAY%',
|
@@ -148,31 +151,31 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
148 |
'%SHARE-BUTTON%'
|
149 |
);
|
150 |
|
151 |
-
foreach(
|
152 |
-
$template = str_ireplace(
|
153 |
}
|
154 |
return $template;
|
155 |
}
|
156 |
|
157 |
public function return_poll_css(
|
158 |
$css = "", $attr = array(
|
159 |
-
'location'
|
160 |
-
'preview'
|
161 |
'template_id' => '',
|
162 |
-
'loc'
|
163 |
)
|
164 |
-
)
|
165 |
-
|
166 |
-
$
|
167 |
-
|
|
|
168 |
$template = $css;
|
169 |
-
$template.="li.yop-poll-li-answer-%POLL-ID% {width:100%}";
|
170 |
-
$template.="div.yop-poll-answers-%POLL-ID% ul{width:100%}";
|
171 |
-
$template = str_ireplace(
|
172 |
-
$template = str_ireplace(
|
173 |
-
return stripslashes(
|
174 |
-
}
|
175 |
-
else {
|
176 |
$unique_id = $this->ID . $this->unique_id;
|
177 |
|
178 |
/*if ( !$poll_id ){
|
@@ -192,175 +195,175 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
192 |
$template_details = self::get_poll_template_from_database( $template_id );
|
193 |
$template = $template_details['css'];*/
|
194 |
|
195 |
-
$template = str_ireplace(
|
196 |
-
if(
|
197 |
-
$template = str_ireplace(
|
|
|
|
|
198 |
}
|
199 |
-
|
200 |
-
$template = str_ireplace( '%POLL-WIDTH%', $this->template_width, $template );
|
201 |
-
}
|
202 |
-
return stripslashes( $template );
|
203 |
}
|
204 |
}
|
205 |
|
206 |
-
private static function count_other_answers(
|
207 |
-
|
|
|
208 |
$nr = 0;
|
209 |
-
for(
|
210 |
-
if(
|
211 |
-
$nr
|
212 |
}
|
213 |
}
|
214 |
return $nr;
|
215 |
}
|
216 |
|
217 |
-
public function return_poll_js(
|
218 |
-
|
219 |
-
$
|
|
|
220 |
$unique_id = $this->unique_id;
|
221 |
|
222 |
-
if(
|
223 |
return '';
|
224 |
}
|
225 |
|
226 |
-
if(
|
227 |
$template_id = $this->widget_template;
|
228 |
-
}
|
229 |
-
else {
|
230 |
$template_id = $this->template;
|
231 |
}
|
232 |
|
233 |
-
if(
|
234 |
//get default template
|
235 |
$template_details = self::get_poll_template_from_database();
|
236 |
-
}
|
237 |
-
|
238 |
-
$template_details = self::get_poll_template_from_database( $template_id );
|
239 |
}
|
240 |
|
241 |
$tabulate = array();
|
242 |
|
243 |
-
foreach(
|
244 |
$answers_tabulated_cols = 1; //vertical display
|
245 |
$results_tabulated_cols = 1;
|
246 |
|
247 |
-
$include_others
|
248 |
-
$display_answers = array(
|
249 |
|
250 |
-
if(
|
251 |
|
252 |
-
if(
|
253 |
-
$include_others
|
254 |
-
$display_answers = array(
|
255 |
}
|
256 |
}
|
257 |
|
258 |
|
259 |
-
if(
|
260 |
-
$ans_no = $question->countanswers(
|
261 |
-
if(
|
262 |
$answers_tabulated_cols = $ans_no;
|
263 |
}
|
264 |
-
if(
|
265 |
-
$answers_tabulated_cols
|
266 |
}
|
267 |
-
}
|
268 |
-
|
269 |
-
if( 'tabulated' == $question->display_answers ) {
|
270 |
$answers_tabulated_cols = $question->display_answers_tabulated_cols;
|
271 |
//yop_poll_dump($answers_tabulated_cols);
|
272 |
|
273 |
}
|
274 |
|
275 |
-
if(
|
276 |
-
$ans_no = $question->countanswers(
|
277 |
-
if(
|
278 |
$results_tabulated_cols = $ans_no;
|
279 |
}
|
280 |
-
}
|
281 |
-
else if( 'tabulated' == $question->display_results ) {
|
282 |
$results_tabulated_cols = $question->display_results_tabulated_cols;
|
283 |
}
|
284 |
|
285 |
-
array_push($tabulate, array(
|
286 |
}
|
287 |
|
288 |
$template = $template_details['js'];
|
289 |
-
if(
|
290 |
-
$template.="jQuery(document).ready(function(){ jQuery('.yop-poll-li-answer-%POLL-ID%').css('float','none');});"
|
291 |
|
292 |
}
|
293 |
-
$template = str_ireplace(
|
294 |
-
$template = str_ireplace(
|
295 |
-
$template = str_ireplace(
|
296 |
-
$template = str_ireplace(
|
297 |
-
return stripslashes(
|
298 |
}
|
299 |
|
300 |
-
public function question_replace_callback(
|
301 |
-
|
|
|
302 |
$return_string = "";
|
303 |
-
$that
|
304 |
-
foreach(
|
305 |
|
306 |
$qunique_id = $question->ID;
|
307 |
-
$temp
|
308 |
-
$temp
|
309 |
|
310 |
-
$temp = str_ireplace('class = '.'"'. 'yop-poll-li-answer-' . $this->ID . $this->unique_id
|
311 |
|
312 |
-
if(
|
313 |
/** Start Anwer replace */
|
314 |
-
if(
|
315 |
$pattern = '\[(\[?)(ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
316 |
-
$temp
|
317 |
-
return $that->answer_replace_callback(
|
318 |
-
}, $temp
|
319 |
}
|
320 |
/** End Anwer replace */
|
321 |
|
322 |
/** Start Other Answer replace */
|
323 |
$pattern = '\[(\[?)(OTHER_ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
324 |
-
$temp = str_ireplace('class = '.'"'. 'yop-poll-li-answer-' . $this->ID . $this->unique_id
|
325 |
|
326 |
-
$temp
|
327 |
-
return $that->other_answer_replace_callback(
|
328 |
-
}, $temp
|
329 |
/** End Other Answer replace */
|
330 |
|
331 |
/** Start Custom Fields replace*/
|
332 |
$pattern = '\[(\[?)(CUSTOM_FIELD_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
333 |
-
$temp
|
334 |
-
return $that->custom_field_replace_callback(
|
335 |
-
}, $temp
|
336 |
/** End Custom Fields replace*/
|
337 |
}
|
338 |
$pattern = '\[(\[?)(ANSWER_RESULT_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
339 |
-
$temp
|
340 |
-
return $that->answer_result_replace_callback(
|
341 |
-
}, $temp
|
342 |
|
343 |
$return_string .= $temp;
|
344 |
}
|
345 |
return $return_string;
|
346 |
}
|
347 |
|
348 |
-
private static function count_answers(
|
349 |
-
|
|
|
350 |
$nr = 0;
|
351 |
-
for(
|
352 |
-
if(
|
353 |
-
$nr
|
354 |
}
|
355 |
}
|
356 |
return $nr;
|
357 |
}
|
358 |
|
359 |
-
public function answer_replace_callback(
|
|
|
360 |
$unique_id = $this->unique_id;
|
361 |
|
362 |
$multiple_answers = false;
|
363 |
-
if(
|
364 |
$multiple_answers = true;
|
365 |
}
|
366 |
|
@@ -368,77 +371,77 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
368 |
|
369 |
/** Get question total votes( default + other ) */
|
370 |
|
|
|
|
|
371 |
/**Is allowed to display other answers?*/
|
372 |
$display_other_answers = false;
|
373 |
|
374 |
-
if(
|
375 |
-
if(
|
376 |
$display_other_answers = true;
|
377 |
}
|
378 |
}
|
379 |
|
380 |
$percentages_decimals = 0;
|
381 |
-
if(
|
382 |
$percentages_decimals = $this->percentages_decimals;
|
383 |
}
|
384 |
|
385 |
-
$id
|
386 |
|
387 |
$view_results = $this->is_view_poll_results();
|
388 |
-
|
389 |
-
$that
|
390 |
-
foreach(
|
391 |
/**Check if is allowed to display current answers*/
|
392 |
-
if
|
393 |
continue;
|
394 |
}
|
395 |
-
if($view_results){
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
}
|
403 |
-
if( function_exists( 'icl_translate' ) ) {
|
404 |
-
$answer->answer = icl_translate( 'yop_poll', $answer->ID . '_answer', $answer->answer );
|
405 |
-
}
|
406 |
-
if( $multiple_answers ) {
|
407 |
-
if( isset( $answer->is_default_answer ) && $answer->is_default_answer == "yes" ) {
|
408 |
-
$temp_answer_model = str_ireplace( '%POLL-ANSWER-CHECK-INPUT%', '<input type="checkbox" checked="checked" value="' . $answer->ID . '" name="yop_poll_answer[' . $question->ID . '][]" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $answer->ID . '" />', $m );
|
409 |
-
}
|
410 |
-
else {
|
411 |
-
$temp_answer_model = str_ireplace( '%POLL-ANSWER-CHECK-INPUT%', '<input type="checkbox" value="' . $answer->ID . '" name="yop_poll_answer[' . $question->ID . '][]" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $answer->ID . '" />', $m );
|
412 |
}
|
413 |
}
|
414 |
-
|
415 |
-
|
416 |
-
|
|
|
|
|
|
|
|
|
|
|
417 |
}
|
418 |
-
|
419 |
-
|
|
|
|
|
|
|
420 |
}
|
421 |
}
|
422 |
|
423 |
/** Start Answer Description replace */
|
424 |
-
$pattern
|
425 |
-
$temp_answer_model = preg_replace_callback(
|
426 |
-
return $that->answer_description_replace_callback(
|
427 |
-
}, $temp_answer_model
|
428 |
/** End Answer Description replace */
|
429 |
-
if($view_results){
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
}
|
437 |
-
if(
|
438 |
-
$temp_answer_model = str_ireplace(
|
439 |
}
|
440 |
-
if(
|
441 |
-
$temp_answer_model = str_ireplace(
|
442 |
}
|
443 |
|
444 |
$model .= $temp_answer_model;
|
@@ -447,47 +450,52 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
447 |
return $model;
|
448 |
}
|
449 |
|
450 |
-
private static function get_question_votes(
|
|
|
451 |
$total_votes = 0;
|
452 |
-
foreach(
|
453 |
-
$total_votes += intval(
|
454 |
}
|
455 |
return $total_votes;
|
456 |
}
|
457 |
|
458 |
-
private function is_view_poll_results()
|
|
|
459 |
$is_voted = $this->is_voted();
|
460 |
-
if
|
461 |
) {
|
462 |
return true;
|
463 |
}
|
464 |
return false;
|
465 |
}
|
466 |
-
|
467 |
-
|
|
|
|
|
468 |
return "";
|
469 |
}
|
470 |
-
return str_ireplace(
|
471 |
}
|
472 |
|
473 |
-
public function answer_result_bar_callback(
|
474 |
-
|
475 |
-
|
476 |
-
$tmp = str_ireplace(
|
477 |
-
$tmp = str_ireplace(
|
478 |
-
$tmp = str_ireplace(
|
|
|
479 |
return $tmp;
|
480 |
-
}
|
481 |
-
else {
|
482 |
return "";
|
483 |
}
|
484 |
}
|
485 |
|
486 |
-
private static function display_poll_result_bar(
|
|
|
487 |
$result_bar = ' <div class="yop-poll-results-bar-' . $unique_id . '" ';
|
488 |
$result_bar .= ' ';
|
489 |
$result_bar .= '><div>';
|
490 |
-
if(
|
491 |
|
492 |
$result_bar .= '<div style="' . 'width:' . $procent . '%; ';
|
493 |
$result_bar .= 'height:' . $options['bar_height'] . 'px; ' . 'background-color:#' . $options['bar_background'] . '; ' . 'border-style:' . $options['bar_border_style'] . '; ' . 'border-width:' . $options['bar_border_width'] . 'px; ' . 'border-color:#' . $options['bar_border_color'] . '; ';
|
@@ -497,93 +505,91 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
497 |
return $result_bar;
|
498 |
}
|
499 |
|
500 |
-
private static function display_poll_result_votes(
|
|
|
501 |
|
502 |
-
if(
|
503 |
-
if(
|
504 |
-
$options
|
505 |
return $votes . ' ' . $options['singular_answer_result_votes_number_label'];
|
506 |
-
}
|
507 |
-
|
508 |
-
$options = get_option('yop_poll_options' );
|
509 |
return $votes . ' ' . $options['plural_answer_result_votes_number_label'];
|
510 |
}
|
511 |
}
|
512 |
}
|
513 |
|
514 |
-
private static function display_poll_result_percentages(
|
515 |
-
|
|
|
516 |
return $votes . '%';
|
517 |
-
}
|
518 |
-
else {
|
519 |
return '';
|
520 |
}
|
521 |
}
|
522 |
|
523 |
-
public function other_answer_replace_callback(
|
|
|
524 |
$unique_id = $this->unique_id;
|
525 |
|
526 |
$multiple_answers = false;
|
527 |
-
if(
|
528 |
$multiple_answers = true;
|
529 |
}
|
530 |
|
531 |
$model = "";
|
532 |
|
533 |
-
$allow_other_answers
|
534 |
$display_other_answers = false;
|
535 |
-
if(
|
536 |
$allow_other_answers = true;
|
537 |
-
if(
|
538 |
$display_other_answers = true;
|
539 |
}
|
540 |
}
|
541 |
|
542 |
-
if(
|
543 |
/**Display other answer input */
|
544 |
-
if(
|
545 |
-
$other_answer_label = icl_translate(
|
546 |
-
}
|
547 |
-
|
548 |
-
$other_answer_label = yop_poll_kses( $question->other_answers_label );
|
549 |
}
|
550 |
|
551 |
-
if(
|
552 |
-
$temp_answer_model = str_ireplace(
|
553 |
-
}
|
554 |
-
|
555 |
-
$temp_answer_model = str_ireplace( '%POLL-OTHER-ANSWER-CHECK-INPUT%', '<input type="radio" value="other" name="yop_poll_answer[' . $question->ID . ']" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $question->ID . '-other" />', $m );
|
556 |
}
|
557 |
-
$temp_answer_model = str_ireplace(
|
558 |
-
$temp_answer_model = str_ireplace(
|
559 |
|
560 |
-
if(
|
561 |
/**Display only if other answers were not displayed */
|
562 |
-
if(
|
563 |
/** Count question total votes( default + other ) */
|
564 |
-
$total_votes = $this->get_question_votes(
|
565 |
|
566 |
/** Count other answers votes*/
|
567 |
-
$other_votes = $this->get_question_other_votes(
|
568 |
|
569 |
|
570 |
$percentages_decimals = 0;
|
571 |
-
if(
|
572 |
$percentages_decimals = $this->percentages_decimals;
|
573 |
}
|
574 |
|
575 |
-
if(
|
576 |
-
$percentages = floatval(
|
577 |
-
}
|
578 |
-
else {
|
579 |
$percentages = 0;
|
580 |
}
|
581 |
-
if(
|
582 |
-
$temp_answer_model = str_ireplace(
|
583 |
-
$temp_answer_model = str_ireplace(
|
584 |
-
$temp_answer_model = str_ireplace(
|
585 |
|
586 |
-
$temp_answer_model = str_ireplace(
|
587 |
}
|
588 |
}
|
589 |
}
|
@@ -592,29 +598,31 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
592 |
return $model;
|
593 |
}
|
594 |
|
595 |
-
private static function get_question_other_votes(
|
|
|
596 |
$total_votes = 0;
|
597 |
-
foreach(
|
598 |
-
if(
|
599 |
-
$total_votes += intval(
|
600 |
}
|
601 |
}
|
602 |
return $total_votes;
|
603 |
}
|
604 |
|
605 |
-
public function custom_field_replace_callback(
|
|
|
606 |
$unique_id = $this->unique_id;
|
607 |
-
$is_voted
|
608 |
-
$model
|
609 |
-
if(
|
610 |
-
if(
|
611 |
-
foreach(
|
612 |
-
if(
|
613 |
-
$custom_field['custom_field'] = icl_translate(
|
614 |
}
|
615 |
-
$temp_string = str_ireplace(
|
616 |
|
617 |
-
$temp_string = str_ireplace(
|
618 |
$model .= $temp_string;
|
619 |
}
|
620 |
}
|
@@ -622,99 +630,94 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
622 |
return $model;
|
623 |
}
|
624 |
|
625 |
-
public function answer_result_replace_callback(
|
626 |
-
|
|
|
627 |
$return_string = '';
|
628 |
-
$is_voted
|
629 |
-
$id
|
630 |
|
631 |
-
if(
|
632 |
$display_other_answers = false;
|
633 |
-
if(
|
634 |
-
if(
|
635 |
$display_other_answers = true;
|
636 |
}
|
637 |
}
|
638 |
|
639 |
$percentages_decimals = 0;
|
640 |
-
if(
|
641 |
$percentages_decimals = $this->percentages_decimals;
|
642 |
}
|
643 |
|
644 |
-
if(
|
645 |
-
if(
|
646 |
-
$question->sortAnswers(
|
647 |
-
}
|
648 |
-
elseif( 'database' == $this->sorting_results ) {
|
649 |
$order_dir = 'asc';
|
650 |
-
if(
|
651 |
-
$order_dir = (
|
652 |
}
|
653 |
-
$question->sortAnswers(
|
654 |
-
}
|
655 |
-
elseif( 'alphabetical' == $this->sorting_results ) {
|
656 |
$order_dir = 'asc';
|
657 |
-
if(
|
658 |
-
$order_dir = (
|
659 |
}
|
660 |
-
$question->sortAnswers(
|
661 |
-
}
|
662 |
-
elseif( 'votes' == $this->sorting_results ) {
|
663 |
$order_dir = 'asc';
|
664 |
-
if(
|
665 |
-
$order_dir = (
|
666 |
}
|
667 |
-
$question->sortAnswers(
|
668 |
-
}
|
669 |
-
else {
|
670 |
$order_dir = 'asc';
|
671 |
-
if(
|
672 |
-
$order_dir = (
|
673 |
}
|
674 |
-
$question->sortAnswers(
|
675 |
}
|
676 |
-
}
|
677 |
-
else {
|
678 |
$order_dir = 'asc';
|
679 |
-
if(
|
680 |
-
$order_dir = (
|
681 |
}
|
682 |
-
$question->sortAnswers(
|
683 |
}
|
684 |
|
685 |
|
686 |
-
$total_votes = $this->get_question_votes(
|
687 |
|
688 |
-
foreach(
|
689 |
-
if
|
690 |
continue;
|
691 |
}
|
692 |
-
if(
|
693 |
-
$percentages = floatval(
|
694 |
-
}
|
695 |
-
else {
|
696 |
$percentages = 0;
|
697 |
}
|
698 |
|
699 |
-
if(
|
700 |
-
$ans->answer = icl_translate(
|
701 |
}
|
702 |
|
703 |
/** Start Answer Description replace */
|
704 |
$pattern = '\[(\[?)(ANSWER_DESCRIPTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
705 |
-
$temp_string
|
706 |
/** End Answer Description replace */
|
707 |
$ans->type = "text";
|
708 |
-
if(
|
709 |
-
$temp_string = str_ireplace(
|
710 |
}
|
711 |
-
$temp_string = str_ireplace('class = '.'"'. 'yop-poll-li-result-' . $this->ID . $this->unique_id
|
712 |
|
713 |
|
714 |
-
$temp_string = str_ireplace(
|
715 |
-
$temp_string = str_ireplace(
|
716 |
-
$temp_string = str_ireplace(
|
717 |
-
$temp_string = str_ireplace(
|
718 |
$return_string .= $temp_string;
|
719 |
}
|
720 |
}
|
@@ -722,31 +725,32 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
722 |
return $return_string;
|
723 |
}
|
724 |
|
725 |
-
public function register_vote(
|
|
|
726 |
|
727 |
global $current_user;
|
728 |
-
$poll_id
|
729 |
-
$unique_id
|
730 |
-
$location
|
731 |
-
$vote_id
|
732 |
-
$vote_type
|
733 |
-
$SuperCookie
|
734 |
-
$tr_id
|
735 |
-
$votes
|
736 |
-
$user_id
|
737 |
-
$user_type
|
738 |
$user_details = '';
|
739 |
-
if(
|
740 |
-
switch(
|
741 |
default:
|
742 |
{
|
743 |
-
$user_id
|
744 |
$user_type = 'default';
|
745 |
break;
|
746 |
}
|
747 |
case 'wordpress':
|
748 |
{
|
749 |
-
$user_id
|
750 |
$user_type = 'wordpress';
|
751 |
break;
|
752 |
}
|
@@ -758,488 +762,468 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
758 |
|
759 |
}
|
760 |
$log_to_add = array(
|
761 |
-
'poll_id'
|
762 |
-
'vote_id'
|
763 |
-
'ip'
|
764 |
-
'user_id'
|
765 |
-
'user_type'
|
766 |
-
'user_details' => json_encode(
|
767 |
-
'tr_id'
|
768 |
);
|
769 |
-
}
|
770 |
-
|
771 |
-
$
|
772 |
-
$log_to_add
|
773 |
-
insert_log_in_db( $log_to_add );
|
774 |
return false;
|
775 |
}
|
776 |
-
if(
|
777 |
|
778 |
-
$tr_id
|
779 |
$super_perm = true;
|
780 |
-
if(
|
781 |
-
$super_perm = $this->is_voted_supercookie(
|
782 |
}
|
783 |
-
if(
|
784 |
|
785 |
$current_date = yop_poll_get_mysql_curent_date();
|
786 |
-
if(
|
787 |
-
if(
|
788 |
-
if(
|
789 |
-
if(
|
790 |
-
$this->error
|
791 |
-
$log_to_add ['message'] = __yop_poll(
|
792 |
-
insert_log_in_db(
|
793 |
return false;
|
794 |
-
}
|
795 |
-
|
796 |
-
|
797 |
-
$voter
|
798 |
-
$voter['
|
799 |
-
$voter['user_id'] = $current_user->ID;
|
800 |
$voter['user_type'] = $vote_type;
|
801 |
|
802 |
-
if(
|
803 |
-
$i
|
804 |
$cookie = '';
|
805 |
-
$log
|
806 |
-
foreach(
|
807 |
$answers = array();
|
808 |
-
if(
|
809 |
-
if(
|
810 |
-
if(
|
811 |
-
if(
|
812 |
$answers = array();
|
813 |
-
foreach(
|
814 |
-
$new_answer
|
815 |
$new_answer['answer_id'] = $answer;
|
816 |
-
$new_answer['type']
|
817 |
-
if(
|
818 |
$a = new YOP_POLL_Answer_Model();
|
819 |
-
if(
|
820 |
-
$a->type
|
821 |
-
$a->poll_id
|
822 |
-
$a->question_id
|
823 |
-
$a->answer
|
824 |
-
$a->answer_date
|
825 |
-
$a->answer_modified = current_time(
|
826 |
-
$a->status
|
827 |
-
$a->question_order
|
828 |
-
$a->answer_author
|
829 |
$a->save();
|
830 |
|
831 |
-
if(
|
832 |
-
$this->error
|
833 |
-
$log_to_add ['message'] = __yop_poll(
|
834 |
-
insert_log_in_db(
|
835 |
return false;
|
836 |
}
|
837 |
-
}
|
838 |
-
|
839 |
-
$
|
840 |
-
$log_to_add
|
841 |
-
insert_log_in_db( $log_to_add );
|
842 |
return false;
|
843 |
}
|
844 |
-
$question->addAnswer(
|
845 |
$new_answer['answer_id'] = $a->id;
|
846 |
-
$new_answer['type']
|
847 |
-
unset(
|
848 |
}
|
849 |
$new_answer['poll_id'] = $poll_id;
|
850 |
$new_answer['vote_id'] = $vote_id;
|
851 |
-
$new_answer['ip']
|
852 |
$new_answer['user_id'] = $current_user->ID;
|
853 |
|
854 |
$new_answer['user_type'] = 'default';
|
855 |
-
if(
|
856 |
$new_answer['user_type'] = $vote_type;
|
857 |
}
|
858 |
|
859 |
-
$new_answer['http_referer']
|
860 |
-
$new_answer['tr_id']
|
861 |
-
$new_answer['host']
|
862 |
$new_answer['other_answer_value'] = '';
|
863 |
|
864 |
$answers[] = $new_answer;
|
865 |
}
|
866 |
-
}
|
867 |
-
|
868 |
-
$
|
869 |
-
$log_to_add
|
870 |
-
insert_log_in_db( $log_to_add );
|
871 |
return false;
|
872 |
}
|
873 |
-
}
|
874 |
-
|
875 |
-
$
|
876 |
-
$log_to_add
|
877 |
-
insert_log_in_db( $log_to_add );
|
878 |
return false;
|
879 |
}
|
880 |
-
}
|
881 |
-
|
882 |
-
$new_answer = array();
|
883 |
$new_answer['answer_id'] = $request['yop_poll_answer'][$question->ID];
|
884 |
-
$new_answer['type']
|
885 |
-
if(
|
886 |
$a = new YOP_POLL_Answer_Model();
|
887 |
-
if(
|
888 |
-
$a->type
|
889 |
-
$a->poll_id
|
890 |
-
$a->question_id
|
891 |
-
$a->answer
|
892 |
-
$a->answer_date
|
893 |
$a->question_order = $question->countanswers();
|
894 |
-
$a->answer_author
|
895 |
-
$a->votes
|
896 |
$a->save();
|
897 |
|
898 |
-
if(
|
899 |
-
$this->error
|
900 |
-
$log_to_add ['message'] = __yop_poll(
|
901 |
-
insert_log_in_db(
|
902 |
return false;
|
903 |
}
|
904 |
-
}
|
905 |
-
|
906 |
-
$
|
907 |
-
$log_to_add
|
908 |
-
insert_log_in_db( $log_to_add );
|
909 |
return false;
|
910 |
}
|
911 |
|
912 |
-
$question->addAnswer(
|
913 |
$new_answer['answer_id'] = $a->id;
|
914 |
-
$new_answer['type']
|
915 |
-
unset(
|
916 |
}
|
917 |
|
918 |
$new_answer['poll_id'] = $poll_id;
|
919 |
$new_answer['vote_id'] = $vote_id;
|
920 |
-
$new_answer['ip']
|
921 |
$new_answer['user_id'] = $current_user->ID;
|
922 |
|
923 |
$new_answer['user_type'] = 'default';
|
924 |
|
925 |
|
926 |
-
$new_answer['http_referer']
|
927 |
-
$new_answer['tr_id']
|
928 |
-
$new_answer['host']
|
929 |
$new_answer['other_answer_value'] = '';
|
930 |
-
$answers[]
|
931 |
}
|
932 |
|
933 |
-
if(
|
934 |
-
$custom_fields
|
935 |
$poll_custom_fields = $question->custom_fields;
|
936 |
|
937 |
-
if(
|
938 |
|
939 |
-
if(
|
940 |
|
941 |
-
foreach(
|
942 |
|
943 |
-
if(
|
944 |
|
945 |
-
if(
|
946 |
-
$this->error
|
947 |
-
$log_to_add ['message'] = __yop_poll(
|
948 |
-
insert_log_in_db(
|
949 |
return false;
|
950 |
-
}
|
951 |
-
|
952 |
-
|
953 |
-
$new_custom_field
|
954 |
-
$new_custom_field['
|
955 |
-
$new_custom_field['
|
956 |
-
$new_custom_field['vote_id'] = $vote_id;
|
957 |
$new_custom_field['custom_field_id'] = $custom_field->ID;
|
958 |
-
$new_custom_field['user_id']
|
959 |
|
960 |
$new_custom_field['user_type'] = 'default';
|
961 |
|
962 |
-
if(
|
963 |
$new_custom_field['user_type'] = $vote_type;
|
964 |
}
|
965 |
|
966 |
-
$new_custom_field['custom_field_value'] = strip_tags(
|
967 |
-
$custom_fields[]
|
968 |
|
969 |
}
|
970 |
}
|
971 |
-
}
|
972 |
-
|
973 |
-
$this->error = __yop_poll( "Custom field " ) . '"' . $custom_field->custom_field . '"' . __yop_poll( " from question " ) . $i . ' ' . __yop_poll( "is missing ") . '!';
|
974 |
|
975 |
-
$log_to_add ['message'] = __yop_poll(
|
976 |
-
insert_log_in_db(
|
977 |
return false;
|
978 |
}
|
979 |
}
|
980 |
-
}
|
981 |
-
|
982 |
-
$
|
983 |
-
$log_to_add
|
984 |
-
insert_log_in_db( $log_to_add );
|
985 |
return false;
|
986 |
}
|
987 |
}
|
988 |
|
989 |
-
if(
|
990 |
-
require_once(
|
991 |
-
$img
|
992 |
$img->namespace = 'yop_poll_' . $poll_id . $unique_id;
|
993 |
-
if(
|
994 |
$mail_notifications_answers[$question->ID] = array();
|
995 |
|
996 |
-
$add_to_log = $this->update_votes(
|
997 |
|
998 |
$log["q-" . $question->ID]['question'] = $question->question;
|
999 |
-
$log["q-" . $question->ID]['a']
|
1000 |
-
$log["q-" . $question->ID]['answers']
|
1001 |
|
1002 |
-
$mail_notifications_answers[$question->ID] = trim(
|
1003 |
|
1004 |
$mail_notifications_custom_fields[$question->ID] = '';
|
1005 |
-
foreach(
|
1006 |
|
1007 |
-
if(
|
1008 |
$custom_field['user_id'] = 0;
|
1009 |
}
|
1010 |
$custom_field['tr_id'] = $tr_id;
|
1011 |
-
self::insert_vote_custom_field_in_database(
|
1012 |
|
1013 |
-
$cf = $question->getCustomFieldById(
|
1014 |
|
1015 |
$mail_notifications_custom_fields[$question->ID][$cf->custom_field] = $custom_field['custom_field_value'];
|
1016 |
}
|
1017 |
|
1018 |
-
if(
|
1019 |
-
$this->success = str_replace(
|
1020 |
-
}
|
1021 |
-
|
1022 |
-
$this->success = str_replace( '%USER-VOTES-LEFT%', '', $this->message_after_vote );
|
1023 |
}
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
$
|
1027 |
-
$log_to_add
|
1028 |
-
insert_log_in_db( $log_to_add );
|
1029 |
return false;
|
1030 |
}
|
1031 |
-
}
|
1032 |
-
else {
|
1033 |
$mail_notifications_answers[$question->ID] = array();
|
1034 |
|
1035 |
-
$add_to_log = $this->update_votes(
|
1036 |
|
1037 |
$log["q-" . $question->ID]['question'] = $question->question;
|
1038 |
-
$log["q-" . $question->ID]['id']
|
1039 |
-
$log["q-" . $question->ID]['a']
|
1040 |
-
$log["q-" . $question->ID]['answers']
|
1041 |
|
1042 |
|
1043 |
$mail_notifications_custom_fields[$question->ID] = array();
|
1044 |
$add_to_log = array();
|
1045 |
-
foreach(
|
1046 |
|
1047 |
-
if(
|
1048 |
$custom_field['user_id'] = $google_user_details['id'];
|
1049 |
}
|
1050 |
-
if(
|
1051 |
$custom_field['user_id'] = 0;
|
1052 |
}
|
1053 |
$custom_field['tr_id'] = $tr_id;
|
1054 |
|
1055 |
-
$cf_id = self::insert_vote_custom_field_in_database(
|
1056 |
|
1057 |
$add_to_log[] = $cf_id;
|
1058 |
|
1059 |
-
$cf = $question->getCustomFieldById(
|
1060 |
|
1061 |
$mail_notifications_custom_fields[$question->ID][$cf->custom_field] = $custom_field['custom_field_value'];
|
1062 |
}
|
1063 |
$log["q-" . $question->ID]['cf'] = $add_to_log;
|
1064 |
|
1065 |
-
if(
|
1066 |
-
$this->success = str_replace(
|
1067 |
-
}
|
1068 |
-
|
1069 |
-
$this->success = str_replace( '%USER-VOTES-LEFT%', '', $this->message_after_vote );
|
1070 |
}
|
1071 |
}
|
1072 |
-
}
|
1073 |
-
|
1074 |
-
$
|
1075 |
-
$log_to_add
|
1076 |
-
insert_log_in_db( $log_to_add );
|
1077 |
return false;
|
1078 |
}
|
1079 |
-
}
|
1080 |
-
|
1081 |
-
$
|
1082 |
-
$log_to_add
|
1083 |
-
insert_log_in_db( $log_to_add );
|
1084 |
return false;
|
1085 |
}
|
1086 |
-
$i
|
1087 |
}
|
1088 |
-
}
|
1089 |
-
|
1090 |
-
$
|
1091 |
-
$log_to_add
|
1092 |
-
insert_log_in_db( $log_to_add );
|
1093 |
return false;
|
1094 |
}
|
1095 |
-
}
|
1096 |
-
|
1097 |
-
$
|
1098 |
-
$log_to_add
|
1099 |
-
insert_log_in_db( $log_to_add );
|
1100 |
return false;
|
1101 |
}
|
1102 |
}
|
1103 |
-
}
|
1104 |
-
|
1105 |
-
$
|
1106 |
-
$log_to_add
|
1107 |
-
insert_log_in_db( $log_to_add );
|
1108 |
return false;
|
1109 |
}
|
1110 |
-
}
|
1111 |
-
|
1112 |
-
$
|
1113 |
-
$log_to_add
|
1114 |
-
insert_log_in_db( $log_to_add );
|
1115 |
return false;
|
1116 |
}
|
1117 |
-
}
|
1118 |
-
|
1119 |
-
$
|
1120 |
-
$log_to_add
|
1121 |
-
insert_log_in_db( $log_to_add );
|
1122 |
return false;
|
1123 |
}
|
1124 |
-
}
|
1125 |
-
|
1126 |
-
$this->error = __yop_poll( "You are not allowed to vote!" );
|
1127 |
return false;
|
1128 |
}
|
1129 |
|
1130 |
-
}
|
1131 |
-
|
1132 |
-
$
|
1133 |
-
$log_to_add
|
1134 |
-
insert_log_in_db( $log_to_add );
|
1135 |
return false;
|
1136 |
}
|
1137 |
|
1138 |
-
if(
|
1139 |
-
$this->sendMail(
|
1140 |
}
|
1141 |
|
1142 |
$this->update_poll_total_votes(1);
|
1143 |
|
1144 |
-
$log_to_add ['message']
|
1145 |
-
$log_to_add ['vote_details'] = json_encode(
|
1146 |
|
1147 |
-
insert_log_in_db(
|
1148 |
-
$ip_data
|
1149 |
$log_to_add['country'] = $ip_data->geoplugin_countryName;
|
1150 |
-
insert_result_in_db(
|
1151 |
|
1152 |
-
$this->set_vote_cookie(
|
1153 |
|
1154 |
$this->vote = true;
|
1155 |
-
$this->poll_total_votes+=1;
|
1156 |
|
1157 |
-
return do_shortcode(
|
1158 |
}
|
1159 |
|
1160 |
-
function is_voted_supercookie(
|
1161 |
-
|
1162 |
-
$
|
1163 |
-
$
|
1164 |
-
|
|
|
1165 |
return true;
|
1166 |
}
|
1167 |
-
$cookie_expire = convert_date(
|
1168 |
|
1169 |
|
1170 |
-
if(
|
1171 |
$value = $this->blocking_voters_interval_value;
|
1172 |
}
|
1173 |
$unit = 'days';
|
1174 |
-
if(
|
1175 |
$unit = $this->blocking_voters_interval_unit;
|
1176 |
}
|
1177 |
|
1178 |
-
switch(
|
1179 |
case 'seconds' :
|
1180 |
$expire_cookie = $value;
|
1181 |
break;
|
1182 |
case 'minutes' :
|
1183 |
-
$expire_cookie = (
|
1184 |
break;
|
1185 |
case 'hours' :
|
1186 |
-
$expire_cookie = (
|
1187 |
break;
|
1188 |
case 'days' :
|
1189 |
-
$expire_cookie = (
|
1190 |
break;
|
1191 |
}
|
1192 |
-
$timeFirst
|
1193 |
-
$timeSecond
|
1194 |
$differenceInSeconds = $timeFirst - $timeSecond;
|
1195 |
-
if(
|
1196 |
return true;
|
1197 |
}
|
1198 |
-
if(
|
1199 |
return false;
|
1200 |
}
|
1201 |
return true;
|
1202 |
}
|
1203 |
|
1204 |
-
private function update_votes(
|
|
|
1205 |
|
1206 |
-
foreach(
|
1207 |
|
1208 |
-
$answer_to_update = & $question->getAnswerById(
|
1209 |
|
1210 |
|
1211 |
-
if(
|
1212 |
$answer['user_id'] = 0;
|
1213 |
}
|
1214 |
|
1215 |
-
if(
|
1216 |
-
if(
|
1217 |
$answer_to_update->type = 'text';
|
1218 |
-
$answer['type']
|
1219 |
}
|
1220 |
}
|
1221 |
-
$votes
|
1222 |
|
1223 |
-
$answer_to_update->answer_modified = current_time(
|
1224 |
-
$answer_to_update->answer_status
|
1225 |
-
$answer_to_update->votes
|
1226 |
|
1227 |
$answer_to_update->save();
|
1228 |
|
1229 |
-
$add_to_log['a'][]
|
1230 |
$add_to_log['answers'][] = $answer_to_update->answer;
|
1231 |
-
$mail_notification[]
|
1232 |
|
1233 |
-
unset(
|
1234 |
}
|
1235 |
return $add_to_log;
|
1236 |
}
|
1237 |
|
1238 |
-
private static function insert_vote_custom_field_in_database(
|
|
|
1239 |
global $wpdb;
|
1240 |
|
1241 |
-
$custom_field['custom_field_value'] = strip_tags(
|
1242 |
-
$wpdb->query(
|
1243 |
INSERT INTO " . $wpdb->yop_poll_votes_custom_fields . "
|
1244 |
SET
|
1245 |
poll_id = %d,
|
@@ -1251,53 +1235,54 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
1251 |
custom_field_value = %s,
|
1252 |
tr_id = %s,
|
1253 |
vote_date = %s
|
1254 |
-
", $custom_field['poll_id'], $custom_field['question_id'], $custom_field['vote_id'], $custom_field['custom_field_id'], $custom_field['user_id'], $custom_field['user_type'], $custom_field['custom_field_value'], $custom_field['tr_id'], current_time(
|
1255 |
return $wpdb->insert_id;
|
1256 |
}
|
1257 |
|
1258 |
-
private function update_poll_total_votes(
|
|
|
1259 |
global $wpdb;
|
1260 |
-
$wpdb->query(
|
1261 |
UPDATE {$wpdb->yop_polls}
|
1262 |
SET
|
1263 |
poll_total_votes = poll_total_votes + %d
|
1264 |
WHERE
|
1265 |
ID = %d
|
1266 |
-
", $votes, $this->ID
|
1267 |
|
1268 |
}
|
1269 |
|
1270 |
public function return_poll_html(
|
1271 |
$attr = array(
|
1272 |
-
'tr_id'
|
1273 |
'location' => 'page',
|
1274 |
'load_css' => false,
|
1275 |
-
'load_js'
|
1276 |
-
'show_results'=>''
|
1277 |
)
|
1278 |
-
)
|
1279 |
-
|
1280 |
-
$
|
1281 |
-
|
1282 |
-
|
1283 |
-
$date_format="m-
|
1284 |
-
|
1285 |
-
|
1286 |
-
$
|
1287 |
-
$
|
1288 |
-
$
|
1289 |
-
$
|
|
|
1290 |
$unique_id = $this->unique_id;
|
1291 |
-
$poll_id
|
1292 |
-
if(
|
1293 |
return '';
|
1294 |
}
|
1295 |
|
1296 |
//Get template id based on location(widget/page)
|
1297 |
-
if(
|
1298 |
$template_id = $this->widget_template;
|
1299 |
-
}
|
1300 |
-
else {
|
1301 |
$template_id = $this->template;
|
1302 |
}
|
1303 |
|
@@ -1305,249 +1290,244 @@ Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model {
|
|
1305 |
/**
|
1306 |
* Init Options
|
1307 |
*/
|
1308 |
-
$general_options = get_option(
|
1309 |
-
foreach(
|
1310 |
-
if(
|
1311 |
$this->$key = $value;
|
1312 |
}
|
1313 |
}
|
1314 |
|
1315 |
-
if(
|
1316 |
//get default template
|
1317 |
$template_details = self::get_poll_template_from_database();
|
1318 |
-
}
|
1319 |
-
|
1320 |
-
$template_details = self::get_poll_template_from_database( $template_id );
|
1321 |
}
|
1322 |
|
1323 |
$template_css = $template_details['css'];
|
1324 |
-
$template_details['before_vote_template']=
|
1325 |
-
$template_details['before_vote_template']=
|
1326 |
-
$template_details['before_vote_template']=
|
1327 |
-
$template_details['after_end_date_template']=
|
1328 |
-
$template_details['after_vote_template']=
|
1329 |
-
$template_details['after_end_date_template']=
|
1330 |
-
$template_details['after_vote_template']=
|
1331 |
-
$template_details['after_end_date_template']=
|
1332 |
-
$template_details['after_vote_template']=
|
1333 |
-
$template_details['after_end_date_template']=
|
1334 |
-
$template_details['after_vote_template']=
|
1335 |
-
$template_details['after_end_date_template']=
|
1336 |
-
$template_details['after_vote_template']=
|
1337 |
$poll_details = $this;
|
1338 |
-
$this->vote_button_label = empty($this->vote_button_label
|
1339 |
-
$this->vote_permisions_wordpress_label = empty($this->vote_permisions_wordpress_label
|
1340 |
-
$this->vote_permisions_anonymous_label = empty($this->vote_permisions_anonymous_label
|
1341 |
|
1342 |
//Translate labels
|
1343 |
-
if(
|
1344 |
// $poll_details = icl_translate( 'yop_poll', $poll_details->ID . '_poll_title', $poll_details->name );
|
1345 |
-
$this->singular_answer_result_votes_number_label = icl_translate(
|
1346 |
-
$this->plural_answer_result_votes_number_label
|
1347 |
-
$this->vote_button_label
|
1348 |
-
$this->view_results_link_label
|
1349 |
-
$this->view_back_to_vote_link_label
|
1350 |
-
$this->view_total_votes_label
|
1351 |
-
$this->view_total_answers_label
|
1352 |
-
$this->view_total_voters_label
|
1353 |
-
$this->archive_link_label
|
1354 |
-
$this->answer_result_label
|
1355 |
-
$this->vote_permisions_wordpress_label
|
1356 |
-
$this->vote_share_google_label
|
1357 |
-
$this->vote_permisions_anonymous_label
|
1358 |
}
|
1359 |
|
1360 |
-
$is_voted
|
1361 |
$current_date = self::get_mysql_curent_date();
|
1362 |
-
if(
|
1363 |
|
1364 |
-
if(
|
1365 |
//poll is active
|
1366 |
-
if(
|
1367 |
//user hasn't voted yet
|
1368 |
$template = $template_details['before_vote_template'];
|
1369 |
-
if(isset($show_results)
|
1370 |
|
1371 |
$template = $template_details['after_vote_template'];
|
1372 |
-
$this->view_results=array('before');
|
1373 |
}
|
1374 |
-
if(
|
1375 |
-
if(
|
1376 |
-
$template = str_ireplace(
|
1377 |
}
|
1378 |
}
|
1379 |
-
$template = str_ireplace(
|
1380 |
-
}
|
1381 |
-
else {
|
1382 |
//user has voted
|
1383 |
|
1384 |
-
if(
|
1385 |
-
in_array(
|
1386 |
-
in_array(
|
1387 |
-
(
|
1388 |
) {
|
1389 |
|
1390 |
$template = $template_details['after_vote_template'];
|
1391 |
|
1392 |
-
if(
|
1393 |
-
$template = str_ireplace(
|
1394 |
}
|
1395 |
}
|
1396 |
|
1397 |
-
if(
|
1398 |
-
$vote
|
1399 |
$this->vote = false;
|
1400 |
-
if(
|
1401 |
-
$template = str_ireplace(
|
1402 |
}
|
1403 |
$this->vote = $vote;
|
1404 |
}
|
1405 |
|
1406 |
}
|
1407 |
-
}
|
1408 |
-
else {
|
1409 |
//poll has ended
|
1410 |
$template = $template_details['after_end_date_template'];
|
1411 |
-
if(
|
1412 |
-
if(
|
1413 |
-
$template = str_ireplace(
|
1414 |
-
$template = str_ireplace(
|
1415 |
-
$template = str_ireplace(
|
1416 |
}
|
1417 |
}
|
1418 |
|
1419 |
}
|
1420 |
-
}
|
1421 |
-
else {
|
1422 |
//poll hasn't started
|
1423 |
$template = $template_details['before_start_date_template'];
|
1424 |
-
$template = str_ireplace(
|
1425 |
-
$template = str_ireplace(
|
1426 |
-
if(
|
1427 |
-
if(
|
1428 |
-
$template = str_ireplace(
|
1429 |
|
1430 |
}
|
1431 |
|
1432 |
}
|
1433 |
}
|
1434 |
|
1435 |
-
if(
|
1436 |
-
$template = str_ireplace(
|
1437 |
-
$template = str_ireplace(
|
1438 |
-
if(
|
1439 |
|
1440 |
-
if(
|
1441 |
-
$template = str_ireplace(
|
1442 |
}
|
1443 |
}
|
1444 |
}
|
1445 |
-
$template = str_ireplace(
|
1446 |
-
$template = str_ireplace(
|
1447 |
-
$template = stripslashes_deep(
|
1448 |
|
1449 |
-
$template = str_ireplace(
|
1450 |
-
$template = str_ireplace(
|
1451 |
-
$template = str_ireplace(
|
1452 |
-
$template = str_ireplace(
|
1453 |
|
1454 |
-
if(
|
1455 |
-
$template = str_ireplace(
|
1456 |
-
}
|
1457 |
-
|
1458 |
-
$template = str_ireplace( '%POLL-END-DATE%', esc_html( stripslashes( convert_date( $this->end_date,$date_format ) ) ), $template );
|
1459 |
}
|
1460 |
|
1461 |
-
if(
|
1462 |
-
$template = str_ireplace(
|
1463 |
}
|
1464 |
-
if(
|
1465 |
-
$template = str_ireplace(
|
1466 |
}
|
1467 |
$poll_total_answers = 0;
|
1468 |
-
foreach(
|
1469 |
-
foreach($q->answers as $a
|
1470 |
-
$poll_total_answers
|
1471 |
}
|
1472 |
|
1473 |
|
1474 |
-
if(
|
1475 |
-
$template = str_ireplace(
|
1476 |
-
$template = str_ireplace(
|
1477 |
}
|
1478 |
-
if(
|
1479 |
-
$template = str_ireplace(
|
1480 |
-
$template = str_ireplace(
|
1481 |
}
|
1482 |
|
1483 |
$msgDivS = false;
|
1484 |
$msgDivE = false;
|
1485 |
|
1486 |
-
if(
|
1487 |
-
$msgDivS
|
1488 |
-
$template = str_ireplace(
|
1489 |
}
|
1490 |
-
if(
|
1491 |
-
$msgDivE
|
1492 |
-
$template = str_ireplace(
|
1493 |
}
|
1494 |
|
1495 |
-
$that
|
1496 |
|
1497 |
/** Start Question replace*/
|
1498 |
-
$pattern
|
1499 |
-
$template = preg_replace_callback(
|
1500 |
return $that->question_replace_callback($m);
|
1501 |
-
}, $template
|
1502 |
/** End Question replace*/
|
1503 |
|
1504 |
|
1505 |
/** Start CAPTCHA replace*/
|
1506 |
-
$pattern
|
1507 |
-
$template = preg_replace_callback(
|
1508 |
return $that->captcha_replace_callback($m);
|
1509 |
-
}, $template
|
1510 |
/** End CAPTCHA replace*/
|
1511 |
|
1512 |
|
1513 |
-
$temp = self::strip_all_tags(
|
1514 |
|
1515 |
$template = "";
|
1516 |
-
if(
|
1517 |
-
$template .= '<style scoped>' . self::return_poll_css(
|
1518 |
|
1519 |
}
|
1520 |
|
1521 |
|
1522 |
$template .= '<div id="yop-poll-container-' . $this->ID . $unique_id . '" class="yop-poll-container">';
|
1523 |
-
if(
|
1524 |
$template .= '<div id="yop-poll-container-success-' . $this->ID . $unique_id . '" class="yop-poll-container-success"></div>';
|
1525 |
}
|
1526 |
-
if(
|
1527 |
$template .= '<div id="yop-poll-container-error-' . $this->ID . $unique_id . '" class="yop-poll-container-error"></div>';
|
1528 |
}
|
1529 |
|
1530 |
-
$template .= '<form id="yop-poll-form-' . $this->ID . $unique_id . '" class="yop-poll-forms yop-poll-forms-display">' . $temp . '<input type="hidden" id="yop-poll-tr-id-' . $this->ID . $unique_id . '" name="yop_poll_tr_id" value="' . $tr_id . '"/>' . wp_nonce_field(
|
1531 |
-
|
1532 |
|
1533 |
|
1534 |
return $template;
|
1535 |
}
|
1536 |
|
1537 |
-
public function captcha_replace_callback(
|
1538 |
-
|
|
|
1539 |
$return_string = '';
|
1540 |
-
$temp_string
|
1541 |
-
|
1542 |
-
if(
|
1543 |
-
$sid
|
1544 |
-
$temp_string = str_ireplace(
|
1545 |
-
$temp_string = str_ireplace(
|
1546 |
-
$temp_string = str_ireplace(
|
1547 |
-
$temp_string = str_ireplace(
|
1548 |
-
$temp_string = str_ireplace(
|
1549 |
-
<param name="movie" value="' . YOP_POLL_URL . 'captcha/securimage_play.swf?bgcol=#ffffff&icon_file=' . YOP_POLL_URL . 'images/captcha-audio.gif&audio_file=' . urlencode(
|
1550 |
-
</object>', $temp_string
|
1551 |
}
|
1552 |
$return_string .= $temp_string;
|
1553 |
|
1 |
<?php
|
2 |
|
3 |
+
Class YOP_POLL_Poll_Model extends YOP_POLL_Abstract_Model
|
4 |
+
{
|
5 |
|
6 |
protected $type = 'poll';
|
7 |
|
8 |
+
function __construct($id = 0, $is_view_results = 'no', $question_sort = "poll_order", $question_sort_rule = "ASC", $answer_sort = "question_order", $answer_sort_rule = "ASC")
|
9 |
+
{
|
10 |
|
11 |
+
parent::__construct($id, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule);
|
12 |
|
13 |
}
|
14 |
|
15 |
+
public static function return_template_preview_html($template_id = '', $loc = 1)
|
16 |
+
{
|
17 |
|
18 |
+
if ('' == $template_id) {
|
19 |
return "";
|
20 |
+
} else {
|
21 |
+
$uID = uniqid('t');
|
22 |
+
$poll = new YOP_POLL_Poll_Model();
|
23 |
+
$template_details = self::get_poll_template_from_database(intval($template_id));
|
24 |
+
$template = $template_details['before_vote_template'];
|
25 |
+
$template = stripslashes_deep($template);
|
|
|
26 |
|
27 |
+
$template = str_ireplace('%POLL-NAME%', "Poll Name", $template);
|
28 |
+
$template = str_ireplace('%POLL-VOTE-BUTTON%', '<button class="yop_poll_vote_button" onclick="return false;">Vote</button>', $template);
|
29 |
|
30 |
+
$question = new YOP_POLL_Question_Model();
|
31 |
|
32 |
+
$question->question = "Poll Question";
|
33 |
$question->allow_multiple_answers = "no";
|
34 |
+
$question->allow_other_answers = "no";
|
35 |
|
36 |
+
for ($i = 0; $i < 5; $i++) {
|
37 |
+
$a = new YOP_POLL_Answer_Model();
|
38 |
+
$j = $i + 1;
|
39 |
+
$a->ID = $i + 1;
|
40 |
$a->answer = "Answer {$j}";
|
41 |
|
42 |
+
$question->addAnswer($a);
|
43 |
+
unset($a);
|
44 |
}
|
45 |
+
$poll->questions = $question;
|
46 |
+
$t = $template;
|
47 |
$pattern = '\[(\[?)(QUESTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
48 |
+
preg_match("/$pattern/s", $t, $m);
|
49 |
$m = $m[5];
|
50 |
|
51 |
+
$m = str_ireplace("%POLL-QUESTION%", $question->question, $m);
|
52 |
|
53 |
$pattern = '/\[(\[?)(ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
54 |
+
preg_match($pattern, $m, $m1);
|
55 |
$m1 = $m1[5];
|
56 |
|
57 |
$ts = "";
|
58 |
|
59 |
/** Start Answer Description replace */
|
60 |
$pattern = '\[(\[?)(ANSWER_DESCRIPTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
61 |
+
$m1 = preg_replace("/$pattern/s", "", $m1);
|
62 |
/** End Answer Description replace */
|
63 |
|
64 |
/** Start Answer Result replace */
|
65 |
$pattern = '\[(\[?)(ANSWER_RESULT_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
66 |
+
$m1 = preg_replace("/$pattern/s", "", $m1);
|
67 |
/** End Answer Result replace */
|
68 |
|
69 |
+
foreach ($question->answers as $answer) {
|
70 |
+
$temps = str_ireplace('%POLL-ANSWER-CHECK-INPUT%', '<input type="radio" value="' . $answer->ID . '" name="yop_poll_answer-' . $uID . '" id="yop-poll-answer-' . $uID . '-' . $answer->ID . '" />', $m1);
|
71 |
+
$temps = str_ireplace('%POLL-ANSWER-LABEL%', '<label>' . $answer->answer . '</label>', $temps);
|
72 |
$ts .= $temps;
|
73 |
}
|
74 |
|
75 |
$pattern = '/\[(\[?)(ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
|
76 |
+
$m = preg_replace($pattern, $ts, $m);
|
77 |
|
78 |
+
$pattern = '\[(\[?)(QUESTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
79 |
+
$template = preg_replace("/$pattern/s", $m, $template);
|
80 |
|
81 |
+
$pattern = array(
|
82 |
'/\[(\[?)(OTHER_ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/',
|
83 |
'/\[(\[?)(CUSTOM_FIELD_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/',
|
84 |
'/\[(\[?)(ANSWER_RESULT_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/',
|
85 |
'/\[(\[?)(CAPTCHA_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/'
|
86 |
);
|
87 |
+
$template = preg_replace($pattern, "", $template);
|
88 |
+
$template = preg_replace('/\[\/?QUESTION_CONTAINER\]/', "", $template);
|
89 |
+
$template = str_ireplace("%POLL-ID%", "preview-" . $uID, $template);
|
90 |
+
$template = self::strip_all_tags($template);
|
91 |
+
|
92 |
+
$t = '<style type="text/css">' . $poll->return_poll_css($template_details['css'], array(
|
93 |
+
"location" => 'page',
|
94 |
+
'preview' => true,
|
95 |
'template_id' => $uID,
|
96 |
+
'loc' => $loc
|
97 |
+
)) . '</style>';
|
98 |
$t .= '<div id="yop-poll-container-preview-' . $uID . '" class="yop-poll-container" style="position: relative; z-index: 1;">';
|
99 |
$t .= '' . $template . '</div>';
|
100 |
|
101 |
+
$qID = uniqid('q');
|
102 |
+
$t = str_ireplace("%QUESTION-ID%", $qID, $t);
|
103 |
return $t;
|
104 |
}
|
105 |
}
|
106 |
|
107 |
+
private static function strip_all_tags($template)
|
108 |
+
{
|
109 |
|
110 |
$tags = array(
|
111 |
'%CAPTCHA-PLAY%',
|
151 |
'%SHARE-BUTTON%'
|
152 |
);
|
153 |
|
154 |
+
foreach ($tags as $tag) {
|
155 |
+
$template = str_ireplace($tag, '', $template);
|
156 |
}
|
157 |
return $template;
|
158 |
}
|
159 |
|
160 |
public function return_poll_css(
|
161 |
$css = "", $attr = array(
|
162 |
+
'location' => 'page',
|
163 |
+
'preview' => false,
|
164 |
'template_id' => '',
|
165 |
+
'loc' => 1
|
166 |
)
|
167 |
+
)
|
168 |
+
{
|
169 |
+
$preview = isset($attr['preview']) ? $attr['preview'] : false;
|
170 |
+
$location = isset($attr['location']) ? $attr['location'] : 'page';
|
171 |
+
if ($preview) {
|
172 |
$template = $css;
|
173 |
+
$template .= "li.yop-poll-li-answer-%POLL-ID% {width:100%}";
|
174 |
+
$template .= "div.yop-poll-answers-%POLL-ID% ul{width:100%}";
|
175 |
+
$template = str_ireplace("%POLL-ID%", 'preview-' . $attr['template_id'] . '', $template);
|
176 |
+
$template = str_ireplace("%POLL-WIDTH%", '200px', $template);
|
177 |
+
return stripslashes($template);
|
178 |
+
} else {
|
|
|
179 |
$unique_id = $this->ID . $this->unique_id;
|
180 |
|
181 |
/*if ( !$poll_id ){
|
195 |
$template_details = self::get_poll_template_from_database( $template_id );
|
196 |
$template = $template_details['css'];*/
|
197 |
|
198 |
+
$template = str_ireplace('%POLL-ID%', $unique_id, $css);
|
199 |
+
if ('widget' == $location) {
|
200 |
+
$template = str_ireplace('%POLL-WIDTH%', $this->widget_template_width, $template);
|
201 |
+
} else {
|
202 |
+
$template = str_ireplace('%POLL-WIDTH%', $this->template_width, $template);
|
203 |
}
|
204 |
+
return stripslashes($template);
|
|
|
|
|
|
|
205 |
}
|
206 |
}
|
207 |
|
208 |
+
private static function count_other_answers($question)
|
209 |
+
{
|
210 |
+
$n = count($question->answers);
|
211 |
$nr = 0;
|
212 |
+
for ($i = 0; $i < $n; $i++) {
|
213 |
+
if ($question->answers[$i]->type == "other") {
|
214 |
+
$nr++;
|
215 |
}
|
216 |
}
|
217 |
return $nr;
|
218 |
}
|
219 |
|
220 |
+
public function return_poll_js($attr = array('location' => 'page'))
|
221 |
+
{
|
222 |
+
$poll_id = $this->ID;
|
223 |
+
$location = isset($attr['location']) ? $attr['location'] : 'page';
|
224 |
$unique_id = $this->unique_id;
|
225 |
|
226 |
+
if (!$poll_id) {
|
227 |
return '';
|
228 |
}
|
229 |
|
230 |
+
if ('widget' == $location) {
|
231 |
$template_id = $this->widget_template;
|
232 |
+
} else {
|
|
|
233 |
$template_id = $this->template;
|
234 |
}
|
235 |
|
236 |
+
if ('' == $template_id) {
|
237 |
//get default template
|
238 |
$template_details = self::get_poll_template_from_database();
|
239 |
+
} else {
|
240 |
+
$template_details = self::get_poll_template_from_database($template_id);
|
|
|
241 |
}
|
242 |
|
243 |
$tabulate = array();
|
244 |
|
245 |
+
foreach ($this->questions as $question) {
|
246 |
$answers_tabulated_cols = 1; //vertical display
|
247 |
$results_tabulated_cols = 1;
|
248 |
|
249 |
+
$include_others = false;
|
250 |
+
$display_answers = array('text', 'image', 'video');
|
251 |
|
252 |
+
if (isset($question->allow_other_answers) && 'yes' == $question->allow_other_answers) {
|
253 |
|
254 |
+
if (isset($question->display_other_answers_values) && 'yes' == $question->display_other_answers_values) {
|
255 |
+
$include_others = true;
|
256 |
+
$display_answers = array('text', 'image', 'video', 'other');
|
257 |
}
|
258 |
}
|
259 |
|
260 |
|
261 |
+
if ('orizontal' == $question->display_answers) {
|
262 |
+
$ans_no = $question->countanswers($display_answers, $include_others);
|
263 |
+
if ($ans_no > 0) {
|
264 |
$answers_tabulated_cols = $ans_no;
|
265 |
}
|
266 |
+
if (isset($question->allow_other_answers) && 'yes' == $question->allow_other_answers) {
|
267 |
+
$answers_tabulated_cols++;
|
268 |
}
|
269 |
+
} else
|
270 |
+
if ('tabulated' == $question->display_answers) {
|
|
|
271 |
$answers_tabulated_cols = $question->display_answers_tabulated_cols;
|
272 |
//yop_poll_dump($answers_tabulated_cols);
|
273 |
|
274 |
}
|
275 |
|
276 |
+
if ('orizontal' == $question->display_results) {
|
277 |
+
$ans_no = $question->countanswers($display_answers, $include_others);
|
278 |
+
if ($ans_no > 0) {
|
279 |
$results_tabulated_cols = $ans_no;
|
280 |
}
|
281 |
+
} else if ('tabulated' == $question->display_results) {
|
|
|
282 |
$results_tabulated_cols = $question->display_results_tabulated_cols;
|
283 |
}
|
284 |
|
285 |
+
array_push($tabulate, array($answers_tabulated_cols, $results_tabulated_cols, $ans_per_question, $question->ID));
|
286 |
}
|
287 |
|
288 |
$template = $template_details['js'];
|
289 |
+
if ('vertical' == $question->display_answers) {
|
290 |
+
$template .= "jQuery(document).ready(function(){ jQuery('.yop-poll-li-answer-%POLL-ID%').css('float','none');});";
|
291 |
|
292 |
}
|
293 |
+
$template = str_ireplace('%POLL-ID%', $poll_id . $unique_id, $template);
|
294 |
+
$template = str_ireplace('%ANSWERS-TABULATED-COLS%', json_encode($tabulate), $template);
|
295 |
+
$template = str_ireplace('%POLL-WIDTH%', str_replace("px", "", $this->template_width), $template);
|
296 |
+
$template = str_ireplace('%RESULTS-TABULATED-COLS%', json_encode($tabulate), $template);
|
297 |
+
return stripslashes($template);
|
298 |
}
|
299 |
|
300 |
+
public function question_replace_callback($m)
|
301 |
+
{
|
302 |
+
$is_voted = $this->is_voted();
|
303 |
$return_string = "";
|
304 |
+
$that = $this;
|
305 |
+
foreach ($this->questions as $question) {
|
306 |
|
307 |
$qunique_id = $question->ID;
|
308 |
+
$temp = str_ireplace('%QUESTION-ID%', $qunique_id, $m[5]);
|
309 |
+
$temp = str_ireplace('%POLL-QUESTION%', $question->question, $temp);
|
310 |
|
311 |
+
$temp = str_ireplace('class = ' . '"' . 'yop-poll-li-answer-' . $this->ID . $this->unique_id, 'class=' . '"' . 'yop-poll-li-answer-' . $this->ID . $this->unique_id . ' yop-poll-li-answer-' . $this->ID . $this->unique_id . "-" . $question->ID, $temp);
|
312 |
|
313 |
+
if (!$is_voted) {
|
314 |
/** Start Anwer replace */
|
315 |
+
if ($this->count_answers($question) > 0) {
|
316 |
$pattern = '\[(\[?)(ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
317 |
+
$temp = preg_replace_callback("/$pattern/s", function ($m) use ($that, $question) {
|
318 |
+
return $that->answer_replace_callback($m[5], $question);
|
319 |
+
}, $temp);
|
320 |
}
|
321 |
/** End Anwer replace */
|
322 |
|
323 |
/** Start Other Answer replace */
|
324 |
$pattern = '\[(\[?)(OTHER_ANSWER_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
325 |
+
$temp = str_ireplace('class = ' . '"' . 'yop-poll-li-answer-' . $this->ID . $this->unique_id, 'class=' . '"' . 'yop-poll-li-answer-' . $this->ID . $this->unique_id . ' yop-poll-li-answer-' . $this->ID . $this->unique_id . "-" . $question->ID, $temp);
|
326 |
|
327 |
+
$temp = preg_replace_callback("/$pattern/s", function ($m) use ($that, $question) {
|
328 |
+
return $that->other_answer_replace_callback($m[5], $question);
|
329 |
+
}, $temp);
|
330 |
/** End Other Answer replace */
|
331 |
|
332 |
/** Start Custom Fields replace*/
|
333 |
$pattern = '\[(\[?)(CUSTOM_FIELD_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
334 |
+
$temp = preg_replace_callback("/$pattern/s", function ($m) use ($that, $question) {
|
335 |
+
return $that->custom_field_replace_callback($m[5], $question);
|
336 |
+
}, $temp);
|
337 |
/** End Custom Fields replace*/
|
338 |
}
|
339 |
$pattern = '\[(\[?)(ANSWER_RESULT_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
340 |
+
$temp = preg_replace_callback("/$pattern/s", function ($m) use ($that, $question) {
|
341 |
+
return $that->answer_result_replace_callback($m[5], $question);
|
342 |
+
}, $temp);
|
343 |
|
344 |
$return_string .= $temp;
|
345 |
}
|
346 |
return $return_string;
|
347 |
}
|
348 |
|
349 |
+
private static function count_answers($question)
|
350 |
+
{
|
351 |
+
$n = count($question->answers);
|
352 |
$nr = 0;
|
353 |
+
for ($i = 0; $i < $n; $i++) {
|
354 |
+
if (in_array($question->answers[$i]->type, array('text'))) {
|
355 |
+
$nr++;
|
356 |
}
|
357 |
}
|
358 |
return $nr;
|
359 |
}
|
360 |
|
361 |
+
public function answer_replace_callback($m, $question)
|
362 |
+
{
|
363 |
$unique_id = $this->unique_id;
|
364 |
|
365 |
$multiple_answers = false;
|
366 |
+
if ($question->allow_multiple_answers == 'yes') {
|
367 |
$multiple_answers = true;
|
368 |
}
|
369 |
|
371 |
|
372 |
/** Get question total votes( default + other ) */
|
373 |
|
374 |
+
$total_votes = $this->get_question_votes($question);
|
375 |
+
|
376 |
/**Is allowed to display other answers?*/
|
377 |
$display_other_answers = false;
|
378 |
|
379 |
+
if (isset($question->allow_other_answers) && 'yes' == $question->allow_other_answers) {
|
380 |
+
if (isset($question->display_other_answers_values) && 'yes' == $question->display_other_answers_values) {
|
381 |
$display_other_answers = true;
|
382 |
}
|
383 |
}
|
384 |
|
385 |
$percentages_decimals = 0;
|
386 |
+
if (isset($this->percentages_decimals)) {
|
387 |
$percentages_decimals = $this->percentages_decimals;
|
388 |
}
|
389 |
|
390 |
+
$id = $this->ID;
|
391 |
|
392 |
$view_results = $this->is_view_poll_results();
|
393 |
+
|
394 |
+
$that = $this;
|
395 |
+
foreach ($question->answers as $answer) {
|
396 |
/**Check if is allowed to display current answers*/
|
397 |
+
if (($answer->type == "other") && !$display_other_answers) {
|
398 |
continue;
|
399 |
}
|
400 |
+
if ($view_results) {
|
401 |
+
if ($answer->votes > 0) {
|
402 |
+
if (isset($total_votes) && $total_votes > 0) {
|
403 |
+
$percentages = floatval($answer->votes * 100 / $total_votes);
|
404 |
+
}
|
405 |
+
} else {
|
406 |
+
$percentages = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
}
|
408 |
}
|
409 |
+
if (function_exists('icl_translate')) {
|
410 |
+
$answer->answer = icl_translate('yop_poll', $answer->ID . '_answer', $answer->answer);
|
411 |
+
}
|
412 |
+
if ($multiple_answers) {
|
413 |
+
if (isset($answer->is_default_answer) && $answer->is_default_answer == "yes") {
|
414 |
+
$temp_answer_model = str_ireplace('%POLL-ANSWER-CHECK-INPUT%', '<input type="checkbox" checked="checked" value="' . $answer->ID . '" name="yop_poll_answer[' . $question->ID . '][]" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $answer->ID . '" />', $m);
|
415 |
+
} else {
|
416 |
+
$temp_answer_model = str_ireplace('%POLL-ANSWER-CHECK-INPUT%', '<input type="checkbox" value="' . $answer->ID . '" name="yop_poll_answer[' . $question->ID . '][]" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $answer->ID . '" />', $m);
|
417 |
}
|
418 |
+
} else {
|
419 |
+
if (isset($answer->is_default_answer) && $answer->is_default_answer == "yes") {
|
420 |
+
$temp_answer_model = str_ireplace('%POLL-ANSWER-CHECK-INPUT%', '<input type="radio" checked="checked" value="' . $answer->ID . '" name="yop_poll_answer[' . $question->ID . ']" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $answer->ID . '" />', $m);
|
421 |
+
} else {
|
422 |
+
$temp_answer_model = str_ireplace('%POLL-ANSWER-CHECK-INPUT%', '<input type="radio" value="' . $answer->ID . '" name="yop_poll_answer[' . $question->ID . ']" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $answer->ID . '" />', $m);
|
423 |
}
|
424 |
}
|
425 |
|
426 |
/** Start Answer Description replace */
|
427 |
+
$pattern = '\[(\[?)(ANSWER_DESCRIPTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
428 |
+
$temp_answer_model = preg_replace_callback("/$pattern/s", function ($m) use ($that, $answer, $id, $unique_id) {
|
429 |
+
return $that->answer_description_replace_callback($m[5], $answer, $id, $unique_id);
|
430 |
+
}, $temp_answer_model);
|
431 |
/** End Answer Description replace */
|
432 |
+
if ($view_results) {
|
433 |
+
/** Start Answer Result replace */
|
434 |
+
$pattern = '\[(\[?)(ANSWER_RESULT_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
435 |
+
$temp_answer_model = preg_replace_callback("/$pattern/s", function ($m) use ($that, $answer, $view_results, $id, $unique_id, $percentages, $percentages_decimals) {
|
436 |
+
return $that->answer_result_bar_callback($m[5], $answer, $view_results, $id, $unique_id, $percentages, $percentages_decimals);
|
437 |
+
}, $temp_answer_model);
|
438 |
+
/** End Answer Result replace */
|
439 |
}
|
440 |
+
if ($answer->type == "text") {
|
441 |
+
$temp_answer_model = str_ireplace('%POLL-ANSWER-LABEL%', '<label for="yop-poll-answer-' . $this->ID . $unique_id . '-' . $answer->ID . '">' . yop_poll_kses(stripslashes($answer->answer)) . '</label>', $temp_answer_model);
|
442 |
}
|
443 |
+
if ($answer->type == "other") {
|
444 |
+
$temp_answer_model = str_ireplace('%POLL-ANSWER-LABEL%', '<label style=" cursor: pointer;" for="yop-poll-answer-' . $this->ID . $unique_id . '-' . $answer->ID . '">' . yop_poll_kses(stripslashes($answer->answer)) . '</label>', $temp_answer_model);
|
445 |
}
|
446 |
|
447 |
$model .= $temp_answer_model;
|
450 |
return $model;
|
451 |
}
|
452 |
|
453 |
+
private static function get_question_votes($question)
|
454 |
+
{
|
455 |
$total_votes = 0;
|
456 |
+
foreach ($question->answers as $answer) {
|
457 |
+
$total_votes += intval($answer->votes);
|
458 |
}
|
459 |
return $total_votes;
|
460 |
}
|
461 |
|
462 |
+
private function is_view_poll_results()
|
463 |
+
{
|
464 |
$is_voted = $this->is_voted();
|
465 |
+
if (((in_array('before', $this->view_results)) || (in_array('after', $this->view_results) && $is_voted) || (in_array('custom-date', $this->view_results) && self::get_mysql_curent_date() >= convert_date($this->view_results_start_date, 'Y-m-d H:i:s', 1)) || (in_array('after-poll-end-date', $this->view_results) && self::get_mysql_curent_date() >= convert_date($this->poll_end_date, 'Y-m-d H:i:s'))) && !in_array('never', $this->view_results) && ((in_array('guest', $this->view_results_permissions) && !is_user_logged_in()) || (in_array('registered', $this->view_results_permissions) && is_user_logged_in()))
|
466 |
) {
|
467 |
return true;
|
468 |
}
|
469 |
return false;
|
470 |
}
|
471 |
+
|
472 |
+
public function answer_description_replace_callback($m, $answer, $id, $unique_id)
|
473 |
+
{
|
474 |
+
if ("" == $answer->description) {
|
475 |
return "";
|
476 |
}
|
477 |
+
return str_ireplace("%ANSWER-DESCRIPTION%", '<label for="yop-poll-answer-' . $id . $unique_id . '-' . $answer->ID . '">' . yop_poll_kses(stripslashes($answer->description)) . '</label>', $m);
|
478 |
}
|
479 |
|
480 |
+
public function answer_result_bar_callback($m, $answer, $view_results, $id, $unique_id, $percentages, $percentages_decimals)
|
481 |
+
{
|
482 |
+
if ($view_results) {
|
483 |
+
$tmp = str_ireplace('%POLL-ANSWER-RESULT-BAR%', self::display_poll_result_bar($answer->ID, $percentages, $this->options, $id . $unique_id), $m);
|
484 |
+
$tmp = str_ireplace('%POLL-ANSWER-RESULT-VOTES%', self::display_poll_result_votes($answer->votes, $this->options), $tmp);
|
485 |
+
$tmp = str_ireplace('- ( )', self::display_poll_result_votes($answer->votes, $this->options), $tmp);
|
486 |
+
$tmp = str_ireplace('%POLL-ANSWER-RESULT-PERCENTAGES%', self::display_poll_result_percentages(round($percentages, $percentages_decimals), $this->options), $tmp);
|
487 |
return $tmp;
|
488 |
+
} else {
|
|
|
489 |
return "";
|
490 |
}
|
491 |
}
|
492 |
|
493 |
+
private static function display_poll_result_bar($answer_id = 0, $procent = 0, $options = array(), $unique_id = '')
|
494 |
+
{
|
495 |
$result_bar = ' <div class="yop-poll-results-bar-' . $unique_id . '" ';
|
496 |
$result_bar .= ' ';
|
497 |
$result_bar .= '><div>';
|
498 |
+
if (floatval($procent) > 0) {
|
499 |
|
500 |
$result_bar .= '<div style="' . 'width:' . $procent . '%; ';
|
501 |
$result_bar .= 'height:' . $options['bar_height'] . 'px; ' . 'background-color:#' . $options['bar_background'] . '; ' . 'border-style:' . $options['bar_border_style'] . '; ' . 'border-width:' . $options['bar_border_width'] . 'px; ' . 'border-color:#' . $options['bar_border_color'] . '; ';
|
505 |
return $result_bar;
|
506 |
}
|
507 |
|
508 |
+
private static function display_poll_result_votes($votes = 0, $options = array())
|
509 |
+
{
|
510 |
|
511 |
+
if ('votes-number' == $options['view_results_type'] || 'votes-number-and-percentages' == $options['view_results_type']) {
|
512 |
+
if ('1' == $votes) {
|
513 |
+
$options = get_option('yop_poll_options');
|
514 |
return $votes . ' ' . $options['singular_answer_result_votes_number_label'];
|
515 |
+
} else {
|
516 |
+
$options = get_option('yop_poll_options');
|
|
|
517 |
return $votes . ' ' . $options['plural_answer_result_votes_number_label'];
|
518 |
}
|
519 |
}
|
520 |
}
|
521 |
|
522 |
+
private static function display_poll_result_percentages($votes, $options = array())
|
523 |
+
{
|
524 |
+
if ('percentages' == $options['view_results_type'] || 'votes-number-and-percentages' == $options['view_results_type']) {
|
525 |
return $votes . '%';
|
526 |
+
} else {
|
|
|
527 |
return '';
|
528 |
}
|
529 |
}
|
530 |
|
531 |
+
public function other_answer_replace_callback($m, $question)
|
532 |
+
{
|
533 |
$unique_id = $this->unique_id;
|
534 |
|
535 |
$multiple_answers = false;
|
536 |
+
if ($question->allow_multiple_answers == 'yes') {
|
537 |
$multiple_answers = true;
|
538 |
}
|
539 |
|
540 |
$model = "";
|
541 |
|
542 |
+
$allow_other_answers = false;
|
543 |
$display_other_answers = false;
|
544 |
+
if (isset($question->allow_other_answers) && $question->allow_other_answers == 'yes') {
|
545 |
$allow_other_answers = true;
|
546 |
+
if (isset($question->add_other_answers_to_default_answers) && ('yes' == $question->add_other_answers_to_default_answers)) {
|
547 |
$display_other_answers = true;
|
548 |
}
|
549 |
}
|
550 |
|
551 |
+
if ($allow_other_answers) {
|
552 |
/**Display other answer input */
|
553 |
+
if (function_exists('icl_translate')) {
|
554 |
+
$other_answer_label = icl_translate('yop_poll', $this->ID . '_other_answer_label', yop_poll_kses($question->other_answers_label));
|
555 |
+
} else {
|
556 |
+
$other_answer_label = yop_poll_kses($question->other_answers_label);
|
|
|
557 |
}
|
558 |
|
559 |
+
if ($multiple_answers) {
|
560 |
+
$temp_answer_model = str_ireplace('%POLL-OTHER-ANSWER-CHECK-INPUT%', '<input type="checkbox" value="other" name="yop_poll_answer[' . $question->ID . '][]" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $question->ID . '-other" />', $m);
|
561 |
+
} else {
|
562 |
+
$temp_answer_model = str_ireplace('%POLL-OTHER-ANSWER-CHECK-INPUT%', '<input type="radio" value="other" name="yop_poll_answer[' . $question->ID . ']" id="yop-poll-answer-' . $this->ID . $unique_id . '-' . $question->ID . '-other" />', $m);
|
|
|
563 |
}
|
564 |
+
$temp_answer_model = str_ireplace('%POLL-OTHER-ANSWER-LABEL%', '<label for="yop-poll-answer-' . $this->ID . $unique_id . '-' . $question->ID . '-other">' . $other_answer_label . '</label>', $temp_answer_model);
|
565 |
+
$temp_answer_model = str_ireplace('%POLL-OTHER-ANSWER-TEXT-INPUT%', '<label style="width:100%;"><input onclick="document.getElementById(\'yop-poll-answer-' . $this->ID . $unique_id . '-' . $question->ID . '-other' . '\').checked=true;" type="text" value="" name="yop_poll_other_answer[' . $question->ID . ']" id="yop-poll-other-answer-' . $this->ID . $unique_id . '-other" /></label>', $temp_answer_model);
|
566 |
|
567 |
+
if ($this->is_view_poll_results()) {
|
568 |
/**Display only if other answers were not displayed */
|
569 |
+
if (!$display_other_answers) {
|
570 |
/** Count question total votes( default + other ) */
|
571 |
+
$total_votes = $this->get_question_votes($question);
|
572 |
|
573 |
/** Count other answers votes*/
|
574 |
+
$other_votes = $this->get_question_other_votes($question);
|
575 |
|
576 |
|
577 |
$percentages_decimals = 0;
|
578 |
+
if (isset($this->percentages_decimals)) {
|
579 |
$percentages_decimals = $this->percentages_decimals;
|
580 |
}
|
581 |
|
582 |
+
if ($other_votes > 0) {
|
583 |
+
$percentages = floatval($other_votes * 100 / $total_votes);
|
584 |
+
} else {
|
|
|
585 |
$percentages = 0;
|
586 |
}
|
587 |
+
if ($this->is_view_poll_results()) {
|
588 |
+
$temp_answer_model = str_ireplace('%POLL-OTHER-ANSWER-RESULT-BAR%', self::display_poll_result_bar('other', $percentages, $this->options, $this->ID . $unique_id), $temp_answer_model);
|
589 |
+
$temp_answer_model = str_ireplace('%POLL-ANSWER-RESULT-VOTES%', self::display_poll_result_votes($other_votes, $this->options), $temp_answer_model);
|
590 |
+
$temp_answer_model = str_ireplace('- ( )', self::display_poll_result_votes($other_votes, $this->options), $temp_answer_model);
|
591 |
|
592 |
+
$temp_answer_model = str_ireplace('%POLL-ANSWER-RESULT-PERCENTAGES%', self::display_poll_result_percentages(round($percentages, $percentages_decimals), $this->options), $temp_answer_model);
|
593 |
}
|
594 |
}
|
595 |
}
|
598 |
return $model;
|
599 |
}
|
600 |
|
601 |
+
private static function get_question_other_votes($question)
|
602 |
+
{
|
603 |
$total_votes = 0;
|
604 |
+
foreach ($question->answers as $answer) {
|
605 |
+
if ($answer->type == 'other') {
|
606 |
+
$total_votes += intval($answer->votes);
|
607 |
}
|
608 |
}
|
609 |
return $total_votes;
|
610 |
}
|
611 |
|
612 |
+
public function custom_field_replace_callback($m, $question)
|
613 |
+
{
|
614 |
$unique_id = $this->unique_id;
|
615 |
+
$is_voted = $this->is_voted();
|
616 |
+
$model = "";
|
617 |
+
if (!$is_voted) {
|
618 |
+
if (count($question->custom_fields) > 0) {
|
619 |
+
foreach ($question->custom_fields as $custom_field) {
|
620 |
+
if (function_exists('icl_translate')) {
|
621 |
+
$custom_field['custom_field'] = icl_translate('yop_poll', $custom_field->ID . '_custom_field', $custom_field->custom_field);
|
622 |
}
|
623 |
+
$temp_string = str_ireplace('%POLL-CUSTOM-FIELD-LABEL%', '<label for="yop-poll-customfield-' . $this->ID . $unique_id . '-' . $custom_field->ID . '">' . yop_poll_kses($custom_field->custom_field) . '</label>', $m);
|
624 |
|
625 |
+
$temp_string = str_ireplace('%POLL-CUSTOM-FIELD-TEXT-INPUT%', '<input type="text" value="" name="yop_poll_customfield[' . $question->ID . '][' . $custom_field->ID . ']" id="yop-poll-customfield-' . $this->ID . $unique_id . '-' . $custom_field->ID . '" class=' . '"yop-poll-customfield-' . $this->ID . $unique_id . '"/>', $temp_string);
|
626 |
$model .= $temp_string;
|
627 |
}
|
628 |
}
|
630 |
return $model;
|
631 |
}
|
632 |
|
633 |
+
public function answer_result_replace_callback($m, $question)
|
634 |
+
{
|
635 |
+
$unique_id = $this->unique_id;
|
636 |
$return_string = '';
|
637 |
+
$is_voted = $this->is_voted();
|
638 |
+
$id = $this->ID;
|
639 |
|
640 |
+
if ($this->is_view_poll_results()) {
|
641 |
$display_other_answers = false;
|
642 |
+
if ('yes' == $question->allow_other_answers) {
|
643 |
+
if ('yes' == $question->display_other_answers_values) {
|
644 |
$display_other_answers = true;
|
645 |
}
|
646 |
}
|
647 |
|
648 |
$percentages_decimals = 0;
|
649 |
+
if (isset($this->percentages_decimals)) {
|
650 |
$percentages_decimals = $this->percentages_decimals;
|
651 |
}
|
652 |
|
653 |
+
if (isset($this->sorting_results)) {
|
654 |
+
if ('as_defined' == $this->sorting_results) {
|
655 |
+
$question->sortAnswers('question_order', 'asc');
|
656 |
+
} elseif ('database' == $this->sorting_results) {
|
|
|
657 |
$order_dir = 'asc';
|
658 |
+
if (isset($this->sorting_results_direction)) {
|
659 |
+
$order_dir = ('asc' == $this->sorting_results_direction) ? 'asc' : 'desc';
|
660 |
}
|
661 |
+
$question->sortAnswers('ID', $order_dir);
|
662 |
+
} elseif ('alphabetical' == $this->sorting_results) {
|
|
|
663 |
$order_dir = 'asc';
|
664 |
+
if (isset($this->sorting_results_direction)) {
|
665 |
+
$order_dir = ('asc' == $this->sorting_results_direction) ? 'asc' : 'desc';
|
666 |
}
|
667 |
+
$question->sortAnswers('alphabetical', $order_dir);
|
668 |
+
} elseif ('votes' == $this->sorting_results) {
|
|
|
669 |
$order_dir = 'asc';
|
670 |
+
if (isset($this->sorting_results_direction)) {
|
671 |
+
$order_dir = ('asc' == $this->sorting_results_direction) ? 'asc' : 'desc';
|
672 |
}
|
673 |
+
$question->sortAnswers('votes', $order_dir);
|
674 |
+
} else {
|
|
|
675 |
$order_dir = 'asc';
|
676 |
+
if (isset($this->sorting_results_direction)) {
|
677 |
+
$order_dir = ('asc' == $this->sorting_results_direction) ? 'asc' : 'desc';
|
678 |
}
|
679 |
+
$question->sortAnswers('question_order', $order_dir);
|
680 |
}
|
681 |
+
} else {
|
|
|
682 |
$order_dir = 'asc';
|
683 |
+
if (isset($this->sorting_results_direction)) {
|
684 |
+
$order_dir = ('asc' == $this->sorting_results_direction) ? 'asc' : 'desc';
|
685 |
}
|
686 |
+
$question->sortAnswers('question_order', $order_dir);
|
687 |
}
|
688 |
|
689 |
|
690 |
+
$total_votes = $this->get_question_votes($question);
|
691 |
|
692 |
+
foreach ($question->answers as $ans) {
|
693 |
+
if (($ans->type == "other") && !$display_other_answers) {
|
694 |
continue;
|
695 |
}
|
696 |
+
if ($ans->votes > 0) {
|
697 |
+
$percentages = floatval($ans->votes * 100 / $total_votes);
|
698 |
+
} else {
|
|
|
699 |
$percentages = 0;
|
700 |
}
|
701 |
|
702 |
+
if (function_exists('icl_translate')) {
|
703 |
+
$ans->answer = icl_translate('yop_poll', $ans->ID . '_answer', $ans->answer);
|
704 |
}
|
705 |
|
706 |
/** Start Answer Description replace */
|
707 |
$pattern = '\[(\[?)(ANSWER_DESCRIPTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
708 |
+
$temp_string = preg_replace("/$pattern/s", "", $m);
|
709 |
/** End Answer Description replace */
|
710 |
$ans->type = "text";
|
711 |
+
if ($ans->type == "text") {
|
712 |
+
$temp_string = str_ireplace('%POLL-ANSWER-LABEL%', '<span>' . yop_poll_kses(stripslashes($ans->answer)) . '</span>', $temp_string);
|
713 |
}
|
714 |
+
$temp_string = str_ireplace('class = ' . '"' . 'yop-poll-li-result-' . $this->ID . $this->unique_id, 'class=' . '"' . 'yop-poll-li-result-' . $this->ID . $this->unique_id . ' yop-poll-li-result-' . $this->ID . $this->unique_id . "-" . $question->ID, $temp_string);
|
715 |
|
716 |
|
717 |
+
$temp_string = str_ireplace('%POLL-ANSWER-RESULT-VOTES%', self::display_poll_result_votes($ans->votes, $this->options), $temp_string);
|
718 |
+
$temp_string = str_ireplace('- ( )', self::display_poll_result_votes($ans->votes, $this->options), $temp_string);
|
719 |
+
$temp_string = str_ireplace('%POLL-ANSWER-RESULT-PERCENTAGES%', self::display_poll_result_percentages(round($percentages, $percentages_decimals), $this->options), $temp_string);
|
720 |
+
$temp_string = str_ireplace('%POLL-ANSWER-RESULT-BAR%', self::display_poll_result_bar($ans->ID, $percentages, $this->options, $this->ID . $unique_id), $temp_string);
|
721 |
$return_string .= $temp_string;
|
722 |
}
|
723 |
}
|
725 |
return $return_string;
|
726 |
}
|
727 |
|
728 |
+
public function register_vote($request)
|
729 |
+
{
|
730 |
|
731 |
global $current_user;
|
732 |
+
$poll_id = $this->id;
|
733 |
+
$unique_id = strip_tags(xss_clean($this->unique_id));
|
734 |
+
$location = strip_tags(xss_clean($request['location']));
|
735 |
+
$vote_id = uniqid('vote_id_');
|
736 |
+
$vote_type = $request['vote_type'];
|
737 |
+
$SuperCookie = strip_tags(xss_clean($request['supercookie']));
|
738 |
+
$tr_id = strip_tags(xss_clean($request['yop_poll_tr_id']));
|
739 |
+
$votes = 0;
|
740 |
+
$user_id = 0;
|
741 |
+
$user_type = 'default';
|
742 |
$user_details = '';
|
743 |
+
if (wp_verify_nonce($request['yop-poll-nonce-' . $poll_id . $unique_id], 'yop_poll-' . $this->ID . $unique_id . '-user-actions')) {
|
744 |
+
switch ($vote_type) {
|
745 |
default:
|
746 |
{
|
747 |
+
$user_id = ($current_user->ID != null) ? $current_user->ID : 0;
|
748 |
$user_type = 'default';
|
749 |
break;
|
750 |
}
|
751 |
case 'wordpress':
|
752 |
{
|
753 |
+
$user_id = $current_user->ID;
|
754 |
$user_type = 'wordpress';
|
755 |
break;
|
756 |
}
|
762 |
|
763 |
}
|
764 |
$log_to_add = array(
|
765 |
+
'poll_id' => $this->ID,
|
766 |
+
'vote_id' => $vote_id,
|
767 |
+
'ip' => yop_poll_get_ip(),
|
768 |
+
'user_id' => $user_id,
|
769 |
+
'user_type' => $user_type,
|
770 |
+
'user_details' => json_encode($user_details),
|
771 |
+
'tr_id' => $tr_id,
|
772 |
);
|
773 |
+
} else {
|
774 |
+
$this->error = __yop_poll('Bad Request!');
|
775 |
+
$log_to_add ['message'] = __yop_poll('Bad request');
|
776 |
+
insert_log_in_db($log_to_add);
|
|
|
777 |
return false;
|
778 |
}
|
779 |
+
if (wp_verify_nonce($request['yop-poll-nonce-' . $this->ID . $unique_id], 'yop_poll-' . $this->ID . $unique_id . '-user-actions')) {
|
780 |
|
781 |
+
$tr_id = $request['yop_poll_tr_id'];
|
782 |
$super_perm = true;
|
783 |
+
if (in_array("supercookie", $this->blocking_voters)) {
|
784 |
+
$super_perm = $this->is_voted_supercookie($SuperCookie);
|
785 |
}
|
786 |
+
if ($super_perm == true) {
|
787 |
|
788 |
$current_date = yop_poll_get_mysql_curent_date();
|
789 |
+
if ($this->is_allowed_to_vote($vote_type)) {
|
790 |
+
if ($current_date >= convert_date($this->poll_start_date, 'Y-m-d H:i:s')) {
|
791 |
+
if ($current_date <= convert_date($this->poll_end_date, 'Y-m-d H:i:s')) {
|
792 |
+
if ('closed' == $this->status) {
|
793 |
+
$this->error = __yop_poll('This poll is closed!');
|
794 |
+
$log_to_add ['message'] = __yop_poll('Poll Closed');
|
795 |
+
insert_log_in_db($log_to_add);
|
796 |
return false;
|
797 |
+
} else {
|
798 |
+
if (!$this->is_voted($vote_type, $facebook_user_details, $google_user_details, true, $SuperCookie)) {
|
799 |
+
$voter = array();
|
800 |
+
$voter['poll_id'] = $poll_id;
|
801 |
+
$voter['user_id'] = $current_user->ID;
|
|
|
802 |
$voter['user_type'] = $vote_type;
|
803 |
|
804 |
+
if ($this->user_have_votes_to_vote($voter, $SuperCookie)) {
|
805 |
+
$i = 1;
|
806 |
$cookie = '';
|
807 |
+
$log = array();
|
808 |
+
foreach ($this->questions as &$question) {
|
809 |
$answers = array();
|
810 |
+
if (isset ($request['yop_poll_answer'][$question->ID])) {
|
811 |
+
if ('yes' == $question->allow_multiple_answers) {
|
812 |
+
if (count($request['yop_poll_answer'][$question->ID]) <= intval($question->allow_multiple_answers_number)) {
|
813 |
+
if (count($request['yop_poll_answer'][$question->ID]) >= intval($question->allow_multiple_answers_min_number)) {
|
814 |
$answers = array();
|
815 |
+
foreach ($request['yop_poll_answer'][$question->ID] as $answer) {
|
816 |
+
$new_answer = array();
|
817 |
$new_answer['answer_id'] = $answer;
|
818 |
+
$new_answer['type'] = 'default';
|
819 |
+
if ('other' == $answer) {
|
820 |
$a = new YOP_POLL_Answer_Model();
|
821 |
+
if (isset($request['yop_poll_other_answer'][$question->ID]) && '' != strip_tags(trim($request['yop_poll_other_answer'][$question->ID]))) {
|
822 |
+
$a->type = 'other';
|
823 |
+
$a->poll_id = $poll_id;
|
824 |
+
$a->question_id = $question->ID;
|
825 |
+
$a->answer = strip_tags(trim($request['yop_poll_other_answer'][$question->ID]));
|
826 |
+
$a->answer_date = current_time('mysql');
|
827 |
+
$a->answer_modified = current_time('mysql');
|
828 |
+
$a->status = 'active';
|
829 |
+
$a->question_order = $question->countanswers() + 1;
|
830 |
+
$a->answer_author = $current_user->ID;
|
831 |
$a->save();
|
832 |
|
833 |
+
if (!$a->id) {
|
834 |
+
$this->error = __yop_poll('Other answer for question ') . $i . __yop_poll(' could not be inserted!');
|
835 |
+
$log_to_add ['message'] = __yop_poll('Other answer for question ') . $i . __yop_poll(' could not be inserted');
|
836 |
+
insert_log_in_db($log_to_add);
|
837 |
return false;
|
838 |
}
|
839 |
+
} else {
|
840 |
+
$this->error = __yop_poll('Other answer from question ') . $i . __yop_poll(' is empty');
|
841 |
+
$log_to_add ['message'] = __yop_poll('Other answer from question ') . $i . __yop_poll(' is empty');
|
842 |
+
insert_log_in_db($log_to_add);
|
|
|
843 |
return false;
|
844 |
}
|
845 |
+
$question->addAnswer($a);
|
846 |
$new_answer['answer_id'] = $a->id;
|
847 |
+
$new_answer['type'] = 'other';
|
848 |
+
unset($a);
|
849 |
}
|
850 |
$new_answer['poll_id'] = $poll_id;
|
851 |
$new_answer['vote_id'] = $vote_id;
|
852 |
+
$new_answer['ip'] = yop_poll_get_ip();
|
853 |
$new_answer['user_id'] = $current_user->ID;
|
854 |
|
855 |
$new_answer['user_type'] = 'default';
|
856 |
+
if ($vote_type == 'anonymous' || $vote_type == 'wordpress') {
|
857 |
$new_answer['user_type'] = $vote_type;
|
858 |
}
|
859 |
|
860 |
+
$new_answer['http_referer'] = $_SERVER['HTTP_REFERER'];
|
861 |
+
$new_answer['tr_id'] = $tr_id;
|
862 |
+
$new_answer['host'] = esc_attr(@gethostbyaddr(yop_poll_get_ip()));
|
863 |
$new_answer['other_answer_value'] = '';
|
864 |
|
865 |
$answers[] = $new_answer;
|
866 |
}
|
867 |
+
} else {
|
868 |
+
$this->error = __yop_poll("Too few answers selected for question ") . $i . __yop_poll("! Only more than ") . $question->allow_multiple_answers_min_number . __yop_poll(" answers allowed!");
|
869 |
+
$log_to_add ['message'] = __yop_poll("Too few answers selected for question ") . $i;
|
870 |
+
insert_log_in_db($log_to_add);
|
|
|
871 |
return false;
|
872 |
}
|
873 |
+
} else {
|
874 |
+
$this->error = __yop_poll("Too many answers selected for question ") . $i . __yop_poll("! Only ") . $question->allow_multiple_answers_number . __yop_poll(" answers allowed!");
|
875 |
+
$log_to_add ['message'] = __yop_poll("Too many answers selected for question ") . $i;
|
876 |
+
insert_log_in_db($log_to_add);
|
|
|
877 |
return false;
|
878 |
}
|
879 |
+
} else {
|
880 |
+
$new_answer = array();
|
|
|
881 |
$new_answer['answer_id'] = $request['yop_poll_answer'][$question->ID];
|
882 |
+
$new_answer['type'] = 'default';
|
883 |
+
if ('other' == $request['yop_poll_answer'][$question->ID]) {
|
884 |
$a = new YOP_POLL_Answer_Model();
|
885 |
+
if (isset($request['yop_poll_other_answer'][$question->ID]) && '' != strip_tags(trim($request['yop_poll_other_answer'][$question->ID]))) {
|
886 |
+
$a->type = 'other';
|
887 |
+
$a->poll_id = $poll_id;
|
888 |
+
$a->question_id = $question->ID;
|
889 |
+
$a->answer = strip_tags(trim($request['yop_poll_other_answer'][$question->ID]));
|
890 |
+
$a->answer_date = current_time('mysql');
|
891 |
$a->question_order = $question->countanswers();
|
892 |
+
$a->answer_author = $current_user->ID;
|
893 |
+
$a->votes = 0;
|
894 |
$a->save();
|
895 |
|
896 |
+
if (!$a->id) {
|
897 |
+
$this->error = __yop_poll("Other answer for question ") . $i . __yop_poll(" could not be inserted!");
|
898 |
+
$log_to_add ['message'] = __yop_poll("Other answer for question ") . $i . __yop_poll(" could not be inserted");
|
899 |
+
insert_log_in_db($log_to_add);
|
900 |
return false;
|
901 |
}
|
902 |
+
} else {
|
903 |
+
$this->error = __yop_poll("Other answer from question ") . $i . ' ' . __yop_poll('is empty');
|
904 |
+
$log_to_add ['message'] = __yop_poll("Other answer from question ") . $i . ' ' . __yop_poll('empty');
|
905 |
+
insert_log_in_db($log_to_add);
|
|
|
906 |
return false;
|
907 |
}
|
908 |
|
909 |
+
$question->addAnswer($a);
|
910 |
$new_answer['answer_id'] = $a->id;
|
911 |
+
$new_answer['type'] = 'other';
|
912 |
+
unset($a);
|
913 |
}
|
914 |
|
915 |
$new_answer['poll_id'] = $poll_id;
|
916 |
$new_answer['vote_id'] = $vote_id;
|
917 |
+
$new_answer['ip'] = yop_poll_get_ip();
|
918 |
$new_answer['user_id'] = $current_user->ID;
|
919 |
|
920 |
$new_answer['user_type'] = 'default';
|
921 |
|
922 |
|
923 |
+
$new_answer['http_referer'] = $_SERVER['HTTP_REFERER'];
|
924 |
+
$new_answer['tr_id'] = $tr_id;
|
925 |
+
$new_answer['host'] = esc_attr(@gethostbyaddr(yop_poll_get_ip()));
|
926 |
$new_answer['other_answer_value'] = '';
|
927 |
+
$answers[] = $new_answer;
|
928 |
}
|
929 |
|
930 |
+
if (count($answers) > 0) {
|
931 |
+
$custom_fields = array();
|
932 |
$poll_custom_fields = $question->custom_fields;
|
933 |
|
934 |
+
if (count($poll_custom_fields) > 0) {
|
935 |
|
936 |
+
if (isset($request['yop_poll_customfield'][$question->ID])) {
|
937 |
|
938 |
+
foreach ($poll_custom_fields as $custom_field) {
|
939 |
|
940 |
+
if (isset($request['yop_poll_customfield'][$question->ID][$custom_field->ID])) {
|
941 |
|
942 |
+
if ('' == trim(strip_tags($request['yop_poll_customfield'][$question->ID][$custom_field->ID])) && 'yes' == $custom_field->required) {
|
943 |
+
$this->error = __yop_poll("Custom field ") . $custom_field->custom_field . __yop_poll(" from question ") . $i . ' ' . __yop_poll("is required") . "!";
|
944 |
+
$log_to_add ['message'] = __yop_poll("Custom field ") . $custom_field->custom_field . __yop_poll(" from question ") . $i . ' ' . __yop_poll("required");
|
945 |
+
insert_log_in_db($log_to_add);
|
946 |
return false;
|
947 |
+
} else {
|
948 |
+
if (trim(strip_tags($request['yop_poll_customfield'][$question->ID][$custom_field->ID])) != '') {
|
949 |
+
$new_custom_field = array();
|
950 |
+
$new_custom_field['poll_id'] = $poll_id;
|
951 |
+
$new_custom_field['question_id'] = $question->ID;
|
952 |
+
$new_custom_field['vote_id'] = $vote_id;
|
|
|
953 |
$new_custom_field['custom_field_id'] = $custom_field->ID;
|
954 |
+
$new_custom_field['user_id'] = $current_user->ID;
|
955 |
|
956 |
$new_custom_field['user_type'] = 'default';
|
957 |
|
958 |
+
if ($vote_type == 'wordpress' || $vote_type == 'anonymous') {
|
959 |
$new_custom_field['user_type'] = $vote_type;
|
960 |
}
|
961 |
|
962 |
+
$new_custom_field['custom_field_value'] = strip_tags(trim($request['yop_poll_customfield'][$question->ID][$custom_field->ID]));
|
963 |
+
$custom_fields[] = $new_custom_field;
|
964 |
|
965 |
}
|
966 |
}
|
967 |
+
} else {
|
968 |
+
$this->error = __yop_poll("Custom field ") . '"' . $custom_field->custom_field . '"' . __yop_poll(" from question ") . $i . ' ' . __yop_poll("is missing ") . '!';
|
|
|
969 |
|
970 |
+
$log_to_add ['message'] = __yop_poll("Custom field ") . '"' . $custom_field->custom_field . '"' . __yop_poll(" from question ") . $i . ' ' . __yop_poll("missing");
|
971 |
+
insert_log_in_db($log_to_add);
|
972 |
return false;
|
973 |
}
|
974 |
}
|
975 |
+
} else {
|
976 |
+
$this->error = __yop_poll("Custom fields from question ") . $i . ' ' . __yop_poll("are missing") . '!';
|
977 |
+
$log_to_add ['message'] = __yop_poll("Custom fields from question ") . $i . ' ' . __yop_poll("missing") . '!';
|
978 |
+
insert_log_in_db($log_to_add);
|
|
|
979 |
return false;
|
980 |
}
|
981 |
}
|
982 |
|
983 |
+
if ('yes' == $this->use_captcha) {
|
984 |
+
require_once(YOP_POLL_INC . '/securimage.php');
|
985 |
+
$img = new Yop_Poll_Securimage();
|
986 |
$img->namespace = 'yop_poll_' . $poll_id . $unique_id;
|
987 |
+
if ($img->check($_REQUEST['yop_poll_captcha_input'][$poll_id])) {
|
988 |
$mail_notifications_answers[$question->ID] = array();
|
989 |
|
990 |
+
$add_to_log = $this->update_votes($question, $answers, $votes, $mail_notifications_answers[$question->ID], $facebook_user_details['id'], $google_user_details['id']);
|
991 |
|
992 |
$log["q-" . $question->ID]['question'] = $question->question;
|
993 |
+
$log["q-" . $question->ID]['a'] = $add_to_log['a'];
|
994 |
+
$log["q-" . $question->ID]['answers'] = $add_to_log['answers'];
|
995 |
|
996 |
+
$mail_notifications_answers[$question->ID] = trim($mail_notifications_answers[$question->ID], '<br>');
|
997 |
|
998 |
$mail_notifications_custom_fields[$question->ID] = '';
|
999 |
+
foreach ($custom_fields as $custom_field) {
|
1000 |
|
1001 |
+
if ('anonymous' == $vote_type) {
|
1002 |
$custom_field['user_id'] = 0;
|
1003 |
}
|
1004 |
$custom_field['tr_id'] = $tr_id;
|
1005 |
+
self::insert_vote_custom_field_in_database($custom_field);
|
1006 |
|
1007 |
+
$cf = $question->getCustomFieldById($custom_field['custom_field_id']);
|
1008 |
|
1009 |
$mail_notifications_custom_fields[$question->ID][$cf->custom_field] = $custom_field['custom_field_value'];
|
1010 |
}
|
1011 |
|
1012 |
+
if ('yes' == $this->number_of_votes_per_user) {
|
1013 |
+
$this->success = str_replace('%USER-VOTES-LEFT%', intval($this->number_of_votes_per_user) - $this->get_voter_number_of_votes($voter), $poll_options['message_after_vote']);
|
1014 |
+
} else {
|
1015 |
+
$this->success = str_replace('%USER-VOTES-LEFT%', '', $this->message_after_vote);
|
|
|
1016 |
}
|
1017 |
+
} else {
|
1018 |
+
$this->error = __yop_poll("Incorrect security code entered!");
|
1019 |
+
$log_to_add ['message'] = __yop_poll("Incorrect security code entered");
|
1020 |
+
insert_log_in_db($log_to_add);
|
|
|
1021 |
return false;
|
1022 |
}
|
1023 |
+
} else {
|
|
|
1024 |
$mail_notifications_answers[$question->ID] = array();
|
1025 |
|
1026 |
+
$add_to_log = $this->update_votes($question, $answers, $votes, $mail_notifications_answers[$question->ID], $vote_type, $facebook_user_details['id'], $google_user_details['id']);
|
1027 |
|
1028 |
$log["q-" . $question->ID]['question'] = $question->question;
|
1029 |
+
$log["q-" . $question->ID]['id'] = $question->ID;
|
1030 |
+
$log["q-" . $question->ID]['a'] = $add_to_log['a'];
|
1031 |
+
$log["q-" . $question->ID]['answers'] = $add_to_log['answers'];
|
1032 |
|
1033 |
|
1034 |
$mail_notifications_custom_fields[$question->ID] = array();
|
1035 |
$add_to_log = array();
|
1036 |
+
foreach ($custom_fields as $custom_field) {
|
1037 |
|
1038 |
+
if ('google' == $vote_type) {
|
1039 |
$custom_field['user_id'] = $google_user_details['id'];
|
1040 |
}
|
1041 |
+
if ('anonymous' == $vote_type) {
|
1042 |
$custom_field['user_id'] = 0;
|
1043 |
}
|
1044 |
$custom_field['tr_id'] = $tr_id;
|
1045 |
|
1046 |
+
$cf_id = self::insert_vote_custom_field_in_database($custom_field);
|
1047 |
|
1048 |
$add_to_log[] = $cf_id;
|
1049 |
|
1050 |
+
$cf = $question->getCustomFieldById($custom_field['custom_field_id']);
|
1051 |
|
1052 |
$mail_notifications_custom_fields[$question->ID][$cf->custom_field] = $custom_field['custom_field_value'];
|
1053 |
}
|
1054 |
$log["q-" . $question->ID]['cf'] = $add_to_log;
|
1055 |
|
1056 |
+
if ('yes' == $this->number_of_votes_per_user) {
|
1057 |
+
$this->success = str_replace('%USER-VOTES-LEFT%', intval($this->number_of_votes_per_user) - $this->get_voter_number_of_votes($voter), $this->message_after_vote);
|
1058 |
+
} else {
|
1059 |
+
$this->success = str_replace('%USER-VOTES-LEFT%', '', $this->message_after_vote);
|
|
|
1060 |
}
|
1061 |
}
|
1062 |
+
} else {
|
1063 |
+
$this->error = __yop_poll("No vote registered!");
|
1064 |
+
$log_to_add ['message'] = __yop_poll("No vote registered");
|
1065 |
+
insert_log_in_db($log_to_add);
|
|
|
1066 |
return false;
|
1067 |
}
|
1068 |
+
} else {
|
1069 |
+
$this->error = __yop_poll("No answer selected for question ") . $i;
|
1070 |
+
$log_to_add ['message'] = __yop_poll("No answer selected for question ") . $i;
|
1071 |
+
insert_log_in_db($log_to_add);
|
|
|
1072 |
return false;
|
1073 |
}
|
1074 |
+
$i++;
|
1075 |
}
|
1076 |
+
} else {
|
1077 |
+
$this->error = __yop_poll("You have run out of votes!");
|
1078 |
+
$log_to_add ['message'] = __yop_poll("Run out of votes");
|
1079 |
+
insert_log_in_db($log_to_add);
|
|
|
1080 |
return false;
|
1081 |
}
|
1082 |
+
} else {
|
1083 |
+
$this->error = __yop_poll("You Already voted!");
|
1084 |
+
$log_to_add ['message'] = __yop_poll("Already Voted");
|
1085 |
+
insert_log_in_db($log_to_add);
|
|
|
1086 |
return false;
|
1087 |
}
|
1088 |
}
|
1089 |
+
} else {
|
1090 |
+
$this->error = __yop_poll("This poll is closed!");
|
1091 |
+
$log_to_add ['message'] = __yop_poll("Poll Closed");
|
1092 |
+
insert_log_in_db($log_to_add);
|
|
|
1093 |
return false;
|
1094 |
}
|
1095 |
+
} else {
|
1096 |
+
$this->error = __yop_poll("You can vote once the poll starts!");
|
1097 |
+
$log_to_add ['message'] = __yop_poll("Poll not started");
|
1098 |
+
insert_log_in_db($log_to_add);
|
|
|
1099 |
return false;
|
1100 |
}
|
1101 |
+
} else {
|
1102 |
+
$this->error = __yop_poll("You are not allowed to vote!");
|
1103 |
+
$log_to_add ['message'] = __yop_poll("Not allowed to vote");
|
1104 |
+
insert_log_in_db($log_to_add);
|
|
|
1105 |
return false;
|
1106 |
}
|
1107 |
+
} else {
|
1108 |
+
$this->error = __yop_poll("You are not allowed to vote!");
|
|
|
1109 |
return false;
|
1110 |
}
|
1111 |
|
1112 |
+
} else {
|
1113 |
+
$this->error = __yop_poll("Bad Request!");
|
1114 |
+
$log_to_add ['message'] = __yop_poll("Bad request");
|
1115 |
+
insert_log_in_db($log_to_add);
|
|
|
1116 |
return false;
|
1117 |
}
|
1118 |
|
1119 |
+
if ($this->send_email_notifications == "yes") {
|
1120 |
+
$this->sendMail($mail_notifications_answers, $mail_notifications_custom_fields, $vote_id);
|
1121 |
}
|
1122 |
|
1123 |
$this->update_poll_total_votes(1);
|
1124 |
|
1125 |
+
$log_to_add ['message'] = __yop_poll('Success');
|
1126 |
+
$log_to_add ['vote_details'] = json_encode($log);
|
1127 |
|
1128 |
+
insert_log_in_db($log_to_add);
|
1129 |
+
$ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $log_to_add['ip']));
|
1130 |
$log_to_add['country'] = $ip_data->geoplugin_countryName;
|
1131 |
+
insert_result_in_db($log_to_add);
|
1132 |
|
1133 |
+
$this->set_vote_cookie(json_encode($log), $vote_type, $facebook_user_details, $google_user_details);
|
1134 |
|
1135 |
$this->vote = true;
|
1136 |
+
$this->poll_total_votes += 1;
|
1137 |
|
1138 |
+
return do_shortcode($this->return_poll_html(array('tr_id' => $tr_id, 'location' => $location)));
|
1139 |
}
|
1140 |
|
1141 |
+
function is_voted_supercookie($SuperCookie)
|
1142 |
+
{
|
1143 |
+
$current_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s", mktime()) . " + 365 day"));
|
1144 |
+
$cookie = explode("=", $SuperCookie);
|
1145 |
+
$num_votes = explode(";", $cookie[1]);
|
1146 |
+
if ($num_votes[0] == 0) {
|
1147 |
return true;
|
1148 |
}
|
1149 |
+
$cookie_expire = convert_date($cookie[2], "Y-m-d H:i:s");
|
1150 |
|
1151 |
|
1152 |
+
if (isset($this->blocking_voters_interval_value)) {
|
1153 |
$value = $this->blocking_voters_interval_value;
|
1154 |
}
|
1155 |
$unit = 'days';
|
1156 |
+
if (isset($this->blocking_voters_interval_unit)) {
|
1157 |
$unit = $this->blocking_voters_interval_unit;
|
1158 |
}
|
1159 |
|
1160 |
+
switch ($unit) {
|
1161 |
case 'seconds' :
|
1162 |
$expire_cookie = $value;
|
1163 |
break;
|
1164 |
case 'minutes' :
|
1165 |
+
$expire_cookie = (60 * $value);
|
1166 |
break;
|
1167 |
case 'hours' :
|
1168 |
+
$expire_cookie = (60 * 60 * $value);
|
1169 |
break;
|
1170 |
case 'days' :
|
1171 |
+
$expire_cookie = (60 * 60 * 24 * $value);
|
1172 |
break;
|
1173 |
}
|
1174 |
+
$timeFirst = strtotime($current_time);
|
1175 |
+
$timeSecond = strtotime($cookie_expire);
|
1176 |
$differenceInSeconds = $timeFirst - $timeSecond;
|
1177 |
+
if ($differenceInSeconds >= 31556926) {
|
1178 |
return true;
|
1179 |
}
|
1180 |
+
if ($expire_cookie > $differenceInSeconds) {
|
1181 |
return false;
|
1182 |
}
|
1183 |
return true;
|
1184 |
}
|
1185 |
|
1186 |
+
private function update_votes(&$question, $answers, &$votes, &$mail_notification = '', $vote_type, $facebook_user_id, $google_user_id)
|
1187 |
+
{
|
1188 |
|
1189 |
+
foreach ($answers as $answer) {
|
1190 |
|
1191 |
+
$answer_to_update = & $question->getAnswerById($answer['answer_id']);
|
1192 |
|
1193 |
|
1194 |
+
if ('anonymous' == $vote_type) {
|
1195 |
$answer['user_id'] = 0;
|
1196 |
}
|
1197 |
|
1198 |
+
if ($answer['type'] == 'other') {
|
1199 |
+
if ('yes' == $question->add_other_answers_to_default_answers) {
|
1200 |
$answer_to_update->type = 'text';
|
1201 |
+
$answer['type'] = 'text';
|
1202 |
}
|
1203 |
}
|
1204 |
+
$votes++;
|
1205 |
|
1206 |
+
$answer_to_update->answer_modified = current_time('mysql');
|
1207 |
+
$answer_to_update->answer_status = 'active';
|
1208 |
+
$answer_to_update->votes = intval($answer_to_update->votes) + 1;
|
1209 |
|
1210 |
$answer_to_update->save();
|
1211 |
|
1212 |
+
$add_to_log['a'][] = $answer_to_update->ID;
|
1213 |
$add_to_log['answers'][] = $answer_to_update->answer;
|
1214 |
+
$mail_notification[] = $answer_to_update->answer;
|
1215 |
|
1216 |
+
unset($answer_to_update);
|
1217 |
}
|
1218 |
return $add_to_log;
|
1219 |
}
|
1220 |
|
1221 |
+
private static function insert_vote_custom_field_in_database($custom_field = array())
|
1222 |
+
{
|
1223 |
global $wpdb;
|
1224 |
|
1225 |
+
$custom_field['custom_field_value'] = strip_tags($custom_field['custom_field_value']);
|
1226 |
+
$wpdb->query($wpdb->prepare("
|
1227 |
INSERT INTO " . $wpdb->yop_poll_votes_custom_fields . "
|
1228 |
SET
|
1229 |
poll_id = %d,
|
1235 |
custom_field_value = %s,
|
1236 |
tr_id = %s,
|
1237 |
vote_date = %s
|
1238 |
+
", $custom_field['poll_id'], $custom_field['question_id'], $custom_field['vote_id'], $custom_field['custom_field_id'], $custom_field['user_id'], $custom_field['user_type'], $custom_field['custom_field_value'], $custom_field['tr_id'], current_time('mysql')));
|
1239 |
return $wpdb->insert_id;
|
1240 |
}
|
1241 |
|
1242 |
+
private function update_poll_total_votes($votes = 0)
|
1243 |
+
{
|
1244 |
global $wpdb;
|
1245 |
+
$wpdb->query($wpdb->prepare("
|
1246 |
UPDATE {$wpdb->yop_polls}
|
1247 |
SET
|
1248 |
poll_total_votes = poll_total_votes + %d
|
1249 |
WHERE
|
1250 |
ID = %d
|
1251 |
+
", $votes, $this->ID));
|
1252 |
|
1253 |
}
|
1254 |
|
1255 |
public function return_poll_html(
|
1256 |
$attr = array(
|
1257 |
+
'tr_id' => '',
|
1258 |
'location' => 'page',
|
1259 |
'load_css' => false,
|
1260 |
+
'load_js' => false,
|
1261 |
+
'show_results' => ''
|
1262 |
)
|
1263 |
+
)
|
1264 |
+
{
|
1265 |
+
$time_format = "H:i:s";
|
1266 |
+
$options = get_option('yop_poll_options');
|
1267 |
+
if ($options['date_format'] == "UE")
|
1268 |
+
$date_format = "d-m-Y"; else {
|
1269 |
+
$date_format = "m-d-Y";
|
1270 |
+
}
|
1271 |
+
$date_format = $date_format . ' ' . $time_format;
|
1272 |
+
$tr_id = isset($attr['tr_id']) ? $attr['tr_id'] : '';
|
1273 |
+
$show_results = isset($attr['show_results']) ? $attr['show_results'] : '';
|
1274 |
+
$location = isset($attr['location']) ? $attr['location'] : 'page';
|
1275 |
+
$load_css = isset($attr['load_css']) ? $attr['load_css'] : false;
|
1276 |
$unique_id = $this->unique_id;
|
1277 |
+
$poll_id = $this->ID;
|
1278 |
+
if (!$poll_id) {
|
1279 |
return '';
|
1280 |
}
|
1281 |
|
1282 |
//Get template id based on location(widget/page)
|
1283 |
+
if ('widget' == $location) {
|
1284 |
$template_id = $this->widget_template;
|
1285 |
+
} else {
|
|
|
1286 |
$template_id = $this->template;
|
1287 |
}
|
1288 |
|
1290 |
/**
|
1291 |
* Init Options
|
1292 |
*/
|
1293 |
+
$general_options = get_option("yop_poll_options");
|
1294 |
+
foreach ($general_options as $key => $value) {
|
1295 |
+
if (!isset($this->$key)) {
|
1296 |
$this->$key = $value;
|
1297 |
}
|
1298 |
}
|
1299 |
|
1300 |
+
if ('' == $template_id) {
|
1301 |
//get default template
|
1302 |
$template_details = self::get_poll_template_from_database();
|
1303 |
+
} else {
|
1304 |
+
$template_details = self::get_poll_template_from_database($template_id);
|
|
|
1305 |
}
|
1306 |
|
1307 |
$template_css = $template_details['css'];
|
1308 |
+
$template_details['before_vote_template'] = str_replace('id = "yop-poll-li-answer-%POLL-ID%-%QUESTION-ID%"', '', $template_details['before_vote_template']);
|
1309 |
+
$template_details['before_vote_template'] = str_replace('id = "yop-poll-li-custom-%POLL-ID%-%QUESTION-ID%"', '', $template_details['before_vote_template']);
|
1310 |
+
$template_details['before_vote_template'] = str_replace('id = "yop-poll-customs-%POLL-ID%-%QUESTION-ID%"', '', $template_details['before_vote_template']);
|
1311 |
+
$template_details['after_end_date_template'] = str_replace('id = "pds-feedback-label-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_end_date_template']);
|
1312 |
+
$template_details['after_vote_template'] = str_replace('id = "pds-feedback-label-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_vote_template']);
|
1313 |
+
$template_details['after_end_date_template'] = str_replace('id = "yop-poll-li-result-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_end_date_template']);
|
1314 |
+
$template_details['after_vote_template'] = str_replace('id = "yop-poll-li-result-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_vote_template']);
|
1315 |
+
$template_details['after_end_date_template'] = str_replace('id = "pds-answer-text-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_end_date_template']);
|
1316 |
+
$template_details['after_vote_template'] = str_replace('id = "pds-answer-text-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_vote_template']);
|
1317 |
+
$template_details['after_end_date_template'] = str_replace('id = "pds-feedback-result-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_end_date_template']);
|
1318 |
+
$template_details['after_vote_template'] = str_replace('id = "pds-feedback-result-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_vote_template']);
|
1319 |
+
$template_details['after_end_date_template'] = str_replace('id = "pds-feedback-per-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_end_date_template']);
|
1320 |
+
$template_details['after_vote_template'] = str_replace('id = "pds-feedback-per-%POLL-ID%-%QUESTION-ID%"', '', $template_details['after_vote_template']);
|
1321 |
$poll_details = $this;
|
1322 |
+
$this->vote_button_label = empty($this->vote_button_label) ? $general_options['vote_button_label'] : $this->vote_button_label;
|
1323 |
+
$this->vote_permisions_wordpress_label = empty($this->vote_permisions_wordpress_label) ? $general_options['vote_permisions_wordpress_label'] : $this->vote_permisions_wordpress_label;
|
1324 |
+
$this->vote_permisions_anonymous_label = empty($this->vote_permisions_anonymous_label) ? $general_options['vote_permisions_anonymous_label'] : $this->vote_permisions_anonymous_label;
|
1325 |
|
1326 |
//Translate labels
|
1327 |
+
if (function_exists('icl_translate')) {
|
1328 |
// $poll_details = icl_translate( 'yop_poll', $poll_details->ID . '_poll_title', $poll_details->name );
|
1329 |
+
$this->singular_answer_result_votes_number_label = icl_translate('yop_poll', $poll_details->ID . '_singular_answer_result_votes_number_label', $general_options['singular_answer_result_votes_number_label']);
|
1330 |
+
$this->plural_answer_result_votes_number_label = icl_translate('yop_poll', $poll_details->ID . '_plural_answer_result_votes_number_label', $general_options['plural_answer_result_votes_number_label']);
|
1331 |
+
$this->vote_button_label = icl_translate('yop_poll', $poll_details->ID . '_vote_button_label', empty($this->vote_button_label) ? $general_options['vote_button_label'] : $this->vote_button_label);
|
1332 |
+
$this->view_results_link_label = icl_translate('yop_poll', $poll_details->ID . '_view_results_link_label', $this->view_results_link_label);
|
1333 |
+
$this->view_back_to_vote_link_label = icl_translate('yop_poll', $poll_details->ID . '_view_back_to_vote_link_label', $this->view_back_to_vote_link_label);
|
1334 |
+
$this->view_total_votes_label = icl_translate('yop_poll', $poll_details->ID . '_view_total_votes_label', $this->view_total_votes_label);
|
1335 |
+
$this->view_total_answers_label = icl_translate('yop_poll', $poll_details->ID . '_view_total_answers_label', $this->view_total_answers_label);
|
1336 |
+
$this->view_total_voters_label = icl_translate('yop_poll', $poll_details->ID . '_view_total_voters_label', $this->view_total_voters_label);
|
1337 |
+
$this->archive_link_label = icl_translate('yop_poll', $poll_details->ID . '_archive_link_label', $this->archive_link_label);
|
1338 |
+
$this->answer_result_label = icl_translate('yop_poll', $poll_details->ID . '_answer_result_label', $this->answer_result_label);
|
1339 |
+
$this->vote_permisions_wordpress_label = icl_translate('yop_poll', $poll_details->ID . '_vote_permisions_wordpress_label', $this->vote_permisions_wordpress_label);
|
1340 |
+
$this->vote_share_google_label = icl_translate('yop_poll', $poll_details->ID . '_vote_share_google_label', $this->vote_share_google_label);
|
1341 |
+
$this->vote_permisions_anonymous_label = icl_translate('yop_poll', $poll_details->ID . '_vote_permisions_anonymous_label', $this->vote_permisions_anonymous_label);
|
1342 |
}
|
1343 |
|
1344 |
+
$is_voted = $this->is_voted();
|
1345 |
$current_date = self::get_mysql_curent_date();
|
1346 |
+
if ($current_date >= convert_date($this->poll_start_date, 'Y-m-d H:i:s', 1)) {
|
1347 |
|
1348 |
+
if ($current_date <= convert_date($this->poll_end_date, 'Y-m-d H:i:s', 1)) {
|
1349 |
//poll is active
|
1350 |
+
if (!$is_voted) {
|
1351 |
//user hasn't voted yet
|
1352 |
$template = $template_details['before_vote_template'];
|
1353 |
+
if (isset($show_results) && $show_results == 1) {
|
1354 |
|
1355 |
$template = $template_details['after_vote_template'];
|
1356 |
+
$this->view_results = array('before');
|
1357 |
}
|
1358 |
+
if (in_array('before', $this->view_results)) {
|
1359 |
+
if ($this->is_view_poll_results()) {
|
1360 |
+
$template = str_ireplace('%POLL-ANSWER-RESULT-LABEL%', $this->answer_result_label, $template);
|
1361 |
}
|
1362 |
}
|
1363 |
+
$template = str_ireplace('%POLL-VOTE-BUTTON%', '<button class="yop_poll_vote_button" id="yop_poll_vote-button-' . $this->ID . $unique_id . '" onclick="yop_poll_register_vote(\'' . $this->ID . '\', \'' . $location . '\', \'' . $unique_id . '\'); return false;">' . $this->vote_button_label . '</button>', $template);
|
1364 |
+
} else {
|
|
|
1365 |
//user has voted
|
1366 |
|
1367 |
+
if (
|
1368 |
+
in_array('after', $this->view_results) ||
|
1369 |
+
in_array('before', $this->view_results) ||
|
1370 |
+
(in_array('custom-date', $this->view_results) && self::get_mysql_curent_date() >= convert_date($this->view_results_start_date, 'Y-m-d H:i:s'))
|
1371 |
) {
|
1372 |
|
1373 |
$template = $template_details['after_vote_template'];
|
1374 |
|
1375 |
+
if ($this->is_view_poll_results()) {
|
1376 |
+
$template = str_ireplace('%POLL-ANSWER-RESULT-LABEL%', $this->answer_result_label, $template);
|
1377 |
}
|
1378 |
}
|
1379 |
|
1380 |
+
if ('yes' == $this->view_back_to_vote_link) {
|
1381 |
+
$vote = $this->vote;
|
1382 |
$this->vote = false;
|
1383 |
+
if (!$this->is_voted()) {
|
1384 |
+
$template = str_ireplace('%POLL-BACK-TO-VOTE-LINK%', '<a href="javascript:void(0)" class="yop_poll_back_to_vote_link" id="yop_poll_back_to_vote_link' . $this->ID . $unique_id . '" onClick="yop_poll_back_to_vote(\'' . $this->ID . '\', \'' . $location . '\', \'' . $unique_id . '\')">' . $this->view_back_to_vote_link_label . '</a>', $template);
|
1385 |
}
|
1386 |
$this->vote = $vote;
|
1387 |
}
|
1388 |
|
1389 |
}
|
1390 |
+
} else {
|
|
|
1391 |
//poll has ended
|
1392 |
$template = $template_details['after_end_date_template'];
|
1393 |
+
if (in_array('after-poll-end-date', $this->view_results) || in_array('before', $this->view_results) || in_array('after', $this->view_results)) {
|
1394 |
+
if ($this->is_view_poll_results()) {
|
1395 |
+
$template = str_ireplace('%POLL-ANSWER-RESULT-LABEL%', $this->answer_result_label, $template);
|
1396 |
+
$template = str_ireplace('%POLL-END-DATE%', $this->poll_end_date, $template);
|
1397 |
+
$template = str_ireplace('%POLL-START-DATE%', $this->poll_start_date, $template);
|
1398 |
}
|
1399 |
}
|
1400 |
|
1401 |
}
|
1402 |
+
} else {
|
|
|
1403 |
//poll hasn't started
|
1404 |
$template = $template_details['before_start_date_template'];
|
1405 |
+
$template = str_ireplace('%POLL-END-DATE%', $this->poll_end_date, $template);
|
1406 |
+
$template = str_ireplace('%POLL-START-DATE%', $this->poll_start_date, $template);
|
1407 |
+
if (in_array('before', $this->view_results)) {
|
1408 |
+
if ($this->is_view_poll_results()) {
|
1409 |
+
$template = str_ireplace('%POLL-ANSWER-RESULT-LABEL%', $this->answer_result_label, $template);
|
1410 |
|
1411 |
}
|
1412 |
|
1413 |
}
|
1414 |
}
|
1415 |
|
1416 |
+
if (in_array('custom-date', $this->view_results)) {
|
1417 |
+
$template = str_ireplace('%POLL-END-DATE%', $this->poll_end_date, $template);
|
1418 |
+
$template = str_ireplace('%POLL-START-DATE%', $this->poll_start_date, $template);
|
1419 |
+
if (self::get_mysql_curent_date() >= convert_date($this->view_results_start_date, 'Y-m-d H:i:s', 1)) {
|
1420 |
|
1421 |
+
if ($this->is_view_poll_results()) {
|
1422 |
+
$template = str_ireplace('%POLL-ANSWER-RESULT-LABEL%', $this->answer_result_label, $template);
|
1423 |
}
|
1424 |
}
|
1425 |
}
|
1426 |
+
$template = str_ireplace('%POLL-END-DATE%', $this->poll_end_date, $template);
|
1427 |
+
$template = str_ireplace('%POLL-START-DATE%', $this->poll_start_date, $template);
|
1428 |
+
$template = stripslashes_deep($template);
|
1429 |
|
1430 |
+
$template = str_ireplace('%POLL-ID%', $this->ID . $unique_id, $template);
|
1431 |
+
$template = str_ireplace("%POLL-NAME%", yop_poll_kses(stripslashes($this->poll_title)), $template);
|
1432 |
+
$template = str_ireplace('%POLL-START-DATE%', esc_html(stripslashes(convert_date($this->start_date, $date_format))), $template);
|
1433 |
+
$template = str_ireplace('%POLL-PAGE-URL%', esc_html(yop_poll_kses(stripslashes($this->poll_page_url))), $template);
|
1434 |
|
1435 |
+
if ('01-01-2038 23:59:59' == convert_date($this->poll_end_date, 'Y-m-d H:i:s')) {
|
1436 |
+
$template = str_ireplace('%POLL-END-DATE%', __yop_poll('Never Expire'), $template);
|
1437 |
+
} else {
|
1438 |
+
$template = str_ireplace('%POLL-END-DATE%', esc_html(stripslashes(convert_date($this->end_date, $date_format))), $template);
|
|
|
1439 |
}
|
1440 |
|
1441 |
+
if ('yes' == $this->view_results_link) {
|
1442 |
+
$template = str_ireplace('%POLL-VIEW-RESULT-LINK%', '<a href="javascript:void(0)" class="yop_poll_result_link" id="yop_poll_result_link' . $this->ID . $unique_id . '" onClick="yop_poll_view_results(\'' . $this->ID . '\', \'' . $location . '\', \'' . $unique_id . '\')">' . $this->view_results_link_label . '</a>', $template);
|
1443 |
}
|
1444 |
+
if ('yes' == $this->view_poll_archive_link) {
|
1445 |
+
$template = str_ireplace('%POLL-VIEW-ARCHIVE-LINK%', '<a href="' . get_permalink($this->yop_poll_archive_page_id) . '" class="yop_poll_archive_link" id="yop_poll_archive_link_' . $this->ID . $unique_id . '" >' . $this->archive_link_label . '</a>', $template);
|
1446 |
}
|
1447 |
$poll_total_answers = 0;
|
1448 |
+
foreach ($this->questions as $q) {
|
1449 |
+
foreach ($q->answers as $a)
|
1450 |
+
$poll_total_answers += $a->votes;
|
1451 |
}
|
1452 |
|
1453 |
|
1454 |
+
if ('yes' == $this->view_total_answers) {
|
1455 |
+
$template = str_ireplace('%POLL-TOTAL-ANSWERS-LABEL%', $this->view_total_answers_label, $template);
|
1456 |
+
$template = str_ireplace('%POLL-TOTAL-ANSWERS%', $poll_total_answers, $template);
|
1457 |
}
|
1458 |
+
if ('yes' == $this->view_total_votes) {
|
1459 |
+
$template = str_ireplace('%POLL-TOTAL-VOTES-LABEL%', $this->view_total_votes_label, $template);
|
1460 |
+
$template = str_ireplace('%POLL-TOTAL-VOTES%', $this->poll_total_votes, $template);
|
1461 |
}
|
1462 |
|
1463 |
$msgDivS = false;
|
1464 |
$msgDivE = false;
|
1465 |
|
1466 |
+
if (strpos($template, "%POLL-SUCCESS-MSG%") != false) {
|
1467 |
+
$msgDivS = true;
|
1468 |
+
$template = str_ireplace('%POLL-SUCCESS-MSG%', '<div id="yop-poll-container-success-' . $this->ID . $unique_id . '" class="yop-poll-container-success"></div>', $template);
|
1469 |
}
|
1470 |
+
if (strpos($template, "%POLL-ERROR-MSG%") != false) {
|
1471 |
+
$msgDivE = true;
|
1472 |
+
$template = str_ireplace('%POLL-ERROR-MSG%', '<div id="yop-poll-container-error-' . $this->ID . $unique_id . '" class="yop-poll-container-error"></div>', $template);
|
1473 |
}
|
1474 |
|
1475 |
+
$that = $this;
|
1476 |
|
1477 |
/** Start Question replace*/
|
1478 |
+
$pattern = '\[(\[?)(QUESTION_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
1479 |
+
$template = preg_replace_callback("/$pattern/s", function ($m) use ($that) {
|
1480 |
return $that->question_replace_callback($m);
|
1481 |
+
}, $template);
|
1482 |
/** End Question replace*/
|
1483 |
|
1484 |
|
1485 |
/** Start CAPTCHA replace*/
|
1486 |
+
$pattern = '\[(\[?)(CAPTCHA_CONTAINER)\b([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
|
1487 |
+
$template = preg_replace_callback("/$pattern/s", function ($m) use ($that) {
|
1488 |
return $that->captcha_replace_callback($m);
|
1489 |
+
}, $template);
|
1490 |
/** End CAPTCHA replace*/
|
1491 |
|
1492 |
|
1493 |
+
$temp = self::strip_all_tags($template);
|
1494 |
|
1495 |
$template = "";
|
1496 |
+
if ($load_css) {
|
1497 |
+
$template .= '<style scoped>' . self::return_poll_css($template_css, array("location" => $location)) . ' .yop-poll-forms-display{}' . '</style>';
|
1498 |
|
1499 |
}
|
1500 |
|
1501 |
|
1502 |
$template .= '<div id="yop-poll-container-' . $this->ID . $unique_id . '" class="yop-poll-container">';
|
1503 |
+
if (!$msgDivS) {
|
1504 |
$template .= '<div id="yop-poll-container-success-' . $this->ID . $unique_id . '" class="yop-poll-container-success"></div>';
|
1505 |
}
|
1506 |
+
if (!$msgDivE) {
|
1507 |
$template .= '<div id="yop-poll-container-error-' . $this->ID . $unique_id . '" class="yop-poll-container-error"></div>';
|
1508 |
}
|
1509 |
|
1510 |
+
$template .= '<form id="yop-poll-form-' . $this->ID . $unique_id . '" class="yop-poll-forms yop-poll-forms-display">' . $temp . '<input type="hidden" id="yop-poll-tr-id-' . $this->ID . $unique_id . '" name="yop_poll_tr_id" value="' . $tr_id . '"/>' . wp_nonce_field('yop_poll-' . $this->ID . $unique_id . '-user-actions', 'yop-poll-nonce-' . $this->ID . $unique_id, false, false) . '</form></div>';
|
|
|
1511 |
|
1512 |
|
1513 |
return $template;
|
1514 |
}
|
1515 |
|
1516 |
+
public function captcha_replace_callback($m)
|
1517 |
+
{
|
1518 |
+
$unique_id = $this->unique_id;
|
1519 |
$return_string = '';
|
1520 |
+
$temp_string = '';
|
1521 |
+
|
1522 |
+
if ('yes' == $this->use_captcha) {
|
1523 |
+
$sid = md5(uniqid());
|
1524 |
+
$temp_string = str_ireplace('%CAPTCHA-IMAGE%', '<img class="yop_poll_captcha_image" id="yop_poll_captcha_image_' . $this->ID . $unique_id . '" src="' . admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http')) . '?action=yop_poll_show_captcha&poll_id=' . $this->ID . '&sid=' . $sid . '&unique_id=' . $this->unique_id . '" />', $m[5]);
|
1525 |
+
$temp_string = str_ireplace('%CAPTCHA-INPUT%', '<input type="text" value="" name="yop_poll_captcha_input[' . $this->ID . ']" id="yop-poll-captcha-input-' . $this->ID . $unique_id . '" />', $temp_string);
|
1526 |
+
$temp_string = str_ireplace('%RELOAD-CAPTCHA-IMAGE%', '<a href="javascript:void(0)"><img src="' . YOP_POLL_URL . 'images/captcha_reload.png' . '" alt="' . __('Reload', 'yop_poll') . '" onClick="yop_poll_reloadCaptcha(' . "'" . $this->ID . "', '" . $this->unique_id . "'" . ')" /></a>', $temp_string);
|
1527 |
+
$temp_string = str_ireplace('%CAPTCHA-LABEL%', "<br>" . __yop_poll('Enter the code'), $temp_string);
|
1528 |
+
$temp_string = str_ireplace('%CAPTCHA-PLAY%', '<object type="application/x-shockwave-flash" data="' . YOP_POLL_URL . 'captcha/securimage_play.swf?bgcol=#ffffff&icon_file=' . YOP_POLL_URL . 'images/captcha-audio.gif&audio_file=' . urlencode(admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http')) . '?action=yop_poll_play_captcha&poll_id=' . $this->ID . '&unique_id=' . $this->unique_id) . '" height="30" width="30">
|
1529 |
+
<param name="movie" value="' . YOP_POLL_URL . 'captcha/securimage_play.swf?bgcol=#ffffff&icon_file=' . YOP_POLL_URL . 'images/captcha-audio.gif&audio_file=' . urlencode(admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http')) . '?action=yop_poll_play_captcha&poll_id=' . $this->ID . '&unique_id=' . $this->unique_id) . '" />
|
1530 |
+
</object>', $temp_string);
|
1531 |
}
|
1532 |
$return_string .= $temp_string;
|
1533 |
|
readme.txt
CHANGED
@@ -142,6 +142,19 @@ You can have only one question per poll. If you want to ask more than one questi
|
|
142 |
|
143 |
== Changelog ==
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
= 5.7.4 =
|
146 |
* Fixed security issue. A big thank you to [g0blin Research](https://twitter.com/g0blinResearch) for his help in getting this issue fixed
|
147 |
|
142 |
|
143 |
== Changelog ==
|
144 |
|
145 |
+
= 5.7.6 =
|
146 |
+
* Fixed issues with cloning poll
|
147 |
+
* Fixed conflicts with different plugins
|
148 |
+
* Fixed issue with pagination on archive page
|
149 |
+
* Fixed issue with logs page
|
150 |
+
* Fixed issue with facebook voting
|
151 |
+
* Added new shortcuts for email notifications
|
152 |
+
* Added new column for username in view votes page
|
153 |
+
|
154 |
+
= 5.7.5 =
|
155 |
+
* Fixed issue with vote button not showing up
|
156 |
+
* Other minor fixes
|
157 |
+
|
158 |
= 5.7.4 =
|
159 |
* Fixed security issue. A big thank you to [g0blin Research](https://twitter.com/g0blinResearch) for his help in getting this issue fixed
|
160 |
|
templates/polls_add_edit_template.html
CHANGED
@@ -62,7 +62,7 @@
|
|
62 |
{% endif %}
|
63 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
64 |
|
65 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
66 |
<p>
|
67 |
{{ __('Green v4 Pro')}}
|
68 |
</p><br>
|
@@ -70,7 +70,7 @@
|
|
70 |
</li>
|
71 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
72 |
|
73 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
74 |
<p>
|
75 |
{{ __('Red Pro')}}
|
76 |
</p><br>
|
@@ -78,7 +78,7 @@
|
|
78 |
</li>
|
79 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
80 |
|
81 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
82 |
<p>
|
83 |
{{ __('Green v1 Pro')}}
|
84 |
</p><br>
|
@@ -86,7 +86,7 @@
|
|
86 |
</li>
|
87 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
88 |
|
89 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
90 |
<p>
|
91 |
{{ __('Orange v1 Pro')}}
|
92 |
</p><br>
|
@@ -94,7 +94,7 @@
|
|
94 |
</li>
|
95 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
96 |
|
97 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
98 |
<p>
|
99 |
{{ __('Dark Pro')}}
|
100 |
</p><br>
|
@@ -102,7 +102,7 @@
|
|
102 |
</li>
|
103 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
104 |
|
105 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
106 |
<p>
|
107 |
{{ __('Grey v3 Pro')}}
|
108 |
</p><br>
|
@@ -110,7 +110,7 @@
|
|
110 |
</li>
|
111 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
112 |
|
113 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
114 |
<p>
|
115 |
{{ __('Grey v2 Pro')}}
|
116 |
</p><br>
|
@@ -118,7 +118,7 @@
|
|
118 |
</li>
|
119 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
120 |
|
121 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
122 |
<p>
|
123 |
{{ __('Grey v1 Pro')}}
|
124 |
</p><br>
|
@@ -126,7 +126,7 @@
|
|
126 |
</li>
|
127 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
128 |
|
129 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
130 |
<p>
|
131 |
{{ __('Grey Pro')}}
|
132 |
</p><br>
|
@@ -134,7 +134,7 @@
|
|
134 |
</li>
|
135 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
136 |
|
137 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
138 |
<p>
|
139 |
{{ __('Blue v3 Pro')}}
|
140 |
</p><br>
|
@@ -142,7 +142,7 @@
|
|
142 |
</li>
|
143 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
144 |
|
145 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
146 |
<p>
|
147 |
{{ __('Blue v2 Pro')}}
|
148 |
</p><br>
|
@@ -150,7 +150,7 @@
|
|
150 |
</li>
|
151 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
152 |
|
153 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
154 |
<p>
|
155 |
{{ __('Blue v1 Pro')}}
|
156 |
</p><br>
|
@@ -158,7 +158,7 @@
|
|
158 |
</li>
|
159 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
160 |
|
161 |
-
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li
|
162 |
<p>
|
163 |
{{ __('White Pro')}}
|
164 |
</p><br>
|
@@ -222,9 +222,32 @@
|
|
222 |
<div class="yop-poll-widget-slider" id="yop-poll-widget-template-slider">
|
223 |
|
224 |
<ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
226 |
|
227 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
228 |
<p>
|
229 |
{{ __('Red Pro')}}
|
230 |
</p><br>
|
@@ -232,7 +255,7 @@
|
|
232 |
</li>
|
233 |
<li id="yop-poll-page-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
234 |
|
235 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
236 |
<p>
|
237 |
{{ __('Green v1 Pro')}}
|
238 |
</p><br>
|
@@ -240,7 +263,7 @@
|
|
240 |
</li>
|
241 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
242 |
|
243 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
244 |
<p>
|
245 |
{{ __('Orange v1 Pro')}}
|
246 |
</p><br>
|
@@ -248,7 +271,7 @@
|
|
248 |
</li>
|
249 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
250 |
|
251 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
252 |
<p>
|
253 |
{{ __('Dark Pro')}}
|
254 |
</p><br>
|
@@ -256,7 +279,7 @@
|
|
256 |
</li>
|
257 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
258 |
|
259 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
260 |
<p>
|
261 |
{{ __('Grey v3 Pro')}}
|
262 |
</p><br>
|
@@ -264,7 +287,7 @@
|
|
264 |
</li>
|
265 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
266 |
|
267 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
268 |
<p>
|
269 |
{{ __('Grey v2 Pro')}}
|
270 |
</p><br>
|
@@ -272,7 +295,7 @@
|
|
272 |
</li>
|
273 |
<li id="yop-poll-page-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
274 |
|
275 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
276 |
<p>
|
277 |
{{ __('Grey v1 Pro')}}
|
278 |
</p><br>
|
@@ -280,7 +303,7 @@
|
|
280 |
</li>
|
281 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
282 |
|
283 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
284 |
<p>
|
285 |
{{ __('Grey Pro')}}
|
286 |
</p><br>
|
@@ -289,7 +312,7 @@
|
|
289 |
|
290 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
291 |
|
292 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
293 |
<p>
|
294 |
{{ __('Blue v3 Pro')}}
|
295 |
</p><br>
|
@@ -297,7 +320,7 @@
|
|
297 |
</li>
|
298 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
299 |
|
300 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
301 |
<p>
|
302 |
{{ __('Blue v2 Pro')}}
|
303 |
</p><br>
|
@@ -305,7 +328,7 @@
|
|
305 |
</li>
|
306 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
307 |
|
308 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
309 |
<p>
|
310 |
{{ __('Blue v1 Pro')}}
|
311 |
</p><br>
|
@@ -314,7 +337,7 @@
|
|
314 |
|
315 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
316 |
|
317 |
-
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li
|
318 |
<p>
|
319 |
{{ __('White Pro')}}
|
320 |
</p><br>
|
@@ -328,29 +351,7 @@
|
|
328 |
|
329 |
|
330 |
|
331 |
-
{% if count( templates ) > 0 %}
|
332 |
-
|
333 |
-
{% set i = 0 %}
|
334 |
-
|
335 |
-
{% for template in templates %}
|
336 |
-
|
337 |
-
<li id="yop-poll-widget-template-{{template.id}}" style="cursor: pointer;margin-left:4px;margin-right:4px"
|
338 |
-
|
339 |
-
class='yop-poll-widget-template-li {% if current_poll.widget_template == template.id %} yop-poll-widget-template-selected {% endif%}'
|
340 |
-
|
341 |
-
onclick="yop_poll_select_template({{template.id}}, 'widget')">
|
342 |
|
343 |
-
<p>{{template.name|e}}</p> <br>
|
344 |
-
|
345 |
-
{{template.preview|raw}}
|
346 |
-
|
347 |
-
</li>
|
348 |
-
|
349 |
-
{% set i = i+1 %}
|
350 |
-
|
351 |
-
{% endfor %}
|
352 |
-
|
353 |
-
{% endif %}
|
354 |
|
355 |
</ul>
|
356 |
|
62 |
{% endif %}
|
63 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
64 |
|
65 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy' >
|
66 |
<p>
|
67 |
{{ __('Green v4 Pro')}}
|
68 |
</p><br>
|
70 |
</li>
|
71 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
72 |
|
73 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy' >
|
74 |
<p>
|
75 |
{{ __('Red Pro')}}
|
76 |
</p><br>
|
78 |
</li>
|
79 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
80 |
|
81 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
82 |
<p>
|
83 |
{{ __('Green v1 Pro')}}
|
84 |
</p><br>
|
86 |
</li>
|
87 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
88 |
|
89 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
90 |
<p>
|
91 |
{{ __('Orange v1 Pro')}}
|
92 |
</p><br>
|
94 |
</li>
|
95 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
96 |
|
97 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
98 |
<p>
|
99 |
{{ __('Dark Pro')}}
|
100 |
</p><br>
|
102 |
</li>
|
103 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
104 |
|
105 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
106 |
<p>
|
107 |
{{ __('Grey v3 Pro')}}
|
108 |
</p><br>
|
110 |
</li>
|
111 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
112 |
|
113 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
114 |
<p>
|
115 |
{{ __('Grey v2 Pro')}}
|
116 |
</p><br>
|
118 |
</li>
|
119 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
120 |
|
121 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
122 |
<p>
|
123 |
{{ __('Grey v1 Pro')}}
|
124 |
</p><br>
|
126 |
</li>
|
127 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
128 |
|
129 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
130 |
<p>
|
131 |
{{ __('Grey Pro')}}
|
132 |
</p><br>
|
134 |
</li>
|
135 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
136 |
|
137 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
138 |
<p>
|
139 |
{{ __('Blue v3 Pro')}}
|
140 |
</p><br>
|
142 |
</li>
|
143 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
144 |
|
145 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
146 |
<p>
|
147 |
{{ __('Blue v2 Pro')}}
|
148 |
</p><br>
|
150 |
</li>
|
151 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
152 |
|
153 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy'>
|
154 |
<p>
|
155 |
{{ __('Blue v1 Pro')}}
|
156 |
</p><br>
|
158 |
</li>
|
159 |
<li id="yop-poll-1"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
160 |
|
161 |
+
class='yop_poll_tooltip-buy_pro yop-poll-page-template-li yop-poll-page-template-buy' >
|
162 |
<p>
|
163 |
{{ __('White Pro')}}
|
164 |
</p><br>
|
222 |
<div class="yop-poll-widget-slider" id="yop-poll-widget-template-slider">
|
223 |
|
224 |
<ul>
|
225 |
+
{% if count( templates ) > 0 %}
|
226 |
+
|
227 |
+
{% set i = 0 %}
|
228 |
+
|
229 |
+
{% for template in templates %}
|
230 |
+
|
231 |
+
<li id="yop-poll-widget-template-{{template.id}}" style="cursor: pointer;margin-left:4px;margin-right:4px"
|
232 |
+
|
233 |
+
class='yop-poll-widget-template-li {% if current_poll.widget_template == template.id %} yop-poll-widget-template-selected {% endif%}'
|
234 |
+
|
235 |
+
onclick="yop_poll_select_template({{template.id}}, 'widget')">
|
236 |
+
|
237 |
+
<p>{{template.name|e}}</p> <br>
|
238 |
+
|
239 |
+
{{template.preview|raw}}
|
240 |
+
|
241 |
+
</li>
|
242 |
+
|
243 |
+
{% set i = i+1 %}
|
244 |
+
|
245 |
+
{% endfor %}
|
246 |
+
|
247 |
+
{% endif %}
|
248 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
249 |
|
250 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy' >
|
251 |
<p>
|
252 |
{{ __('Red Pro')}}
|
253 |
</p><br>
|
255 |
</li>
|
256 |
<li id="yop-poll-page-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
257 |
|
258 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy' >
|
259 |
<p>
|
260 |
{{ __('Green v1 Pro')}}
|
261 |
</p><br>
|
263 |
</li>
|
264 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
265 |
|
266 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
267 |
<p>
|
268 |
{{ __('Orange v1 Pro')}}
|
269 |
</p><br>
|
271 |
</li>
|
272 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
273 |
|
274 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
275 |
<p>
|
276 |
{{ __('Dark Pro')}}
|
277 |
</p><br>
|
279 |
</li>
|
280 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
281 |
|
282 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
283 |
<p>
|
284 |
{{ __('Grey v3 Pro')}}
|
285 |
</p><br>
|
287 |
</li>
|
288 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
289 |
|
290 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
291 |
<p>
|
292 |
{{ __('Grey v2 Pro')}}
|
293 |
</p><br>
|
295 |
</li>
|
296 |
<li id="yop-poll-page-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
297 |
|
298 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
299 |
<p>
|
300 |
{{ __('Grey v1 Pro')}}
|
301 |
</p><br>
|
303 |
</li>
|
304 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
305 |
|
306 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
307 |
<p>
|
308 |
{{ __('Grey Pro')}}
|
309 |
</p><br>
|
312 |
|
313 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
314 |
|
315 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
316 |
<p>
|
317 |
{{ __('Blue v3 Pro')}}
|
318 |
</p><br>
|
320 |
</li>
|
321 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
322 |
|
323 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
324 |
<p>
|
325 |
{{ __('Blue v2 Pro')}}
|
326 |
</p><br>
|
328 |
</li>
|
329 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
330 |
|
331 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
332 |
<p>
|
333 |
{{ __('Blue v1 Pro')}}
|
334 |
</p><br>
|
337 |
|
338 |
<li id="yop-poll-widget-template-{{template.id}}"style="cursor: pointer;margin-left:2px;margin-right:2px"
|
339 |
|
340 |
+
class='yop_poll_tooltip-buy_pro yop-poll-widget-template-li yop-poll-widget-template-buy'>
|
341 |
<p>
|
342 |
{{ __('White Pro')}}
|
343 |
</p><br>
|
351 |
|
352 |
|
353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
|
356 |
</ul>
|
357 |
|
tinymce/yop-poll-editor-functions.js
CHANGED
@@ -43,7 +43,7 @@ jQuery(document).ready(function($){
|
|
43 |
if(document.getElementById("ed_toolbar")){
|
44 |
edButtons[edButtons.length] = new edButton("ed_yop_poll", yop_poll_editor_config.name, "", "", "");
|
45 |
jQuery(document).ready(function($){
|
46 |
-
jQuery('#qt_content_ed_yop_poll').replaceWith('<input onclick="show_tb();" type="button" id="qt_content_ed_yop_poll" accesskey="" class="ed_button" value="' + yop_poll_editor_config.name + '" title="' + yop_poll_editor_config.title + '" />');
|
47 |
});
|
48 |
}
|
49 |
});
|
43 |
if(document.getElementById("ed_toolbar")){
|
44 |
edButtons[edButtons.length] = new edButton("ed_yop_poll", yop_poll_editor_config.name, "", "", "");
|
45 |
jQuery(document).ready(function($){
|
46 |
+
jQuery('#qt_content_ed_yop_poll').replaceWith('<input onclick="show_tb();" type="button" id="qt_content_ed_yop_poll" accesskey="" class="ed_button button button-small" value="' + yop_poll_editor_config.name + '" title="' + yop_poll_editor_config.title + '" />');
|
47 |
});
|
48 |
}
|
49 |
});
|
twig-gettext-extractor/twig-gettext-extractor.php
CHANGED
@@ -18,7 +18,7 @@
|
|
18 |
define ( 'YOP_POLL_PLUGIN_PATH', rtrim( dirname( dirname( dirname( __FILE__ ) ) ), '/'). PATH_SEPARATOR );
|
19 |
define ( 'YOP_POLL_PATH', rtrim( dirname( dirname( __FILE__ ) ), '/') . '/' );
|
20 |
|
21 |
-
require_once (YOP_POLL_PATH . 'lib/Twig/
|
22 |
Yop_Twig_Autoloader::register();
|
23 |
|
24 |
require_once YOP_POLL_PATH . 'twig-gettext-extractor/composer/autoload_real.php';
|
18 |
define ( 'YOP_POLL_PLUGIN_PATH', rtrim( dirname( dirname( dirname( __FILE__ ) ) ), '/'). PATH_SEPARATOR );
|
19 |
define ( 'YOP_POLL_PATH', rtrim( dirname( dirname( __FILE__ ) ), '/') . '/' );
|
20 |
|
21 |
+
require_once (YOP_POLL_PATH . 'lib/Twig/AutoloaderYOP.php' );
|
22 |
Yop_Twig_Autoloader::register();
|
23 |
|
24 |
require_once YOP_POLL_PATH . 'twig-gettext-extractor/composer/autoload_real.php';
|
yop_poll.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: YOP Poll
|
5 |
* Plugin URI: http://www.yop-poll.com
|
6 |
* Description: Use a full option polling functionality to get the answers you need. YOP Poll is the perfect, easy to use poll plugin for your WordPress website.
|
7 |
-
* Version: 5.7.
|
8 |
* Author: yourownprogrammer
|
9 |
* Author URI: http://www.yop-poll.com
|
10 |
* License: GPLv2 or later
|
@@ -14,7 +14,7 @@ if (!(version_compare(phpversion(), '5.3', '<'))) {
|
|
14 |
|
15 |
define ( 'YOP_POLL_DOMAIN', 'yop_poll' );
|
16 |
define ( 'YOP_POLL_WP_VERSION', '3.3' );
|
17 |
-
define ( 'YOP_POLL_VERSION', '5.7.
|
18 |
define ( 'YOP_POLL_PATH', plugin_dir_path( __FILE__ ) ); ///home/..../wp-content/plugins/yop-poll-2.0/
|
19 |
define ( 'YOP_POLL_URL', plugin_dir_url( __FILE__ ) ); //http://your-domain/wp-content/plugins/yop-poll-2.0/
|
20 |
define ( 'YOP_POLL_PLUGIN_FILE', __FILE__ ); ///home/..../wp-content/plugins/yop-poll-2.0/yop-poll-2.0.php
|
@@ -24,7 +24,7 @@ if (!(version_compare(phpversion(), '5.3', '<'))) {
|
|
24 |
define ( 'YOP_POLL_MODELS', YOP_POLL_PATH . 'models/' );
|
25 |
define ( "YOP_POLL_DEBUG", false );
|
26 |
|
27 |
-
require_once( YOP_POLL_PATH . 'lib/Twig/
|
28 |
Yop_Twig_Autoloader::register();
|
29 |
|
30 |
require_once( YOP_POLL_MODELS . 'abstract_model.php' );
|
4 |
* Plugin Name: YOP Poll
|
5 |
* Plugin URI: http://www.yop-poll.com
|
6 |
* Description: Use a full option polling functionality to get the answers you need. YOP Poll is the perfect, easy to use poll plugin for your WordPress website.
|
7 |
+
* Version: 5.7.6
|
8 |
* Author: yourownprogrammer
|
9 |
* Author URI: http://www.yop-poll.com
|
10 |
* License: GPLv2 or later
|
14 |
|
15 |
define ( 'YOP_POLL_DOMAIN', 'yop_poll' );
|
16 |
define ( 'YOP_POLL_WP_VERSION', '3.3' );
|
17 |
+
define ( 'YOP_POLL_VERSION', '5.7.6' );
|
18 |
define ( 'YOP_POLL_PATH', plugin_dir_path( __FILE__ ) ); ///home/..../wp-content/plugins/yop-poll-2.0/
|
19 |
define ( 'YOP_POLL_URL', plugin_dir_url( __FILE__ ) ); //http://your-domain/wp-content/plugins/yop-poll-2.0/
|
20 |
define ( 'YOP_POLL_PLUGIN_FILE', __FILE__ ); ///home/..../wp-content/plugins/yop-poll-2.0/yop-poll-2.0.php
|
24 |
define ( 'YOP_POLL_MODELS', YOP_POLL_PATH . 'models/' );
|
25 |
define ( "YOP_POLL_DEBUG", false );
|
26 |
|
27 |
+
require_once( YOP_POLL_PATH . 'lib/Twig/AutoloaderYOP.php' );
|
28 |
Yop_Twig_Autoloader::register();
|
29 |
|
30 |
require_once( YOP_POLL_MODELS . 'abstract_model.php' );
|