YOP Poll - Version 5.5

Version Description

  • Fixed issue with clone poll
  • Fixed issue with archive page
  • Fixed issue with captcha
Download this release

Release Info

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

Code changes from version 5.3 to 5.5

Files changed (46) hide show
  1. css/flexslider.css +162 -0
  2. css/reveal.css +66 -0
  3. css/yop-poll-admin.css +1 -1
  4. fonts/flexslider-icon.eot +0 -0
  5. fonts/flexslider-icon.svg +19 -0
  6. fonts/flexslider-icon.ttf +0 -0
  7. fonts/flexslider-icon.woff +0 -0
  8. images/images2/image1.jpg +0 -0
  9. images/images2/image2.jpg +0 -0
  10. images/images2/image3.jpg +0 -0
  11. images/images2/image4.jpg +0 -0
  12. images/images2/image6.jpg +0 -0
  13. inc/admin.php +10 -1
  14. inc/import_admin.php +431 -428
  15. inc/maintenance.php +4 -0
  16. inc/plugin-functions.php +6 -6
  17. inc/poll_admin.php +61 -13
  18. inc/pro_admin.php +6 -2
  19. inc/public-admin.php +8 -5
  20. js/bxslider/bower.json +25 -0
  21. js/bxslider/images/bx_loader.gif +0 -0
  22. js/bxslider/images/controls.png +0 -0
  23. js/bxslider/jquery.bxslider.css +205 -0
  24. js/bxslider/jquery.bxslider.js +1349 -0
  25. js/bxslider/plugins/jquery.easing.1.3.js +205 -0
  26. js/bxslider/plugins/jquery.fitvids.js +80 -0
  27. js/jquery.flexslider.js +1157 -0
  28. js/jquery.reveal.js +165 -0
  29. js/polls/yop-poll-add-edit.js +200 -74
  30. js/polls/yop-poll-results-votes.js +2 -2
  31. js/yop-poll-admin-templates.js +2 -2
  32. js/yop-poll-admin.js +84 -53
  33. js/yop-poll-general-options.js +10 -2
  34. js/yop-poll-modal-functions.js +2 -2
  35. js/yop-poll-public.js +9 -6
  36. js/yop-poll-sidebar-optin-functions.js +5 -3
  37. models/abstract_model.php +9 -6
  38. models/custom_field_model.php +11 -11
  39. readme.txt +6 -1
  40. templates/options_poll_options.html +2 -3
  41. templates/polls_add_edit.html +2 -2
  42. templates/polls_add_edit_options.html +22 -1
  43. templates/polls_base.html +42 -97
  44. templates/polls_results_votes.html +208 -206
  45. templates/pro_pre_upgrade.html +57 -89
  46. yop_poll.php +3 -3
