YOP Poll - Version 4.9.1

Version Description

  • Fixed issue with Template preview not working in IE8
  • Fixed issue with wpautop filter
  • Redefined admin area allowed tags: a(href, title, target), img( src, title), br
  • Fixed issue with Other answers
Download this release

Release Info

Developer yourownprogrammer
Plugin Icon 128x128 YOP Poll
Version 4.9.1
Comparing to
See all releases

Code changes from version 4.9 to 4.9.1

css/yop-poll-donate.css ADDED
@@ -0,0 +1,62 @@
1
+ #donate {
2
+ width: 100%;
3
+ }
4
+
5
+ #donate #toggle {
6
+ background: #00a8ff !important;
7
+ height: 1.5em;
8
+ font-variant: small-caps;
9
+ font-size: 1.25em;
10
+ padding: 5px 15px 0px 15px;
11
+ color:#FFFFFF;
12
+ }
13
+
14
+ #donate #toggle #toggle_title{
15
+ width: 12em;
16
+ display: inline-block;
17
+ }
18
+
19
+ #donate .handlediv {
20
+ color: #FFFFFF !important;
21
+ }
22
+
23
+ #donate .inside {
24
+ background: #f7f7f7; /* Old browsers */
25
+ background: -moz-linear-gradient(45deg, #f7f7f7 0%, #ffffff 100%); /* FF3.6+ */
26
+ background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#f7f7f7), color-stop(100%,#ffffff)); /* Chrome,Safari4+ */
27
+ background: -webkit-linear-gradient(45deg, #f7f7f7 0%,#ffffff 100%); /* Chrome10+,Safari5.1+ */
28
+ background: -o-linear-gradient(45deg, #f7f7f7 0%,#ffffff 100%); /* Opera 11.10+ */
29
+ background: -ms-linear-gradient(45deg, #f7f7f7 0%,#ffffff 100%); /* IE10+ */
30
+ background: linear-gradient(45deg, #f7f7f7 0%,#ffffff 100%); /* W3C */
31
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
32
+ border: 1px solid #cfcccc;
33
+ color: #95abb7;
34
+ padding: 5px 5px 20px 10px;
35
+ margin: 0 !important;
36
+ }
37
+
38
+ #donate .inside #donateButton {
39
+ position: relative;
40
+ padding-top: 3px;
41
+ width: 9em;
42
+ font-size: 1.25em;
43
+ border: none;
44
+ background: #00a8ff;
45
+ height: 1.5em;
46
+ color: #FFFFFF !important;
47
+ cursor: pointer;
48
+ margin-left: auto;
49
+ margin-right: auto;
50
+ }
51
+
52
+ #donateButton span {
53
+ width: 100%;
54
+ margin-left: 30%;
55
+ margin-right: auto;
56
+ }
57
+
58
+ #donate .inside a {
59
+ text-decoration: none;
60
+ color: #00a8ff;
61
+ width: auto;
62
+ }
css/yop-poll-optin1.css ADDED
@@ -0,0 +1,116 @@
1
+ @font-face{
2
+ font-family: Lato-Reg;
3
+ src: url(../fonts/Lato-Reg.ttf);
4
+ }
5
+
6
+ @font-face{
7
+ font-family: Lato-Lig;
8
+ src: url(../fonts/Lato-Lig.ttf);
9
+ }
10
+
11
+ @font-face{
12
+ font-family: Lato-Bla;
13
+ src: url(../fonts/Lato-Lato-Bla.ttf);
14
+ }
15
+
16
+ @font-face {
17
+ font-family: 'FontomasCustomRegular';
18
+ src: url('../fonts/fontomas-webfont.eot');
19
+ src: url('../fonts/fontomas-webfont.eot?#iefix') format('embedded-opentype'),
20
+ url('../fonts/fontomas-webfont.woff') format('woff'),
21
+ url('../fonts/fontomas-webfont.ttf') format('truetype'),
22
+ url('../fonts/fontomas-webfont.svg#FontomasCustomRegular') format('svg');
23
+ font-weight: normal;
24
+ font-style: normal;
25
+ }
26
+
27
+ .optin {
28
+ text-align: center;
29
+ width: 18.75em;
30
+ margin: 0;
31
+ padding: 0;
32
+ border: 0;
33
+ font-size: 100%;
34
+ font: inherit;
35
+ vertical-align: baseline;
36
+ }
37
+
38
+ .optin #circle {
39
+ border-radius: 50%;
40
+ background: #00a8ff;
41
+ position: relative;
42
+ margin: 0 auto;
43
+ margin-top: 0.75em;
44
+ width: 7.75em;
45
+ height: 7.75em;
46
+ }
47
+
48
+ .optin h1 {
49
+ font-size: 8em;
50
+ color: #fff;
51
+ font-family: Lato-Bla, Arial, Helvetica, sans-serif;
52
+ line-height: 1em;
53
+ }
54
+
55
+ .optin h2 {
56
+ font-size: 1.5em;
57
+ margin-top: 0.5em;
58
+ font-variant: small-caps;
59
+ color: #95ABB7;
60
+ }
61
+
62
+ .optin label {
63
+ position: relative;
64
+ padding-right: 5px;
65
+ }
66
+
67
+ #optin1 {
68
+ background: #f7f7f7; /* Old browsers */
69
+ background: -moz-linear-gradient(45deg, #f7f7f7 0%, #ffffff 100%); /* FF3.6+ */
70
+ background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#f7f7f7), color-stop(100%,#ffffff)); /* Chrome,Safari4+ */
71
+ background: -webkit-linear-gradient(45deg, #f7f7f7 0%,#ffffff 100%); /* Chrome10+,Safari5.1+ */
72
+ background: -o-linear-gradient(45deg, #f7f7f7 0%,#ffffff 100%); /* Opera 11.10+ */
73
+ background: -ms-linear-gradient(45deg, #f7f7f7 0%,#ffffff 100%); /* IE10+ */
74
+ background: linear-gradient(45deg, #f7f7f7 0%,#ffffff 100%); /* W3C */
75
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
76
+ border: 1px solid #fff;
77
+ -moz-box-shadow: 0px 0px 9px #dadada;
78
+ -webkit-box-shadow: 0px 0px 9px #dadada;
79
+ box-shadow: 0px 0px 9px #dadada;
80
+ color: #95abb7;
81
+ }
82
+
83
+ #optin1 #circle {
84
+ background: #00a8ff;
85
+ position: relative;
86
+ margin: 0 auto;
87
+ margin-top: 0.75em;
88
+ width: 125px;
89
+ height: 125px;
90
+ }
91
+
92
+ #optin1 #email {
93
+ width: 95%;
94
+ height: 3em;
95
+ }
96
+
97
+ #optin1 #email:focus {
98
+ background: #f9f9f9;
99
+ }
100
+
101
+ #optin1 #send {
102
+ margin-top: 10px;
103
+ font-size: 1.5em;
104
+ height: 2.5;
105
+ }
106
+
107
+ #optin1 [data-icon]:after {
108
+ left: 2px;
109
+ content: attr(data-icon);
110
+ font-family: 'FontomasCustomRegular';
111
+ color: #00a8ff;
112
+ position: absolute;
113
+ left: 5px;
114
+ top: 4px;
115
+ width: 20px;
116
+ }
css/yop-poll-optin2.css ADDED
@@ -0,0 +1,147 @@
1
+ #WFItem394041 {
2
+ background: #0097e5; /* Old browsers */
3
+ background: -moz-linear-gradient(45deg, #0097e5 0%, #20b3ff 100%); /* FF3.6+ */
4
+ background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#0097e5), color-stop(100%,#20b3ff)); /* Chrome,Safari4+ */
5
+ background: -webkit-linear-gradient(45deg, #0097e5 0%,#20b3ff 100%); /* Chrome10+,Safari5.1+ */
6
+ background: -o-linear-gradient(45deg, #0097e5 0%,#20b3ff 100%); /* Opera 11.10+ */
7
+ background: -ms-linear-gradient(45deg, #0097e5 0%,#20b3ff 100%); /* IE10+ */
8
+ background: linear-gradient(45deg, #0097e5 0%,#20b3ff 100%); /* W3C */
9
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0097e5', endColorstr='#20b3ff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
10
+ border: 1px solid #cfcccc;
11
+ color: #fff;
12
+ margin-top: 20px;
13
+ height: 170px;
14
+ position: relative;
15
+ }
16
+
17
+ #WFItem394041 #content {
18
+ text-align: left;
19
+ padding: 10px 15px 0px 15px;
20
+ position: absolute;
21
+ }
22
+
23
+ #WFItem394041 #circle{
24
+ background: rgba(255,255,255,0.1);
25
+ position: absolute;
26
+ width: 250px;
27
+ height: 250px;
28
+ margin-top: 0px;
29
+ margin-left: 80px;
30
+ }
31
+
32
+ #WFItem394041 h1 {
33
+ margin-top: 10px;
34
+ font-size: 13em;
35
+ color: rgba(255,255,255,0.1);
36
+ z-index: 0;
37
+ }
38
+
39
+ #WFItem394041 .wf-button {
40
+ border: 1px solid rgba(255,255,255,0.5);
41
+ font-size: 1em;
42
+ margin-top: 10px;
43
+ z-index: 999;
44
+ position: relative !important;
45
+ }
46
+
47
+ @font-face{
48
+ font-family: Lato-Reg;
49
+ src: url(../fonts/Lato-Reg.ttf);
50
+ }
51
+
52
+ @font-face{
53
+ font-family: Lato-Lig;
54
+ src: url(../fonts/Lato-Lig.ttf);
55
+ }
56
+
57
+ @font-face{
58
+ font-family: Lato-Bla;
59
+ src: url(../fonts/Lato-Bla.ttf);
60
+ }
61
+
62
+ @font-face {
63
+ font-family: 'FontomasCustomRegular';
64
+ src: url('../fonts/fontomas-webfont.eot');
65
+ src: url('../fonts/fontomas-webfont.eot?#iefix') format('embedded-opentype'),
66
+ url('../fonts/fontomas-webfont.woff') format('woff'),
67
+ url('../fonts/fontomas-webfont.ttf') format('truetype'),
68
+ url('../fonts/fontomas-webfont.svg#FontomasCustomRegular') format('svg');
69
+ font-weight: normal;
70
+ font-style: normal;
71
+ }
72
+
73
+
74
+ .optin {
75
+ text-align: center;
76
+ }
77
+
78
+ .optin #circle {
79
+ border-radius: 50%;
80
+ background: #00a8ff;
81
+ position: relative;
82
+ margin: 0 auto;
83
+ margin-top: 0.75em;
84
+ width: 7.75em;
85
+ height: 7.75em;
86
+ z-index: 0;
87
+ }
88
+
89
+ .optin h1 {
90
+ font-size: 8em;
91
+ color: #fff;
92
+ font-family: Lato-Bla, Arial, Helvetica, sans-serif;
93
+ line-height: 1em;
94
+ }
95
+
96
+ .optin h2 {
97
+ font-size: 1.5em;
98
+ margin-top: 0.5em;
99
+ font-variant: small-caps;
100
+ }
101
+
102
+
103
+ .optin label {
104
+ position: relative;
105
+ }
106
+
107
+ .optin #email {
108
+ background: none repeat scroll 0 0 #FFFFFF;
109
+ border: 1px solid #00A8FF;
110
+ color: #AEAAAA;
111
+ font-family: Calibri,Arial,Helvetica,sans-serif;
112
+ font-size: 1.125em;
113
+ height: 2em;
114
+ margin-top: 0.5em;
115
+ padding-left: 2em;
116
+ transition: all 0.3s linear 0s;
117
+ width: 95%;
118
+ }
119
+
120
+ .optin #email:focus {
121
+ background: #f9f9f9;
122
+ }
123
+
124
+ .optin [data-icon]:after {
125
+ content: attr(data-icon);
126
+ font-family: 'FontomasCustomRegular';
127
+ font-size: 1.5em;
128
+ color: #00a8ff;
129
+ position: absolute;
130
+ left: 0px;
131
+ top: 4px;
132
+ width: 30px;
133
+ }
134
+
135
+ .wf-button {
136
+ margin-bottom: 0.5em;
137
+ border: none;
138
+ background: #00a8ff;
139
+ height: 2em;
140
+ color: white;
141
+ cursor: pointer;
142
+ z-index: 100 !important;
143
+ }
144
+
145
+ .wf-button:active {
146
+ background: #0098e6;
147
+ }
fonts/Lato-Bla.ttf ADDED
Binary file
fonts/Lato-BlaIta.ttf ADDED
Binary file
fonts/Lato-Bol.ttf ADDED
Binary file
fonts/Lato-BolIta.ttf ADDED
Binary file
fonts/Lato-Hai.ttf ADDED
Binary file
fonts/Lato-HaiIta.ttf ADDED
Binary file
fonts/Lato-Lig.ttf ADDED
Binary file
fonts/Lato-LigIta.ttf ADDED
Binary file
fonts/Lato-Reg.ttf ADDED
Binary file
fonts/Lato-RegIta.ttf ADDED
Binary file
fonts/fontomas-webfont.eot ADDED
Binary file
fonts/fontomas-webfont.svg ADDED
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>
5
+ This is a custom SVG webfont generated by Font Squirrel.
6
+ </metadata>
7
+ <defs>
8
+ <font id="FontomasCustomRegular" horiz-adv-x="1024" >
9
+ <font-face units-per-em="2048" ascent="1536" descent="-512" />
10
+ <missing-glyph horiz-adv-x="500" />
11
+ <glyph unicode="e" d="M31 102v1004l1030 -483l1018 481v-1002h-2048zM31 1389v249h2048v-249l-1020 -484z" />
12
+ <glyph unicode="p" d="M31 102l780 781q-12 63 -12 116q0 264 187.5 451.5t452.5 187.5t452.5 -187t187.5 -452.5t-187.5 -453t-453.5 -187.5q-51 0 -115 13l-12 -13v-256h-256v-256h-256v-256h-768v512zM1311 998.5q0 -52.5 37.5 -90.5t91 -38t90.5 38t37 90.5t-37 90t-90.5 37.5t-91 -37.5 t-37.5 -90z" />
13
+ <glyph unicode="u" d="M207 -90q0 45 112.5 111.5t305.5 138.5q193 68 264.5 139.5t71.5 196.5q0 33 -12.5 55t-30 36.5t-37 55.5t-31.5 102q-4 20 -14.5 29.5t-22.5 15t-24.5 14.5t-21.5 37.5t-15 76.5q0 31 10 52t20 27l11 7q-20 102 -29 180q0 7 -1 13q0 28 7 61q8 42 34.5 92.5t70 90.5 t120 67.5t174.5 27.5q100 0 178 -27.5t122 -67.5t71 -90.5t35 -92.5q5 -28 5 -51q0 -12 -1 -23q-8 -78 -29 -180q37 -16 37 -86q-2 -47 -12 -76t-21.5 -38t-23.5 -14.5t-22.5 -14.5t-14.5 -30q-10 -61 -30.5 -102t-37 -55.5t-30 -37t-13.5 -54.5q0 -125 72 -197t260 -139 q195 -72 306.5 -138.5t111.5 -111.5v-217h-963h-962v217z" />
14
+ <glyph unicode="&#x2000;" horiz-adv-x="819" />
15
+ <glyph unicode="&#x2001;" horiz-adv-x="1638" />
16
+ <glyph unicode="&#x2002;" horiz-adv-x="819" />
17
+ <glyph unicode="&#x2003;" horiz-adv-x="1638" />
18
+ <glyph unicode="&#x2004;" horiz-adv-x="544" />
19
+ <glyph unicode="&#x2005;" horiz-adv-x="409" />
20
+ <glyph unicode="&#x2006;" horiz-adv-x="272" />
21
+ <glyph unicode="&#x2007;" horiz-adv-x="272" />
22
+ <glyph unicode="&#x2008;" horiz-adv-x="204" />
23
+ <glyph unicode="&#x2009;" horiz-adv-x="327" />
24
+ <glyph unicode="&#x200a;" horiz-adv-x="90" />
25
+ <glyph unicode="&#x2013;" d="M205 512v205h614v-205h-614z" />
26
+ <glyph unicode="&#x2014;" horiz-adv-x="2048" d="M205 512v205h1638v-205h-1638z" />
27
+ <glyph unicode="&#x202f;" horiz-adv-x="327" />
28
+ <glyph unicode="&#x205f;" horiz-adv-x="409" />
29
+ <glyph unicode="&#xe000;" horiz-adv-x="500" d="M0 0v0v0v0v0z" />
30
+ </font>
31
+ </defs></svg>
fonts/fontomas-webfont.ttf ADDED
Binary file
fonts/fontomas-webfont.woff ADDED
Binary file
inc/admin.php CHANGED
</
@@ -1,31 +1,28 @@
1
<?php
2
- class Yop_Poll_Admin extends Yop_Poll_Plugin {
3
protected function init() {
4
- $this->add_action ( 'init', 'admin_loader' );
5
- $this->add_action ( 'admin_notices', 'popup_bar' );
6
- $this->add_action ( 'admin_init', 'popup_bar_operations' );
7
- $this->add_action ( 'admin_enqueue_scripts', 'my_yop_poll_button' );
8
- $this->add_action ( 'wpmu_new_blog', 'new_blog', 10, 6 );
9
- $this->add_action ( 'delete_blog', 'delete_blog', 10, 2 );
10
- register_activation_hook ( $this->_config->plugin_file, array (
11
- $this,
12
- 'yop_poll_activate'
13
- ) );
14
- register_deactivation_hook ( $this->_config->plugin_file, array (
15
- $this,
16
- 'yop_poll_deactivate'
17
- ) );
18
- register_uninstall_hook ( $this->_config->plugin_file, 'yop_poll_uninstall' );
19
- $this->add_action ( 'admin_enqueue_scripts', 'load_editor_functions' );
20
- $this->add_action ( 'plugins_loaded', 'db_update' );
21
}
22
- function new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
23
global $wpdb;
24
- if (! function_exists ( 'is_plugin_active_for_network' ))
25
- require_once (ABSPATH . '/wp-admin/includes/plugin.php');
26
- if (is_plugin_active_for_network ( 'yop-poll/yop_poll.php' )) {
27
$old_blog = $wpdb->blogid;
28
- switch_to_blog ( $blog_id );
29
$wpdb->yop_polls = $wpdb->prefix . 'yop_polls';
30
$wpdb->yop_poll_answers = $wpdb->prefix . 'yop_poll_answers';
31
$wpdb->yop_poll_templates = $wpdb->prefix . 'yop_poll_templates';
@@ -37,105 +34,100 @@
37
$wpdb->yop_poll_bans = $wpdb->prefix . 'yop_poll_bans';
38
$wpdb->yop_poll_votes_custom_fields = $wpdb->prefix . 'yop_poll_votes_custom_fields';
39
$wpdb->yop_poll_facebook_users = $wpdb->prefix . 'yop_poll_facebook_users';
40
- $this->activate ( NULL );
41
- switch_to_blog ( $old_blog );
42
}
43
}
44
- function delete_blog($blog_id) {
45
global $wpdb;
46
$old_blog = $wpdb->blogid;
47
- switch_to_blog ( $blog_id );
48
- $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`" );
49
- switch_to_blog ( $old_blog );
50
}
51
52
- function yop_poll_network_propagate($pfunction, $networkwide) {
53
global $wpdb;
54
55
- if (function_exists ( 'is_multisite' ) && is_multisite ()) {
56
// check if it is a network activation - if so, run the activation function
57
// for each blog id
58
- if ($networkwide) {
59
$old_blog = $wpdb->blogid;
60
// Get all blog ids
61
- $blogids = $wpdb->get_col ( "SELECT blog_id FROM {$wpdb->blogs}" );
62
foreach ( $blogids as $blog_id ) {
63
- switch_to_blog ( $blog_id );
64
- $wpdb->yop_polls = $wpdb->prefix . 'yop_polls';
65
- $wpdb->yop_poll_answers = $wpdb->prefix . 'yop_poll_answers';
66
- $wpdb->yop_poll_templates = $wpdb->prefix . 'yop_poll_templates';
67
- $wpdb->yop_poll_custom_fields = $wpdb->prefix . 'yop_poll_custom_fields';
68
- $wpdb->yop_pollmeta = $wpdb->prefix . 'yop_pollmeta';
69
- $wpdb->yop_poll_answermeta = $wpdb->prefix . 'yop_poll_answermeta';
70
- $wpdb->yop_poll_logs = $wpdb->prefix . 'yop_poll_logs';
71
- $wpdb->yop_poll_voters = $wpdb->prefix . 'yop_poll_voters';
72
- $wpdb->yop_poll_bans = $wpdb->prefix . 'yop_poll_bans';
73
$wpdb->yop_poll_votes_custom_fields = $wpdb->prefix . 'yop_poll_votes_custom_fields';
74
- $wpdb->yop_poll_facebook_users = $wpdb->prefix . 'yop_poll_facebook_users';
75
- call_user_func ( array (
76
- $this,
77
- $pfunction
78
- ), $networkwide );
79
}
80
- switch_to_blog ( $old_blog );
81
return;
82
}
83
}
84
- call_user_func ( array (
85
- $this,
86
- $pfunction
87
- ), $networkwide );
88
}
89
90
- function yop_poll_activate($networkwide) {
91
- $this->yop_poll_network_propagate ( 'activate', $networkwide );
92
}
93
94
- function yop_poll_deactivate($networkwide) {
95
- $this->yop_poll_network_propagate ( 'deactivate', $networkwide );
96
}
97
98
public function db_update() {
99
global $wpdb;
100
global $current_user;
101
102
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
103
- $installed_version = get_option ( "yop_poll_version" );
104
105
// update for version 1.5
106
- if (version_compare ( $installed_version, '1.5', '<=' )) {
107
- $default_options = get_option ( 'yop_poll_options' );
108
- if (! isset ( $default_options ['vote_button_label'] )) {
109
$default_options ['vote_button_label'] = 'Vote';
110
}
111
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
112
- update_option ( 'yop_poll_options', $default_options );
113
}
114
115
// update for version 1.6
116
- if (version_compare ( $installed_version, '1.6', '<=' )) {
117
- $default_options = get_option ( 'yop_poll_options' );
118
- if (! isset ( $default_options ['display_other_answers_values'] )) {
119
$default_options ['display_other_answers_values'] = 'no';
120
}
121
- if (! isset ( $default_options ['percentages_decimals'] )) {
122
$default_options ['percentages_decimals'] = '0';
123
}
124
- if (! isset ( $default_options ['plural_answer_result_votes_number_label'] )) {
125
$default_options ['singular_answer_result_votes_number_label'] = 'vote';
126
}
127
- if (! isset ( $default_options ['plural_answer_result_votes_number_label'] )) {
128
$default_options ['plural_answer_result_votes_number_label'] = 'votes';
129
}
130
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
131
- update_option ( 'yop_poll_options', $default_options );
132
}
133
134
// update for version 2.0
135
- if (version_compare ( $installed_version, '2.0', '<=' )) {
136
- $wpdb->query ( 'ALTER TABLE `' . $wpdb->yop_polls . '` CHANGE `total_votes` `total_answers` INT( 11 ) NOT NULL ' );
137
- $wpdb->query ( 'ALTER TABLE `' . $wpdb->yop_polls . '` CHANGE `total_voters` `total_votes` INT( 11 ) NOT NULL ' );
138
- $wpdb->query ( "
139
UPDATE " . $wpdb->yop_poll_templates . "
140
SET
141
before_vote_template = REPLACE( before_vote_template, 'POLL-TOTAL-VOTERS', 'POLL-TOTAL-ANSWERS'),
@@ -145,314 +137,314 @@
145
css = REPLACE( css, 'POLL-TOTAL-VOTERS', 'POLL-TOTAL-ANSWERS'),
146
js = REPLACE( js, 'POLL-TOTAL-VOTERS', 'POLL-TOTAL-ANSWERS')
147
" );
148
- $default_options = get_option ( 'yop_poll_options' );
149
- if (! isset ( $default_options ['view_total_answers'] )) {
150
$default_options ['view_total_answers'] = $default_options ['view_total_voters'];
151
}
152
- if (! isset ( $default_options ['view_total_answers_label'] )) {
153
$default_options ['view_total_answers_label'] = 'Total Answers %POLL-TOTAL-ANSWERS%';
154
}
155
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
156
- update_option ( 'yop_poll_options', $default_options );
157
}
158
159
// update for version 3.2
160
- if (version_compare ( $installed_version, '3.2', '<=' )) {
161
- $wpdb->query ( "
162
UPDATE " . $wpdb->yop_poll_templates . "
163
SET
164
js = REPLACE( js, 'findWidest = false ) {\r\n', 'findWidest ) {\r\n findWidest = typeof findWidest !== \'undefined\' ? findWidest : false;\r\n ')
165
" );
166
167
- $default_options = get_option ( 'yop_poll_options' );
168
- if (! isset ( $default_options ['auto_generate_poll_page'] )) {
169
$default_options ['auto_generate_poll_page'] = 'no';
170
}
171
- if (! isset ( $default_options ['has_auto_generate_poll_page'] )) {
172
$default_options ['has_auto_generate_poll_page'] = 'no';
173
}
174
- update_option ( 'yop_poll_options', $default_options );
175
176
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
177
}
178
179
// update for version 3.3
180
- if (version_compare ( $installed_version, '3.3', '<=' )) {
181
- $yop_poll_first_install_date = get_option ( 'yop_poll_first_install_date' );
182
- if (! $yop_poll_first_install_date) {
183
- $oldest_yop_poll = Yop_Poll_Model::get_oldest_poll_from_database ();
184
- update_option ( "yop_poll_first_install_date", $oldest_yop_poll ['date_added'] );
185
}
186
- $yop_poll_admin_notices_donate = get_option ( 'yop_poll_admin_notices_donate' );
187
- if (! $yop_poll_admin_notices_donate) {
188
- update_option ( "yop_poll_admin_notices_donate", 'yes' );
189
}
190
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
191
}
192
193
// update for version 3.7
194
- if (version_compare ( $installed_version, '3.7', '<=' )) {
195
- $default_options = get_option ( 'yop_poll_options' );
196
- if (! isset ( $default_options ['poll_name_html_tags'] )) {
197
$default_options ['poll_name_html_tags'] = 'no';
198
}
199
- if (! isset ( $default_options ['poll_question_html_tags'] )) {
200
$default_options ['poll_question_html_tags'] = 'no';
201
}
202
- if (! isset ( $default_options ['poll_answer_html_tags'] )) {
203
$default_options ['poll_answer_html_tags'] = 'no';
204
}
205
- if (! isset ( $default_options ['poll_custom_field_html_tags'] )) {
206
$default_options ['poll_custom_field_html_tags'] = 'no';
207
}
208
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
209
- update_option ( 'yop_poll_options', $default_options );
210
}
211
212
- if (version_compare ( $installed_version, '3.9', '<=' )) {
213
- require_once (ABSPATH . 'wp-admin/includes/upgrade.php');
214
- require_once (YOP_POLL_INC . '/' . 'db_schema.php');
215
- Yop_Poll_DbSchema::create_polls_table ();
216
- Yop_Poll_DbSchema::create_polls_templates_table ();
217
218
- wp_get_current_user ();
219
- if ($current_user->ID > 0) {
220
- $wpdb->query ( "UPDATE " . $wpdb->yop_polls . " SET poll_author = " . $current_user->ID . " WHERE poll_author = 0" );
221
- $wpdb->query ( "UPDATE " . $wpdb->yop_poll_templates . " SET template_author = " . $current_user->ID . " WHERE template_author = 0" );
222
}
223
224
- $default_options = get_option ( 'yop_poll_options' );
225
- if (! isset ( $default_options ['use_default_loading_image'] )) {
226
$default_options ['use_default_loading_image'] = 'yes';
227
}
228
- if (! isset ( $default_options ['loading_image_url'] )) {
229
$default_options ['loading_image_url'] = '';
230
}
231
- update_option ( 'yop_poll_options', $default_options );
232
233
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
234
}
235
236
- if (version_compare ( $installed_version, '4.1', '<=' )) {
237
238
- $this->update_to_4_2 ();
239
- $default_options = get_option ( 'yop_poll_options' );
240
- if (! isset ( $default_options ['use_captcha'] )) {
241
$default_options ['use_captcha'] = 'no';
242
}
243
244
- update_option ( 'yop_poll_options', $default_options );
245
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
246
}
247
248
- if (version_compare ( $installed_version, '4.2', '<=' ) ) {
249
250
- require_once (ABSPATH . 'wp-admin/includes/upgrade.php');
251
- require_once (YOP_POLL_INC . '/' . 'db_schema.php');
252
- Yop_Poll_DbSchema::create_poll_facebook_users_table ();
253
- Yop_Poll_DbSchema::create_poll_logs_table ();
254
- Yop_Poll_DbSchema::create_poll_votes_custom_fields_table ();
255
256
- $optin_box_modal_options = get_option ( 'yop_poll_optin_box_modal_options' );
257
- if (! isset ( $optin_box_modal_options ['show'] )) {
258
$optin_box_modal_options ['show'] = 'yes';
259
}
260
- if (! isset ( $optin_box_modal_options ['last_show_date'] )) {
261
- $optin_box_modal_options ['last_show_date'] = Yop_Poll_Model::get_mysql_curent_date ();
262
}
263
- if (! isset ( $optin_box_modal_options ['modal_had_submit'] )) {
264
$optin_box_modal_options ['modal_had_submit'] = 'no';
265
}
266
- if (! isset ( $optin_box_modal_options ['sidebar_had_submit'] )) {
267
$optin_box_modal_options ['sidebar_had_submit'] = 'no';
268
}
269
- update_option ( 'yop_poll_optin_box_modal_options', $optin_box_modal_options );
270
271
- $pro_options = get_option ( 'yop_poll_pro_options' );
272
- if (! isset ( $pro_options ['pro_key'] )) {
273
$pro_options ['pro_key'] = '';
274
}
275
- if (! isset ( $pro_options ['pro_api_key'] )) {
276
$pro_options ['pro_api_key'] = '';
277
}
278
- if (! isset ( $pro_options ['pro_api_server_url'] )) {
279
$pro_options ['pro_api_server_url'] = 'http://www.yop-poll.com/pro';
280
}
281
- if (! isset ( $pro_options ['pro_user'] )) {
282
$pro_options ['pro_user'] = 'no';
283
}
284
285
- $default_options = get_option ( 'yop_poll_options' );
286
- if (! isset ( $default_options ['vote_permisions_facebook'] )) {
287
$default_options ['vote_permisions_facebook'] = 'no';
288
}
289
- if (! isset ( $default_options ['vote_permisions_facebook_label'] )) {
290
$default_options ['vote_permisions_facebook_label'] = 'Vote as Facebook User';
291
}
292
- if (! isset ( $default_options ['vote_permisions_wordpress'] )) {
293
$default_options ['vote_permisions_wordpress'] = 'no';
294
}
295
- if (! isset ( $default_options ['vote_permisions_wordpress_label'] )) {
296
$default_options ['vote_permisions_wordpress_label'] = 'Vote as Wordpress User';
297
}
298
- if (! isset ( $default_options ['vote_permisions_anonymous'] )) {
299
$default_options ['vote_permisions_anonymous'] = 'no';
300
}
301
- if (! isset ( $default_options ['vote_permisions_anonymous_label'] )) {
302
$default_options ['vote_permisions_anonymous_label'] = 'Vote as Anonymous User';
303
}
304
305
- if (! isset ( $default_options ['share_after_vote'] )) {
306
$default_options ['share_after_vote'] = 'no';
307
- }
308
- if (! isset ( $default_options ['share_picture'] )) {
309
$default_options ['share_picture'] = '';
310
}
311
- if (! isset ( $default_options ['share_name'] )) {
312
$default_options ['share_name'] = '';
313
}
314
- if (! isset ( $default_options ['share_caption'] )) {
315
$default_options ['share_caption'] = '';
316
}
317
- if (! isset ( $default_options ['share_description'] )) {
318
$default_options ['share_description'] = '';
319
}
320
- if (! isset ( $default_options ['redirect_after_vote'] )) {
321
$default_options ['redirect_after_vote'] = 'no';
322
}
323
- if (! isset ( $default_options ['redirect_after_vote_url'] )) {
324
$default_options ['redirect_after_vote_url'] = '';
325
}
326
- if (! isset ( $default_options ['allow_multiple_answers_min_number'] )) {
327
$default_options ['allow_multiple_answers_min_number'] = '1';
328
}
329
- if (! isset ( $default_options ['is_default_answer'] )) {
330
$default_options ['is_default_answer'] = 'no';
331
}
332
- if (! isset ( $default_options ['template_width'] )) {
333
$default_options ['template_width'] = '200px';
334
}
335
- if (! isset ( $default_options ['widget_template'] )) {
336
$default_options ['widget_template'] = $default_options['template'];
337
- }
338
- if (! isset ( $default_options ['widget_template_width'] )) {
339
$default_options ['widget_template_width'] = '200px';
340
}
341
342
- $wpdb->query ( "
343
UPDATE " . $wpdb->yop_poll_templates . "
344
SET
345
css = REPLACE( css, 'width:200px;', 'width:%POLL-WIDTH%;')
346
- " );
347
348
- update_option ( 'yop_poll_options', $default_options );
349
350
- update_option ( 'yop_poll_pro_options', $pro_options );
351
352
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
353
}
354
355
- if (version_compare ( $installed_version, '4.3', '<=' ) ) {
356
- require_once (ABSPATH . 'wp-admin/includes/upgrade.php');
357
- require_once (YOP_POLL_INC . '/' . 'db_schema.php');
358
- Yop_Poll_DbSchema::create_poll_voters_table ();
359
360
- $wpdb->query ( "
361
UPDATE " . $wpdb->yop_poll_templates . "
362
SET
363
css = CONCAT( css, '\r\n\r\n#yop-poll-container-success-%POLL-ID% {\r\n font-size:12px;\r\n font-style:italic;\r\n color:green;\r\n}' )
364
- WHERE
365
css NOT LIKE '%#yop-poll-container-success-%'
366
" );
367
368
- $default_options = get_option ( 'yop_poll_options' );
369
370
- if (! isset ( $default_options ['limit_number_of_votes_per_user'] )) {
371
$default_options ['limit_number_of_votes_per_user'] = 'no';
372
}
373
374
- if (! isset ( $default_options ['number_of_votes_per_user'] )) {
375
$default_options ['number_of_votes_per_user'] = 1;
376
}
377
378
- if (! isset ( $default_options ['message_after_vote'] )) {
379
$default_options ['message_after_vote'] = 'Thank you for your vote!';
380
}
381
382
- if (! isset ( $default_options ['start_scheduler'] )) {
383
$default_options ['start_scheduler'] = 'no';
384
}
385
- if (! isset ( $default_options ['schedule_reset_poll_stats'] )) {
386
$default_options ['schedule_reset_poll_stats'] = 'no';
387
}
388
- if (! isset ( $default_options ['schedule_reset_poll_date'] )) {
389
$default_options ['schedule_reset_poll_date'] = current_time( 'timestamp' );
390
}
391
- if (! isset ( $default_options ['schedule_reset_poll_recurring_value'] )) {
392
$default_options ['schedule_reset_poll_recurring_value'] = '9999';
393
}
394
- if (! isset ( $default_options ['schedule_reset_poll_recurring_unit'] )) {
395
$default_options ['schedule_reset_poll_recurring_unit'] = 'DAY';
396
}
397
398
- update_option ( 'yop_poll_options', $default_options );
399
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
400
}
401
402
- if (version_compare ( $installed_version, '4.4', '<=' ) ) {
403
- require_once (ABSPATH . 'wp-admin/includes/upgrade.php');
404
- require_once (YOP_POLL_INC . '/' . 'db_schema.php');
405
- Yop_Poll_DbSchema::create_poll_logs_table ();
406
- Yop_Poll_DbSchema::create_poll_votes_custom_fields_table ();
407
408
- $default_options = get_option ( 'yop_poll_options' );
409
410
- if (! isset ( $default_options ['view_results_permissions'] )) {
411
$default_options ['view_results_permissions'] = 'guest-registered';
412
}
413
414
- if (! isset ( $default_options ['date_format'] )) {
415
$default_options ['date_format'] = 'd/m/Y H:i:s';
416
}
417
418
- if (! isset ( $default_options ['add_other_answers_to_default_answers'] )) {
419
$default_options ['add_other_answers_to_default_answers'] = 'no';
420
}
421
422
- update_option ( 'yop_poll_options', $default_options );
423
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
424
}
425
426
- if (version_compare ( $installed_version, '4.5', '<=' ) ) {
427
428
- $default_options = get_option ( 'yop_poll_options' );
429
430
- if (! isset ( $default_options ['send_email_notifications'] )) {
431
$default_options ['send_email_notifications'] = 'no';
432
}
433
434
- if (! isset ( $default_options ['email_notifications_from_name'] )) {
435
$default_options ['email_notifications_from_name'] = 'Yop Poll';
436
}
437
438
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
439
- if ( substr( $sitename, 0, 4 ) == 'www.' ) {
440
$sitename = substr( $sitename, 4 );
441
}
442
443
- if (! isset ( $default_options ['email_notifications_from_email'] )) {
444
- $default_options ['email_notifications_from_email'] = 'yop-poll@'.$sitename;
445
}
446
447
- if (! isset ( $default_options ['email_notifications_recipients'] )) {
448
$default_options ['email_notifications_recipients'] = '';
449
}
450
451
- if (! isset ( $default_options ['email_notifications_subject'] )) {
452
$default_options ['email_notifications_subject'] = 'New Vote';
453
}
454
455
- if (! isset ( $default_options ['email_notifications_body'] )) {
456
$default_options ['email_notifications_body'] = '<p>A new vote was registered on [VOTE_DATE] for [POLL_NAME]</p>
457
<p>Vote Details:</p>
458
<p><b>Question:</b> [QUESTION]</p>
@@ -461,41 +453,45 @@
461
<p><b>Vote ID:</b> <br />[VOTE_ID]</p>';
462
}
463
464
- update_option ( 'yop_poll_options', $default_options );
465
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
466
}
467
468
- if (version_compare ( $installed_version, '4.7', '<=' ) ) {
469
$this->update_to_4_8();
470
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
471
}
472
473
- if (version_compare ( $installed_version, '4.8', '<=' ) ) {
474
$this->update_to_4_9();
475
- update_option ( "yop_poll_version", $wpdb->yop_poll_version );
476
}
477
478
}
479
480
public function update_to_4_2() {
481
global $wpdb;
482
483
- $saved_templates = $wpdb->get_results ( "
484
SELECT id FROM " . $wpdb->yop_poll_templates . "
485
WHERE
486
before_vote_template LIKE '%<div id=\\" . '"' . "yop-poll-vote-\%POLL-ID\%\\" . '"' . " class=\\" . '"' . "yop-poll-footer\\" . '"' . ">%' AND
487
before_vote_template NOT LIKE '%[CAPTCHA_CONTAINER]%'
488
", ARRAY_A );
489
490
- $updated_templates = $wpdb->get_results ( "
491
SELECT id FROM " . $wpdb->yop_poll_templates . "
492
WHERE
493
before_vote_template LIKE '%<div id=\\\\\\\\" . '"' . "yop-poll-vote-\%POLL-ID\%\\\\\\\\" . '"' . " class=\\\\\\\\" . '"' . "yop-poll-footer\\\\\\\\" . '"' . ">%' AND
494
before_vote_template NOT LIKE '%[CAPTCHA_CONTAINER]%'
495
", ARRAY_A );
496
- if (count ( $saved_templates ) > 0) {
497
foreach ( $saved_templates as $template ) {
498
- $wpdb->query ( "
499
UPDATE " . $wpdb->yop_poll_templates . " SET
500
before_vote_template = REPLACE( before_vote_template, '<div id=\\" . '"' . "yop-poll-vote-%POLL-ID%\\" . '"' . " class=\\" . '"' . "yop-poll-footer\\" . '"' . ">', '[CAPTCHA_CONTAINER]\r\n<div id=\"yop-poll-captcha-%POLL-ID%\">\r\n <div class=\"yop-poll-captcha-image-div\" id=\"yop-poll-captcha-image-div-%POLL-ID%\">\r\n %CAPTCHA-IMAGE%\r\n <div class=\"yop-poll-captcha-helpers-div\" id=\"yop-poll-captcha-helpers-div-%POLL-ID%\">%RELOAD-CAPTCHA-IMAGE% </div>\r\n <div class=\"yop_poll_clear\"></div>\r\n </div>\r\n %CAPTCHA-LABEL%\r\n <div class=\"yop-poll-captcha-input-div\" id=\"yop-poll-captcha-input-div-%POLL-ID%\">%CAPTCHA-INPUT%</div>\r\n</div>\r\n[/CAPTCHA_CONTAINER]\r\n<div id=\\" . '"' . "yop-poll-vote-%POLL-ID%\\" . '"' . " class=\\" . '"' . "yop-poll-footer\\" . '"' . ">')
501
WHERE
@@ -504,9 +500,9 @@
504
" );
505
}
506
}
507
- if (count ( $updated_templates ) > 0) {
508
foreach ( $updated_templates as $template ) {
509
- $wpdb->query ( "
510
UPDATE " . $wpdb->yop_poll_templates . " SET
511
before_vote_template = REPLACE( before_vote_template, '<div id=\\\\" . '"' . "yop-poll-vote-%POLL-ID%\\\\" . '"' . " class=\\\\" . '"' . "yop-poll-footer\\\\" . '"' . ">', '[CAPTCHA_CONTAINER]\r\n<div id=\"yop-poll-captcha-%POLL-ID%\">\r\n <div class=\"yop-poll-captcha-image-div\" id=\"yop-poll-captcha-image-div-%POLL-ID%\">\r\n %CAPTCHA-IMAGE%\r\n <div class=\"yop-poll-captcha-helpers-div\" id=\"yop-poll-captcha-helpers-div-%POLL-ID%\">%RELOAD-CAPTCHA-IMAGE% </div>\r\n <div class=\"yop_poll_clear\"></div>\r\n </div>\r\n %CAPTCHA-LABEL%\r\n <div class=\"yop-poll-captcha-input-div\" id=\"yop-poll-captcha-input-div-%POLL-ID%\">%CAPTCHA-INPUT%</div>\r\n</div>\r\n[/CAPTCHA_CONTAINER]\r\n<div id=\\" . '"' . "yop-poll-vote-%POLL-ID%\\" . '"' . " class=\\" . '"' . "yop-poll-footer\\" . '"' . ">')
512
WHERE
@@ -516,16 +512,16 @@
516
}
517
}
518
519
- $css_templates = $wpdb->get_results ( "
520
SELECT id FROM " . $wpdb->yop_poll_templates . "
521
WHERE
522
css LIKE '%#yop-poll-custom-%POLL-ID% ul li input { margin:0px 0px 5px 0px; padding:2\%; width:96\%; text-indent:2\%; font-size:12px; }%' AND
523
css NOT LIKE '%yop-poll-captcha%'
524
", ARRAY_A );
525
526
- if (count ( $css_templates ) > 0) {
527
foreach ( $css_templates as $template ) {
528
- $wpdb->query ( "
529
UPDATE " . $wpdb->yop_poll_templates . " SET
530
css = REPLACE( css, '#yop-poll-custom-%POLL-ID% ul li input { margin:0px 0px 5px 0px; padding:2%; width:96%; text-indent:2%; font-size:12px; }', '#yop-poll-container-%POLL-ID% input[type=\'text\'] { margin:0px 0px 5px 0px; padding:2%; width:96%; text-indent:2%; font-size:12px; }\r\n\r\n#yop-poll-captcha-input-div-%POLL-ID% {\r\nmargin-top:5px;\r\n}\r\n#yop-poll-captcha-helpers-div-%POLL-ID% {\r\nwidth:30px;\r\nfloat:left;\r\nmargin-left:5px;\r\nheight:0px;\r\n}\r\n\r\n#yop-poll-captcha-helpers-div-%POLL-ID% img {\r\nmargin-bottom:2px;\r\n}\r\n\r\n#yop-poll-captcha-image-div-%POLL-ID% {\r\nmargin-bottom:5px;\r\n}\r\n\r\n#yop_poll_captcha_image_%POLL-ID% {\r\nfloat:left;\r\n}\r\n\r\n.yop_poll_clear {\r\nclear:both;\r\n}\r\n\r\n')
531
WHERE
@@ -535,16 +531,16 @@
535
}
536
}
537
538
- $css_templates_1 = $wpdb->get_results ( "
539
SELECT id FROM " . $wpdb->yop_poll_templates . "
540
WHERE
541
css LIKE '%#yop-poll-custom-%POLL-ID% ul li input { margin:0px 0px 5px 0px; padding:2\%; width:95\%; text-indent:2\%; font-size:12px; }%' AND
542
css NOT LIKE '%yop-poll-captcha%'
543
", ARRAY_A );
544
545
- if (count ( $css_templates_1 ) > 0) {
546
foreach ( $css_templates_1 as $template ) {
547
- $wpdb->query ( "
548
UPDATE " . $wpdb->yop_poll_templates . " SET
549
css = REPLACE( css, '#yop-poll-custom-%POLL-ID% ul li input { margin:0px 0px 5px 0px; padding:2%; width:95%; text-indent:2%; font-size:12px; }', '#yop-poll-container-%POLL-ID% input[type=\'text\'] { margin:0px 0px 5px 0px; padding:2%; width:96%; text-indent:2%; font-size:12px; }\r\n\r\n#yop-poll-captcha-input-div-%POLL-ID% {\r\nmargin-top:5px;\r\n}\r\n#yop-poll-captcha-helpers-div-%POLL-ID% {\r\nwidth:30px;\r\nfloat:left;\r\nmargin-left:5px;\r\nheight:0px;\r\n}\r\n\r\n#yop-poll-captcha-helpers-div-%POLL-ID% img {\r\nmargin-bottom:2px;\r\n}\r\n\r\n#yop-poll-captcha-image-div-%POLL-ID% {\r\nmargin-bottom:5px;\r\n}\r\n\r\n#yop_poll_captcha_image_%POLL-ID% {\r\nfloat:left;\r\n}\r\n\r\n.yop_poll_clear {\r\nclear:both;\r\n}\r\n\r\n')
550
WHERE
@@ -554,9 +550,10 @@
554
}
555
}
556
}
557
public function update_to_4_8() {
558
global $wpdb;
559
- $sql = <<<EOT
560
UPDATE $wpdb->yop_poll_templates
561
SET
562
js = CONCAT( js, '
@@ -564,452 +561,346 @@
564
runOnPollStateChange_%POLL-ID%();
565
});
566
567
- function runOnPollStateChange_%POLL-ID%() {};'
568
)
569
WHERE js NOT LIKE '%runOnPollStateChange_%'
570
EOT;
571
- $updated_templates = $wpdb->query($sql);
572
}
573
public function update_to_4_9() {
574
global $wpdb;
575
- $sql =<<<EOT
576
- UPDATE $wpdb->yop_poll_templates
577
- SET `before_vote_template` =
578
- REPLACE( `before_vote_template` ,
579
- '<div id="yop-poll-answers-%POLL-ID"',
580
- '<div id="yop-poll-answers-%POLL-ID%"' )
581
- WHERE `before_vote_template` LIKE '%<div id="yop-poll-answers-%POLL-ID"%
582
EOT;
583
- $wpdb->query($sql);
584
}
585
public function admin_loader() {
586
// $this->add_action ( 'network_admin_menu', 'admin_menu', 1 );
587
- $this->add_action ( 'admin_init', 'yop_poll_options_admin_init', 1 );
588
- $this->add_action ( 'admin_menu', 'admin_menu', 1 );
589
- $this->add_action ( 'wp_ajax_yop_poll_editor', 'ajax_get_polls_for_editor', 1 );
590
- $this->add_action ( 'wp_ajax_yop_poll_preview_template', 'ajax_preview_template', 1 );
591
- $this->add_action ( 'wp_ajax_yop_poll_html_editor', 'ajax_get_polls_for_html_editor', 1 );
592
- $this->add_action ( 'wp_ajax_yop_poll_edit_add_new_poll', 'ajax_edit_add_new_poll', 1 );
593
- $this->add_action ( 'wp_ajax_yop_poll_edit_add_new_poll_template', 'ajax_edit_add_new_poll_template', 1 );
594
- $this->add_action ( 'wp_ajax_yop_poll_reset_poll_template', 'ajax_reset_poll_template', 1 );
595
- $this->add_action ( 'wp_ajax_yop_poll_show_optin_box_modal', 'ajax_show_optin_box_modal', 1 );
596
- $this->add_action ( 'wp_ajax_yop_poll_modal_option_signup', 'ajax_modal_option_signup', 1 );
597
- $this->add_action ( 'wp_ajax_yop_poll_sidebar_option_signup', 'ajax_sidebar_option_signup', 1 );
598
- $this->add_action ( 'wp_ajax_yop_poll_show_change_votes_number_answer', 'ajax_show_change_votes_number_answer', 1 );
599
- $this->add_action ( 'wp_ajax_yop_poll_do_change_votes_number_answer', 'ajax_do_change_votes_number_answer', 1 );
600
601
- $this->add_action ( 'wp_ajax_yop_poll_show_change_total_number_poll', 'ajax_show_change_total_number_poll', 1 );
602
- $this->add_action ( 'wp_ajax_yop_poll_do_change_total_number_poll', 'ajax_do_change_total_number_poll', 1 );
603
604
- $this->add_action ( 'wp_ajax_yop_poll_show_change_poll_author', 'ajax_show_change_poll_author', 1 );
605
- $this->add_action ( 'wp_ajax_yop_poll_do_change_poll_author', 'ajax_do_change_poll_author', 1 );
606
607
- $this->add_action ( 'wp_ajax_yop_poll_show_change_template_author', 'ajax_show_change_template_author', 1 );
608
- $this->add_action ( 'wp_ajax_yop_poll_do_change_template_author', 'ajax_do_change_template_author', 1 );
609
610
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_do_vote', 'yop_poll_do_vote', 1 );
611
- $this->add_action ( 'wp_ajax_yop_poll_do_vote', 'yop_poll_do_vote', 1 );
612
613
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_view_results', 'yop_poll_view_results', 1 );
614
- $this->add_action ( 'wp_ajax_yop_poll_view_results', 'yop_poll_view_results', 1 );
615
616
- $this->add_action ( 'wp_ajax_yop_poll_back_to_vote', 'yop_poll_back_to_vote', 1 );
617
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_back_to_vote', 'yop_poll_back_to_vote', 1 );
618
619
- $this->add_action ( 'wp_ajax_yop_poll_load_css', 'yop_poll_load_css', 1 );
620
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_load_css', 'yop_poll_load_css', 1 );
621
622
- $this->add_action ( 'wp_ajax_yop_poll_load_js', 'yop_poll_load_js', 1 );
623
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_load_js', 'yop_poll_load_js', 1 );
624
625
- $this->add_action ( 'wp_ajax_yop_poll_show_captcha', 'ajax_show_captcha', 1 );
626
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_show_captcha', 'ajax_show_captcha', 1 );
627
628
- $this->add_action ( 'wp_ajax_yop_poll_play_captcha', 'ajax_play_captcha', 1 );
629
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_play_captcha', 'ajax_play_captcha', 1 );
630
631
- $this->add_action ( 'wp_ajax_yop_poll_is_wordpress_user', 'ajax_is_wordpress_user', 1 );
632
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_is_wordpress_user', 'ajax_is_wordpress_user', 1 );
633
634
- $this->add_action ( 'wp_ajax_yop_poll_set_wordpress_vote', 'ajax_set_wordpress_vote', 1 );
635
- $this->add_action ( 'wp_ajax_nopriv_yop_poll_set_wordpress_vote', 'ajax_set_wordpress_vote', 1 );
636
}
637
638
/**
639
* this file is executed on activation
640
* it creates the database and adds some data to database's table
641
*/
642
- public function activate($networkwide) {
643
global $wp_version;
644
- if (! version_compare ( $wp_version, YOP_POLL_WP_VERSION, '>=' )) {
645
- $error = new WP_Error ( 'Wordpress_version_error', sprintf ( __ ( 'You need at least Wordpress version %s to use this plugin', 'yop_poll' ), YOP_POLL_WP_VERSION ), __ ( 'Error: Wordpress Version Problem', 'yop_poll' ) );
646
647
// die & print error message & code - for admins only!
648
- if (isset ( $error ) && is_wp_error ( $error ) && current_user_can ( 'manage_options' ))
649
- wp_die ( $error->get_error_message (), $error->get_error_data () );
650
- } else {
651
- if (! extension_loaded ( 'json' )) {
652
- $error = new WP_Error ( 'Wordpress_json_error', __ ( 'You need the json php extension for this plugin', 'yop_poll' ), __ ( 'Error: Wordpress Extension Problem', 'yop_poll' ) );
653
654
// die & print error message & code - for admins only!
655
- if (isset ( $error ) && is_wp_error ( $error ) && current_user_can ( 'manage_options' ))
656
- wp_die ( $error->get_error_message (), $error->get_error_data () );
657
}
658
// including upgrade.php for using dbDelta()
659
- require_once (ABSPATH . 'wp-admin/includes/upgrade.php');
660
// including db_schema class file
661
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
662
- require_once (YOP_POLL_INC . '/' . 'db_schema.php');
663
// create tables
664
- Yop_Poll_DbSchema::create_poll_database_tables ();
665
}
666
}
667
- public function deactivate($networkwide) {
668
/*
669
* global $wpdb; delete_option( 'yop_poll_version' ); delete_option( 'yop_poll_options' ); delete_option( 'yop_poll_first_install_date' ); delete_option( 'yop_poll_admin_notices_donate' ); $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_bans`, `". $wpdb->prefix ."yop_poll_templates`, `". $wpdb->prefix ."yop_poll_votes_custom_fields`");
670
*/
671
- $poll_archive_page = get_page_by_path ( 'yop-poll-archive', ARRAY_A );
672
- if ($poll_archive_page) {
673
$poll_archive_page_id = $poll_archive_page ['ID'];
674
- wp_delete_post ( $poll_archive_page_id, true );
675
}
676
- $schedule_timestamp = wp_next_scheduled( 'yop_poll_hourly_event', array() );
677
- if ( $schedule_timestamp ) {
678
wp_unschedule_event( $schedule_timestamp, 'yop_poll_hourly_event', array() );
679
}
680
}
681
682
public function admin_menu() {
683
- if (is_admin () && $this->current_user_can ( 'edit_own_polls' )) {
684
- if (function_exists ( 'add_menu_page' )) {
685
- if ($this->current_user_can ( 'edit_own_polls' ))
686
- $page = add_menu_page ( __ ( 'Yop Poll', 'yop_poll' ), __ ( 'Yop Poll', 'yop_poll' ), 'read', 'yop-polls', array (
687
- $this,
688
- 'manage_pages'
689
- ), "{$this->_config->plugin_url}/images/yop-poll-admin-menu-icon16.png", '28.734' );
690
- }
691
- if ($this->current_user_can ( 'edit_own_polls' ))
692
- add_action ( "load-$page", array (
693
- &$this,
694
- 'manage_pages_load'
695
- ) );
696
- if (function_exists ( 'add_submenu_page' )) {
697
-
698
- if ($this->current_user_can ( 'edit_own_polls' )) {
699
- $subpage = add_submenu_page ( 'yop-polls', __ ( 'All Polls', 'yop_poll' ), __ ( 'All Polls', 'yop_poll' ), 'read', 'yop-polls', array (
700
- &$this,
701
- 'manage_pages'
702
- ) );
703
- add_action ( "load-$subpage", array (
704
- &$this,
705
- 'manage_pages_load'
706
- ) );
707
- }
708
- if ($this->current_user_can ( 'edit_own_polls' )) {
709
- $subpage = add_submenu_page ( 'yop-polls', __ ( 'Add New', 'yop_poll' ), __ ( 'Add New', 'yop_poll' ), 'read', 'yop-polls-add-new', array (
710
- &$this,
711
- 'manage_pages'
712
- ) );
713
- add_action ( "load-$subpage", array (
714
- &$this,
715
- 'manage_pages_load'
716
- ) );
717
- }
718
- if ($this->current_user_can ( 'manage_polls_options' )) {
719
- $subpage = add_submenu_page ( 'yop-polls', __ ( 'Options', 'yop_poll' ), __ ( 'Options', 'yop_poll' ), 'read', 'yop-polls-options', array (
720
- &$this,
721
- 'manage_pages'
722
- ) );
723
- add_action ( "load-$subpage", array (
724
- &$this,
725
- 'manage_pages_load'
726
- ) );
727
- }
728
- if ($this->current_user_can ( 'edit_own_polls_templates' )) {
729
- $subpage = add_submenu_page ( 'yop-polls', __ ( 'Templates', 'yop_poll' ), __ ( 'Templates', 'yop_poll' ), 'read', 'yop-polls-templates', array (
730
- &$this,
731
- 'manage_pages'
732
- ) );
733
- add_action ( "load-$subpage", array (
734
- &$this,
735
- 'manage_pages_load'
736
- ) );
737
- }
738
- if ($this->current_user_can ( 'view_own_polls_logs' )) {
739
- $subpage = add_submenu_page ( 'yop-polls', __ ( 'Logs', 'yop_poll' ), __ ( 'Logs', 'yop_poll' ), 'read', 'yop-polls-logs', array (
740
- &$this,
741
- 'manage_pages'
742
- ) );
743
- add_action ( "load-$subpage", array (
744
- &$this,
745
- 'manage_pages_load'
746
- ) );
747
- }
748
- if ($this->current_user_can ( 'manage_polls_bans' )) {
749
- $subpage = add_submenu_page ( 'yop-polls', __ ( 'Bans', 'yop_poll' ), __ ( 'Bans', 'yop_poll' ), 'read', 'yop-polls-bans', array (
750
- &$this,
751
- 'manage_pages'
752
- ) );
753
- add_action ( "load-$subpage", array (
754
- &$this,
755
- 'manage_pages_load'
756
- ) );
757
- }
758
- if ($this->current_user_can ( 'become_pro' )) {
759
- $subpage = add_submenu_page ( 'yop-polls', __ ( 'Become Pro', 'yop_poll' ), __ ( 'Become Pro', 'yop_poll' ), 'read', 'yop-polls-become-pro', array (
760
- &$this,
761
- 'manage_pages'
762
- ) );
763
- add_action ( "load-$subpage", array (
764
- &$this,
765
- 'manage_pages_load'
766
- ) );
767
}
768
}
769
}
770
}
771
public function manage_pages() {
772
global $page, $action;
773
- switch ($page) {
774
case 'yop-polls' :
775
- if ('custom-fields' == $action) {
776
- $this->view_poll_custom_fields ();
777
break;
778
}
779
- if ('results' == $action) {
780
- $this->view_poll_results ();
781
break;
782
- } elseif ('edit' == $action) {
783
- } else {
784
- $this->view_all_polls ();
785
break;
786
}
787
case 'yop-polls-add-new' :
788
- $this->view_add_edit_new_poll ();
789
break;
790
case 'yop-polls-options' :
791
- $this->view_yop_poll_options ();
792
break;
793
case 'yop-polls-logs' :
794
- $this->view_yop_poll_logs ();
795
break;
796
case 'yop-polls-bans' :
797
- $this->view_yop_poll_bans ();
798
break;
799
case 'yop-polls-become-pro' :
800
- $this->view_yop_poll_become_pro ();
801
break;
802
case 'yop-polls-templates' :
803
- if ('add-new' == $action || 'edit' == $action) {
804
- $this->view_add_edit_poll_template ();
805
- } else {
806
- $this->view_yop_poll_templates ();
807
}
808
break;
809
default :
810
- $this->view_all_polls ();
811
}
812
}
813
public function manage_pages_load() {
814
- wp_reset_vars ( array (
815
- 'page',
816
- 'action',
817
- 'orderby',
818
- 'order'
819
- ) );
820
global $page, $action, $orderby, $order, $yop_poll_add_new_config;
821
- $default_options = get_option ( 'yop_poll_options', array () );
822
823
- wp_enqueue_style ( 'yop-poll-admin', "{$this->_config->plugin_url}/css/yop-poll-admin.css", array (), $this->_config->version );
824
- $answers_number = $this->_config->min_number_of_answers + 1; // total +1
825
$customfields_number = $this->_config->min_number_of_customfields + 1; // total +1
826
827
- wp_enqueue_script('yop-poll-admin', "{$this->_config->plugin_url}/js/yop-poll-admin.js", array (
828
- 'jquery'
829
- ), $this->_config->version, true );
830
-
831
- switch ($page) {
832
case 'yop-polls' :
833
- if ('results' == $action) {
834
- wp_enqueue_style ( 'yop-poll-admin-results', "{$this->_config->plugin_url}/css/yop-poll-admin-results.css", array (), $this->_config->version );
835
- wp_enqueue_style ( 'yop-poll-timepicker', "{$this->_config->plugin_url}/css/timepicker.css", array (), $this->_config->version );
836
- wp_enqueue_style ( 'yop-poll-jquery-ui', "{$this->_config->plugin_url}/css/jquery-ui.css", array (), $this->_config->version );
837
- wp_enqueue_script ( 'yop-poll-jquery-ui-timepicker', "{$this->_config->plugin_url}/js/jquery-ui-timepicker-addon.js", array (
838
- 'jquery',
839
- 'jquery-ui-datepicker',
840
- 'jquery-ui-slider'
841
- ), $this->_config->version, true );
842
- wp_enqueue_style ( 'yop-poll-admin-custom-fields', "{$this->_config->plugin_url}/css/yop-poll-admin-custom-fields.css", array (), $this->_config->version );
843
- wp_enqueue_script ( 'yop-poll-admin-custom-fields', "{$this->_config->plugin_url}/js/yop-poll-admin-custom-fields.js", array (
844
- 'jquery',
845
- 'yop-poll-jquery-ui-timepicker'
846
- ), $this->_config->version, true );
847
- $this->yop_poll_custom_fields_results_operations ();
848
break;
849
}
850
- if ('custom-fields' == $action) {
851
- wp_enqueue_style ( 'yop-poll-timepicker', "{$this->_config->plugin_url}/css/timepicker.css", array (), $this->_config->version );
852
- wp_enqueue_style ( 'yop-poll-jquery-ui', "{$this->_config->plugin_url}/css/jquery-ui.css", array (), $this->_config->version );
853
- wp_enqueue_script ( 'yop-poll-jquery-ui-timepicker', "{$this->_config->plugin_url}/js/jquery-ui-timepicker-addon.js", array (
854
- 'jquery',
855
- 'jquery-ui-datepicker',
856
- 'jquery-ui-slider'
857
- ), $this->_config->version, true );
858
- wp_enqueue_style ( 'yop-poll-admin-custom-fields', "{$this->_config->plugin_url}/css/yop-poll-admin-custom-fields.css", array (), $this->_config->version );
859
- wp_enqueue_script ( 'yop-poll-admin-custom-fields', "{$this->_config->plugin_url}/js/yop-poll-admin-custom-fields.js", array (
860
- 'jquery',
861
- 'yop-poll-jquery-ui-timepicker'
862
- ), $this->_config->version, true );
863
- $this->yop_poll_custom_fields_operations ();
864
break;
865
- }
866
- elseif ('edit' == $action) {
867
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
868
- $poll_id = (isset ( $_GET ['id'] ) ? intval ( $_GET ['id'] ) : 0);
869
- $yop_poll_model = new Yop_Poll_Model ( $poll_id );
870
- $answers = Yop_Poll_Model::get_poll_answers ( $poll_id );
871
- $answers_number = count ( $answers ) + 1; // total +1
872
- $custom_fields = Yop_Poll_Model::get_poll_customfields ( $poll_id );
873
- $customfields_number = count ( $custom_fields ) + 1; // total +1
874
- }
875
else {
876
- $this->view_all_polls_operations ();
877
- wp_enqueue_script ( 'link' );
878
- wp_enqueue_script ( 'xfn' );
879
- wp_enqueue_script ( 'yop-poll-optin-form', "http://app.getresponse.com/view_webform.js?wid=394041&mg_param1=1", NULL, $this->_config->version, true );
880
- $this->load_optin_box ();
881
break;
882
}
883
884
case 'yop-polls-add-new' :
885
- $yop_poll_add_new_config = array (
886
- 'ajax' => array (
887
- 'url' => admin_url ( 'admin-ajax.php', (is_ssl () ? 'https' : 'http') ),
888
- 'action' => 'yop_poll_edit_add_new_poll',
889
- 'beforeSendMessage' => __ ( 'Please wait a moment while we process your request...', 'yop_poll' ),
890
- 'errorMessage' => __ ( 'An error has occured...', 'yop_poll' )
891
- ),
892
- 'text_answer' => __ ( 'Answer', 'yop_poll' ),
893
- 'text_customfield' => __ ( 'Custom Text Field', 'yop_poll' ),
894
- 'text_requiered_customfield' => __ ( 'Required', 'yop_poll' ),
895
- 'text_remove_answer' => __ ( 'Remove', 'yop_poll' ),
896
- 'text_remove_customfield' => __ ( 'Remove', 'yop_poll' ),
897
- 'text_customize_answer' => __ ( 'More Options', 'yop_poll' ),
898
- 'text_change_votes_number_answer' => __ ( 'Change Number Of Votes', 'yop_poll' ),
899
- 'text_change_votes_number_poll' => __ ( 'Change Number Of Total Votes', 'yop_poll' ),
900
- 'text_change_answers_number_poll' => __ ( 'Change Number Of Total Answers', 'yop_poll' ),
901
- 'plugin_url' => $this->_config->plugin_url,
902
- 'default_number_of_answers' => $answers_number,
903
- 'default_number_of_customfields' => $customfields_number,
904
- 'text_is_default_answer' => __( 'Make this the default answer', 'yop_poll').'<br><font size="0">(' . __('if "yes", answer will be autoselected when poll is displayed', 'yop_poll' ) .')</font>',
905
- 'text_poll_bar_style' => array (
906
- 'use_template_bar_label' => __ ( 'Use Template Result Bar', 'yop_poll' ),
907
- 'use_template_bar_yes_label' => __ ( 'Yes', 'yop_poll' ),
908
- 'use_template_bar_no_label' => __ ( 'No', 'yop_poll' ),
909
- 'poll_bar_style_label' => __ ( 'Yop Poll Bar Style', 'yop_poll' ),
910
- 'poll_bar_preview_label' => __ ( 'Yop Poll Bar Preview', 'yop_poll' ),
911
- 'poll_bar_style_background_label' => __ ( 'Background Color', 'yop_poll' ),
912
- 'poll_bar_style_height_label' => __ ( 'Height', 'yop_poll' ),
913
- 'poll_bar_style_border_color_label' => __ ( 'Border Color', 'yop_poll' ),
914
- 'poll_bar_style_border_width_label' => __ ( 'Border Width', 'yop_poll' ),
915
- 'poll_bar_style_border_style_label' => __ ( 'Border Style', 'yop_poll' )
916
- ),
917
- 'poll_bar_default_options' => array (
918
- 'use_template_bar' => isset ( $default_options ['use_template_bar'] ) ? $default_options ['use_template_bar'] : 'yes',
919
- 'height' => isset ( $default_options ['bar_height'] ) ? $default_options ['bar_height'] : 10,
920
- 'background_color' => isset ( $default_options ['bar_background'] ) ? $default_options ['bar_background'] : 'd8e1eb',
921
- 'border' => isset ( $default_options ['bar_border_style'] ) ? $default_options ['bar_border_style'] : 'solid',
922
- 'border_width' => isset ( $default_options ['bar_border_width'] ) ? $default_options ['bar_border_width'] : 1,
923
- 'border_color' => isset ( $default_options ['bar_border_color'] ) ? $default_options ['bar_border_color'] : 'c8c8c8'
924
- )
925
- );
926
- wp_enqueue_style ( 'yop-poll-admin-add-new', "{$this->_config->plugin_url}/css/yop-poll-admin-add-new.css", array (), $this->_config->version );
927
- wp_enqueue_style ( 'yop-poll-timepicker', "{$this->_config->plugin_url}/css/timepicker.css", array (), $this->_config->version );
928
- wp_enqueue_style ( 'yop-poll-jquery-ui', "{$this->_config->plugin_url}/css/jquery-ui.css", array (), $this->_config->version );
929
-
930
- wp_enqueue_script ( 'yop-poll-admin-add-new', "{$this->_config->plugin_url}/js/yop-poll-admin-add-new.js", array (
931
- 'jquery',
932
- 'yop-poll-jquery-ui-timepicker'
933
- ), $this->_config->version, true );
934
- wp_enqueue_script ( 'yop-poll-jquery-ui-timepicker', "{$this->_config->plugin_url}/js/jquery-ui-timepicker-addon.js", array (
935
- 'jquery',
936
- 'jquery-ui-datepicker',
937
- 'jquery-ui-slider'
938
- ), $this->_config->version, true );
939
- wp_enqueue_script ( 'yop-poll-modal-box-js', "{$this->_config->plugin_url}/modal/js/jquery.modalbox-1.5.0-min.js", array (
940
- 'jquery'
941
- ), $this->_config->version, true );
942
- wp_enqueue_style ( 'yop-poll-modal-box-css', "{$this->_config->plugin_url}/modal/css/jquery.modalbox-skin-precious-white.css", array (), $this->_config->version );
943
- wp_localize_script ( 'yop-poll-admin-add-new', 'yop_poll_add_new_config', $yop_poll_add_new_config );
944
- wp_enqueue_script ( 'link' );
945
- wp_enqueue_script ( 'xfn' );
946
break;
947
case 'yop-polls-logs' :
948
- wp_enqueue_style ( 'yop-poll-timepicker', "{$this->_config->plugin_url}/css/timepicker.css", array (), $this->_config->version );
949
- wp_enqueue_style ( 'yop-poll-jquery-ui', "{$this->_config->plugin_url}/css/jquery-ui.css", array (), $this->_config->version );
950
- wp_enqueue_script ( 'yop-poll-jquery-ui-timepicker', "{$this->_config->plugin_url}/js/jquery-ui-timepicker-addon.js", array (
951
- 'jquery',
952
- 'jquery-ui-datepicker',
953
- 'jquery-ui-slider'
954
- ), $this->_config->version, true );
955
- wp_enqueue_script ( 'yop-poll-admin-logs', "{$this->_config->plugin_url}/js/yop-poll-admin-logs.js", array (
956
- 'jquery',
957
- 'yop-poll-jquery-ui-timepicker'
958
- ), $this->_config->version, true );
959
- $this->view_yop_poll_logs_operations ();
960
break;
961
case 'yop-polls-bans' :
962
- wp_enqueue_script ( 'yop-poll-admin-bans', "{$this->_config->plugin_url}/js/yop-poll-admin-bans.js", array (
963
- 'jquery'
964
- ), $this->_config->version, true );
965
- $this->view_yop_poll_bans_operations ();
966
break;
967
case 'yop-polls-options' :
968
- wp_enqueue_style ( 'yop-poll-admin-options', "{$this->_config->plugin_url}/css/yop-poll-admin-options.css", array (), $this->_config->version );
969
- wp_enqueue_style ( 'yop-poll-timepicker', "{$this->_config->plugin_url}/css/timepicker.css", array (), $this->_config->version );
970
- wp_enqueue_style ( 'yop-poll-jquery-ui', "{$this->_config->plugin_url}/css/jquery-ui.css", array (), $this->_config->version );
971
- wp_enqueue_script ( 'yop-poll-admin-options', "{$this->_config->plugin_url}/js/yop-poll-admin-options.js", array (
972
- 'jquery',
973
- 'yop-poll-jquery-ui-timepicker'
974
- ), $this->_config->version, true );
975
- wp_enqueue_script ( 'yop-poll-jquery-ui-timepicker', "{$this->_config->plugin_url}/js/jquery-ui-timepicker-addon.js", array (
976
- 'jquery',
977
- 'jquery-ui-datepicker',
978
- 'jquery-ui-slider'
979
- ), $this->_config->version, true );
980
- wp_enqueue_script ( 'link' );
981
- wp_enqueue_script ( 'xfn' );
982
break;
983
case 'yop-polls-templates' :
984
- add_filter ( 'user_can_richedit', create_function ( '$a', 'return false;' ), 1 );
985
- wp_enqueue_script ( array (
986
- 'editor',
987
- 'thickbox'
988
- ) );
989
- wp_enqueue_style ( 'thickbox' );
990
- wp_enqueue_script ( 'yop-poll-admin-templates', "{$this->_config->plugin_url}/js/yop-poll-admin-templates.js", array (
991
- 'jquery'
992
- ), $this->_config->version, true );
993
- $yop_poll_add_new_template_config = array (
994
- 'ajax' => array (
995
- 'url' => admin_url ( 'admin-ajax.php', (is_ssl () ? 'https' : 'http') ),
996
- 'action' => 'yop_poll_edit_add_new_poll_template',
997
- 'reset_action' => 'yop_poll_reset_poll_template',
998
- 'beforeSendMessage' => __ ( 'Please wait a moment while we process your request...', 'yop_poll' ),
999
- 'errorMessage' => __ ( 'An error has occured...', 'yop_poll' )
1000
- )
1001
- );
1002
- wp_enqueue_script ( 'yop-poll-modal-box-js', "{$this->_config->plugin_url}/modal/js/jquery.modalbox-1.5.0-min.js", array (
1003
- 'jquery'
1004
- ), $this->_config->version, true );
1005
- wp_enqueue_style ( 'yop-poll-modal-box-css', "{$this->_config->plugin_url}/modal/css/jquery.modalbox-skin-precious-white.css", array (), $this->_config->version );
1006
- wp_localize_script ( 'yop-poll-admin-templates', 'yop_poll_add_new_template_config', $yop_poll_add_new_template_config );
1007
- $this->view_yop_poll_templates_operations ();
1008
break;
1009
default :
1010
- $this->view_all_polls_operations ();
1011
break;
1012
}
1013
}
1014
1015
/**
@@ -1017,365 +908,311 @@ EOT;
1017
*/
1018
public function view_yop_poll_logs_operations() {
1019
global $page, $action, $order, $orderby, $current_user;
1020
- if ('-1' != $action && isset ( $_REQUEST ['yoppolllogscheck'] )) {
1021
- if ('delete' == $action) {
1022
- check_admin_referer ( 'yop-poll-logs' );
1023
- $bulklogs = ( array ) $_REQUEST ['yoppolllogscheck'];
1024
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1025
$total_deleted = 0;
1026
foreach ( $bulklogs as $log_id ) {
1027
- $log_id = ( int ) $log_id;
1028
- $poll_id = Yop_Poll_Model::get_poll_log_field_from_database_by_id ( 'poll_id', $log_id );
1029
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $poll_id );
1030
- if (($this->current_user_can ( 'delete_own_polls_logs' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls_logs' )))
1031
- Yop_Poll_Model::delete_poll_log_from_db ( $log_id );
1032
- else
1033
- $total_deleted ++;
1034
- }
1035
- wp_redirect ( add_query_arg ( 'deleted', count ( $bulklogs ) - $total_deleted, remove_query_arg ( array (
1036
- '_wp_http_referer',
1037
- '_wpnonce',
1038
- 'action',
1039
- 'yoppolllogscheck'
1040
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1041
exit ();
1042
}
1043
1044
- if ('delete_group' == $action) {
1045
- check_admin_referer ( 'yop-poll-logs' );
1046
- $bulklogs = ( array ) $_REQUEST ['yoppolllogscheck'];
1047
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1048
$total_deleted_group = 0;
1049
foreach ( $bulklogs as $vote_id ) {
1050
- $poll_id = Yop_Poll_Model::get_poll_log_field_from_database_by_vote_id ( 'poll_id', $vote_id );
1051
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $poll_id );
1052
- if (($this->current_user_can ( 'delete_own_polls_logs' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls_logs' )))
1053
- Yop_Poll_Model::delete_group_poll_log_from_db ( $vote_id );
1054
- else
1055
- $total_deleted_group ++;
1056
- }
1057
- wp_redirect ( add_query_arg ( 'deleted', count ( $bulklogs ) - $total_deleted_group, remove_query_arg ( array (
1058
- '_wp_http_referer',
1059
- '_wpnonce',
1060
- 'action',
1061
- 'yoppolllogscheck'
1062
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1063
exit ();
1064
}
1065
- } elseif ('-1' != $action && isset ( $_REQUEST ['id'] )) {
1066
- if ('delete' == $action) {
1067
- check_admin_referer ( 'yop-poll-logs-delete' );
1068
- $log_id = ( int ) $_REQUEST ['id'];
1069
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1070
- $poll_id = Yop_Poll_Model::get_poll_log_field_from_database_by_id ( 'poll_id', $log_id );
1071
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $poll_id );
1072
- if (($this->current_user_can ( 'delete_own_polls_logs' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls_logs' )))
1073
- Yop_Poll_Model::delete_poll_log_from_db ( $log_id );
1074
- else
1075
- wp_die ( __ ( 'You are not allowed to delete this item.', 'yop_poll' ) );
1076
- wp_redirect ( add_query_arg ( 'deleted', 1, remove_query_arg ( array (
1077
- '_wpnonce',
1078
- 'id',
1079
- 'action'
1080
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1081
exit ();
1082
}
1083
- if ('delete_group' == $action) {
1084
- check_admin_referer ( 'yop-poll-logs-delete' );
1085
$vote_id = $_REQUEST ['id'];
1086
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1087
- $poll_id = Yop_Poll_Model::get_poll_log_field_from_database_by_vote_id ( 'poll_id', $vote_id );
1088
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $poll_id );
1089
- if (($this->current_user_can ( 'delete_own_polls_logs' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls_logs' )))
1090
- Yop_Poll_Model::delete_group_poll_log_from_db ( $vote_id );
1091
- else
1092
- wp_die ( __ ( 'You are not allowed to delete this item.', 'yop_poll' ) );
1093
- wp_redirect ( add_query_arg ( 'deleted', 1, remove_query_arg ( array (
1094
- '_wpnonce',
1095
- 'id',
1096
- 'action'
1097
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1098
exit ();
1099
}
1100
- } elseif (isset ( $_REQUEST ['export'] )) {
1101
global $wpdb;
1102
- if ( isset( $_REQUEST ['a'] ) && __ ( 'Export', 'yop_poll' ) == $_REQUEST ['a'] ) {
1103
- check_admin_referer ( 'yop-poll-logs' );
1104
- $per_page = (isset ( $_GET ['per_page'] ) ? intval ( $_GET ['per_page'] ) : 100);
1105
- $page_no = isset ( $_REQUEST ['page_no'] ) ? ( int ) $_REQUEST ['page_no'] : 1;
1106
- $orderby = (empty ( $orderby )) ? 'name' : $orderby;
1107
- $poll_id = isset ( $_REQUEST ['poll_id'] ) ? ( int ) $_REQUEST ['poll_id'] : NULL;
1108
- $log_sdate = (isset ( $_GET ['log_sdate'] ) ? $_GET ['log_sdate'] : '');
1109
- $log_edate = (isset ( $_GET ['log_edate'] ) ? $_GET ['log_edate'] : '');
1110
- $group_by = (isset ( $_GET ['group_by'] ) ? $_GET ['group_by'] : 'vote');
1111
-
1112
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1113
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $poll_id );
1114
- if ($this->current_user_can ( 'view_own_polls_logs' ) && $poll_id) {
1115
- if ($poll_author != $current_user->ID && ! $this->current_user_can ( 'view_polls_logs' ))
1116
- wp_die ( __ ( 'You are not allowed to access this section.', 'yop_poll' ) );
1117
- } elseif (! $this->current_user_can ( 'view_polls_logs' )) {
1118
- wp_die ( __ ( 'You are not allowed to access this section.', 'yop_poll' ) );
1119
- }
1120
-
1121
- $yop_polls = Yop_Poll_Model::get_yop_polls_filter_search ( 'id', 'asc' );
1122
- if ($group_by == 'vote')
1123
- $search = array (
1124
- 'fields' => array (
1125
- 'name',
1126
- 'ip',
1127
- 'user_nicename',
1128
- 'user_email',
1129
- 'user_from',
1130
- 'tr_id'
1131
- ),
1132
- 'value' => isset ( $_REQUEST ['s'] ) ? trim ( $_REQUEST ['s'] ) : ''
1133
- );
1134
- else
1135
- $search = array (
1136
- 'fields' => array (
1137
- 'name',
1138
- 'answer',
1139
- 'ip',
1140
- 'other_answer_value',
1141
- 'user_nicename',
1142
- 'user_from',
1143
- 'user_email',
1144
- 'tr_id'
1145
- ),
1146
- 'value' => isset ( $_REQUEST ['s'] ) ? trim ( $_REQUEST ['s'] ) : ''
1147
- );
1148
- $filter = array (
1149
- 'field' => NULL,
1150
- 'value' => NULL,
1151
- 'operator' => '='
1152
- );
1153
- if ('all' == $_REQUEST ['export'])
1154
- if ($group_by == 'vote')
1155
- $logs = Yop_Poll_Model::get_group_logs_filter_search ( $orderby, $order, $search, $poll_id, 0, 99999999, $log_sdate, $log_edate );
1156
- else
1157
- $logs = Yop_Poll_Model::get_logs_filter_search ( $orderby, $order, $search, $poll_id, 0, 99999999, $log_sdate, $log_edate );
1158
- if ('page' == $_REQUEST ['export'])
1159
- if ($group_by == 'vote')
1160
- $logs = Yop_Poll_Model::get_group_logs_filter_search ( $orderby, $order, $search, $poll_id, ($page_no - 1) * $per_page, $per_page, $log_sdate, $log_edate );
1161
- else
1162
- $logs = Yop_Poll_Model::get_logs_filter_search ( $orderby, $order, $search, $poll_id, ($page_no - 1) * $per_page, $per_page, $log_sdate, $log_edate );
1163
-
1164
- $csv_file_name = 'logs_export.' . date ( 'YmdHis' ) . '.csv';
1165
- $csv_header_array = array (
1166
- __ ( '#', 'yop_poll' ),
1167
- __ ( 'Vote ID', 'yop_poll' ),
1168
- __ ( 'POLL Name', 'yop_poll' ),
1169
- __ ( 'Answer', 'yop_poll' ),
1170
- __ ( 'User Type', 'yop_poll' ),
1171
- __ ( 'User', 'yop_poll' ),
1172
- __ ( 'User Email', 'yop_poll' ),
1173
- __ ( 'Tracking ID', 'yop_poll' ),
1174
- __ ( 'IP', 'yop_poll' ),
1175
- __ ( 'Vote Date', 'yop_poll' )
1176
- );
1177
-
1178
- header ( 'Content-type: application/csv' );
1179
- header ( 'Content-Disposition: attachment; filename="' . $csv_file_name . '"' );
1180
- ob_start ();
1181
- $f = fopen ( 'php://output', 'w' ) or show_error ( __ ( "Can't open php://output!", 'yop_poll' ) );
1182
-
1183
- if (! fputcsv ( $f, $csv_header_array ))
1184
- _e ( "Can't write header!", 'yop_poll' );
1185
-
1186
- if (count ( $logs ) > 0) {
1187
$index = 1;
1188
foreach ( $logs as $log ) {
1189
- $logs_data = array (
1190
- $index,
1191
- $log ['vote_id'],
1192
- stripslashes ( $log ['name'] ),
1193
- ('Other' == $log ['answer']) ? 'Other - ' . stripslashes ( $log ['other_answer_value'] ) : stripslashes ( $log ['answer'] ),
1194
- stripslashes ( $log ['user_from'] ),
1195
- stripslashes ( $log ['user_nicename'] ),
1196
- stripslashes ( $log ['user_email'] ),
1197
- stripslashes ( $log ['tr_id'] ),
1198
- stripslashes ( $log ['ip'] ),
1199
- stripslashes ( $log ['vote_date'] )
1200
- );
1201
- if (! fputcsv ( $f, $logs_data ))
1202
- _e ( "Can't write header!", 'yop_poll' );
1203
- $index ++;
1204
}
1205
}
1206
1207
- fclose ( $f ) or show_error ( __ ( "Can't close php://output!", 'yop_poll' ) );
1208
- $csvStr = ob_get_contents ();
1209
- ob_end_clean ();
1210
1211
echo $csvStr;
1212
exit ();
1213
}
1214
1215
- wp_safe_redirect ( remove_query_arg ( array (
1216
- '_wp_http_referer',
1217
- '_wpnonce',
1218
- 'export',
1219
- 'a'
1220
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1221
exit ();
1222
- } elseif (! empty ( $_GET ['_wp_http_referer'] )) {
1223
- wp_safe_redirect ( remove_query_arg ( array (
1224
- '_wp_http_referer',
1225
- '_wpnonce'
1226
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1227
exit ();
1228
}
1229
}
1230
public function yop_poll_custom_fields_operations() {
1231
global $page, $action;
1232
- if (isset ( $_REQUEST ['export'] )) {
1233
- check_admin_referer ( 'yop-poll-custom-fields' );
1234
- if ('' != $_REQUEST ['export']) {
1235
- $per_page = (isset ( $_GET ['per_page'] ) ? intval ( $_GET ['per_page'] ) : 100);
1236
- $page_no = (isset ( $_REQUEST ['page_no'] ) ? ( int ) $_REQUEST ['page_no'] : 1);
1237
- $poll_id = (isset ( $_GET ['id'] ) ? intval ( $_GET ['id'] ) : 0);
1238
- $sdate = (isset ( $_GET ['sdate'] ) ? $_GET ['sdate'] : '');
1239
- $edate = (isset ( $_GET ['edate'] ) ? $_GET ['edate'] : '');
1240
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1241
- $poll_details = YOP_POLL_MODEL::get_poll_from_database_by_id ( $poll_id );
1242
- $poll_custom_fields = YOP_POLL_MODEL::get_poll_customfields ( $poll_id );
1243
- $custom_fields_number = count ( $poll_custom_fields );
1244
- $column_custom_fields_ids = array ();
1245
- $total_custom_fields_logs = YOP_POLL_MODEL::get_poll_total_customfields_logs ( $poll_id, $sdate, $edate );
1246
- $total_custom_fields_logs_pages = ceil ( $total_custom_fields_logs / $per_page );
1247
- if (intval ( $page_no ) > intval ( $total_custom_fields_logs_pages ))
1248
$page_no = 1;
1249
1250
- if ('all' == $_REQUEST ['export'])
1251
- $custom_fields_logs = YOP_POLL_MODEL::get_poll_customfields_logs ( $poll_id, 'vote_id', 'asc', 0, 99999999, $sdate, $edate );
1252
- if ('page' == $_REQUEST ['export'])
1253
- $custom_fields_logs = YOP_POLL_MODEL::get_poll_customfields_logs ( $poll_id, 'vote_id', 'asc', ($page_no - 1) * $per_page, $per_page, $sdate, $edate );
1254
1255
- $csv_file_name = 'custom_fields_export.' . date ( 'YmdHis' ) . '.csv';
1256
- $csv_header_array = array (
1257
- __ ( '#', 'yop_poll' )
1258
- );
1259
foreach ( $poll_custom_fields as $custom_field ) {
1260
$column_custom_fields_ids [] = $custom_field ['id'];
1261
- $csv_header_array [] = ucfirst ( $custom_field ['custom_field'] );
1262
}
1263
- $csv_header_array [] = __ ( 'Vote Date', 'yop_poll' );
1264
1265
- header ( 'Content-type: application/csv' );
1266
- header ( 'Content-Disposition: attachment; filename="' . $csv_file_name . '"' );
1267
- ob_start ();
1268
- $f = fopen ( 'php://output', 'w' ) or show_error ( __ ( "Can't open php://output!", 'yop_poll' ) );
1269
$n = 0;
1270
- if (isset ( $csv_header_array ))
1271
- if (! fputcsv ( $f, $csv_header_array ))
1272
- _e ( "Can't write header!", 'yop_poll' );
1273
1274
- if (count ( $custom_fields_logs ) > 0) {
1275
$index = 1;
1276
foreach ( $custom_fields_logs as $logs ) {
1277
- $column_custom_fields_values = array (
1278
- $index
1279
- );
1280
foreach ( $column_custom_fields_ids as $custom_field_id ) {
1281
- $vote_log_values = array ();
1282
- $vote_logs = explode ( '<#!,>', $logs ['vote_log'] );
1283
- if (count ( $vote_logs ) > 0) {
1284
foreach ( $vote_logs as $vote_log ) {
1285
- $temp = explode ( '<#!->', $vote_log );
1286
- $vote_log_values [$temp [1]] = stripslashes ( $temp [0] );
1287
}
1288
}
1289
$column_custom_fields_values [] = isset ( $vote_log_values [$custom_field_id] ) ? $vote_log_values [$custom_field_id] : '';
1290
}
1291
$column_custom_fields_values [] = $logs ['vote_date'];
1292
- if (! fputcsv ( $f, $column_custom_fields_values ))
1293
- _e ( "Can't write record!", 'yop_poll' );
1294
- $index ++;
1295
}
1296
}
1297
- fclose ( $f ) or show_error ( __ ( "Can't close php://output!", 'yop_poll' ) );
1298
- $csvStr = ob_get_contents ();
1299
- ob_end_clean ();
1300
1301
echo $csvStr;
1302
exit ();
1303
}
1304
- wp_safe_redirect ( remove_query_arg ( array (
1305
- '_wp_http_referer',
1306
- '_wpnonce',
1307
- 'export',
1308
- 'a'
1309
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1310
exit ();
1311
- } elseif (! empty ( $_GET ['_wp_http_referer'] )) {
1312
- wp_safe_redirect ( remove_query_arg ( array (
1313
- '_wp_http_referer',
1314
- '_wpnonce',
1315
- 'a'
1316
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1317
exit ();
1318
}
1319
}
1320
public function yop_poll_custom_fields_results_operations() {
1321
global $page, $action;
1322
- if (isset ( $_REQUEST ['export'] )) {
1323
- check_admin_referer ( 'yop-poll-custom-fields' );
1324
- if (__ ( 'Export', 'yop_poll' ) == $_REQUEST ['a']) {
1325
- $cf_per_page = (isset ( $_GET ['cf_per_page'] ) ? intval ( $_GET ['cf_per_page'] ) : 100);
1326
- $cf_page_no = (isset ( $_REQUEST ['cf_page_no'] ) ? ( int ) $_REQUEST ['cf_page_no'] : 1);
1327
- $poll_id = (isset ( $_GET ['id'] ) ? intval ( $_GET ['id'] ) : 0);
1328
- $cf_sdate = (isset ( $_GET ['cf_sdate'] ) ? $_GET ['cf_sdate'] : '');
1329
- $cf_edate = (isset ( $_GET ['cf_edate'] ) ? $_GET ['cf_edate'] : '');
1330
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1331
- $poll_details = YOP_POLL_MODEL::get_poll_from_database_by_id ( $poll_id );
1332
- $poll_custom_fields = YOP_POLL_MODEL::get_poll_customfields ( $poll_id );
1333
- $custom_fields_number = count ( $poll_custom_fields );
1334
- $column_custom_fields_ids = array ();
1335
- $total_custom_fields_logs = YOP_POLL_MODEL::get_poll_total_customfields_logs ( $poll_id, $cf_sdate, $cf_edate );
1336
- $total_custom_fields_logs_pages = ceil ( $total_custom_fields_logs / $cf_per_page );
1337
- if (intval ( $cf_page_no ) > intval ( $total_custom_fields_logs_pages ))
1338
$cf_page_no = 1;
1339
1340
- if ('all' == $_REQUEST ['export'])
1341
- $custom_fields_logs = YOP_POLL_MODEL::get_poll_customfields_logs ( $poll_id, 'vote_id', 'asc', 0, 99999999, $cf_sdate, $cf_edate );
1342
- if ('page' == $_REQUEST ['export'])
1343
- $custom_fields_logs = YOP_POLL_MODEL::get_poll_customfields_logs ( $poll_id, 'vote_id', 'asc', ($cf_page_no - 1) * $cf_per_page, $cf_per_page, $cf_sdate, $cf_edate );
1344
1345
- $csv_file_name = 'custom_fields_export.' . date ( 'YmdHis' ) . '.csv';
1346
- $csv_header_array = array (
1347
- __ ( '#', 'yop_poll' )
1348
- );
1349
foreach ( $poll_custom_fields as $custom_field ) {
1350
$column_custom_fields_ids [] = $custom_field ['id'];
1351
- $csv_header_array [] = ucfirst ( $custom_field ['custom_field'] );
1352
}
1353
- $csv_header_array [] = __ ( 'Vote ID', 'yop_poll' );
1354
- $csv_header_array [] = __ ( 'Traking ID', 'yop_poll' );
1355
- $csv_header_array [] = __ ( 'Vote Date', 'yop_poll' );
1356
-
1357
- header ( 'Content-type: application/csv' );
1358
- header ( 'Content-Disposition: attachment; filename="' . $csv_file_name . '"' );
1359
- ob_start ();
1360
- $f = fopen ( 'php://output', 'w' ) or show_error ( __ ( "Can't open php://output!", 'yop_poll' ) );
1361
$n = 0;
1362
- if (isset ( $csv_header_array ))
1363
- if (! fputcsv ( $f, $csv_header_array ))
1364
- _e ( "Can't write header!", 'yop_poll' );
1365
1366
- if (count ( $custom_fields_logs ) > 0) {
1367
$index = 1;
1368
foreach ( $custom_fields_logs as $logs ) {
1369
- $column_custom_fields_values = array (
1370
- $index
1371
- );
1372
foreach ( $column_custom_fields_ids as $custom_field_id ) {
1373
- $vote_log_values = array ();
1374
- $vote_logs = explode ( '<#!,>', $logs ['vote_log'] );
1375
- if (count ( $vote_logs ) > 0) {
1376
foreach ( $vote_logs as $vote_log ) {
1377
- $temp = explode ( '<#!->', $vote_log );
1378
- $vote_log_values [$temp [1]] = stripslashes ( $temp [0] );
1379
}
1380
}
1381
$column_custom_fields_values [] = isset ( $vote_log_values [$custom_field_id] ) ? $vote_log_values [$custom_field_id] : '';
@@ -1383,332 +1220,287 @@ EOT;
1383
$column_custom_fields_values [] = $logs ['vote_id'];
1384
$column_custom_fields_values [] = $logs ['tr_id'];
1385
$column_custom_fields_values [] = $logs ['vote_date'];
1386
- if (! fputcsv ( $f, $column_custom_fields_values ))
1387
- _e ( "Can't write record!", 'yop_poll' );
1388
- $index ++;
1389
}
1390
}
1391
- fclose ( $f ) or show_error ( __ ( "Can't close php://output!", 'yop_poll' ) );
1392
- $csvStr = ob_get_contents ();
1393
- ob_end_clean ();
1394
1395
echo $csvStr;
1396
exit ();
1397
}
1398
- wp_safe_redirect ( remove_query_arg ( array (
1399
- '_wp_http_referer',
1400
- '_wpnonce',
1401
- 'export',
1402
- 'a'
1403
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1404
exit ();
1405
- } elseif (! empty ( $_GET ['_wp_http_referer'] )) {
1406
- wp_safe_redirect ( remove_query_arg ( array (
1407
- '_wp_http_referer',
1408
- '_wpnonce',
1409
- 'a'
1410
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1411
exit ();
1412
}
1413
}
1414
public function view_yop_poll_bans_operations() {
1415
global $page, $action;
1416
- if ('-1' != $action && isset ( $_REQUEST ['yoppollbanscheck'] )) {
1417
- if ('delete' == $action) {
1418
- check_admin_referer ( 'yop-poll-bans' );
1419
- $bulkbans = ( array ) $_REQUEST ['yoppollbanscheck'];
1420
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1421
foreach ( $bulkbans as $ban_id ) {
1422
- $ban_id = ( int ) $ban_id;
1423
- Yop_Poll_Model::delete_poll_ban_from_db ( $ban_id );
1424
- }
1425
- wp_redirect ( add_query_arg ( 'deleted', count ( $bulkbans ), remove_query_arg ( array (
1426
- '_wp_http_referer',
1427
- '_wpnonce',
1428
- 'yoppollbanscheck'
1429
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1430
exit ();
1431
}
1432
- } elseif ('-1' != $action && isset ( $_REQUEST ['id'] )) {
1433
- if ('delete' == $action) {
1434
- check_admin_referer ( 'yop-poll-bans-delete' );
1435
- $ban_id = ( int ) $_REQUEST ['id'];
1436
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1437
- Yop_Poll_Model::delete_poll_ban_from_db ( $ban_id );
1438
- wp_redirect ( add_query_arg ( 'deleted', 1, remove_query_arg ( array (
1439
- '_wpnonce',
1440
- 'id',
1441
- 'action'
1442
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1443
exit ();
1444
}
1445
- } elseif ('add-ban' == $action) {
1446
- check_admin_referer ( 'yop-poll-add-ban' );
1447
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1448
- $bans = Yop_Poll_Model::add_bans ( $_REQUEST );
1449
- if ($bans ['error'] != '') {
1450
- wp_redirect ( add_query_arg ( 'bans-error', urlencode ( $bans ['error'] ), remove_query_arg ( array (
1451
- '_wpnonce',
1452
- 'id',
1453
- 'action'
1454
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1455
exit ();
1456
- } else {
1457
- wp_redirect ( add_query_arg ( 'bans-added', urlencode ( ( int ) $bans ['success'] ), remove_query_arg ( array (
1458
- '_wpnonce',
1459
- 'id',
1460
- 'action'
1461
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1462
exit ();
1463
}
1464
- } elseif (! empty ( $_GET ['_wp_http_referer'] )) {
1465
- wp_safe_redirect ( remove_query_arg ( array (
1466
- '_wp_http_referer',
1467
- '_wpnonce'
1468
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1469
exit ();
1470
}
1471
}
1472
public function view_yop_poll_templates_operations() {
1473
global $page, $action, $yop_poll_add_new_config, $current_user;
1474
- if ('-1' != $action && isset ( $_REQUEST ['templatecheck'] )) {
1475
- if ('delete' == $action) {
1476
- check_admin_referer ( 'yop-poll-templates' );
1477
- $bulktemplates = ( array ) $_REQUEST ['templatecheck'];
1478
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1479
$total_deleted = 0;
1480
foreach ( $bulktemplates as $template_id ) {
1481
- $template_id = ( int ) $template_id;
1482
- $template_author = Yop_Poll_Model::get_poll_template_field_from_database_by_id ( 'template_author', $template_id );
1483
- if (($this->current_user_can ( 'delete_own_polls_templates' ) && $template_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls_templates' )))
1484
- Yop_Poll_Model::delete_poll_template_from_db ( $template_id );
1485
- else
1486
- $total_deleted ++;
1487
}
1488
- wp_redirect ( add_query_arg ( 'deleted', count ( $bulktemplates ) - $total_deleted, remove_query_arg ( array (
1489
- '_wp_http_referer',
1490
- '_wpnonce',
1491
- 'templatecheck'
1492
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1493
exit ();
1494
}
1495
- if ('clone' == $action) {
1496
- check_admin_referer ( 'yop-poll-templates' );
1497
- $bulktemplates = ( array ) $_REQUEST ['templatecheck'];
1498
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1499
$total_cloned = 0;
1500
foreach ( $bulktemplates as $template_id ) {
1501
- $template_id = ( int ) $template_id;
1502
- $template_author = Yop_Poll_Model::get_poll_template_field_from_database_by_id ( 'template_author', $template_id );
1503
- if (($this->current_user_can ( 'clone_own_polls_templates' ) && $template_author == $current_user->ID) || ($this->current_user_can ( 'clone_polls_templates' )))
1504
- Yop_Poll_Model::clone_poll_template ( $template_id );
1505
- else
1506
- $total_cloned ++;
1507
}
1508
- wp_redirect ( add_query_arg ( 'cloned', count ( $bulktemplates ) - $total_cloned, remove_query_arg ( array (
1509
- '_wp_http_referer',
1510
- '_wpnonce',
1511
- 'templatecheck'
1512
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1513
exit ();
1514
}
1515
- } elseif ('-1' != $action && isset ( $_REQUEST ['id'] )) {
1516
- if ('delete' == $action) {
1517
- check_admin_referer ( 'yop-poll-templates' );
1518
- $template_id = ( int ) $_REQUEST ['id'];
1519
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1520
- $template_author = Yop_Poll_Model::get_poll_template_field_from_database_by_id ( 'template_author', $template_id );
1521
- if (($this->current_user_can ( 'delete_own_polls_templates' ) && $template_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls_templates' )))
1522
- Yop_Poll_Model::delete_poll_template_from_db ( $template_id );
1523
- else
1524
- wp_die ( __ ( 'You are not allowed to delete this item.', 'yop_poll' ) );
1525
- wp_redirect ( add_query_arg ( 'deleted', 1, remove_query_arg ( array (
1526
- '_wpnonce',
1527
- 'id',
1528
- 'action'
1529
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1530
exit ();
1531
}
1532
- if ('clone' == $action) {
1533
- check_admin_referer ( 'yop-poll-templates' );
1534
- $template_id = ( int ) $_REQUEST ['id'];
1535
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1536
- $template_author = Yop_Poll_Model::get_poll_template_field_from_database_by_id ( 'template_author', $template_id );
1537
- if (($this->current_user_can ( 'clone_own_polls_templates' ) && $template_author == $current_user->ID) || ($this->current_user_can ( 'clone_polls_templates' )))
1538
- Yop_Poll_Model::clone_poll_template ( $template_id );
1539
- else
1540
- wp_die ( __ ( 'You are not allowed to clone this item.', 'yop_poll' ) );
1541
- wp_redirect ( add_query_arg ( 'cloned', 1, remove_query_arg ( array (
1542
- '_wpnonce',
1543
- 'id',
1544
- 'action'
1545
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1546
exit ();
1547
}
1548
- } elseif (! empty ( $_GET ['_wp_http_referer'] )) {
1549
- wp_safe_redirect ( remove_query_arg ( array (
1550
- '_wp_http_referer',
1551
- '_wpnonce'
1552
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1553
exit ();
1554
}
1555
}
1556
public function view_all_polls_operations() {
1557
global $page, $action, $yop_poll_add_new_config, $current_user;
1558
- if ('-1' != $action && isset ( $_REQUEST ['yoppollcheck'] )) {
1559
- if ('delete' == $action) {
1560
- check_admin_referer ( 'yop-poll-view' );
1561
- $bulkyoppolls = ( array ) $_REQUEST ['yoppollcheck'];
1562
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1563
$total_undeleted = 0;
1564
foreach ( $bulkyoppolls as $yoppoll_id ) {
1565
- $yoppoll_id = ( int ) $yoppoll_id;
1566
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $yoppoll_id );
1567
- if (($this->current_user_can ( 'delete_own_polls' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls' )))
1568
- Yop_Poll_Model::delete_poll_from_db ( $yoppoll_id );
1569
- else
1570
- $total_undeleted ++;
1571
}
1572
- wp_redirect ( add_query_arg ( 'deleted', count ( $bulkyoppolls ) - $total_undeleted, remove_query_arg ( array (
1573
- '_wp_http_referer',
1574
- '_wpnonce',
1575
- 'yoppollcheck'
1576
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1577
exit ();
1578
}
1579
- if ('clone' == $action) {
1580
- check_admin_referer ( 'yop-poll-view' );
1581
- $bulkyoppolls = ( array ) $_REQUEST ['yoppollcheck'];
1582
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1583
$total_uncloned = 0;
1584
foreach ( $bulkyoppolls as $yoppoll_id ) {
1585
- $yoppoll_id = ( int ) $yoppoll_id;
1586
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $yoppoll_id );
1587
- if (($this->current_user_can ( 'clone_own_polls' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'clone_polls' )))
1588
- Yop_Poll_Model::clone_poll ( $yoppoll_id );
1589
- else
1590
- $total_uncloned ++;
1591
}
1592
- wp_redirect ( add_query_arg ( 'cloned', count ( $bulkyoppolls ) - $total_uncloned, remove_query_arg ( array (
1593
- '_wp_http_referer',
1594
- '_wpnonce',
1595
- 'yoppollcheck'
1596
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1597
exit ();
1598
}
1599
- if ('reset_votes' == $action) {
1600
- check_admin_referer ( 'yop-poll-view' );
1601
- $bulkyoppolls = ( array ) $_REQUEST ['yoppollcheck'];
1602
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1603
$total_unreseted = 0;
1604
foreach ( $bulkyoppolls as $yoppoll_id ) {
1605
- $yoppoll_id = ( int ) $yoppoll_id;
1606
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $yoppoll_id );
1607
- if (($this->current_user_can ( 'reset_own_polls_stats' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'reset_polls_stats' )))
1608
- Yop_Poll_Model::reset_votes_for_poll ( $yoppoll_id );
1609
- else
1610
- $total_unreseted ++;
1611
}
1612
- wp_redirect ( add_query_arg ( 'reseted_votes', count ( $bulkyoppolls ) - $total_unreseted, remove_query_arg ( array (
1613
- '_wp_http_referer',
1614
- '_wpnonce',
1615
- 'yoppollcheck'
1616
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1617
exit ();
1618
}
1619
- if ('delete_logs' == $action) {
1620
- check_admin_referer ( 'yop-poll-view' );
1621
- $bulkyoppolls = ( array ) $_REQUEST ['yoppollcheck'];
1622
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1623
$total_undeleted_logs = 0;
1624
foreach ( $bulkyoppolls as $yoppoll_id ) {
1625
- $yoppoll_id = ( int ) $yoppoll_id;
1626
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $yoppoll_id );
1627
- if (($this->current_user_can ( 'delete_own_polls_logs' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls_logs' )))
1628
- Yop_Poll_Model::delete_all_poll_logs ( $yoppoll_id );
1629
- else
1630
- $total_undeleted_logs ++;
1631
}
1632
- wp_redirect ( add_query_arg ( 'deleted_logs', count ( $bulkyoppolls ) - $total_undeleted_logs, remove_query_arg ( array (
1633
- '_wp_http_referer',
1634
- '_wpnonce',
1635
- 'yoppollcheck'
1636
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1637
exit ();
1638
}
1639
- } elseif ('-1' != $action && isset ( $_REQUEST ['id'] )) {
1640
- if ('delete' == $action) {
1641
- check_admin_referer ( 'yop-poll-delete' );
1642
- $yoppoll_id = ( int ) $_REQUEST ['id'];
1643
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1644
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $yoppoll_id );
1645
- if (($this->current_user_can ( 'delete_own_polls' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls' )))
1646
- Yop_Poll_Model::delete_poll_from_db ( $yoppoll_id );
1647
- else
1648
- wp_die ( __ ( 'You are not allowed to delete this item.', 'yop_poll' ) );
1649
- wp_redirect ( add_query_arg ( 'deleted', 1, remove_query_arg ( array (
1650
- '_wpnonce',
1651
- 'id',
1652
- 'action'
1653
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1654
exit ();
1655
}
1656
1657
- if ('clone' == $action) {
1658
- check_admin_referer ( 'yop-poll-clone' );
1659
- $yoppoll_id = ( int ) $_REQUEST ['id'];
1660
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1661
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $yoppoll_id );
1662
- if (($this->current_user_can ( 'clone_own_polls' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'clone_polls' )))
1663
- Yop_Poll_Model::clone_poll ( $yoppoll_id );
1664
- else
1665
- wp_die ( __ ( 'You are not allowed to clone this item.', 'yop_poll' ) );
1666
- wp_redirect ( add_query_arg ( 'cloned', 1, remove_query_arg ( array (
1667
- '_wpnonce',
1668
- 'id',
1669
- 'action'
1670
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1671
exit ();
1672
}
1673
1674
- if ('reset_votes' == $action) {
1675
- check_admin_referer ( 'yop-poll-reset-votes' );
1676
- $yoppoll_id = ( int ) $_REQUEST ['id'];
1677
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1678
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $yoppoll_id );
1679
- if (($this->current_user_can ( 'reset_own_polls_stats' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'reset_polls_stats' )))
1680
- Yop_Poll_Model::reset_votes_for_poll ( $yoppoll_id );
1681
- else
1682
- wp_die ( __ ( 'You are not allowed to reset stats for this item.', 'yop_poll' ) );
1683
- wp_redirect ( add_query_arg ( 'reseted_votes', 1, remove_query_arg ( array (
1684
- '_wpnonce',
1685
- 'id',
1686
- 'action'
1687
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1688
exit ();
1689
}
1690
1691
- if ('delete_logs' == $action) {
1692
- check_admin_referer ( 'yop-poll-delete-logs' );
1693
- $yoppoll_id = ( int ) $_REQUEST ['id'];
1694
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1695
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $yoppoll_id );
1696
- if (($this->current_user_can ( 'delete_own_polls_logs' ) && $poll_author == $current_user->ID) || ($this->current_user_can ( 'delete_polls_logs' )))
1697
- Yop_Poll_Model::delete_all_poll_logs ( $yoppoll_id );
1698
- else
1699
- wp_die ( __ ( 'You are not allowed to delete logs for this item.', 'yop_poll' ) );
1700
- wp_redirect ( add_query_arg ( 'deleted_logs', 1, remove_query_arg ( array (
1701
- '_wpnonce',
1702
- 'id',
1703
- 'action'
1704
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) ) );
1705
exit ();
1706
}
1707
- } elseif (! empty ( $_GET ['_wp_http_referer'] )) {
1708
- wp_safe_redirect ( remove_query_arg ( array (
1709
- '_wp_http_referer',
1710
- '_wpnonce'
1711
- ), stripslashes ( $_SERVER ['REQUEST_URI'] ) ) );
1712
exit ();
1713
}
1714
}
@@ -1722,90 +1514,43 @@ EOT;
1722
*/
1723
public function view_all_polls() {
1724
global $page, $action, $orderby, $order, $current_user;
1725
- $orderby = (empty ( $orderby )) ? 'name' : $orderby;
1726
- $order_direction = array (
1727
- 'id' => 'asc',
1728
- 'name' => 'asc',
1729
- 'question' => 'asc',
1730
- 'start_date' => 'asc',
1731
- 'end_date' => 'asc',
1732
- 'total_votes' => 'asc',
1733
- 'total_answers' => 'asc'
1734
- );
1735
- $order_direction [$orderby] = ('desc' == $order) ? 'asc' : 'desc';
1736
-
1737
- $order_direction_reverse = array (
1738
- 'id' => 'desc',
1739
- 'name' => 'desc',
1740
- 'question' => 'desc',
1741
- 'start_date' => 'desc',
1742
- 'end_date' => 'desc',
1743
- 'total_votes' => 'desc',
1744
- 'total_answers' => 'desc'
1745
- );
1746
- $order_direction_reverse [$orderby] = ('desc' == $order) ? 'desc' : 'asc';
1747
-
1748
- $order_sortable = array (
1749
- 'id' => 'sortable',
1750
- 'name' => 'sortable',
1751
- 'question' => 'sortable',
1752
- 'start_date' => 'sortable',
1753
- 'end_date' => 'sortable',
1754
- 'total_votes' => 'sortable',
1755
- 'total_answers' => 'sortable'
1756
- );
1757
$order_sortable [$orderby] = 'sorted';
1758
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
1759
- $filter = array (
1760
- 'field' => NULL,
1761
- 'value' => NULL,
1762
- 'operator' => '='
1763
- );
1764
- if (isset ( $_REQUEST ['filters'] )) {
1765
- switch ($_REQUEST ['filters']) {
1766
case 'started' :
1767
- $filter = array (
1768
- 'field' => 'start_date',
1769
- 'value' => YOP_POLL_MODEL::get_mysql_curent_date (),
1770
- 'operator' => '<='
1771
- );
1772
break;
1773
case 'not_started' :
1774
- $filter = array (
1775
- 'field' => 'start_date',
1776
- 'value' => YOP_POLL_MODEL::get_mysql_curent_date (),
1777
- 'operator' => '>='
1778
- );
1779
break;
1780
case 'never_expire' :
1781
- $filter = array (
1782
- 'field' => 'end_date',
1783
- 'value' => '9999-12-31 23:59:59',
1784
- 'operator' => '='
1785
- );
1786
break;
1787
case 'expired' :
1788
- $filter = array (
1789
- 'field' => 'end_date',
1790
- 'value' => YOP_POLL_MODEL::get_mysql_curent_date (),
1791
- 'operator' => '<='
1792
- );
1793
break;
1794
}
1795
}
1796
- $search = array (
1797
- 'fields' => array (
1798
- 'name',
1799
- 'question'
1800
- ),
1801
- 'value' => isset ( $_REQUEST ['s'] ) ? $_REQUEST ['s'] : ''
1802
);
1803
- $yop_polls = Yop_Poll_Model::get_yop_polls_filter_search ( $orderby, $order, $filter, $search );
1804
- $optin_box_modal_options = get_option ( 'yop_poll_optin_box_modal_options' );
1805
- $optin_box_modal_query = admin_url ( 'admin-ajax.php', (is_ssl () ? 'https' : 'http') );
1806
- $optin_box_modal_query = add_query_arg ( 'action', 'yop_poll_show_optin_box_modal', $optin_box_modal_query );
1807
?>
1808
- <?php if ( $optin_box_modal_options['show'] == 'yes' ) { ?>
1809
<a id="yop-poll-show-modal-box"
1810
href="<?php echo $optin_box_modal_query; ?>" style="display: none;"></a>
1811
<?php } ?>
@@ -1818,48 +1563,40 @@ EOT;
1818
href="<?php echo esc_url( add_query_arg( array( 'page' => 'yop-polls-add-new', 'id' => false, 'deleted' => false, 'cloned' => false ) ) ); ?>"><?php _e( 'Add New', 'yop_poll' ); ?></a>
1819
</h2>
1820
<?php
1821
- if (isset ( $_REQUEST ['deleted'] )) {
1822
echo '<div id="message" class="updated"><p>';
1823
- $deleted = ( int ) $_REQUEST ['deleted'];
1824
- printf ( _n ( '%s Poll deleted.', '%s Polls deleted.', $deleted ), $deleted );
1825
echo '</p></div>';
1826
- $_SERVER ['REQUEST_URI'] = remove_query_arg ( array (
1827
- 'deleted'
1828
- ), $_SERVER ['REQUEST_URI'] );
1829
}
1830
?>
1831
<?php
1832
- if (isset ( $_REQUEST ['cloned'] )) {
1833
echo '<div id="message" class="updated"><p>';
1834
- $cloned = ( int ) $_REQUEST ['cloned'];
1835
- printf ( _n ( '%s Poll cloned.', '%s Polls cloned.', $cloned ), $cloned );
1836
echo '</p></div>';
1837
- $_SERVER ['REQUEST_URI'] = remove_query_arg ( array (
1838
- 'cloned'
1839
- ), $_SERVER ['REQUEST_URI'] );
1840
}
1841
?>
1842
<?php
1843
- if (isset ( $_REQUEST ['reseted_votes'] )) {
1844
echo '<div id="message" class="updated"><p>';
1845
- $reseted_votes = ( int ) $_REQUEST ['reseted_votes'];
1846
- printf ( _n ( 'Vote reseted for %s Poll.', 'Votes reseted for %s Poll.', $reseted_votes ), $reseted_votes );
1847
echo '</p></div>';
1848
- $_SERVER ['REQUEST_URI'] = remove_query_arg ( array (
1849
- 'reseted_votes'
1850
- ), $_SERVER ['REQUEST_URI'] );
1851
}
1852
?>
1853
1854
<?php
1855
- if (isset ( $_REQUEST ['deleted_logs'] )) {
1856
echo '<div id="message" class="updated"><p>';
1857
- $deleted_logs = ( int ) $_REQUEST ['deleted_logs'];
1858
- printf ( _n ( 'Log deleted for %s Poll.', 'Log deleted for %s Polls.', $deleted_logs ), $deleted_logs );
1859
echo '</p></div>';
1860
- $_SERVER ['REQUEST_URI'] = remove_query_arg ( array (
1861
- 'deleted_logs'
1862
- ), $_SERVER ['REQUEST_URI'] );
1863
}
1864
?>
1865
@@ -1868,16 +1605,16 @@ EOT;
1868
<form action="" method="get">
1869
<div id="post-body-content">
1870
<?php wp_nonce_field( 'yop-poll-view' ); ?>
1871
- <input type="hidden" name="order" value="<?php echo $order ?>" />
1872
- <input type="hidden" name="orderby" value="<?php echo $orderby ?>" />
1873
- <input type="hidden" name="page" value="yop-polls" />
1874
<p class="search-box">
1875
<label class="screen-reader-text" for="yop-poll-search-input"><?php _e( 'Search Polls', 'yop_poll' ) ?></label>
1876
<input id="yop-poll-search-input" type="search"
1877
- value="<?php if( isset( $_REQUEST['s'] ) ): echo esc_html( stripslashes( $_REQUEST['s'] ) ); endif; ?>"
1878
- name="s" /> <input id="search-submit" class="button"
1879
type="submit" value="<?php _e( 'Search Polls', 'yop_poll' ); ?>"
1880
- name="" />
1881
</p>
1882
<div class="tablenav top">
1883
<div class="alignleft actions">
@@ -1887,7 +1624,8 @@ EOT;
1887
<option value="clone"><?php _e( 'Clone', 'yop_poll' ); ?></option>
1888
<option value="reset_votes"><?php _e( 'Reset Votes', 'yop_poll' ); ?></option>
1889
<option value="delete_logs"><?php _e( 'Delete Logs', 'yop_poll' ); ?></option>
1890
- </select> <input type="submit"
1891
value="<?php _e( 'Apply', 'yop_poll' ); ?>"
1892
class="button-secondary action" id="doaction" name="">
1893
</div>
@@ -1895,18 +1633,19 @@ EOT;
1895
<select name="filters">
1896
<option value="0"><?php _e( 'View All Polls', 'yop_poll' ); ?></option>
1897
<option
1898
- <?php echo isset( $_REQUEST['filters'] ) ? ( 'never_expire' == $_REQUEST['filters'] ? 'selected="selected"' : '' ) : ''?>
1899
value="never_expire"><?php _e( 'No end date', 'yop_poll' ); ?></option>
1900
<option
1901
- <?php echo isset( $_REQUEST['filters'] ) ? ( 'expired' == $_REQUEST['filters'] ? 'selected="selected"' : '' ) : ''?>
1902
value="expired"><?php _e( 'Expired', 'yop_poll' ); ?></option>
1903
<option
1904
- <?php echo isset( $_REQUEST['filters'] ) ? ( 'started' == $_REQUEST['filters'] ? 'selected="selected"' : '' ) : ''?>
1905
value="started"><?php _e( 'Started', 'yop_poll' ); ?></option>
1906
<option
1907
- <?php echo isset( $_REQUEST['filters'] ) ? ( 'not_started' == $_REQUEST['filters'] ? 'selected="selected"' : '' ) : ''?>
1908
value="not_started"><?php _e( 'Not Started', 'yop_poll' ); ?></option>
1909
- </select> <input type="submit"
1910
value="<?php _e( 'Filter', 'yop_poll' ); ?>"
1911
class="button-secondary" id="post-query-submit" name="">
1912
</div>
@@ -1916,135 +1655,118 @@ EOT;
1916
<thead>
1917
<tr>
1918
<th id="cb" class="manage-column column-cb check-column"
1919
- style="width: 2%;" scope="col"><input type="checkbox"></th>
1920
- <th id="id"
1921
- class="manage-column <?php echo $order_sortable[ 'id' ] ?> <?php echo $order_direction_reverse[ 'id' ] ?>"
1922
- style="width: 5%" scope="col"><a
1923
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'id', 'order' => $order_direction[ 'id' ] ) ) ); ?>">
1924
- <span><?php _e( 'ID', 'yop_poll' ); ?></span> <span
1925
- class="sorting-indicator"></span>
1926
- </a></th>
1927
<th id="name"
1928
- class="manage-column <?php echo $order_sortable[ 'name' ] ?> <?php echo $order_direction_reverse[ 'name' ] ?>"
1929
style="width: 30%" scope="col"><a
1930
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'name', 'order' => $order_direction[ 'name' ] ) ) ); ?>">
1931
<span><?php _e( 'Name', 'yop_poll' ); ?></span> <span
1932
class="sorting-indicator"></span>
1933
</a></th>
1934
<th id="total_votes"
1935
- class="manage-column <?php echo $order_sortable[ 'total_votes' ] ?> <?php echo $order_direction_reverse[ 'total_votes' ] ?>"
1936
style="width: 6%" scope="col"><a
1937
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'total_votes', 'order' => $order_direction[ 'total_votes' ] ) ) ); ?>">
1938
<span><?php _e( 'Total Votes', 'yop_poll' ); ?></span> <span
1939
class="sorting-indicator"></span>
1940
</a></th>
1941
<th id="total_answers"
1942
- class="manage-column <?php echo $order_sortable[ 'total_answers' ] ?> <?php echo $order_direction_reverse[ 'total_answers' ] ?>"
1943
style="width: 7%" scope="col"><a
1944
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'total_answers', 'order' => $order_direction[ 'total_answers' ] ) ) ); ?>">
1945
<span><?php _e( 'Total Answers', 'yop_poll' ); ?></span> <span
1946
class="sorting-indicator"></span>
1947
</a></th>
1948
<th id="question"
1949
- class="manage-column <?php echo $order_sortable[ 'question' ] ?> <?php echo $order_direction_reverse[ 'question' ] ?>"
1950
style="width: 24%" scope="col"><a
1951
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'question', 'order' => $order_direction[ 'question' ] ) ) ); ?>">
1952
<span><?php _e( 'Question', 'yop_poll' ); ?></span> <span
1953
class="sorting-indicator"></span>
1954
</a></th>
1955
- <th id="poll_author" class="manage-column" style="width: 5%"
1956
scope="col"><span><?php _e( 'Author', 'yop_poll' ); ?></span></th>
1957
<th id="start-date"
1958
- class="manage-column <?php echo $order_sortable[ 'start_date' ] ?> <?php echo $order_direction_reverse[ 'start_date' ] ?>"
1959
style="width: 10%" scope="col"><a
1960
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'start_date', 'order' => $order_direction[ 'start_date' ] ) ) ); ?>">
1961
<span><?php _e( 'Start Date', 'yop_poll' ); ?></span> <span
1962
class="sorting-indicator"></span>
1963
</a></th>
1964
<th id="end-date"
1965
- class="manage-column <?php echo $order_sortable[ 'end_date' ] ?> <?php echo $order_direction_reverse[ 'end_date' ] ?>"
1966
style="width: 10%" scope="col"><a
1967
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'end_date', 'order' => $order_direction[ 'end_date' ] ) ) ); ?>">
1968
<span><?php _e( 'End Date', 'yop_poll' ); ?></span> <span
1969
class="sorting-indicator"></span>
1970
</a></th>
1971
</tr>
1972
</thead>
1973
<?php
1974
- if (count ( $yop_polls ) > 0) {
1975
foreach ( $yop_polls as $yop_poll ) {
1976
?>
1977
<tbody id="the-list">
1978
<tr valign="middle" class="alternate"
1979
id="yop-poll-<?php echo $yop_poll['id']; ?>">
1980
<th class="check-column" scope="row">
1981
- <?php if ( ( $this->current_user_can( 'delete_own_polls') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'delete_polls' ) ) ) { ?>
1982
<input type="checkbox"
1983
value="<?php echo $yop_poll['id']; ?>" name="yoppollcheck[]">
1984
<?php } ?>
1985
</th>
1986
<td><strong>
1987
- <?php if ( ( $this->current_user_can( 'edit_own_polls') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'edit_polls' ) ) ) { ?>
1988
- <a title="<?php echo $yop_poll['id']; ?>"
1989
- href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $yop_poll['id'] ) ) ); ?>"
1990
- class="row-title">
1991
- <?php }?>
1992
- <?php echo $yop_poll['id']; ?>
1993
- <?php if ( ( $this->current_user_can( 'edit_own_polls') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'edit_polls' ) ) ) { ?>
1994
- </a>
1995
- <?php } ?></strong><br></td>
1996
- <td><strong>
1997
- <?php if ( ( $this->current_user_can( 'edit_own_polls') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'edit_polls' ) ) ) { ?>
1998
<a
1999
title="<?php echo esc_html( stripslashes( $yop_poll['name'] ) ); ?>"
2000
href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $yop_poll['id'] ) ) ); ?>"
2001
class="row-title">
2002
<?php } ?>
2003
<?php echo esc_html( stripslashes( $yop_poll['name'] ) ); ?>
2004
- <?php if ( ( $this->current_user_can( 'edit_own_polls') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'edit_polls' ) ) ) { ?>
2005
</a>
2006
<?php } ?>
2007
</strong><br>
2008
<div class="row-actions">
2009
- <?php if ( ( $this->current_user_can( 'edit_own_polls') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'edit_polls' ) ) ) { ?>
2010
<span class="edit"><a
2011
href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'id' => $yop_poll['id'] ) ) ); ?>"><?php _e( 'Edit', 'yop_poll' ) ?></a>
2012
| </span>
2013
<?php } ?>
2014
- <?php if ( ( $this->current_user_can( 'view_own_polls_logs') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'view_polls_logs' ) ) ) { ?>
2015
<span class="edit"><a
2016
href="<?php echo esc_url( add_query_arg( array( 'page' => 'yop-polls-logs', 'poll_id' => $yop_poll['id'] ) ) ); ?>"><?php _e( 'Logs', 'yop_poll' ) ?></a>
2017
| </span>
2018
<?php } ?>
2019
- <?php if ( ( $this->current_user_can( 'delete_own_polls') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'delete_polls' ) ) ) { ?>
2020
<span class="delete"><a
2021
- onclick="if ( confirm( '<?php echo __( "You are about to delete this poll",'yop_poll').": \'".esc_html( $yop_poll['name'] )."\' \\n \'".__("Cancel", 'yop_poll')."\' ". __('to stop', 'yop_poll'). ", \'".__('OK', 'yop_poll')."\' ".__('to delete', 'yop_poll'); ?>' ) ) { return true;}return false;"
2022
href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'id' => $yop_poll['id'] ) ), 'yop-poll-delete' ); ?>"
2023
class="submitdelete"><?php _e( 'Delete', 'yop_poll' ) ?></a>
2024
| </span>
2025
<?php } ?>
2026
- <?php if ( ( $this->current_user_can( 'clone_own_polls') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'clone_polls' ) ) ) { ?>
2027
<span class="clone"><a
2028
- onclick="if ( confirm( '<?php echo __( "You are about to clone this poll",'yop_poll').": \'".esc_html( $yop_poll['name'] )."\' \\n \'".__("Cancel", 'yop_poll')."\' ". __('to stop', 'yop_poll'). ", \'".__('OK', 'yop_poll')."\' ".__('to clone', 'yop_poll'); ?>' ) ) { return true;}return false;"
2029
href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'clone', 'id' => $yop_poll['id'] ) ), 'yop-poll-clone' ); ?>"
2030
class="submitclone"><?php _e( 'Clone', 'yop_poll' ) ?></a> |
2031
</span>
2032
<?php } ?>
2033
- <?php if ( ( $this->current_user_can( 'view_own_polls_results') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'view_polls_results' ) ) ) { ?>
2034
<span class="results"><a
2035
href="<?php echo esc_url( add_query_arg( array( 'action' => 'results', 'id' => $yop_poll['id'] ) ) ); ?>"><?php _e( 'Results', 'yop_poll' ) ?></a>
2036
| </span>
2037
<?php } ?>
2038
- <?php if ( ( $this->current_user_can( 'reset_own_polls_stats') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'reset_polls_stats' ) ) ) { ?>
2039
<span class="delete"><a
2040
- onclick="if ( confirm( '<?php echo __( "You are about to reset votes for this poll",'yop_poll').": \'".esc_html( $yop_poll['name'] )."\' \\n \'".__("Cancel", 'yop_poll')."\' ". __('to stop', 'yop_poll'). ", \'".__('OK', 'yop_poll')."\' ".__('to reset votes', 'yop_poll'); ?>' ) ) { return true;}return false;"
2041
href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'reset_votes', 'id' => $yop_poll['id'] ) ), 'yop-poll-reset-votes' ); ?>"
2042
class="submitresetvotes"><?php _e( 'Reset Stats', 'yop_poll' ) ?></a>
2043
| </span>
2044
<?php } ?>
2045
- <?php if ( ( $this->current_user_can( 'delete_own_polls_logs') && $yop_poll['poll_author'] == $current_user->ID ) || ($this->current_user_can( 'delete_polls_logs' ) ) ) { ?>
2046
<span class="delete"><a
2047
- onclick="if ( confirm( '<?php echo __( "You are about to delete logs for this poll",'yop_poll').": \'".esc_html( $yop_poll['name'] )."\' \\n \'".__("Cancel", 'yop_poll')."\' ". __('to stop', 'yop_poll'). ", \'".__('OK', 'yop_poll')."\' ".__('to delete logs', 'yop_poll'); ?>' ) ) { return true;}return false;"
2048
href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'delete_logs', 'id' => $yop_poll['id'] ) ), 'yop-poll-delete-logs' ); ?>"
2049
class="submitresetvotes"><?php _e( 'Delete Logs', 'yop_poll' ) ?></a></span>
2050
<?php } ?>
@@ -2060,11 +1782,13 @@ EOT;
2060
</td>
2061
<td>
2062
<?php
2063
- $user_info = get_userdata ( $yop_poll ['poll_author'] );
2064
- if ($user_info)
2065
- echo esc_html ( stripslashes ( $user_info->user_login ) );
2066
- else
2067
echo '';
2068
?>
2069
</td>
2070
<td>
@@ -2072,21 +1796,24 @@ EOT;
2072
</td>
2073
<td>
2074
<?php
2075
- if (YOP_POLL_MODEL::get_mysql_curent_date () > $yop_poll ['end_date'])
2076
echo '<font style="color:#CC0000;"><b>';
2077
- echo ('9999-12-31 23:59:59' == $yop_poll ['end_date']) ? __ ( 'No end date', 'yop_poll' ) : esc_html ( stripslashes ( $yop_poll ['end_date'] ) );
2078
- if (YOP_POLL_MODEL::get_mysql_curent_date () > $yop_poll ['end_date'])
2079
- echo '</b></font>'?>
2080
</td>
2081
</tr>
2082
</tbody>
2083
<?php
2084
}
2085
- } else {
2086
?>
2087
<tbody id="the-list">
2088
<tr valign="middle" class="alternate" id="yop-poll-<?php ?>">
2089
- <th colspan="9">
2090
<?php _e( 'No poll found!', 'yop_poll' ); ?>
2091
</th>
2092
</tr>
@@ -2099,54 +1826,47 @@ EOT;
2099
<tr>
2100
<th id="cb" class="manage-column column-cb check-column"
2101
style="" scope="col"><input type="checkbox"></th>
2102
- <th id="id"
2103
- class="manage-column <?php echo $order_sortable[ 'id' ] ?> <?php echo $order_direction_reverse[ 'id' ] ?>"
2104
- style="" scope="col"><a
2105
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'id', 'order' => $order_direction[ 'id' ] ) ) ); ?>">
2106
- <span><?php _e( 'ID', 'yop_poll' ); ?></span> <span
2107
- class="sorting-indicator"></span>
2108
- </a></th>
2109
<th id="name"
2110
- class="manage-column <?php echo $order_sortable[ 'name' ] ?> <?php echo $order_direction_reverse[ 'name' ] ?>"
2111
style="" scope="col"><a
2112
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'name', 'order' => $order_direction[ 'name' ] ) ) ); ?>">
2113
<span><?php _e( 'Name', 'yop_poll' ); ?></span> <span
2114
class="sorting-indicator"></span>
2115
</a></th>
2116
<th id="total_votes"
2117
- class="manage-column <?php echo $order_sortable[ 'total_votes' ] ?> <?php echo $order_direction_reverse[ 'total_votes' ] ?>"
2118
style="" scope="col"><a
2119
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'total_votes', 'order' => $order_direction[ 'total_votes' ] ) ) ); ?>">
2120
<span><?php _e( 'Total Votes', 'yop_poll' ); ?></span> <span
2121
class="sorting-indicator"></span>
2122
</a></th>
2123
<th id="total_answers"
2124
- class="manage-column <?php echo $order_sortable[ 'total_answers' ] ?> <?php echo $order_direction_reverse[ 'total_answers' ] ?>"
2125
style="" scope="col"><a
2126
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'total_answers', 'order' => $order_direction[ 'total_answers' ] ) ) ); ?>">
2127
<span><?php _e( 'Total Answers', 'yop_poll' ); ?></span> <span
2128
class="sorting-indicator"></span>
2129
</a></th>
2130
<th id="question"
2131
- class="manage-column <?php echo $order_sortable[ 'question' ] ?> <?php echo $order_direction_reverse[ 'question' ] ?>"
2132
style="" scope="col"><a
2133
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'question', 'order' => $order_direction[ 'question' ] ) ) ); ?>">
2134
<span><?php _e( 'Question', 'yop_poll' ); ?></span> <span
2135
class="sorting-indicator"></span>
2136
</a></th>
2137
<th id="poll_author" class="manage-column" style="width: 5%"
2138
scope="col"><span><?php _e( 'Author', 'yop_poll' ); ?></span></th>
2139
<th id="start-date"
2140
- class="manage-column <?php echo $order_sortable[ 'start_date' ] ?> <?php echo $order_direction_reverse[ 'start_date' ] ?>"
2141
style="" scope="col"><a
2142
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'start_date', 'order' => $order_direction[ 'start_date' ] ) ) ); ?>">
2143
<span><?php _e( 'Start Date', 'yop_poll' ); ?></span> <span
2144
class="sorting-indicator"></span>
2145
</a></th>
2146
<th id="end-date"
2147
- class="manage-column <?php echo $order_sortable[ 'end_date' ] ?> <?php echo $order_direction_reverse[ 'end_date' ] ?>"
2148
style="" scope="col"><a
2149
- href="<?php echo esc_url( add_query_arg( array( 'orderby' => 'end_date', 'order' => $order_direction[ 'end_date' ] ) ) ); ?>">
2150
<span><?php _e( 'End Date', 'yop_poll' ); ?></span> <span
2151
class="sorting-indicator"></span>
2152
</a></th>
@@ -2162,74 +1882,59 @@ EOT;
2162
</div>
2163
<?php
2164
}
2165
public function view_poll_results() {
2166
global $page, $action, $current_user;
2167
- $poll_id = (isset ( $_GET ['id'] ) ? intval ( $_GET ['id'] ) : 0);
2168
- $results_order_by = (isset ( $_GET ['results_order_by'] ) ? $_GET ['results_order_by'] : 'id');
2169
- $results_order = (isset ( $_GET ['results_order'] ) ? $_GET ['results_order'] : 'ASC');
2170
- $soav = (isset ( $_GET ['soav'] ) ? $_GET ['soav'] : 'no');
2171
- require_once ($this->_config->plugin_inc_dir . '/yop_poll_model.php');
2172
- $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id ( 'poll_author', $poll_id );
2173
- if ((! $this->current_user_can ( 'view_own_polls_results' ) || $poll_author != $current_user->ID) && (! $this->current_user_can ( 'view_polls_results' )))
2174
- wp_die ( __ ( 'You are not allowed to view results for this item.', 'yop_poll' ) );
2175
- $poll_details = YOP_POLL_MODEL::get_poll_from_database_by_id ( $poll_id );
2176
- if ( 'yes' == $soav )