css/flexslider.css ADDED
@@ -0,0 +1,162 @@
1
+ /*
2
+ * jQuery FlexSlider v2.2.0
3
+ * http://www.woothemes.com/flexslider/
4
+ *
5
+ * Copyright 2012 WooThemes
6
+ * Free to use under the GPLv2 license.
7
+ * http://www.gnu.org/licenses/gpl-2.0.html
8
+ *
9
+ * Contributing author: Tyler Smith (@mbmufffin)
10
+ */
11
+
12
+
13
+ /* Browser Resets
14
+ *********************************/
15
+ .flex-container a:active,
16
+ .flexslider a:active,
17
+ .flex-container a:focus,
18
+ .flexslider a:focus {outline: none;}
19
+ .slides,
20
+ .flex-control-nav,
21
+ .flex-direction-nav {margin: 0; padding: 0; list-style: none;}
22
+
23
+ /* Icon Fonts
24
+ *********************************/
25
+ /* Font-face Icons */
26
+ @font-face {
27
+ font-family: 'flexslider-icon';
28
+ src:url('../fonts/flexslider-icon.eot');
29
+ src:url('../fonts/flexslider-icon.eot?#iefix') format('embedded-opentype'),
30
+ url('../fonts/flexslider-icon.woff') format('woff'),
31
+ url('../fonts/flexslider-icon.ttf') format('truetype'),
32
+ url('../fonts/flexslider-icon.svg#flexslider-icon') format('svg');
33
+ font-weight: normal;
34
+ font-style: normal;
35
+ }
36
+
37
+ /* FlexSlider Necessary Styles
38
+ *********************************/
39
+ .flexslider {margin: 0; padding: 0;}
40
+ .flexslider .slides > li {display: none; -webkit-backface-visibility: hidden;} /* Hide the slides before the JS is loaded. Avoids image jumping */
41
+ .flexslider .slides img {width: 100%; display: block;}
42
+ .flex-pauseplay span {text-transform: capitalize;}
43
+
44
+ /* Clearfix for the .slides element */
45
+ .slides:after {content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0;}
46
+ html[xmlns] .slides {display: block;}
47
+ * html .slides {height: 1%;}
48
+
49
+ /* No JavaScript Fallback */
50
+ /* If you are not using another script, such as Modernizr, make sure you
51
+ * include js that eliminates this class on page load */
52
+ .no-js .slides > li:first-child {display: block;}
53
+
54
+ /* FlexSlider Default Theme
55
+ *********************************/
56
+ .flexslider { margin: 0 0 60px; background: #fff; border: 4px solid #fff; position: relative; -webkit-border-radius: 4px; -moz-border-radius: 4px; -o-border-radius: 4px; border-radius: 4px; -webkit-box-shadow: 0 1px 4px rgba(0,0,0,.2); -moz-box-shadow: 0 1px 4px rgba(0,0,0,.2); -o-box-shadow: 0 1px 4px rgba(0,0,0,.2); box-shadow: 0 1px 4px rgba(0,0,0,.2); zoom: 1; }
57
+ .flex-viewport { max-height: 2000px; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; transition: all 1s ease; }
58
+ .loading .flex-viewport { max-height: 300px; }
59
+ .flexslider .slides { zoom: 1; }
60
+ .carousel li { margin-right: 5px; }
61
+
62
+ /* Direction Nav */
63
+ .flex-direction-nav {*height: 0;}
64
+ .flex-direction-nav a { text-decoration:none; display: block; width: 40px; height: 40px; margin: -20px 0 0; position: absolute; top: 50%; z-index: 10; overflow: hidden; opacity: 0; cursor: pointer; color: rgba(0,0,0,0.8); text-shadow: 1px 1px 0 rgba(255,255,255,0.3); -webkit-transition: all .3s ease; -moz-transition: all .3s ease; transition: all .3s ease; }
65
+ .flex-direction-nav .flex-prev { left: 10px; opacity: 0.7 }
66
+ .flex-direction-nav .flex-next { right: 10px; text-align: right;opacity: 0.7 }
67
+ .flexslider:hover .flexslider:hover { opacity: 1; }
68
+ .flex-direction-nav .flex-disabled { opacity: 0!important; filter:alpha(opacity=0); cursor: default; }
69
+ .flex-direction-nav a:before { font-family: "flexslider-icon"; font-size: 40px; line-height:1; display: inline-block; content: '\f001'; }
70
+ .flex-direction-nav a.flex-next:before { content: '\f002'; }
71
+
72
+ /* Pause/Play */
73
+ .flex-pauseplay a { display: block; width: 20px; height: 20px; position: absolute; bottom: 5px; left: 10px; opacity: 0.8; z-index: 10; overflow: hidden; cursor: pointer; color: #000; }
74
+ .flex-pauseplay a:before { font-family: "flexslider-icon"; font-size: 20px; display: inline-block; content: '\f004'; }
75
+ .flex-pauseplay a:hover { opacity: 1; }
76
+ .flex-pauseplay a.flex-play:before { content: '\f003'; }
77
+
78
+ /* Control Nav */
79
+ .flex-control-nav {width: 100%; position: absolute; bottom: -40px; text-align: center;}
80
+ .flex-control-nav li {margin: 0 6px; display: inline-block; zoom: 1; *display: inline;}
81
+ .flex-control-paging li a {width: 11px; height: 11px; display: block; background: #666; background: rgba(0,0,0,0.5); cursor: pointer; text-indent: -9999px; -webkit-border-radius: 20px; -moz-border-radius: 20px; -o-border-radius: 20px; border-radius: 20px; -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.3); -moz-box-shadow: inset 0 0 3px rgba(0,0,0,0.3); -o-box-shadow: inset 0 0 3px rgba(0,0,0,0.3); box-shadow: inset 0 0 3px rgba(0,0,0,0.3); }
82
+ .flex-control-paging li a:hover { background: #333; background: rgba(0,0,0,0.7); }
83
+ .flex-control-paging li a.flex-active { background: #000; background: rgba(0,0,0,0.9); cursor: default; }
84
+
85
+ .flex-control-thumbs {margin: 5px 0 0; position: static; overflow: hidden;}
86
+ .flex-control-thumbs li {width: 25%; float: left; margin: 0;}
87
+ .flex-control-thumbs img {width: 100%; display: block; opacity: .7; cursor: pointer;}
88
+ .flex-control-thumbs img:hover {opacity: 1;}
89
+ .flex-control-thumbs .flex-active {opacity: 1; cursor: default;}
90
+
91
+ @media screen and (max-width: 860px) {
92
+ .flex-direction-nav .flex-prev { opacity: 1; left: 10px;}
93
+ .flex-direction-nav .flex-next { opacity: 1; right: 10px;}
94
+ }
95
+ .yop_testimonials{
96
+ border-color:#0088cc ;
97
+ border: 2px solid;
98
+ border-radius: 15px;
99
+ }
100
+ .yop_testimonials_header{
101
+ text-align: left;
102
+ font-size: 20px;
103
+ font-weight: bold;
104
+ margin-left: 5%;
105
+ }
106
+ .yop_testimonials_content{
107
+ text-align: left;
108
+ font-size: 15px;
109
+ margin-left: 5%;
110
+ margin-right: 5%;
111
+ }
112
+ .yop_testimonials_client{
113
+ text-align: right;
114
+ font-size: 15px;
115
+ margin-left: 5%;
116
+ margin-right: 5%;
117
+ font-weight: bold;
118
+ }
119
+ .upgrade_button{
120
+ color: #fff;
121
+ display: inline-block;
122
+ font-weight: bold;
123
+ margin-left: auto;
124
+ margin-right: auto;
125
+ text-align: center !important;
126
+ text-decoration: none !important;
127
+ border-radius: 5px;
128
+ font-size: 21px;
129
+ padding: 15px 35px;
130
+ background-color: rgb(14, 141, 199);
131
+ border:none;
132
+ cursor: pointer;
133
+ }
134
+ .upgrade_button:hover{
135
+ background-color: #0b72a1 !important;
136
+ }
137
+ .yop_testimonials_pro1{
138
+ border-color:#0088cc ;
139
+ border: 2px solid;
140
+ border-radius: 15px;
141
+ text-align: center;
142
+ width: 44%;
143
+ float: left;
144
+ margin-top: 10px;
145
+ }
146
+ .yop_testimonials_pro2{
147
+ border-color:#0088cc ;
148
+ border: 2px solid;
149
+ border-radius: 15px;
150
+ margin-right: 10%;
151
+ width:44%;
152
+ float:right;
153
+ margin-top: 10px;
154
+
155
+ }
156
+ section {
157
+ width: 80%;
158
+ height: 200px;
159
+ text-align: center;
160
+ margin: auto;
161
+ padding: 10px;
162
+ }
css/reveal.css ADDED
@@ -0,0 +1,66 @@
1
+ /* --------------------------------------------------
2
+ Reveal Modals
3
+ -------------------------------------------------- */
4
+
5
+ .reveal-modal-bg {
6
+ position: fixed;
7
+ height: 100%;
8
+ width: 100%;
9
+ background: #000;
10
+ background: rgba(0,0,0,.8);
11
+ z-index: 100;
12
+ display: none;
13
+ top: 0;
14
+ left: 0;
15
+ }
16
+
17
+ .reveal-modal {
18
+ visibility: hidden;
19
+ top: 100px;
20
+ left: 50%;
21
+ margin-left: -570px;
22
+ width: 1050px;
23
+ background: #eee url(modal-gloss.png) no-repeat -200px -80px;
24
+ position: absolute;
25
+ z-index: 101;
26
+ padding: 30px 40px 34px;
27
+ -moz-border-radius: 5px;
28
+ -webkit-border-radius: 5px;
29
+ border-radius: 5px;
30
+ -moz-box-shadow: 0 0 10px rgba(0,0,0,.4);
31
+ -webkit-box-shadow: 0 0 10px rgba(0,0,0,.4);
32
+ -box-shadow: 0 0 10px rgba(0,0,0,.4);
33
+ }
34
+
35
+ .reveal-modal.small { width: 200px; margin-left: -140px;}
36
+ .reveal-modal.medium { width: 400px; margin-left: -240px;}
37
+ .reveal-modal.large { width: 600px; margin-left: -340px;}
38
+ .reveal-modal.xlarge { width: 800px; margin-left: -440px;}
39
+
40
+ .reveal-modal .close-reveal-modal {
41
+ font-size: 22px;
42
+ line-height: .5;
43
+ position: absolute;
44
+ top: 8px;
45
+ right: 11px;
46
+ color: #aaa;
47
+ text-shadow: 0 -1px 1px rbga(0,0,0,.6);
48
+ font-weight: bold;
49
+ cursor: pointer;
50
+ }
51
+ /*
52
+
53
+ NOTES
54
+
55
+ Close button entity is ×
56
+
57
+ Example markup
58
+
59
+ <div id="myModal" class="reveal-modal">
60
+ <h2>Awesome. I have it.</h2>
61
+ <p class="lead">Your couch. I it's mine.</p>
62
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ultrices aliquet placerat. Duis pulvinar orci et nisi euismod vitae tempus lorem consectetur. Duis at magna quis turpis mattis venenatis eget id diam. </p>
63
+ <a class="close-reveal-modal">&#215;</a>
64
+ </div>
65
+
66
+ */
css/yop-poll-admin.css CHANGED
@@ -272,4 +272,4 @@ a {
272
color: #0088cc;
273
text-decoration: none;
274
}
275
- .wp-switch-editor { display:none!important; }
272
color: #0088cc;
273
text-decoration: none;
274
}
275
+ .wp-switch-editor { display:none!important; }
fonts/flexslider-icon.eot ADDED
Binary file
fonts/flexslider-icon.svg ADDED
@@ -0,0 +1,19 @@
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 font generated by IcoMoon.
6
+ <iconset grid="14"></iconset>
7
+ </metadata>
8
+ <defs>
9
+ <font id="flexslider-icon" horiz-adv-x="448" >
10
+ <font-face units-per-em="448" ascent="384" descent="-64" />
11
+ <missing-glyph horiz-adv-x="448" />
12
+ <glyph unicode="&#xf001;" d="M 185.50-9.25l-163.00,162.75q-9.25,9.25 -9.25,22.625t 9.25,22.625l 163.00,162.75q 9.25,9.25 22.625,9.25t 22.625-9.25l 18.75-18.75q 9.25-9.25 9.25-22.625t-9.25-22.625l-121.50-121.50l 121.50-121.25q 9.25-9.50 9.25-22.75t-9.25-22.50l-18.75-18.75q-9.25-9.25 -22.625-9.25t-22.625,9.25z" horiz-adv-x="288" />
13
+ <glyph unicode="&#xf002;" d="M 274.75,176.00q0.00-13.00 -9.25-22.75l-163.00-162.75q-9.25-9.25 -22.50-9.25t-22.50,9.25l-19.00,18.75q-9.25,9.75 -9.25,22.75q0.00,13.25 9.25,22.50l 121.50,121.50l-121.50,121.25q-9.25,9.75 -9.25,22.75q0.00,13.25 9.25,22.50l 19.00,18.75q 9.00,9.50 22.50,9.50t 22.50-9.50l 163.00-162.75q 9.25-9.25 9.25-22.50z" horiz-adv-x="288" />
14
+ <glyph unicode="&#xf003;" d="M 346.00,152.25l-332.00-184.50q-5.75-3.25 -9.875-0.75t-4.125,9.00l0.00,368.00 q0.00,6.50 4.125,9.00t 9.875-0.75l 332.00-184.50q 5.75-3.25 5.75-7.75t-5.75-7.75z" horiz-adv-x="352" />
15
+ <glyph unicode="&#xf004;" d="M 384.00,336.00l0.00-352.00 q0.00-6.50 -4.75-11.25t-11.25-4.75l-128.00,0.00 q-6.50,0.00 -11.25,4.75t-4.75,11.25l0.00,352.00 q0.00,6.50 4.75,11.25t 11.25,4.75l 128.00,0.00 q 6.50,0.00 11.25-4.75t 4.75-11.25zM 160.00,336.00l0.00-352.00 q0.00-6.50 -4.75-11.25t-11.25-4.75l-128.00,0.00 q-6.50,0.00 -11.25,4.75t-4.75,11.25l0.00,352.00 q0.00,6.50 4.75,11.25t 11.25,4.75l 128.00,0.00 q 6.50,0.00 11.25-4.75t 4.75-11.25z" horiz-adv-x="384" />
16
+ <glyph unicode="&#xf005;" d="M 402.75,208.00q0.00-13.25 -9.25-22.50l-162.75-162.75q-9.50-9.50 -22.75-9.50q-13.50,0.00 -22.50,9.50l-162.75,162.75q-9.50,9.00 -9.50,22.50q0.00,13.25 9.50,22.75l 18.50,18.75q 9.75,9.25 22.75,9.25q 13.25,0.00 22.50-9.25l 121.50-121.50l 121.50,121.50q 9.25,9.25 22.50,9.25q 13.00,0.00 22.75-9.25l 18.75-18.75q 9.25-9.75 9.25-22.75z" horiz-adv-x="416" />
17
+ <glyph unicode="&#x20;" horiz-adv-x="224" />
18
+ <glyph class="hidden" unicode="&#xf000;" d="M0,384L 448 -64L0 -64 z" horiz-adv-x="0" />
19
+ </font></defs></svg>
fonts/flexslider-icon.ttf ADDED
Binary file
fonts/flexslider-icon.woff ADDED
Binary file
images/images2/image1.jpg ADDED
Binary file
images/images2/image2.jpg ADDED
Binary file
images/images2/image3.jpg ADDED
Binary file
images/images2/image4.jpg ADDED
Binary file
images/images2/image6.jpg ADDED
Binary file
inc/admin.php CHANGED
@@ -199,16 +199,17 @@ class Yop_Poll_Admin extends Yop_Poll_Plugin {
199
public function ajax_modal_option_signup() {
200
$optin_box_modal_options = get_option( 'yop_poll_optin_box_modal_options_yop' );
201
$optin_box_modal_options ['modal_had_submit'] = 'yes';
202
update_option( 'yop_poll_optin_box_modal_options', $optin_box_modal_options );
203
die ();
204
}
205
public function ajax_show_optin_box_modal() {
206
$this->yop_poll_optin_form1();
207
-
208
$optin_box_modal_options = get_option( 'yop_poll_optin_box_modal_options' );
209
$optin_box_modal_options ['show'] = 'no'; //restore to no
210
$optin_box_modal_options ['sidebar_had_submit'] = 'no';
211
$optin_box_modal_options ['modal_had_submit'] = 'no';
212
update_option( 'yop_poll_optin_box_modal_options_yop', $optin_box_modal_options );
213
214
@@ -415,6 +416,7 @@ class Yop_Poll_Admin extends Yop_Poll_Plugin {
415
$optin_box_modal_options = get_option( 'yop_poll_optin_box_modal_options_yop' );
416
$optin_box_modal_options ['sidebar_had_submit'] = 'yes';
417
$optin_box_modal_options ['modal_had_submit'] = 'yes';
418
update_option( 'yop_poll_optin_box_modal_options_yop', $optin_box_modal_options );
419
die ();
420
}
@@ -430,6 +432,12 @@ class Yop_Poll_Admin extends Yop_Poll_Plugin {
430
wp_enqueue_style( 'yop-poll-timepicker', YOP_POLL_URL . "css/timepicker.css", array(), YOP_POLL_VERSION );
431
wp_enqueue_style( 'yop-poll-colorpicker', YOP_POLL_URL . "css/colorpicker.css", array(), YOP_POLL_VERSION );
432
wp_enqueue_style( 'yop-poll-jquery-ui', YOP_POLL_URL . "css/jquery-ui.css", array(), YOP_POLL_VERSION );
433
wp_enqueue_script( 'yop-poll-admin-js', YOP_POLL_URL . "js/yop-poll-admin.js", array( 'jquery','jquery-ui-tooltip' ), YOP_POLL_VERSION, true );
434
wp_enqueue_script( 'yop-poll-tool_tips-js', YOP_POLL_URL . "js/yop_poll_tool_tips.js", array( 'jquery','jquery-ui-tooltip' ), YOP_POLL_VERSION, true );
435
wp_enqueue_script( 'yop-poll-color', YOP_POLL_URL . "js/color.picker.js", array( 'jquery','jquery-ui-tooltip' ), YOP_POLL_VERSION, true );
@@ -439,6 +447,7 @@ class Yop_Poll_Admin extends Yop_Poll_Plugin {
439
'jquery-ui-slider'
440
), YOP_POLL_VERSION, true );
441
442
$time_format="hh:mm:ss";
443
$options = get_option('yop_poll_options' );
444
if($options['date_format']=="UE")
199
public function ajax_modal_option_signup() {
200
$optin_box_modal_options = get_option( 'yop_poll_optin_box_modal_options_yop' );
201
$optin_box_modal_options ['modal_had_submit'] = 'yes';
202
+ $optin_box_modal_options['modal_email']=isset($_POST['email'])?$_POST['email']:"johndoe@email.com";
203
update_option( 'yop_poll_optin_box_modal_options', $optin_box_modal_options );
204
die ();
205
}
206
public function ajax_show_optin_box_modal() {
207
$this->yop_poll_optin_form1();
208
$optin_box_modal_options = get_option( 'yop_poll_optin_box_modal_options' );
209
$optin_box_modal_options ['show'] = 'no'; //restore to no
210
$optin_box_modal_options ['sidebar_had_submit'] = 'no';
211
$optin_box_modal_options ['modal_had_submit'] = 'no';
212
+ $optin_box_modal_options['modal_email']=isset($_POST['email'])?$_POST['email']:"johndoe@email.com";
213
update_option( 'yop_poll_optin_box_modal_options_yop', $optin_box_modal_options );
214
215
416
$optin_box_modal_options = get_option( 'yop_poll_optin_box_modal_options_yop' );
417
$optin_box_modal_options ['sidebar_had_submit'] = 'yes';
418
$optin_box_modal_options ['modal_had_submit'] = 'yes';
419
+ $optin_box_modal_options['modal_email']=isset($_POST['email'])?$_POST['email']:"johndoe@email.com";
420
update_option( 'yop_poll_optin_box_modal_options_yop', $optin_box_modal_options );
421
die ();
422
}
432
wp_enqueue_style( 'yop-poll-timepicker', YOP_POLL_URL . "css/timepicker.css", array(), YOP_POLL_VERSION );
433
wp_enqueue_style( 'yop-poll-colorpicker', YOP_POLL_URL . "css/colorpicker.css", array(), YOP_POLL_VERSION );
434
wp_enqueue_style( 'yop-poll-jquery-ui', YOP_POLL_URL . "css/jquery-ui.css", array(), YOP_POLL_VERSION );
435
+ wp_enqueue_style( 'yop-poll-bxslider-css', YOP_POLL_URL . "js/bxslider/jquery.bxslider.css", array(), YOP_POLL_VERSION );
436
+ wp_enqueue_style( 'yop-poll-flex-slider-css', YOP_POLL_URL . "css/flexslider.css", array(), YOP_POLL_VERSION );
437
+ wp_enqueue_style( 'yop-poll-reveal-css', YOP_POLL_URL . "css/reveal.css", array(), YOP_POLL_VERSION );
438
+ wp_enqueue_script( 'yop-poll--flex-slider-js', YOP_POLL_URL . "js/jquery.flexslider.js", array( 'jquery','jquery-ui-slider' ), YOP_POLL_VERSION, true );
439
+ wp_enqueue_script( 'yop-poll-jquery-bxslider.js', YOP_POLL_URL . "js/bxslider/jquery.bxslider.js", array( 'jquery','jquery-ui-slider' ), YOP_POLL_VERSION, true );
440
+ wp_enqueue_script( 'yop-poll-reveal.js', YOP_POLL_URL . "js/jquery.reveal.js", array( 'jquery' ), YOP_POLL_VERSION, true );
441
wp_enqueue_script( 'yop-poll-admin-js', YOP_POLL_URL . "js/yop-poll-admin.js", array( 'jquery','jquery-ui-tooltip' ), YOP_POLL_VERSION, true );
442
wp_enqueue_script( 'yop-poll-tool_tips-js', YOP_POLL_URL . "js/yop_poll_tool_tips.js", array( 'jquery','jquery-ui-tooltip' ), YOP_POLL_VERSION, true );
443
wp_enqueue_script( 'yop-poll-color', YOP_POLL_URL . "js/color.picker.js", array( 'jquery','jquery-ui-tooltip' ), YOP_POLL_VERSION, true );
447
'jquery-ui-slider'
448
), YOP_POLL_VERSION, true );
449
450
+
451
$time_format="hh:mm:ss";
452
$options = get_option('yop_poll_options' );
453
if($options['date_format']=="UE")
inc/import_admin.php CHANGED
@@ -1,464 +1,467 @@
1
<?php
2
3
- class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
4
5
- private static $_instance = NULL;
6
7
8
9
- protected function __construct() {
10
11
- parent::__construct( 'imports' );
12
13
- }
14
15
16
17
- public static function get_instance() {
18
19
- if ( self::$_instance == NULL ){
20
21
- $class = __CLASS__;
22
23
- self::$_instance = new $class;
24
25
}
26
27
- return self::$_instance;
28
29
- }
30
31
32
33
- public function manage_imports() {
34
35
- switch ( $GLOBALS['page'] ) {
36
37
- default:
38
39
- $this->manage_options();
40
41
- break;
42
43
}
44
45
46
47
- }
48
49
- public function manage_load_imports() {
50
51
- wp_enqueue_style( 'yop-poll-timepicker', YOP_POLL_URL . "css/timepicker.css", array(), YOP_POLL_VERSION );
52
53
- wp_enqueue_style( 'yop-poll-jquery-ui', YOP_POLL_URL . "css/jquery-ui.css", array(), YOP_POLL_VERSION );
54
55
- }
56
57
58
59
- private function manage_options() {
60
61
- global $page, $action, $message;
62
- switch ( $action ) {
63
64
65
66
- case 'import-all':
67
68
- {
69
70
- $this->import_wp_polls();
71
72
73
- break;
74
75
- }
76
77
- case 'import':
78
79
- {
80
81
- $this->import_wp_poll();
82
83
- break;
84
85
- }
86
87
- default:
88
89
- {
90
- self:: view_wp_polls();
91
92
- }
93
94
95
96
97
98
- }
99
-
100
101
102
- }
103
104
- private function import_wp_poll() {
105
106
107
- if ( !current_user_can( 'edit_own_yop_polls' ) && ( !current_user_can( 'edit_yop_polls' )) ){
108
109
- wp_die( __yop_poll( 'You are not allowed to edit this item.' ) );
110
111
- }
112
113
- else
114
115
- if( check_admin_referer('yop-poll-import', 'yop-poll-imports') ) {
116
117
- if (isset ($_REQUEST['id']))
118
119
- {
120
121
- self::import_wp_poll_fom_db($_REQUEST['id']);
122
123
- }
124
125
- else if ( isset ( $_REQUEST ['yoppollwppollcheck'] ) ){
126
127
- $wp_poll = ( array )$_REQUEST ['yoppollwppollcheck'];
128
129
- foreach ( $wp_poll as $wp_id ) {
130
131
- $wp_id = ( int )$wp_id ;
132
133
- $message = self::import_wp_poll_fom_db($wp_id);
134
135
}
136
137
}
138
139
- }
140
141
- else {
142
143
- wp_die( __yop_poll('You do not have enough permission to import a Wp-poll'));
144
145
- }
146
147
- self:: view_wp_polls();
148
149
- }
150
151
- private function import_wp_poll_fom_db($id)
152
153
- { self::activation_hook();
154
- $current_date= date('Y/m/d H:i:s');
155
156
- $wp_polls=self::get_wp_poll_search_by_id($id );
157
- global $message;
158
159
160
- foreach ($wp_polls as $wp_poll)
161
162
- {
163
- $poll = new YOP_POLL_Poll_Model(0);
164
165
- $answers= self::get_wp_poll_answers_from_db_by_id($wp_poll['pollq_id']);
166
167
- $poll->poll_title=$wp_poll['pollq_question'];
168
169
- $poll->poll_name=$wp_poll['pollq_question'];
170
171
- $poll->poll_author=get_current_user_id();
172
173
- $poll->poll_start_date=date("Y-m-d H:i:s", $wp_poll['pollq_timestamp']);
174
- if($wp_poll['pollq_multiple']>0){
175
- $poll->allow_multiple_answers="yes";
176
- $poll->allow_multiple_answers_max_number=$wp_poll['pollq_multiple'];
177
178
- }
179
180
- if($wp_poll['pollq_expiry']!="")
181
182
- $poll->poll_end_date= date("Y-m-d H:i:s", $wp_poll['pollq_expiry']);
183
184
- else
185
186
- $poll->poll_end_date="01-01-2038 23:59:59";
187
188
- $poll->poll_status="active";
189
190
- $poll->poll_date=$current_date;
191
192
- $poll->poll_modified=$current_date;
193
194
- $poll->poll_total_votes=$wp_poll['pollq_totalvotes'];
195
196
- $question= new YOP_POLL_Question_Model();
197
198
199
200
- $poll_id=$poll->save();
201
202
203
204
- $question->poll_id=$poll_id;
205
206
- $question->question=$wp_poll['pollq_question'];
207
208
- $question->question_status="active";
209
210
- $question->type="text";
211
- if($wp_poll['pollq_multiple']>0){
212
- $question->allow_multiple_answers="yes";
213
- $question->allow_multiple_answers_max_number=$wp_poll['pollq_multiple'];
214
215
- }
216
217
- $question->question_author=get_current_user_id();
218
219
- $question->poll_order=1;
220
221
- $question->question_date =$current_date;
222
223
- $question->question_modified=$current_date;
224
225
226
227
- $question->save();
228
229
230
231
- foreach($answers as $answer){
232
233
234
235
- $poll_answer =new YOP_POLL_Answer_Model();
236
237
- $poll_answer->poll_id=$poll_id;
238
239
- $poll_answer->question_id=$question->ID;
240
241
- $poll_answer->answer=$answer['polla_answers'];
242
243
- $poll_answer->answer_status="active";
244
245
- $poll_answer->type="text";
246
247
- $poll_answer->question_order=1;
248
249
- $poll_answer->answer_author=get_current_user_id();
250
251
- $poll_answer->votes=$answer['polla_votes'];
252
253
- $poll_answer->answer_date=$current_date;
254
255
- $poll_answer->answer_modified=$current_date;
256
257
258
259
- $poll_answer->save();
260
261
- unset($log_details);
262
263
- $log_details= self::get_log_from_db_by_poll_id($wp_poll['pollq_id'],$answer['polla_aid']);
264
265
- foreach($log_details as $log)
266
267
- {
268
269
- $arg['poll_id']=$poll->ID;
270
271
- $arg['ip']=$log['pollip_ip'];
272
273
- if($log['pollip_user']=='Guest'){
274
275
- $arg['user_type']='anonymous';
276
277
- }else
278
279
- $arg['user_type']="wordpress";
280
281
- $arg['user_id']=$log['pollip_userid'];
282
283
- $arg['vote_date']=$log['pollip_timestamp'];
284
285
- $a = self::get_answer_from_db_by_id($log['pollip_aid']);
286
287
- $arg[1]["q-".$question->ID ]['a'][0]= $poll_answer->ID;
288
289
- $arg[1]["q-".$question->ID ]['answers'][0]=$a[0]['polla_answers'];
290
291
- $q = self::get_question_from_db_by_id($log['pollip_qid']);
292
293
- $arg[1]["q-".$question->ID ]['question']=$q[0]['pollq_question'];
294
295
- $arg['vote_details']=json_encode($arg[1]);
296
297
- $this->insert_log_in_db($arg);
298
299
300
- unset($arg);
301
302
}
303
304
- }
305
306
307
308
}
309
- if($poll_id){
310
- $message['success']="Poll imported!" ;
311
- }
312
- else
313
- $message['error']="Could not import ban from database! Please try again!" ;
314
315
- }
316
317
318
319
- private function import_wp_polls()
320
321
- { self::activation_hook();
322
323
- if( check_admin_referer('yop-poll-import', 'yop-poll-imports') ) {
324
325
- if(current_user_can('import_wp_polls')){
326
327
- $current_date= date('Y/m/d H:i:s');
328
329
- $wp_polls=self::get_wp_polls_from_db();
330
331
- foreach ($wp_polls as $wp_poll)
332
333
- {
334
335
- $poll = new YOP_POLL_Poll_Model(0);
336
337
- $answers = self::get_wp_poll_answers_from_db_by_id($wp_poll->pollq_id);
338
339
- $poll->poll_title =$wp_poll->pollq_question;
340
341
- $poll->poll_name =$wp_poll->pollq_question;
342
343
- $poll->poll_author =get_current_user_id();
344
345
- $poll->poll_start_date=date("Y-m-d H:i:s", $wp_poll['pollq_timestamp']);
346
347
- if($wp_poll['pollq_expiry']!="")
348
349
- $poll->poll_end_date = date("Y-m-d H:i:s", $wp_poll['pollq_expiry']);
350
351
- else
352
353
- $poll->poll_end_date ="01-01-2038 23:59:59";
354
355
- $poll->poll_status ="active";
356
357
- $poll->poll_date =$current_date;
358
359
- $poll->poll_modified =$current_date;
360
361
- $poll->poll_total_votes =$wp_poll->pollq_totalvotes;
362
363
- $question = new YOP_POLL_Question_Model();
364
365
366
367
- $poll_id=$poll->save();
368
369
370
371
- $question->poll_d =$poll_id;
372
373
- $question->question =$wp_poll->pollq_question;
374
375
- $question->question_status ="active";
376
377
- $question->question_author =get_current_user_id();
378
379
- $question->poll_order =1;
380
381
- $question->question_date =$current_date;
382
383
- $question->question_modified =$current_date;
384
385
386
387
- $question->save();
388
389
390
391
- foreach($answers as $answer){
392
393
- $poll_answer =new YOP_POLL_Answer_Model();
394
395
- $poll_answer->poll_id =$poll_id;
396
397
- $poll_answer->question_id =$question->ID;
398
399
- $poll_answer->answer =$answer['polla_answers'];
400
401
- $poll_answer->answer_status ="active";
402
403
- $poll_answer->question_order =1;
404
405
- $poll_answer->answer_author =get_current_user_id();
406
407
- $poll_answer->votes =$answer['polla_votes'];
408
409
- $poll_answer->answer_date =$current_date;
410
411
- $poll_answer->answer_modified =$current_date;
412
413
414
415
- $poll_answer->save();
416
417
- unset($log_details);
418
419
- $log_details= self::get_log_from_db_by_poll_id($wp_poll->pollq_id,$answer['polla_aid']);
420
421
- foreach($log_details as $log)
422
423
- {
424
425
- $arg['poll_id'] =$poll->ID;
426
427
- $arg['ip'] =$log['pollip_ip'];
428
429
- if($log['pollip_user']=='Guest'){
430
431
- $arg['user_type']='anonymous';
432
433
- }else
434
435
- $arg['user_type'] ="wordpress";
436
437
- $arg['user_id'] =$log['pollip_userid'];
438
439
- $arg['vote_date'] =$log['pollip_timestamp'];
440
441
- $a =self::get_answer_from_db_by_id($log['pollip_aid']);
442
443
- $arg[1]["q-".$question->ID ]['a'][0]= $poll_answer->ID;
444
445
- $arg[1]["q-".$question->ID ]['answers'][0]=$a[0]['polla_answers'];
446
447
- $q = self::get_question_from_db_by_id($log['pollip_qid']);
448
449
- $arg[1]["q-".$question->ID ]['question']=$q[0]['pollq_question'];
450
451
- $arg['vote_details'] =json_encode($arg[1]);
452
453
- $message=$this->insert_log_in_db($arg);
454
455
456
- if($message['error']!=""|| $message['success']!="")
457
458
- $data['message']=$message;
459
460
461
- unset($arg);
462
463
}
464
@@ -466,37 +469,35 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
466
467
}
468
469
- }
470
-
471
- else
472
473
- wp_die( __yop_poll('You do not have enough permission to import a Wp-poll'));
474
475
- }
476
477
- else {
478
479
- wp_die( __yop_poll('You do not have enough permission to import a Wp-poll'));
480
481
- }
482
483
484
485
- $data['title']='Import Polls from Wp-Poll';
486
487
488
489
- $this->display('imports.html',$data);
490
491
- }
492
493
- public function get_wp_polls_from_db(){
494
495
496
497
- global $wpdb;
498
499
- return $wpdb->get_results($wpdb->prepare( "
500
501
SELECT *
502
@@ -506,15 +507,15 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
506
507
"));
508
509
- }
510
511
512
513
- public function get_wp_poll_answers_from_db_by_id($poll_id)
514
515
- { global $wpdb;
516
517
- return $wpdb->get_results($wpdb->prepare( "
518
519
SELECT *
520
@@ -526,15 +527,15 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
526
527
528
529
- }
530
531
532
533
- public function get_log_from_db_by_poll_id($poll_id,$a_id)
534
535
- {global $wpdb;
536
537
- return $wpdb->get_results($wpdb->prepare( "
538
539
SELECT *
540
@@ -546,15 +547,15 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
546
547
548
549
- }
550
551
552
553
- public function get_answer_from_db_by_id($poll_id)
554
555
- {global $wpdb;
556
557
- return $wpdb->get_results($wpdb->prepare( "
558
559
SELECT *
560
@@ -566,13 +567,13 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
566
567
568
569
- }
570
571
- public function get_question_from_db_by_id($poll_id)
572
573
- {global $wpdb;
574
575
- return $wpdb->get_results($wpdb->prepare( "
576
577
SELECT *
578
@@ -584,23 +585,23 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
584
585
586
587
- }
588
589
- public function insert_log_in_db( $log ){
590
591
- global $wpdb;
592
593
594
595
- $response['success'] = "";
596
597
- $response['error'] = "";
598
599
- define( 'DIEONDBERROR', true );
600
601
602
603
- $sql = $wpdb->query( $wpdb->prepare( "
604
605
INSERT INTO {$wpdb->yop_poll_logs} (
606
@@ -618,272 +619,274 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
618
619
) VALUES ( %d, %s, %d, %s, %s, %s )",
620
621
- $log['poll_id'],
622
623
- $log['ip'],
624
625
- $log['user_id'],
626
627
- $log['user_type'],
628
629
- $log['vote_details'],
630
631
- $log['vote_date']
632
633
- ));
634
635
- if ( $sql ){
636
637
- $response['success'] = __yop_poll( 'Polls imported!' );
638
639
- $response['insert_id'] = $wpdb->insert_id;
640
641
- }
642
643
- else {
644
645
- $response['error'] = __yop_poll( 'Could not import polls into database!' );
646
647
- }
648
649
- return $response;
650
651
652
653
654
655
- }
656
657
- private function view_wp_polls(){
658
659
- $data['REQUEST'] = $_REQUEST;
660
661
- $voter['poll_id']=7;
662
663
- $voter['user_id']=1;
664
665
- $voter['user_type']="wordpress";
666
667
- global $wpdb, $message;
668
669
- global $page, $action, $orderby, $order, $current_user;
670
671
- $orderby = ( empty ( $GLOBALS['orderby'] ) ) ? 'pollq_question' : $GLOBALS['orderby'];
672
673
- $order = ( empty ( $GLOBALS['order'] ) ) ? 'desc' : $GLOBALS['order'];
674
675
- $data['per_page'] = ( isset ( $_GET ['per_page'] ) ? intval( $_GET ['per_page'] ) : 100 );
676
677
- $data['page_no'] = isset ( $_REQUEST ['page_no'] ) ? ( int )$_REQUEST ['page_no'] : 1;
678
679
- $order_fields = array( 'pollq_question', 'pollq_totalvoters' );
680
681
682
683
- $data['orderby'] = ( empty ( $data['REQUEST']['orderby'] ) ) ? 'pollq_question' : $data['REQUEST']['orderby'];
684
685
- $data['order'] = ( empty ( $data['REQUEST']['order'] ) ) ? 'desc' : $data['REQUEST']['order'];
686
687
- $data['order_direction'] = $this->make_order_array( $order_fields, 'asc', $orderby, ( 'desc' == $order ) ? 'asc' : 'desc' );
688
689
- $data['order_sortable'] = $this->make_order_array( $order_fields, 'sortable', $orderby, 'sorted' );
690
691
- $data['order_direction_reverse'] = $this->make_order_array( $order_fields, 'desc', $orderby, ( 'desc' == $order ) ? 'desc' : 'asc' );
692
693
- $data['search'] = array( 'fields' => array( 'pollq_question' ), 'value' => isset ( $_REQUEST ['s'] ) ? trim( $_REQUEST ['s'] ) : '' );
694
695
- $data['wp_polls'] = self::get_wp_poll_search( $data['orderby'], $data['order'], $data['search'], $data['page_no'], $data['per_page'] );
696
- if(!empty($data['wp_polls']))
697
- foreach($data['wp_polls']as &$wp_poll)
698
699
- {
700
701
- $wp_poll['pollq_timestamp']=date("Y-m-d H:i:s", $wp_poll['pollq_timestamp']);
702
703
- $wp_poll['pollq_expiry']=date("Y-m-d H:i:s", $wp_poll['pollq_expiry']);
704
705
706
707
- }
708
709
- $data['total_wp_polls'] = self::count_wp_search( $data['orderby'], $data['order'], $data['search'] );
710
711
- $data['total_polls'] = $data['total_wp_polls'][0]['poll_no'];
712
713
- $data['message'] = array( 'error' => $message['error'], 'success' => $message['success'] );
714
715
- if ( intval( $data['page_no'] ) > intval( $data['total_polls'] ) ){
716
717
- $data['page_no'] = 1;
718
719
- }
720
721
- $args = array(
722
723
- 'base' => remove_query_arg(
724
725
- 'page_no',
726
727
- $_SERVER ['REQUEST_URI'] ) . '%_%',
728
729
- 'format' => '&page_no=%#%',
730
731
- 'current' => max( 1, $data['page_no'] ),
732
733
- 'total' => ceil( $data['total_wp_polls'][0]['poll_no'] / $data['per_page'] ),
734
735
- 'prev_next' => true,
736
737
- 'prev_text' => __( '&laquo;' ),
738
739
- 'next_text' => __( '&raquo;' )
740
741
- );
742
743
744
745
- $data['pagination'] = paginate_links( $args );
746
747
748
749
- $_SERVER ['REQUEST_URI'] = remove_query_arg( array( 'action' ), $_SERVER ['REQUEST_URI'] );
750
751
- $data['request']['uri'] = $_SERVER["REQUEST_URI"];
752
753
754
755
- $data['title']='Import Polls from Wp-Poll';
756
757
- $this->display('imports.html',$data);
758
759
- }
760
761
- public static function get_wp_poll_search( $orderby = 'pollq_question', $order = 'desc', $search = array( 'fields' => array(), 'value' => NULL ), $offset = 0 , $per_page = 100 ,$poll_id = NULL ) {
762
763
- global $wpdb;
764
- if($wpdb->get_var("SHOW TABLES LIKE '$wpdb->pollsq'") == $wpdb->pollsq) {
765
- $sql = "SELECT * FROM " . $wpdb->pollsq;
766
767
768
769
- $sql_search = '';
770
771
- if ( $poll_id ){
772
773
- $sql_search .= $wpdb->prepare( ' WHERE pollq_id = %d', $poll_id );
774
775
- }
776
777
778
779
780
781
- if ( count( $search['fields'] ) > 0 ){
782
783
784
785
- $sql_search .= ' WHERE (';
786
787
788
789
- foreach ( $search['fields'] as $field ) {
790
791
- $sql_search .= $wpdb->prepare( ' ' . esc_attr( $field ) . ' like \'%%%s%%\' OR', $search['value'] );
792
793
- }
794
795
- $sql_search = trim( $sql_search, 'OR' );
796
797
- $sql_search .= ' ) ';
798
799
- }
800
801
- $sql .= $sql_search;
802
803
- $sql_order_by = ' ORDER BY ' . esc_attr( $orderby ) . ' ' . esc_attr( $order ) . ' ';
804
805
- $sql .= $sql_order_by;
806
807
- $sql .= $wpdb->prepare( ' LIMIT %d, %d', (($offset-1) * $per_page), $per_page );
808
809
- return $wpdb->get_results( $sql, ARRAY_A );
810
}
811
- }
812
813
- public static function get_wp_poll_search_by_id($poll_id = NULL ) {
814
815
- global $wpdb;
816
817
- $sql = "SELECT * FROM " . $wpdb->pollsq;
818
819
820
821
- $sql_search = '';
822
823
- if ( $poll_id ){
824
825
- $sql_search .= $wpdb->prepare( ' WHERE pollq_id = %d', $poll_id );
826
827
- }
828
829
830
831
832
833
- $sql .= $sql_search;
834
835
836
837
- return $wpdb->get_results( $sql, ARRAY_A );
838
839
- }
840
841
- public static function count_wp_search( $orderby = 'pollq_question', $order = 'desc', $search = array( 'fields' => array(), 'value' => NULL ) ) {
842
843
- global $wpdb;
844
- if($wpdb->get_var("SHOW TABLES LIKE '$wpdb->pollsq'") == $wpdb->pollsq) {
845
- $sql = "SELECT COUNT(*) AS poll_no FROM " . $wpdb->pollsq;
846
847
- $sql_search = '';
848
849
- if ( count( $search['fields'] ) > 0 ){
850
851
852
853
- $sql_search .= ' WHERE (';
854
855
856
857
- foreach ( $search['fields'] as $field ) {
858
859
- $sql_search .= $wpdb->prepare( ' ' . esc_attr( $field ) . ' like \'%%%s%%\' OR', $search['value'] );
860
861
- }
862
863
- $sql_search = trim( $sql_search, 'OR' );
864
865
- $sql_search .= ' ) ';
866
867
- }
868
869
- $sql .= $sql_search;
870
- yop_poll_dump($sql);
871
872
- $sql_order_by = ' ORDER BY ' . esc_attr( $orderby ) . ' ' . esc_attr( $order ) . ' ';
873
874
- $sql .= $sql_order_by;
875
876
- return $wpdb->get_results( $sql, ARRAY_A );
877
}
878
- }
879
880
881
882
- public function yop_poll_get_polls_meta_from_db(){
883
884
- global $wpdb;
885
886
- $result = $wpdb->get_results( "
887
888
SELECT *
889
@@ -891,17 +894,17 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
891
892
", ARRAY_A );
893
894
- return $result;
895
896
897
898
- }
899
900
- public function yop_poll_get_polls_from_db(){
901
902
- global $wpdb;
903
904
- $result = $wpdb->get_results( ( "
905
906
SELECT *
907
@@ -909,109 +912,109 @@ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
909
910
"), ARRAY_A );
911
912
- return $result;
913
914
915
916
- }
917
918
919
920
921
- public function yop_poll_get_answers_meta_from_db() {
922
- global $wpdb;
923
924
- $result = $wpdb->get_results( "
925
SELECT *
926
FROM " . $wpdb->prefix . "yop_poll_answermeta
927
928
" , ARRAY_A );
929
- return $result;
930
931
- }
932
933
- public function yop_poll_get_templates_from_db() {
934
- global $wpdb;
935
- $result = $wpdb->get_results( "
936
SELECT *
937
FROM " . $wpdb->prefix . "yop_poll_templates
938
" , ARRAY_A );
939
- return $result;
940
- }
941
942
- public function yop_poll_get_custom_fields_from_db() {
943
- global $wpdb;
944
- $result = $wpdb->get_results("
945
SELECT *
946
FROM " . $wpdb->prefix . "yop_poll_custom_fields ORDER BY poll_id ASC
947
" , ARRAY_A );
948
- return $result;
949
- }
950
951
- public function yop_poll_get_custom_fields_votes_from_db() {
952
- global $wpdb;
953
- $result = $wpdb->get_results( "
954
SELECT *
955
FROM " . $wpdb->prefix . "yop_poll_votes_custom_fields
956
" , ARRAY_A );
957
- return $result;
958
- }
959
960
- public function yop_poll_get_bans_from_db() {
961
- global $wpdb;
962
- $result = $wpdb->get_results( "
963
SELECT *
964
FROM " . $wpdb->prefix . "yop_poll_bans ORDER BY poll_id ASC
965
" , ARRAY_A );
966
- return $result;
967
- }
968
969
- public function yop_poll_get_answers_from_db() {
970
- global $wpdb;
971
- $result = $wpdb->get_results( "
972
SELECT *
973
FROM " . $wpdb->prefix . "yop_poll_answers ORDER BY poll_id ASC
974
", ARRAY_A );
975
- return $result;
976
- }
977
978
- public function yop_poll_get_logs_from_db() {
979
- global $wpdb;
980
- $result = $wpdb->get_results( ( "
981
SELECT *
982
FROM " . $wpdb->prefix . "yop_poll_logs WHERE ID>%d
983
" ), ARRAY_A );
984
- return $result;
985
- }
986
987
- private static function insert_ban_in_db( $ban ) {
988
- global $wpdb;
989
- $sql = $wpdb->query( $wpdb->prepare( "
990
INSERT INTO $wpdb->yop_poll_bans
991
( poll_id,type,value,period ,unit)
992
VALUES(%d,%s,%s,%d,%s)
993
", $ban['poll_id'], $ban['type'], $ban['value'], intval( $ban['period'] ), $ban['unit'] ) );
994
- return $wpdb->get_results( $sql );
995
- }
996
- private function save_poll_order( $poll, $poll_order ) {
997
- $poll_archive_order = get_option( 'yop_poll_archive_order', array() );
998
- if( $poll_archive_order == "" ) {
999
- $poll_archive_order = array();
1000
- }if( trim( $poll_order ) <= 0 ) {
1001
- $poll_order = 1;
1002
}
1003
- $key = array_search( $poll, $poll_archive_order );
1004
- if( $key !== false ) {
1005
- unset( $poll_archive_order[$key] );
1006
- }
1007
- if( $poll_order > count( $poll_archive_order ) ) {
1008
- array_push( $poll_archive_order, $poll );
1009
- }
1010
- else {
1011
- array_splice( $poll_archive_order, trim( $poll_order ) - 1, 0, array( $poll ) );
1012
}
1013
- update_option( 'yop_poll_archive_order', $poll_archive_order );
1014
- }
1015
1016
1017
- }
1
<?php
2
3
+ class YOP_POLL_Imports_Admin extends YOP_POLL_Abstract_Admin{
4
5
+ private static $_instance = NULL;
6
7
8
9
+ protected function __construct() {
10
11
+ parent::__construct( 'imports' );
12
+
13
+ }
14
15
16
17
+ public static function get_instance() {
18
19
+ if ( self::$_instance == NULL ){
20
21
+ $class = __CLASS__;
22
23
+ self::$_instance = new $class;
24
+
25
+ }
26
27
+ return self::$_instance;
28
29
}
30
31
32
33
+ public function manage_imports() {
34
+
35
+ switch ( $GLOBALS['page'] ) {
36
37
+ default:
38
39
+ $this->manage_options();
40
41
+ break;
42
43
+ }
44
45
46
47
}
48
49
+ public function manage_load_imports() {
50
51
+ wp_enqueue_style( 'yop-poll-timepicker', YOP_POLL_URL . "css/timepicker.css", array(), YOP_POLL_VERSION );
52
53
+ wp_enqueue_style( 'yop-poll-jquery-ui', YOP_POLL_URL . "css/jquery-ui.css", array(), YOP_POLL_VERSION );
54
55
+ }
56
57
58
59
+ private function manage_options() {
60
61
+ global $page, $action, $message;
62
63
+ switch ( $action ) {
64
65
66
67
+ case 'import-all':
68
69
+ {
70
71
+ $this->import_wp_polls();
72
73
74
+ break;
75
76
+ }
77
78
+ case 'import':
79
80
+ {
81
82
+ $this->import_wp_poll();
83
84
+ break;
85
86
+ }
87
88
+ default:
89
90
+ {
91
+ self:: view_wp_polls();
92
93
+ }
94
95
96
97
98
99
+ }
100
101
102
103
+ }
104
105
+ private function import_wp_poll() {
106
107
108
+ if ( !current_user_can( 'edit_own_yop_polls' ) && ( !current_user_can( 'edit_yop_polls' )) ){
109
110
+ wp_die( __yop_poll( 'You are not allowed to edit this item.' ) );
111
112
+ }
113
114
+ else
115
116
+ if( check_admin_referer('yop-poll-import', 'yop-poll-imports') ) {
117
118
+ if (isset ($_REQUEST['id']))
119
120
+ {
121
122
+ self::import_wp_poll_fom_db($_REQUEST['id']);
123
124
+ }
125
126
+ else if ( isset ( $_REQUEST ['yoppollwppollcheck'] ) ){
127
128
+ $wp_poll = ( array )$_REQUEST ['yoppollwppollcheck'];
129
130
+ foreach ( $wp_poll as $wp_id ) {
131
132
+ $wp_id = ( int )$wp_id ;
133
134
+ $message = self::import_wp_poll_fom_db($wp_id);
135
136
+ }
137
138
}
139
140
}
141
142
+ else {
143
144
+ wp_die( __yop_poll('You do not have enough permission to import a Wp-poll'));
145
146
+ }
147
148
+ self:: view_wp_polls();
149
150
+ }
151
152
+ private function import_wp_poll_fom_db($id)
153
154
+ {
155
+ $current_date= date('Y/m/d H:i:s');
156
157
+ $wp_polls=self::get_wp_poll_search_by_id($id );
158
+ global $message;
159
160
161
+ foreach ($wp_polls as $wp_poll)
162
163
+ {
164
+ $poll = new YOP_POLL_Poll_Model(0);
165
166
+ $answers= self::get_wp_poll_answers_from_db_by_id($wp_poll['pollq_id']);
167
168
+ $poll->poll_title=$wp_poll['pollq_question'];
169
170
+ $poll->poll_name=$wp_poll['pollq_question'];
171
172
+ $poll->poll_author=get_current_user_id();
173
174
+ $poll->poll_start_date=date("Y-m-d H:i:s", $wp_poll['pollq_timestamp']);
175
+ if($wp_poll['pollq_multiple']>0){
176
+ $poll->allow_multiple_answers="yes";
177
+ $poll->allow_multiple_answers_max_number=$wp_poll['pollq_multiple'];
178
179
+ }
180
181
+ if($wp_poll['pollq_expiry']!="")
182
183
+ $poll->poll_end_date= date("Y-m-d H:i:s", $wp_poll['pollq_expiry']);
184
185
+ else
186
187
+ $poll->poll_end_date="01-01-2038 23:59:59";
188
189
+ $poll->poll_status="active";
190
191
+ $poll->poll_date=$current_date;
192
193
+ $poll->poll_modified=$current_date;
194
195
+ $poll->poll_total_votes=$wp_poll['pollq_totalvotes'];
196
197
+ $question= new YOP_POLL_Question_Model();
198
199
200
201
+ $poll_id=$poll->save();
202
203
204
205
+ $question->poll_id=$poll_id;
206
207
+ $question->question=$wp_poll['pollq_question'];
208
209
+ $question->question_status="active";
210
211
+ $question->type="text";
212
+ if($wp_poll['pollq_multiple']>0){
213
+ $question->allow_multiple_answers="yes";
214
+ $question->allow_multiple_answers_max_number=$wp_poll['pollq_multiple'];
215
216
+ }
217
218
+ $question->question_author=get_current_user_id();
219
220
+ $question->poll_order=1;
221
222
+ $question->question_date =$current_date;
223
224
+ $question->question_modified=$current_date;
225
226
227
228
+ $question->save();
229
230
231
232
+ foreach($answers as $answer){
233
234
235
236
+ $poll_answer =new YOP_POLL_Answer_Model();
237
238
+ $poll_answer->poll_id=$poll_id;
239
240
+ $poll_answer->question_id=$question->ID;
241
242
+ $poll_answer->answer=$answer['polla_answers'];
243
244
+ $poll_answer->answer_status="active";
245
246
+ $poll_answer->type="text";
247
248
+ $poll_answer->question_order=1;
249
250
+ $poll_answer->answer_author=get_current_user_id();
251
252
+ $poll_answer->votes=$answer['polla_votes'];
253
254
+ $poll_answer->answer_date=$current_date;
255
256
+ $poll_answer->answer_modified=$current_date;
257
258
259
260
+ $poll_answer->save();
261
262
+ unset($log_details);
263
264
+ $log_details= self::get_log_from_db_by_poll_id($wp_poll['pollq_id'],$answer['polla_aid']);
265
266
+ foreach($log_details as $log)
267
268
+ {
269
270
+ $arg['poll_id']=$poll->ID;
271
272
+ $arg['ip']=$log['pollip_ip'];
273
274
+ if($log['pollip_user']=='Guest'){
275
276
+ $arg['user_type']='anonymous';
277
278
+ }else
279
280
+ $arg['user_type']="wordpress";
281
282
+ $arg['user_id']=$log['pollip_userid'];
283
284
+ $arg['vote_date']=$log['pollip_timestamp'];
285
286
+ $a = self::get_answer_from_db_by_id($log['pollip_aid']);
287
288
+ $arg[1]["q-".$question->ID ]['a'][0]= $poll_answer->ID;
289
290
+ $arg[1]["q-".$question->ID ]['answers'][0]=$a[0]['polla_answers'];
291
292
+ $q = self::get_question_from_db_by_id($log['pollip_qid']);
293
294
+ $arg[1]["q-".$question->ID ]['question']=$q[0]['pollq_question'];
295
296
+ $arg['vote_details']=json_encode($arg[1]);
297
298
+ $this->insert_log_in_db($arg);
299
300
301
+ unset($arg);
302
303
+ }
304
305
}
306
307
308
309
+ }
310
+ if($poll_id){
311
+ $message['success']="Poll imported!" ;
312
+ }
313
+ else
314
+ $message['error']="Could not import ban from database! Please try again!" ;
315
316
}
317
318
319
320
+ private function import_wp_polls()
321
322
+ {
323
324
+ if( check_admin_referer('yop-poll-import', 'yop-poll-imports') ) {
325
326
+ if(current_user_can('import_wp_polls')){
327
328
+ $current_date= date('Y/m/d H:i:s');
329
330
+ $wp_polls=self::get_wp_polls_from_db();
331
332
+ foreach ($wp_polls as $wp_poll)
333
334
+ {
335
336
+ $poll = new YOP_POLL_Poll_Model(0);
337
338
+ $answers = self::get_wp_poll_answers_from_db_by_id($wp_poll->pollq_id);
339
340
+ $poll->poll_title =$wp_poll->pollq_question;
341
342
+ $poll->poll_name =$wp_poll->pollq_question;
343
344
+ $poll->poll_author =get_current_user_id();
345
346
+ $poll->poll_start_date=date("Y-m-d H:i:s", $wp_poll['pollq_timestamp']);
347
348
+ if($wp_poll['pollq_expiry']!="")
349
350
+ $poll->poll_end_date = date("Y-m-d H:i:s", $wp_poll['pollq_expiry']);
351
352
+ else
353
354
+ $poll->poll_end_date ="01-01-2038 23:59:59";
355
356
+ $poll->poll_status ="active";
357
358
+ $poll->poll_date =$current_date;
359
360
+ $poll->poll_modified =$current_date;
361
362
+ $poll->poll_total_votes =$wp_poll->pollq_totalvotes;
363
364
+ $question = new YOP_POLL_Question_Model();
365
366
367
368
+ $poll_id=$poll->save();
369
370
371
372
+ $question->poll_d =$poll_id;
373
374
+ $question->question =$wp_poll->pollq_question;
375
376
+ $question->question_status ="active";
377
378
+ $question->question_author =get_current_user_id();
379
380
+ $question->poll_order =1;
381
382
+ $question->question_date =$current_date;
383
384
+ $question->question_modified =$current_date;
385
386
387
388
+ $question->save();
389
390
391
392
+ foreach($answers as $answer){
393
394
+ $poll_answer =new YOP_POLL_Answer_Model();
395
396
+ $poll_answer->poll_id =$poll_id;
397
398
+ $poll_answer->question_id =$question->ID;
399
400
+ $poll_answer->answer =$answer['polla_answers'];
401
402
+ $poll_answer->answer_status ="active";
403
404
+ $poll_answer->question_order =1;
405
406
+ $poll_answer->answer_author =get_current_user_id();
407
408
+ $poll_answer->votes =$answer['polla_votes'];
409
410
+ $poll_answer->answer_date =$current_date;
411
412
+ $poll_answer->answer_modified =$current_date;
413
414
415
416
+ $poll_answer->save();
417
418
+ unset($log_details);
419
420
+ $log_details= self::get_log_from_db_by_poll_id($wp_poll->pollq_id,$answer['polla_aid']);
421
422
+ foreach($log_details as $log)
423
424
+ {
425
426
+ $arg['poll_id'] =$poll->ID;
427
428
+ $arg['ip'] =$log['pollip_ip'];
429
430
+ if($log['pollip_user']=='Guest'){
431
432
+ $arg['user_type']='anonymous';
433
434
+ }else
435
436
+ $arg['user_type'] ="wordpress";
437
438
+ $arg['user_id'] =$log['pollip_userid'];
439
440
+ $arg['vote_date'] =$log['pollip_timestamp'];
441
442
+ $a =self::get_answer_from_db_by_id($log['pollip_aid']);
443
444
+ $arg[1]["q-".$question->ID ]['a'][0]= $poll_answer->ID;
445
446
+ $arg[1]["q-".$question->ID ]['answers'][0]=$a[0]['polla_answers'];
447
448
+ $q = self::get_question_from_db_by_id($log['pollip_qid']);
449
450
+ $arg[1]["q-".$question->ID ]['question']=$q[0]['pollq_question'];
451
452
+ $arg['vote_details'] =json_encode($arg[1]);
453
454
+ $message=$this->insert_log_in_db($arg);
455
456
457
+ if($message['error']!=""|| $message['success']!="")
458
459
+ $data['message']=$message;
460
461
462
+ unset($arg);
463
464
+ }
465
466
}
467
469
470
}
471
472
+ else
473
474
+ wp_die( __yop_poll('You do not have enough permission to import a Wp-poll'));
475
476
+ }
477
478
+ else {
479
480
+ wp_die( __yop_poll('You do not have enough permission to import a Wp-poll'));
481
482
+ }
483
484
485
486
+ $data['title']='Import Polls from Wp-Poll';
487
488
489
490
+ $this->display('imports.html',$data);
491
492
+ }
493
494
+ public function get_wp_polls_from_db(){
495
496
497
498
+ global $wpdb;
499
500
+ return $wpdb->get_results($wpdb->prepare( "
501
502
SELECT *
503
507
508
"));
509
510
+ }
511
512
513
514
+ public function get_wp_poll_answers_from_db_by_id($poll_id)
515
516
+ { global $wpdb;
517
518
+ return $wpdb->get_results($wpdb->prepare( "
519
520
SELECT *
521
527
528
529
530
+ }
531
532
533
534
+ public function get_log_from_db_by_poll_id($poll_id,$a_id)
535
536
+ {global $wpdb;
537
538
+ return $wpdb->get_results($wpdb->prepare( "
539
540
SELECT *
541
547
548
549
550
+ }
551
552
553
554
+ public function get_answer_from_db_by_id($poll_id)
555
556
+ {global $wpdb;
557
558
+ return $wpdb->get_results($wpdb->prepare( "
559
560
SELECT *
561
567
568
569
570
+ }
571
572
+ public function get_question_from_db_by_id($poll_id)
573
574
+ {global $wpdb;
575
576
+ return $wpdb->get_results($wpdb->prepare( "
577
578
SELECT *
579
585
586
587
588
+ }
589
590
+ public function insert_log_in_db( $log ){
591
592
+ global $wpdb;
593
594
595
596
+ $response['success'] = "";
597
598
+ $response['error'] = "";
599
600
+ define( 'DIEONDBERROR', true );
601
602
603
604
+ $sql = $wpdb->query( $wpdb->prepare( "
605
606
INSERT INTO {$wpdb->yop_poll_logs} (
607
619
620
) VALUES ( %d, %s, %d, %s, %s, %s )",
621
622
+ $log['poll_id'],
623
624
+ $log['ip'],
625
626
+ $log['user_id'],
627
628
+ $log['user_type'],
629
630
+ $log['vote_details'],
631
632
+ $log['vote_date']
633
634
+ ));
635
636
+ if ( $sql ){
637
638
+ $response['success'] = __yop_poll( 'Polls imported!' );
639
640
+ $response['insert_id'] = $wpdb->insert_id;
641
642
+ }
643
644
+ else {
645
646
+ $response['error'] = __yop_poll( 'Could not import polls into database!' );
647
648
+ }
649
650
+ return $response;
651
652
653
654
655
656
+ }
657
658
+ private function view_wp_polls(){
659
+ global $wpdb;
660
661
+ if( $wpdb->get_var("SHOW TABLES LIKE '" . $wpdb->prefix . "pollsq'") === $wpdb->prefix . 'pollsq' ) {
662
+ $data['REQUEST'] = $_REQUEST;
663
664
665
+ $voter['poll_id']=7;
666
667
+ $voter['user_id']=1;
668
669
+ $voter['user_type']="wordpress";
670
671
+ global $wpdb, $message;
672
673
+ global $page, $action, $orderby, $order, $current_user;
674
675
+ $orderby = ( empty ( $GLOBALS['orderby'] ) ) ? 'pollq_question' : $GLOBALS['orderby'];
676
677
+ $order = ( empty ( $GLOBALS['order'] ) ) ? 'desc' : $GLOBALS['order'];
678
679
+ $data['per_page'] = ( isset ( $_GET ['per_page'] ) ? intval( $_GET ['per_page'] ) : 100 );
680
681
+ $data['page_no'] = isset ( $_REQUEST ['page_no'] ) ? ( int )$_REQUEST ['page_no'] : 1;
682
683
+ $order_fields = array( 'pollq_question', 'pollq_totalvoters' );
684
685
686
687
+ $data['orderby'] = ( empty ( $data['REQUEST']['orderby'] ) ) ? 'pollq_question' : $data['REQUEST']['orderby'];
688
689
+ $data['order'] = ( empty ( $data['REQUEST']['order'] ) ) ? 'desc' : $data['REQUEST']['order'];
690
691
+ $data['order_direction'] = $this->make_order_array( $order_fields, 'asc', $orderby, ( 'desc' == $order ) ? 'asc' : 'desc' );
692
693
+ $data['order_sortable'] = $this->make_order_array( $order_fields, 'sortable', $orderby, 'sorted' );
694
695
+ $data['order_direction_reverse'] = $this->make_order_array( $order_fields, 'desc', $orderby, ( 'desc' == $order ) ? 'desc' : 'asc' );
696
697
+ $data['search'] = array( 'fields' => array( 'pollq_question' ), 'value' => isset ( $_REQUEST ['s'] ) ? trim( $_REQUEST ['s'] ) : '' );
698
699
+ $data['wp_polls'] = self::get_wp_poll_search( $data['orderby'], $data['order'], $data['search'], $data['page_no'], $data['per_page'] );
700
701
+ foreach($data['wp_polls']as &$wp_poll)
702
703
+ {
704
705
+ $wp_poll['pollq_timestamp']=date("Y-m-d H:i:s", $wp_poll['pollq_timestamp']);
706
707
+ $wp_poll['pollq_expiry']=date("Y-m-d H:i:s", $wp_poll['pollq_expiry']);
708
709
710
711
+ }
712
713
+ $data['total_wp_polls'] = self::count_wp_search( $data['orderby'], $data['order'], $data['search'] );
714
715
+ $data['total_polls'] = $data['total_wp_polls'][0]['poll_no'];
716
717
+ $data['message'] = array( 'error' => $message['error'], 'success' => $message['success'] );
718
719
+ if ( intval( $data['page_no'] ) > intval( $data['total_polls'] ) ){
720
721
+ $data['page_no'] = 1;
722
723
+ }
724
725
+ $args = array(
726
727
+ 'base' => remove_query_arg(
728
729
+ 'page_no',
730
731
+ $_SERVER ['REQUEST_URI'] ) . '%_%',
732
733
+ 'format' => '&page_no=%#%',
734
735
+ 'current' => max( 1, $data['page_no'] ),
736
737
+ 'total' => ceil( $data['total_wp_polls'][0]['poll_no'] / $data['per_page'] ),
738
739
+ 'prev_next' => true,
740
741
+ 'prev_text' => __( '&laquo;' ),
742
743
+ 'next_text' => __( '&raquo;' )
744
745
+ );
746
747
748
749
+ $data['pagination'] = paginate_links( $args );
750
751
752
753
+ $_SERVER ['REQUEST_URI'] = remove_query_arg( array( 'action' ), $_SERVER ['REQUEST_URI'] );
754
755
+ $data['request']['uri'] = $_SERVER["REQUEST_URI"];
756
757
758
+ }
759
+ $data['title']='Import Polls from Wp-Poll';
760
761
+ $this->display('imports.html',$data);
762
763
+ }
764
765
+ public static function get_wp_poll_search( $orderby = 'pollq_question', $order = 'desc', $search = array( 'fields' => array(), 'value' => NULL ), $offset = 0 , $per_page = 100 ,$poll_id = NULL ) {
766
767
+ global $wpdb;
768
769
+ $sql = "SELECT * FROM " . $wpdb->pollsq;
770
771
772
773
+ $sql_search = '';
774
775
+ if ( $poll_id ){
776
777
+ $sql_search .= $wpdb->prepare( ' WHERE pollq_id = %d', $poll_id );
778
779
+ }
780
781
782
783
784
785
+ if ( count( $search['fields'] ) > 0 ){
786
787
788
789
+ $sql_search .= ' WHERE (';
790
791
792
793
+ foreach ( $search['fields'] as $field ) {
794
795
+ $sql_search .= $wpdb->prepare( ' ' . esc_attr( $field ) . ' like \'%%%s%%\' OR', $search['value'] );
796
797
+ }
798
799
+ $sql_search = trim( $sql_search, 'OR' );
800
+
801
+ $sql_search .= ' ) ';
802
+
803
+ }
804
805
+ $sql .= $sql_search;
806
807
+ $sql_order_by = ' ORDER BY ' . esc_attr( $orderby ) . ' ' . esc_attr( $order ) . ' ';
808
809
+ $sql .= $sql_order_by;
810
811
+ $sql .= $wpdb->prepare( ' LIMIT %d, %d', (($offset-1) * $per_page), $per_page );
812
+
813
+ return $wpdb->get_results( $sql, ARRAY_A );
814
815
}
816
817
+ public static function get_wp_poll_search_by_id($poll_id = NULL ) {
818
819
+ global $wpdb;
820
821
+ $sql = "SELECT * FROM " . $wpdb->pollsq;
822
823
824
825
+ $sql_search = '';
826
827
+ if ( $poll_id ){
828
829
+ $sql_search .= $wpdb->prepare( ' WHERE pollq_id = %d', $poll_id );
830
831
+ }
832
833
834
835
836
837
+ $sql .= $sql_search;
838
839
840
841
+ return $wpdb->get_results( $sql, ARRAY_A );
842
843
+ }
844
845
+ public static function count_wp_search( $orderby = 'pollq_question', $order = 'desc', $search = array( 'fields' => array(), 'value' => NULL ) ) {
846
847
+ global $wpdb;
848
849
+ $sql = "SELECT COUNT(*) AS poll_no FROM " . $wpdb->pollsq;
850
851
+ $sql_search = '';
852
853
+ if ( count( $search['fields'] ) > 0 ){
854
855
856
857
+ $sql_search .= ' WHERE (';
858
859
860
861
+ foreach ( $search['fields'] as $field ) {
862
863
+ $sql_search .= $wpdb->prepare( ' ' . esc_attr( $field ) . ' like \'%%%s%%\' OR', $search['value'] );
864
865
+ }
866
867
+ $sql_search = trim( $sql_search, 'OR' );
868
869
+ $sql_search .= ' ) ';
870
871
+ }
872
+
873
+ $sql .= $sql_search;
874
+
875
+ $sql_order_by = ' ORDER BY ' . esc_attr( $orderby ) . ' ' . esc_attr( $order ) . ' ';
876
877
+ $sql .= $sql_order_by;
878
879
+ return $wpdb->get_results( $sql, ARRAY_A );
880
881
}
882
883
884
885
+ public function yop_poll_get_polls_meta_from_db(){
886
887
+ global $wpdb;
888
889
+ $result = $wpdb->get_results( "
890
891
SELECT *
892
894
895
", ARRAY_A );
896
897
+ return $result;
898
899
900
901
+ }
902
903
+ public function yop_poll_get_polls_from_db(){
904
905
+ global $wpdb;
906
907
+ $result = $wpdb->get_results( ( "
908
909
SELECT *
910
912
913
"), ARRAY_A );
914
915
+ return $result;
916
917
918
919
+ }
920
921
922
923
924
+ public function yop_poll_get_answers_meta_from_db() {
925
+ global $wpdb;
926
927
+ $result = $wpdb->get_results( "
928
SELECT *
929
FROM " . $wpdb->prefix . "yop_poll_answermeta
930
931
" , ARRAY_A );
932
+ return $result;
933
934
+ }
935
936
+ public function yop_poll_get_templates_from_db() {
937
+ global $wpdb;
938
+ $result = $wpdb->get_results( "
939
SELECT *
940
FROM " . $wpdb->prefix . "yop_poll_templates
941
" , ARRAY_A );
942
+ return $result;
943
+ }
944
945
+ public function yop_poll_get_custom_fields_from_db() {
946
+ global $wpdb;
947
+ $result = $wpdb->get_results("
948
SELECT *
949
FROM " . $wpdb->prefix . "yop_poll_custom_fields ORDER BY poll_id ASC
950
" , ARRAY_A );
951
+ return $result;
952
+ }
953
954
+ public function yop_poll_get_custom_fields_votes_from_db() {
955
+ global $wpdb;
956
+ $result = $wpdb->get_results( "
957
SELECT *
958
FROM " . $wpdb->prefix . "yop_poll_votes_custom_fields
959
" , ARRAY_A );
960
+ return $result;
961
+ }
962
963
+ public function yop_poll_get_bans_from_db() {
964
+ global $wpdb;
965
+ $result = $wpdb->get_results( "
966
SELECT *
967
FROM " . $wpdb->prefix . "yop_poll_bans ORDER BY poll_id ASC
968
" , ARRAY_A );
969
+ return $result;
970
+ }
971
972
+ public function yop_poll_get_answers_from_db() {
973
+ global $wpdb;
974
+ $result = $wpdb->get_results( "
975
SELECT *
976
FROM " . $wpdb->prefix . "yop_poll_answers ORDER BY poll_id ASC
977
", ARRAY_A );
978
+ return $result;
979
+ }
980
981
+ public function yop_poll_get_logs_from_db() {
982
+ global $wpdb;
983
+ $result = $wpdb->get_results( ( "
984
SELECT *
985
FROM " . $wpdb->prefix . "yop_poll_logs WHERE ID>%d
986
" ), ARRAY_A );
987
+ return $result;
988
+ }
989
990
+ private static function insert_ban_in_db( $ban ) {
991
+ global $wpdb;
992
+ $sql = $wpdb->query( $wpdb->prepare( "
993
INSERT INTO $wpdb->yop_poll_bans
994
( poll_id,type,value,period ,unit)
995
VALUES(%d,%s,%s,%d,%s)
996
", $ban['poll_id'], $ban['type'], $ban['value'], intval( $ban['period'] ), $ban['unit'] ) );
997
+ return $wpdb->get_results( $sql );
998
}
999
+ private function save_poll_order( $poll, $poll_order ) {
1000
+ $poll_archive_order = get_option( 'yop_poll_archive_order', array() );
1001
+ if( $poll_archive_order == "" ) {
1002
+ $poll_archive_order = array();
1003
+ }if( trim( $poll_order ) <= 0 ) {
1004
+ $poll_order = 1;
1005
+ }
1006
+ $key = array_search( $poll, $poll_archive_order );
1007
+ if( $key !== false ) {
1008
+ unset( $poll_archive_order[$key] );
1009
+ }
1010
+ if( $poll_order > count( $poll_archive_order ) ) {
1011
+ array_push( $poll_archive_order, $poll );
1012
+ }
1013
+ else {
1014
+ array_splice( $poll_archive_order, trim( $poll_order ) - 1, 0, array( $poll ) );
1015
+ }
1016
+ update_option( 'yop_poll_archive_order', $poll_archive_order );
1017
}
1018
1019
1020
+ }
inc/maintenance.php CHANGED
@@ -548,6 +548,10 @@ NOWDOC;
548
}
549
update_option( "yop_poll_version", YOP_POLL_VERSION );
550
}
551
552
}
553
public function yop_poll_get_polls_for_body_mail_update(){
548
}
549
update_option( "yop_poll_version", YOP_POLL_VERSION );
550
}
551
+ $installed_version = get_option( "yop_poll_version" );
552
+ if ( version_compare( $installed_version, '5.3', '<=' ) ){
553
+ update_option( "yop_poll_version", YOP_POLL_VERSION );
554
+ }
555
556
}
557
public function yop_poll_get_polls_for_body_mail_update(){
inc/plugin-functions.php CHANGED
@@ -180,7 +180,7 @@ function yop_poll_default_options() {
180
181
'view_poll_archive_link' => 'no',
182
183
- 'auto_generate_poll_page' => 'yes',
184
185
'has_auto_generate_poll_page' => 'no',
186
@@ -369,7 +369,7 @@ function yop_poll_poll_default_options() {
369
370
'view_poll_archive_link' => 'no',
371
372
- 'auto_generate_poll_page' => 'yes',
373
374
'has_auto_generate_poll_page' => 'no',
375
@@ -983,13 +983,13 @@ function xss_clean($data)
983
}
984
function yop_poll_ret_poll_by_votes_desc ($array){
985
if(count($array)>0) {
986
- $sql = 'SELECT ID FROM ' . $GLOBALS['wpdb']->yop_polls . ' WHERE (ID='.$array[0].')';
987
988
for( $i = 1; $i < count( $array ); $i ++ ) {
989
- $sql.='OR (ID= '. $array[$i]. ')';
990
}
991
$sql.=' ORDER BY poll_total_votes DESC ';
992
- return $GLOBALS['wpdb']->get_results( $sql, ARRAY_A );
993
}
994
}
995
function yop_poll_sort_desc_database ($array){
@@ -1000,7 +1000,7 @@ function xss_clean($data)
1000
$sql.='OR (ID= '. $array[$i]. ')';
1001
}
1002
$sql.=' ORDER BY ID DESC ';
1003
- return $GLOBALS['wpdb']->get_results( $sql, ARRAY_A );
1004
}
1005
}
1006
function yop_poll_sort_asc_database ($array){
180
181
'view_poll_archive_link' => 'no',
182
183
+ 'auto_generate_poll_page' => 'no',
184
185
'has_auto_generate_poll_page' => 'no',
186
369
370
'view_poll_archive_link' => 'no',
371
372
+ 'auto_generate_poll_page' => 'no',
373
374
'has_auto_generate_poll_page' => 'no',
375
983
}
984
function yop_poll_ret_poll_by_votes_desc ($array){
985
if(count($array)>0) {
986
+ $sql = 'SELECT ID, poll_total_votes FROM ' . $GLOBALS['wpdb']->yop_polls . ' WHERE (ID='.$array[0].')';
987
988
for( $i = 1; $i < count( $array ); $i ++ ) {
989
+ $sql.=' OR (ID='. $array[$i]. ')';
990
}
991
$sql.=' ORDER BY poll_total_votes DESC ';
992
+ return $GLOBALS['wpdb']->get_results( $sql, ARRAY_A );
993
}
994
}
995
function yop_poll_sort_desc_database ($array){
1000
$sql.='OR (ID= '. $array[$i]. ')';
1001
}
1002
$sql.=' ORDER BY ID DESC ';
1003
+ return $GLOBALS['wpdb']->get_results( $sql, ARRAY_A );
1004
}
1005
}
1006
function yop_poll_sort_asc_database ($array){
inc/poll_admin.php CHANGED
@@ -580,6 +580,9 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
580
$current->email_notifications_recipients=$options['email_notifications_recipients'];
581
$current->email_notifications_subject=$options['email_notifications_subject'];
582
$current->email_notifications_body=$options['email_notifications_body'];
583
}
584
$data['current_poll'] = $current;
585
if( 'edit' == $action_type ) {
@@ -676,6 +679,7 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
676
$archive = get_option( 'yop_poll_archive_order', array() );
677
if(($key = array_search($_REQUEST['id'], $archive)) !== false) {
678
unset($archive[$key]);
679
update_option( 'yop_poll_archive_order', $archive );
680
681
}
@@ -689,6 +693,7 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
689
$archive = get_option( 'yop_poll_archive_order', array() );
690
if(($key = array_search($poll_id, $archive)) !== false) {
691
unset($archive[$key]);
692
update_option( 'yop_poll_archive_order', $archive );
693
}
694
}
@@ -739,11 +744,11 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
739
global $wpdb, $current_user;
740
$poll_details = self::get_poll_from_database_by_id( $poll_id );
741
$clone_number = self::count_poll_from_database_like_name( $poll_details['poll_name'] . ' - clone' );
742
-
743
$current_poll = new YOP_POLL_Poll_Model( $poll_id );
744
- $poll_clone = clone $current_poll;
745
- $poll_clone->poll_total_votes=0;
746
- $poll_clone->ID = NULL;
747
if( $poll_details ) {
748
$poll = array(
749
'title' => $poll_details['poll_title'] . ' - clone' . ( 0 == $clone_number ? '' : $clone_number ),
@@ -751,7 +756,7 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
751
'end_date' => $poll_details['poll_end_date'],
752
'status' => $poll_details['poll_status'],
753
'poll_date' => $poll_details['poll_date'],
754
- 'total_votes' => $poll_details['poll_total_votes'],
755
'author' => $poll_details['poll_author'],
756
'name' => $poll_details['poll_name'] . ' - clone' . ( 0 == $clone_number ? '' : $clone_number ),
757
'type' => $poll_details['poll_type'],
@@ -760,20 +765,63 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
760
$poll_clone->poll_name = $poll['name'];
761
$poll_clone->poll_title = $poll['title'];
762
763
- foreach( $poll_clone->questions as &$question ) {
764
- $question->ID = NULL;
765
-
766
- foreach( $question->answers as &$answer ) {
767
- $answer->ID = NULL;
768
}
769
}
770
771
- // yop_poll_dump($poll_clone);
772
- $poll_clone->save();
773
774
}
775
}
776
777
public static function get_poll_total_customfields_logs( $poll_id, $quest_id, $sdate = '', $edate = '' ) {
778
global $wpdb;
779
$sdatesql = '';
@@ -2243,7 +2291,7 @@ class YOP_POLL_Poll_Admin extends YOP_POLL_Abstract_Admin {
2243
unset($answer_details);
2244
}
2245
if($cheked==0){
2246
- $message['error']= "You must select at least an answer!";
2247
wp_die( json_encode( $message ) );
2248
}
2249
}
580
$current->email_notifications_recipients=$options['email_notifications_recipients'];
581
$current->email_notifications_subject=$options['email_notifications_subject'];
582
$current->email_notifications_body=$options['email_notifications_body'];
583
+ $current->vote_permisions_wordpress_label=$options['vote_permisions_wordpress_label'];
584
+ $current->vote_permisions_anonymous_label=$options['vote_permisions_anonymous_label'];
585
+ $current->vote_button_label=$options['vote_button_label'];
586
}
587
$data['current_poll'] = $current;
588
if( 'edit' == $action_type ) {
679
$archive = get_option( 'yop_poll_archive_order', array() );
680
if(($key = array_search($_REQUEST['id'], $archive)) !== false) {
681
unset($archive[$key]);
682
+ $archive=array_values($archive);
683
update_option( 'yop_poll_archive_order', $archive );
684
685
}
693
$archive = get_option( 'yop_poll_archive_order', array() );
694
if(($key = array_search($poll_id, $archive)) !== false) {
695
unset($archive[$key]);
696
+ $archive=array_values($archive);
697
update_option( 'yop_poll_archive_order', $archive );
698
}
699
}
744
global $wpdb, $current_user;
745
$poll_details = self::get_poll_from_database_by_id( $poll_id );
746
$clone_number = self::count_poll_from_database_like_name( $poll_details['poll_name'] . ' - clone' );
747
+ $meta = get_yop_poll_meta( $poll_id, 'options', true );
748
$current_poll = new YOP_POLL_Poll_Model( $poll_id );
749
+ $current_poll->poll_total_votes=0;
750
+ $poll_clone =$current_poll;
751
+ $poll_clone->ID = 0;
752
if( $poll_details ) {
753
$poll = array(
754
'title' => $poll_details['poll_title'] . ' - clone' . ( 0 == $clone_number ? '' : $clone_number ),
756
'end_date' => $poll_details['poll_end_date'],
757
'status' => $poll_details['poll_status'],
758
'poll_date' => $poll_details['poll_date'],
759
+ 'poll_total_votes' => 0,
760
'author' => $poll_details['poll_author'],
761
'name' => $poll_details['poll_name'] . ' - clone' . ( 0 == $clone_number ? '' : $clone_number ),
762
'type' => $poll_details['poll_type'],
765
$poll_clone->poll_name = $poll['name'];
766
$poll_clone->poll_title = $poll['title'];
767
768
+ foreach( $poll_clone->questions as $question ) {
769
+ $question->ID = 0;
770
+ foreach( $question->answers as $answer ) {
771
+ $answer->ID = 0;
772
+ }
773
+ if(isset($question->custom_fields))
774
+ foreach($question->custom_fields as $custom){
775
+ $custom->ID=0;
776
+ $custom->poll_id=0;
777
+ $custom->question_id=0;
778
}
779
}
780
781
+ $id_poll=$poll_clone->save();
782
+ self::save_poll_order($poll_clone,$poll_clone->poll_archive_order);
783
+ update_yop_poll_meta( $id_poll, 'options', $meta );
784
785
}
786
}
787
788
+ private static function save_poll_order( $poll, $poll_order ) {
789
+ $poll_archive_order = get_option( 'yop_poll_archive_order', array() );
790
+ if( $poll_archive_order == "" ) {
791
+ $poll_archive_order = array();
792
+ }
793
+ if( isset( $poll->show_poll_in_archive ) ) {
794
+ if( $poll->show_poll_in_archive == 'yes' ) {
795
+ if( isset( $poll_order ) && is_numeric( trim( $poll_order ) ) ) {
796
+ if( trim( $poll_order ) <= 0 ) {
797
+ $poll_order = 1;
798
+ }
799
+ $key = array_search( $poll->ID, $poll_archive_order );
800
+ if( $key !== false ) {
801
+ unset( $poll_archive_order[$key] );
802
+ }
803
+ if( $poll_order > count( $poll_archive_order ) ) {
804
+ array_push( $poll_archive_order, $poll->ID );
805
+ }
806
+ else {
807
+ array_splice( $poll_archive_order, trim( $poll_order ) - 1, 0, array( $poll->ID ) );
808
+ }
809
+
810
+ }
811
+
812
+ }
813
+ else {
814
+ $key = array_search( $poll->ID, $poll_archive_order );
815
+
816
+ if( $key !== null ) {
817
+ unset( $poll_archive_order[$key] );
818
+ }
819
+ }
820
+ }
821
+
822
+ $poll_archive_order = array_values( $poll_archive_order );
823
+ update_option( 'yop_poll_archive_order', $poll_archive_order );
824
+ }
825
public static function get_poll_total_customfields_logs( $poll_id, $quest_id, $sdate = '', $edate = '' ) {
826
global $wpdb;
827
$sdatesql = '';
2291
unset($answer_details);
2292
}
2293
if($cheked==0){
2294
+ $message['error']= "You must select at least one answer!";
2295
wp_die( json_encode( $message ) );
2296
}
2297
}
inc/pro_admin.php CHANGED
@@ -168,9 +168,13 @@ class YOP_POLL_Pro_Admin extends YOP_POLL_Abstract_Admin {
168
$pro_options = get_option( "yop_poll_pro" );
169
$pro_options['rand_number'] = $rand_number;
170
update_option( "yop_poll_pro", $pro_options );
171
$redirect_url = urlencode( "https://yop-poll.com/yop-licence/upgrade.php?action=getPackageLink&domain=" .
172
urlencode( $domain ) . "&rand=" .
173
- urlencode( $rand_number )."&redirect_after=". urlencode( add_query_arg( array(
174
"page" => "yop-polls-become-pro",
175
"action" => 'after-buy'
176
), admin_url( 'admin.php' ) ) )
@@ -178,7 +182,7 @@ class YOP_POLL_Pro_Admin extends YOP_POLL_Abstract_Admin {
178
$paypalUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7YBTNHDBFJBG6&return=" .
179
"$redirect_url&rm=2&custom=" .
180
urlencode( $domain . ";" .
181
- $rand_number
182
) . "";
183
;
184
168
$pro_options = get_option( "yop_poll_pro" );
169
$pro_options['rand_number'] = $rand_number;
170
update_option( "yop_poll_pro", $pro_options );
171
+ $optin_box_modal_options = get_option( 'yop_poll_optin_box_modal_options_yop' );
172
+ $email=isset($optin_box_modal_options['modal_email'])?$optin_box_modal_options['modal_email']:"johndoe@email.com";
173
$redirect_url = urlencode( "https://yop-poll.com/yop-licence/upgrade.php?action=getPackageLink&domain=" .
174
urlencode( $domain ) . "&rand=" .
175
+ urlencode( $rand_number )."&yop_email=".
176
+ urlencode($email).
177
+ "&redirect_after=". urlencode( add_query_arg( array(
178
"page" => "yop-polls-become-pro",
179
"action" => 'after-buy'
180
), admin_url( 'admin.php' ) ) )
182
$paypalUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7YBTNHDBFJBG6&return=" .
183
"$redirect_url&rm=2&custom=" .
184
urlencode( $domain . ";" .
185
+ $rand_number. ";" .$email
186
) . "";
187
;
188
inc/public-admin.php CHANGED
@@ -169,17 +169,20 @@
169
$temp = "";
170
171
if($ok==1){
172
- for( $i = ( $args['current'] - 1 ) * $per_page; $i <= ( $args['current'] - 1 ) * $per_page + $per_page - 1; $i ++ ) {
173
- $temp .= $this->return_yop_poll( $archives[$i]['ID'], $results );
174
- }
175
}else{
176
for( $i = ( $args['current'] - 1 ) * $per_page; $i <= ( $args['current'] - 1 ) * $per_page + $per_page - 1; $i ++ ) {
177
$temp .= $this->return_yop_poll( $archives[$i], $results );
178
- }
179
}
180
return $temp . paginate_links( $args );
181
182
183
}
184
185
@@ -283,7 +286,7 @@
283
'loading_image_src' => $loading_image_src,
284
'loading_image_alt' => __yop_poll( 'Loading' ),
285
);
286
-
287
$tabulate['results']=false;
288
$tabulate['answers']=false;
289
$tabulate['orizontal_answers']=0;
169
$temp = "";
170
171
if($ok==1){
172
+ for( $i = ( $args['current'] - 1 ) * $per_page; $i <= ( $args['current'] - 1 ) * $per_page + $per_page - 1; $i ++ ) {
173
+ if(isset($archives[$i]['ID']))
174
+ $temp .= $this->return_yop_poll( $archives[$i]['ID'], $results );
175
+ }
176
}else{
177
for( $i = ( $args['current'] - 1 ) * $per_page; $i <= ( $args['current'] - 1 ) * $per_page + $per_page - 1; $i ++ ) {
178
+ if(isset($archives[$i]['ID']))
179
$temp .= $this->return_yop_poll( $archives[$i], $results );
180
+ }
181
}
182
return $temp . paginate_links( $args );
183
184
185
+
186
}
187
188
286
'loading_image_src' => $loading_image_src,
287
'loading_image_alt' => __yop_poll( 'Loading' ),
288
);
289
+
290
$tabulate['results']=false;
291
$tabulate['answers']=false;
292
$tabulate['orizontal_answers']=0;
js/bxslider/bower.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "bxslider-4",
3
+ "version": "4.1.2",
4
+ "homepage": "http://bxslider.com",
5
+ "license": "MIT",
6
+ "main": [
7
+ "jquery.bxslider.js",
8
+ "jquery.bxslider.css",
9
+ "images/bx_loader.gif",
10
+ "images/controls.png"
11
+ ],
12
+ "keywords": [
13
+ "bxslider",
14
+ "javascript",
15
+ "jquery",
16
+ "library"
17
+ ],
18
+ "ignore": [
19
+ "**/.*",
20
+ "*.md"
21
+ ],
22
+ "dependencies": {
23
+ "jquery": ">=1.6"
24
+ }
25
+ }
js/bxslider/images/bx_loader.gif ADDED
Binary file
js/bxslider/images/controls.png ADDED
Binary file
js/bxslider/jquery.bxslider.css ADDED
@@ -0,0 +1,205 @@