PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 5.6.2
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v5.6.2
6.5.0 6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 All 153 releases
poll-maker / admin / class-poll-maker-ays-admin.php

class-poll-maker-ays-admin.php in Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls 5.6.2, at admin/class-poll-maker-ays-admin.php

2,862 lines 126.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The admin-specific functionality of the plugin.
5 *
6 * @link https://ays-pro.com/
7 * @since 1.0.0
8 *
9 * @package Poll_Maker_Ays
10 * @subpackage Poll_Maker_Ays/admin
11 */
12
13 /**
14 * The admin-specific functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the admin-specific stylesheet and JavaScript.
18 *
19 * @package Poll_Maker_Ays
20 * @subpackage Poll_Maker_Ays/admin
21 * @author Poll Maker Team <[email protected]>
22 */
23 class Poll_Maker_Ays_Admin {
24
25 /**
26 * The ID of this plugin.
27 *
28 * @since 1.0.0
29 * @access private
30 * @var string $plugin_name The ID of this plugin.
31 */
32 private $plugin_name;
33
34 /**
35 * The version of this plugin.
36 *
37 * @since 1.0.0
38 * @access private
39 * @var string $version The current version of this plugin.
40 */
41 private $version;
42
43 private $polls_obj;
44 private $cats_obj;
45 private $results_obj;
46 private $each_results_obj;
47 private $settings_obj;
48 private $answer_results_obj;
49 private $capability;
50
51 /**
52 * Initialize the class and set its properties.
53 *
54 * @param string $plugin_name The name of this plugin.
55 * @param string $version The version of this plugin.
56 *
57 * @since 1.0.0
58 */
59 public function __construct( $plugin_name, $version ) {
60
61 $this->plugin_name = $plugin_name;
62 $this->version = $version;
63 add_filter('set-screen-option', array(__CLASS__, 'set_screen'), 10, 3);
64 $per_page_array = array(
65 'polls_per_page',
66 'poll_cats_per_page',
67 'poll_results_per_page',
68 );
69 foreach($per_page_array as $option_name){
70 add_filter('set_screen_option_'.$option_name, array(__CLASS__, 'set_screen'), 10, 3);
71 }
72 }
73
74 /**
75 * Register the styles for the admin menu area.
76 *
77 * @since 1.5.5
78 */
79 public function admin_menu_styles() {
80 echo "
81 <style>
82 #adminmenu a.toplevel_page_poll-maker-ays div.wp-menu-image img {
83 width: 28px;
84 padding-top: 2px;
85 }
86
87 #adminmenu li.toplevel_page_poll-maker-ays ul.wp-submenu.wp-submenu-wrap li:last-child a {
88 color: #68A615;
89 font-weight: bold;
90 }
91
92 .apm-badge {
93 position: relative;
94 top: -1px;
95 right: -3px;
96 }
97
98 .apm-badge.badge-danger {
99 color: #fff;
100 background-color: #ca4a1f;
101 }
102
103 .apm-badge.badge {
104 display: inline-block;
105 vertical-align: top;
106 margin: 1px 0 0 2px;
107 padding: 0 5px;
108 min-width: 7px;
109 height: 17px;
110 border-radius: 11px;
111 font-size: 9px;
112 line-height: 17px;
113 text-align: center;
114 z-index: 26;
115 }
116
117 .wp-first-item .apm-badge {
118 display: none;
119 }
120
121 .apm-badge.badge.apm-no-results {
122 display: none;
123 }
124 </style>
125 ";
126 }
127
128 /**
129 * Register the stylesheets for the admin area.
130 *
131 * @since 1.0.0
132 */
133 public function enqueue_styles( $hook_suffix ) {
134 wp_enqueue_style($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'css/admin.css', array(), $this->version, 'all');
135 wp_enqueue_style($this->plugin_name . '-sweetalert-css', plugin_dir_url(__FILE__) . 'css/poll-maker-sweetalert2.min.css', array(), $this->version, 'all');
136 if (false === strpos($hook_suffix, $this->plugin_name)) {
137 return;
138 }
139 // wp_enqueue_style('wp-color-picker');
140 /**
141 * This function is provided for demonstration purposes only.
142 *
143 * An instance of this class should be passed to the run() function
144 * defined in Poll_Maker_Ays_Loader as all of the hooks are defined
145 * in that particular class.
146 *
147 * The Poll_Maker_Ays_Loader will then create the relationship
148 * between the defined hooks and the functions defined in this
149 * class.
150 */
151
152 // You need styling for the datepicker. For simplicity I've linked to the jQuery UI CSS on a CDN.
153 wp_register_style( 'jquery-ui', 'https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css' );
154 wp_enqueue_style( 'jquery-ui' );
155
156 wp_enqueue_style('wp-color-picker');
157 wp_enqueue_style('ays_poll_animate.css', plugin_dir_url(__FILE__) . 'css/animate.min.css', array(), $this->version, 'all');
158 wp_enqueue_style( $this->plugin_name . '-font-awesome', plugin_dir_url(__FILE__) . 'css/poll-maker-font-awesome-all.css', array(), $this->version, 'all');
159 wp_enqueue_style('ays_poll_bootstrap', plugin_dir_url(__FILE__) . 'css/bootstrap.min.css', array(), $this->version, 'all');
160 wp_enqueue_style($this->plugin_name.'-jquery-datetimepicker', plugin_dir_url(__FILE__) . 'css/jquery-ui-timepicker-addon.css', array(), $this->version, 'all');
161 wp_enqueue_style('ays-poll-select2', plugin_dir_url(__FILE__) . 'css/select2.min.css', array(), $this->version, 'all');
162 wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/poll-maker-ays-admin.css', array(), $this->version, 'all');
163 wp_enqueue_style($this->plugin_name.'popup-layer', plugin_dir_url(__FILE__) . 'css/poll-maker-ays-admin-popup-layer.css', array(), $this->version, 'all');
164 wp_enqueue_style( $this->plugin_name . '-dropdown', plugin_dir_url(__FILE__) . '/css/dropdown.min.css', array(), $this->version, 'all');
165 wp_enqueue_style( $this->plugin_name . '-transition', plugin_dir_url(__FILE__) . '/css/transition.min.css', array(), $this->version, 'all');
166
167
168 }
169
170 /**
171 * Register the JavaScript for the admin area.
172 *
173 * @since 1.0.0
174 */
175 public function enqueue_scripts( $hook_suffix ) {
176 wp_enqueue_script( $this->plugin_name . '-dropdown-min', plugin_dir_url(__FILE__) . '/js/dropdown.min.js', array('jquery'), $this->version, true);
177 wp_enqueue_script( $this->plugin_name . '-transition-min', plugin_dir_url(__FILE__) . '/js/transition.min.js', array('jquery'), $this->version, true);
178 global $wp_version;
179 if (false !== strpos($hook_suffix, "plugins.php")){
180 wp_enqueue_script('sweetalert-js-poll', plugin_dir_url(__FILE__) . 'js/sweetalert2.all.min.js', array('jquery'), $this->version, true);
181
182 wp_enqueue_script($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'js/admin.js', array('jquery'), $this->version, true);
183 wp_localize_script($this->plugin_name . '-admin', 'apm_admin_ajax_obj', array('ajaxUrl' => admin_url('admin-ajax.php')));
184 }
185
186 $version1 = $wp_version;
187 $operator = '>=';
188 $version2 = '5.5';
189 $versionCompare = $this->versionCompare($version1, $operator, $version2);
190 if ($versionCompare) {
191 wp_enqueue_script( $this->plugin_name.'-wp-load-scripts', plugin_dir_url(__FILE__) . 'js/ays-wp-load-scripts.js', array(), $this->version, true);
192 }
193
194 if (false === strpos($hook_suffix, $this->plugin_name)) {
195 return;
196 }
197
198 $poll_banner_date = $this->ays_poll_update_banner_time();
199
200 /**
201 * This function is provided for demonstration purposes only.
202 *
203 * An instance of this class should be passed to the run() function
204 * defined in Poll_Maker_Ays_Loader as all of the hooks are defined
205 * in that particular class.
206 *
207 * The Poll_Maker_Ays_Loader will then create the relationship
208 * between the defined hooks and the functions defined in this
209 * class.
210 */
211 wp_enqueue_script('jquery');
212 wp_enqueue_script('jquery-ui-datepicker');
213 wp_enqueue_media();
214 wp_enqueue_script( $this->plugin_name.'-wp-color-picker-alpha', plugin_dir_url(__FILE__) . 'js/wp-color-picker-alpha.min.js', array('wp-color-picker'), $this->version, true);
215 wp_enqueue_script('ays_poll_popper', plugin_dir_url(__FILE__) . 'js/popper.min.js', array('jquery'), $this->version, true);
216 wp_enqueue_script('ays_poll_bootstrap', plugin_dir_url(__FILE__) . 'js/bootstrap.min.js', array('jquery'), $this->version, true);
217 wp_enqueue_script('ays_poll_select2', plugin_dir_url(__FILE__) . 'js/select2.min.js', array('jquery'), $this->version, true);
218 wp_enqueue_script('sweetalert-js-poll', plugin_dir_url(__FILE__) . 'js/sweetalert2.all.min.js', array('jquery'), $this->version, true);
219 wp_enqueue_script( $this->plugin_name."-jquery.datetimepicker.js", plugin_dir_url( __FILE__ ) . 'js/jquery-ui-timepicker-addon.js', array( 'jquery' ), $this->version, true );
220 wp_enqueue_script('ays-poll-admin-js', plugin_dir_url(__FILE__) . 'js/poll-maker-ays-admin.js', array('jquery', 'wp-color-picker'), $this->version, true);
221 wp_enqueue_script( $this->plugin_name . '-charts-google', plugin_dir_url(__FILE__) . 'js/google-chart.js', array('jquery'), $this->version, false);
222 wp_localize_script('ays-poll-admin-js', 'pollLangObj', array(
223 'pollBannerDate' => $poll_banner_date,
224 'errorMsg' => __('Error', "poll-maker"),
225 'somethingWentWrong' => __('Maybe something went wrong.', "poll-maker"),
226 'add' => __('Add', "poll-maker"),
227 'answersMinCount' => __('Sorry minimum count of answers should be 2', "poll-maker"),
228 'copied' => __('Copied!', "poll-maker"),
229 'clickForCopy' => __('Click for copy.', "poll-maker"),
230 'areYouSure' => __('Are you sure you want to redirect to another poll? Note that the changes made in this poll will not be saved.', "poll-maker"),
231 'deleteAnswer' => __('Are you sure you want to delete this answer?', "poll-maker"),
232 'youCanUuseThisShortcode' => __('Your Poll is Created!<br>Copy the generated shortcode and paste it into any post or page to display Poll', "poll-maker"),
233 'greateJob' => __('Great job', "poll-maker"),
234 'formMoreDetailed' => __('For more detailed configuration visit', "poll-maker"),
235 'done' => __('Done', "poll-maker"),
236 'thumbsUpGreat' => __('Thumbs up, Done', "poll-maker"),
237 ) );
238
239 wp_localize_script('ays-poll-admin-js', 'poll', array(
240 'ajax' => admin_url('admin-ajax.php'),
241 'pleaseEnterMore' => __('Please select more', "poll-maker"),
242 'urlImg' => (POLL_MAKER_AYS_ADMIN_URL . '/images/'),
243 ));
244
245 wp_enqueue_script( $this->plugin_name . '-quick-start-js', plugin_dir_url(__FILE__) . 'js/poll-maker-poll-quick-start.js', array('jquery'), $this->version, true);
246 wp_enqueue_script( $this->plugin_name . '-admin-ajax', plugin_dir_url(__FILE__) . 'js/poll-maker-ays-ajax-admin.js', array('jquery'), $this->version, true);
247 wp_localize_script($this->plugin_name . '-admin-ajax', 'apm_ajax_obj', array('ajaxUrl' => admin_url('admin-ajax.php')));
248
249 $color_picker_strings = array(
250 'clear' => __('Clear', "poll-maker"),
251 'clearAriaLabel' => __('Clear color', "poll-maker"),
252 'defaultString' => __('Default', "poll-maker"),
253 'defaultAriaLabel' => __('Select default color', "poll-maker"),
254 'pick' => __('Select Color', "poll-maker"),
255 'defaultLabel' => __('Color value', "poll-maker"),
256 );
257 wp_localize_script( $this->plugin_name.'-wp-color-picker-alpha', 'wpColorPickerL10n', $color_picker_strings );
258 }
259
260 /**
261 * De-register JavaScript files for the admin area.
262 *
263 * @since 1.0.0
264 */
265 public function disable_scripts($hook_suffix) {
266 if (false !== strpos($hook_suffix, $this->plugin_name)) {
267 if (is_plugin_active('ai-engine/ai-engine.php')) {
268 wp_deregister_script('mwai');
269 wp_deregister_script('mwai-vendor');
270 wp_dequeue_script('mwai');
271 wp_dequeue_script('mwai-vendor');
272 }
273 }
274 }
275
276 public function codemirror_enqueue_scripts($hook) {
277 if(strpos($hook, $this->plugin_name) !== false){
278 if(function_exists('wp_enqueue_code_editor')){
279 $cm_settings['codeEditor'] = wp_enqueue_code_editor(array(
280 'type' => 'text/css',
281 'codemirror' => array(
282 'inputStyle' => 'contenteditable',
283 'theme' => 'cobalt',
284 )
285 ));
286
287 wp_enqueue_script('wp-theme-plugin-editor');
288 wp_localize_script('wp-theme-plugin-editor', 'cm_settings', $cm_settings);
289
290 wp_enqueue_style('wp-codemirror');
291 }
292 }
293 }
294
295 public function versionCompare($version1, $operator, $version2) {
296
297 $_fv = intval ( trim ( str_replace ( '.', '', $version1 ) ) );
298 $_sv = intval ( trim ( str_replace ( '.', '', $version2 ) ) );
299
300 if (strlen ( $_fv ) > strlen ( $_sv )) {
301 $_sv = str_pad ( $_sv, strlen ( $_fv ), 0 );
302 }
303
304 if (strlen ( $_fv ) < strlen ( $_sv )) {
305 $_fv = str_pad ( $_fv, strlen ( $_sv ), 0 );
306 }
307
308 return version_compare ( ( string ) $_fv, ( string ) $_sv, $operator );
309 }
310
311 public function add_plugin_admin_menu() {
312
313 /*
314 * Check unread results
315 *
316 */
317 global $wpdb;
318 $sql = "SELECT COUNT(unread) FROM {$wpdb->prefix}ayspoll_reports WHERE unread=1";
319 $unread_results = $wpdb->get_var($sql);
320 $show = $unread_results > 0 ? '' : "apm-no-results";
321 /*
322 * Add a settings page for this plugin to the Settings menu.
323 *
324 * NOTE: Alternative menu locations are available via WordPress administration menu functions.
325 *
326 * Administration Menus: http://codex.wordpress.org/Administration_Menus
327 *
328 */
329
330 $menu_item = ($unread_results == 0) ? 'Poll Maker' : 'Poll Maker' . '<span class="apm-badge badge badge-danger '.$show.'">' . $unread_results . '</span>';
331
332 $this->capability = $this->poll_maker_capabilities();
333 $capability = $this->poll_maker_capabilities();
334 $hook_poll = add_menu_page(
335 'Poll Maker',
336 $menu_item,
337 $capability,
338 $this->plugin_name,
339 array($this,'display_plugin_polls_page'),
340 POLL_MAKER_AYS_ADMIN_URL . '/images/icons/icon-poll-maker-128x128.svg',
341 '6.33'
342 );
343
344 add_action("load-$hook_poll", array($this, 'screen_option_polls'));
345 add_action("load-$hook_poll", array($this, 'add_tabs'));
346
347 $hook_results_each = add_submenu_page(
348 'all_results_slug',
349 __('Results per poll', "poll-maker"),
350 __('Results per poll', "poll-maker"),
351 $capability,
352 $this->plugin_name . '-results-each',
353 array($this, 'display_plugin_results_each_page')
354 );
355 add_action("load-$hook_results_each", array($this, 'screen_option_each_results'));
356
357 }
358
359
360 public function add_plugin_polls_submenu() {
361 $capability = $this->poll_maker_capabilities();
362
363 $hook_polls = add_submenu_page(
364 $this->plugin_name,
365 __('All Polls', "poll-maker"),
366 __('All Polls', "poll-maker"),
367 $capability,
368 $this->plugin_name,
369 array($this, 'display_plugin_polls_page')
370 );
371 add_action("load-$hook_polls", array($this, 'screen_option_polls'));
372 add_action("load-$hook_polls", array($this, 'add_tabs'));
373 }
374
375 public function add_plugin_add_new_poll_submenu() {
376 $capability = $this->poll_maker_capabilities();
377
378 $hook_polls = add_submenu_page(
379 $this->plugin_name,
380 __('Add new', "poll-maker"),
381 __('Add new', "poll-maker"),
382 $capability,
383 $this->plugin_name . '-add-new',
384 array($this, 'display_plugin_add_new_poll_page')
385 );
386 }
387
388 public function add_plugin_categories_submenu() {
389 $capability = $this->poll_maker_capabilities();
390
391 $hook_cats = add_submenu_page(
392 $this->plugin_name,
393 __('Categories', "poll-maker"),
394 __('Categories', "poll-maker"),
395 $capability,
396 $this->plugin_name . '-cats',
397 array($this, 'display_plugin_cats_page')
398 );
399 add_action("load-$hook_cats", array($this, 'screen_option_cats'));
400 add_action("load-$hook_cats", array($this, 'add_tabs'));
401 }
402
403 public function add_plugin_results_submenu() {
404 /*
405 * Check unread results
406 *
407 */
408 global $wpdb;
409 $sql = "SELECT COUNT(unread) FROM {$wpdb->prefix}ayspoll_reports WHERE unread=1";
410 $unread_results = $wpdb->get_var($sql);
411 $show = $unread_results > 0 ? '' : "apm-no-results";
412
413 $capability = $this->poll_maker_capabilities();
414
415 $hook_results = add_submenu_page(
416 $this->plugin_name,
417 __('Results', "poll-maker"),
418 __('Results', "poll-maker") . " <span class=\"apm-badge badge badge-danger $show\">$unread_results</span>",
419 $capability,
420 $this->plugin_name . '-results',
421 array($this, 'display_plugin_results_page')
422 );
423 add_action("load-$hook_results", array($this, 'screen_option_results'));
424 add_action("load-$hook_results", array($this, 'add_tabs'));
425
426 $hook_all_results = add_submenu_page(
427 'all_results_slug',
428 __('Results', "poll-maker"),
429 $capability,
430 $this->capability,
431 $this->plugin_name . '-all-results',
432 array($this, 'display_plugin_all_results_page')
433 );
434
435 add_action("load-$hook_all_results", array($this, 'screen_option_all_poll_results'));
436
437 add_filter('parent_file', array($this,'poll_maker_select_submenu'));
438 }
439
440 public function add_plugin_formfields_submenu() {
441
442 $hook_formfields = add_submenu_page(
443 $this->plugin_name,
444 __('Custom Fields', "poll-maker"),
445 __('Custom Fields', "poll-maker"),
446 'manage_options',
447 $this->plugin_name . '-formfields',
448 array($this, 'display_plugin_formfields_page')
449 );
450 add_action("load-$hook_formfields", array($this, 'add_tabs'));
451 }
452
453 public function add_plugin_general_settings_submenu() {
454 $hook_settings = add_submenu_page($this->plugin_name,
455 __('General Settings', "poll-maker"),
456 __('General Settings', "poll-maker"),
457 'manage_options',
458 $this->plugin_name . '-settings',
459 array($this, 'display_plugin_settings_page')
460 );
461 add_action("load-$hook_settings", array($this, 'screen_option_settings'));
462 add_action("load-$hook_settings", array($this, 'add_tabs'));
463 }
464
465 public function add_plugin_how_to_use_submenu() {
466 $hook_pro_features = add_submenu_page(
467 $this->plugin_name,
468 __('How to use', "poll-maker"),
469 __('How to use', "poll-maker"),
470 'manage_options',
471 $this->plugin_name . '-how-to-use',
472 array($this, 'display_plugin_how_to_use_page')
473 );
474 add_action("load-$hook_pro_features", array($this, 'add_tabs'));
475 }
476
477 public function add_plugin_pro_features_submenu() {
478 $hook_pro_features = add_submenu_page(
479 $this->plugin_name,
480 __('PRO features', "poll-maker"),
481 __('PRO features', "poll-maker"),
482 'manage_options',
483 $this->plugin_name . '-pro-features',
484 array($this, 'display_plugin_pro_features_page')
485 );
486 add_action("load-$hook_pro_features", array($this, 'add_tabs'));
487 }
488
489 public function add_plugin_featured_plugins_submenu(){
490 $hook_pro_features = add_submenu_page( $this->plugin_name,
491 __('Our products', "poll-maker"),
492 __('Our products', "poll-maker"),
493 'manage_options',
494 $this->plugin_name . '-featured-plugins',
495 array($this, 'display_plugin_featured_plugins_page')
496 );
497 add_action("load-$hook_pro_features", array($this, 'add_tabs'));
498 }
499
500 public function display_poll_creation_popup() {
501 $is_challange_enabled = get_option('ays_poll_maker_poll_creation_challange', false);
502
503 if (!$is_challange_enabled) {
504 return;
505 }
506
507 if (isset($_GET['page']) && strpos($_GET['page'], POLL_MAKER_AYS_NAME) !== false) {
508 $poll_ajax_challenge_cancel_nonce = wp_create_nonce( 'poll-maker-ajax-challenge-cancel-nonce' );
509 ?>
510 <div class="poll-maker-challenge">
511 <div class="poll-maker-challenge-list-block">
512 <i class="fa fa-times-circle list-block-button poll-maker-challenge-cancel" aria-hidden="true" title="Cancel challenge"></i>
513 <input type="hidden" id="poll_maker_ajax_challenge_cancel_nonce" name="poll_maker_ajax_challenge_cancel_nonce" value="<?php echo $poll_ajax_challenge_cancel_nonce ?>">
514 <ul class="poll-maker-challenge-list">
515 <li class="poll-maker-challenge-step-item"><?php echo __('Add a New Poll', "poll-maker"); ?></li>
516 <li class="poll-maker-challenge-step-item"><?php echo __('Name Your Poll', "poll-maker"); ?></li>
517 <li class="poll-maker-challenge-step-item"><?php echo __('Add Options', "poll-maker"); ?></li>
518 <li class="poll-maker-challenge-step-item"><?php echo __('Save the Poll', "poll-maker"); ?></li>
519 <li class="poll-maker-challenge-step-item"><?php echo __('Copy the Shortcode', "poll-maker"); ?></li>
520 <li class="poll-maker-challenge-step-item"><?php echo __('Embed in a Page', "poll-maker"); ?></li>
521 </ul>
522 </div>
523 <div class="poll-maker-challenge-block-timer">
524 <img src="<?php echo POLL_MAKER_AYS_ADMIN_URL ?>/images/icons/poll-maker-logo.png" alt="Poll Maker logo">
525 <h3>Poll Maker</h3>
526 </div>
527 </div>
528 <?php
529 }
530 }
531
532 public function delete_challenge_box() {
533 // Run a security check.
534 check_ajax_referer( 'poll-maker-ajax-challenge-cancel-nonce', sanitize_key( $_REQUEST['_ajax_nonce'] ) );
535
536 // Check for permissions.
537 if ( ! current_user_can( 'manage_options' ) ) {
538 ob_end_clean();
539 $ob_get_clean = ob_get_clean();
540 echo json_encode(array("success" => false));
541 wp_die();
542 }
543
544 $result = array("success" => false);
545 if( is_user_logged_in() ) {
546 delete_option('ays_poll_maker_poll_creation_challange');
547 $result = array("success" => true);
548 }
549
550 ob_end_clean();
551 $ob_get_clean = ob_get_clean();
552 echo json_encode($result);
553 wp_die();
554 }
555
556 /**
557 * Add settings action link to the plugins page.
558 *
559 * @since 1.0.0
560 */
561
562 public function add_action_links( $links ) {
563 /*
564 * Documentation : https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name)
565 */
566 $poll_ajax_deactivate_plugin_nonce = wp_create_nonce( 'poll-maker-ajax-deactivate-plugin-nonce' );
567
568 $settings_link = array(
569 '<a href="' . admin_url('admin.php?page=' . $this->plugin_name) . '">' . __('Settings', "poll-maker") . '</a>',
570 '<a href="https://poll-plugin.com/wordpress-poll-plugin-free-demo/" target="_blank">' . __('Demo', "poll-maker") . '</a>',
571 '<a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=plugins-buy-now-button" class="ays-poll-upgrade-plugin-btn" style="font-weight:bold;color:#01A32A;" target="_blank">' . __('Upgrade 50% Sale', "poll-maker") . '</a><input type="hidden" id="ays_poll_maker_ajax_deactivate_plugin_nonce" name="ays_poll_maker_ajax_deactivate_plugin_nonce" value="' . $poll_ajax_deactivate_plugin_nonce .'">',
572 );
573
574 return array_merge($settings_link, $links);
575
576 }
577
578 public function add_poll_row_meta( $links, $file ) {
579 if ( POLL_MAKER_AYS_BASENAME == $file ) {
580 $row_meta = array(
581 'ays-poll-support' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/poll-maker/' ) . '" target="_blank">' . esc_html__( 'Free Support', "poll-maker" ) . '</a>',
582 'ays-poll-documentation' => '<a href="' . esc_url( 'https://ays-pro.com/wordpress-poll-maker-user-manual' ) . '" target="_blank">' . esc_html__( 'Documentation', "poll-maker" ) . '</a>',
583 'ays-poll-rate-us' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/poll-maker/reviews/?rate=5#new-post' ) . '" target="_blank">' . esc_html__( 'Rate us', "poll-maker" ) . '</a>',
584 'ays-poll-video-tutorial' => '<a href="' . esc_url( 'https://www.youtube.com/channel/UC-1vioc90xaKjE7stq30wmA' ) . '" target="_blank">' . esc_html__( 'Video tutorial', "poll-maker" ) . '</a>',
585 );
586
587 return array_merge( $links, $row_meta );
588 }
589 return $links;
590 }
591
592 /**
593 * Render the settings page for this plugin.
594 *
595 * @since 1.0.0
596 */
597
598 public function display_plugin_polls_page() {
599 $action = (isset($_GET['action'])) ? sanitize_text_field($_GET['action']) : '';
600
601 switch ( $action ) {
602 case 'add':
603 include_once 'partials/poll-maker-ays-polls-actions.php';
604 break;
605 case 'edit':
606 include_once 'partials/poll-maker-ays-polls-actions.php';
607 break;
608 default:
609 include_once 'partials/poll-maker-ays-admin-display.php';
610 }
611 }
612
613 public function display_plugin_add_new_poll_page() {
614 $add_new_poll_url = admin_url('admin.php?page=' . $this->plugin_name . '&action=add');
615 wp_redirect($add_new_poll_url);
616 }
617
618 public function display_plugin_cats_page() {
619 $action = (isset($_GET['action'])) ? sanitize_text_field($_GET['action']) : '';
620
621 switch ( $action ) {
622 case 'add':
623 include_once 'partials/categories/actions/poll-maker-ays-categories-actions.php';
624 break;
625 case 'edit':
626 include_once 'partials/categories/actions/poll-maker-ays-categories-actions.php';
627 break;
628 default:
629 include_once 'partials/categories/poll-maker-ays-categories-display.php';
630 }
631 }
632
633 public function display_plugin_results_page() {
634 include_once 'partials/results/poll-maker-ays-results-display.php';
635 }
636
637 public function display_plugin_results_each_page() {
638 include_once 'partials/results/poll-maker-ays-each-results-display.php';
639 }
640
641 public function display_plugin_formfields_page() {
642 include_once 'partials/features/poll-maker-formfields_page-display.php';
643 }
644
645 public function display_plugin_pro_features_page() {
646 include_once 'partials/features/poll-maker-pro-features-display.php';
647 }
648
649 public function display_plugin_how_to_use_page() {
650 include_once 'partials/features/poll-maker-how-to-use-display.php';
651 }
652
653 public function display_plugin_featured_plugins_page(){
654 include_once('partials/features/poll-maker-featured-display.php');
655 }
656
657 public static function set_screen( $status, $option, $value ) {
658 return $value;
659 }
660
661 public function screen_option_polls() {
662 $option = 'per_page';
663 $args = array(
664 'label' => __('Polls', "poll-maker"),
665 'default' => 20,
666 'option' => 'polls_per_page',
667 );
668
669 add_screen_option($option, $args);
670 $this->polls_obj = new Polls_List_Table($this->plugin_name);
671 $this->settings_obj = new Poll_Maker_Settings_Actions($this->plugin_name);
672
673 }
674
675 public function screen_option_cats() {
676 $option = 'per_page';
677 $args = array(
678 'label' => __('Categories', "poll-maker"),
679 'default' => 5,
680 'option' => 'poll_cats_per_page',
681 );
682
683 add_screen_option($option, $args);
684 $this->cats_obj = new Pma_Categories_List_Table($this->plugin_name);
685 $this->settings_obj = new Poll_Maker_Settings_Actions($this->plugin_name);
686 }
687
688 public function screen_option_results() {
689 $option = 'per_page';
690 $args = array(
691 'label' => __('Results', "poll-maker"),
692 'default' => 50,
693 'option' => 'poll_results_per_page',
694 );
695
696 add_screen_option($option, $args);
697 $this->results_obj = new Pma_Results_List_Table($this->plugin_name);
698 // $this->answer_results_obj = new Poll_Answer_Results($this->plugin_name);
699 }
700
701 public function screen_option_each_results() {
702 $option = 'per_page';
703 $args = array(
704 'label' => __('Results per poll', "poll-maker"),
705 'default' => 50,
706 'option' => 'poll_each_results_per_page',
707 );
708
709 add_screen_option($option, $args);
710 $this->each_results_obj = new Pma_Each_Results_List_Table($this->plugin_name);
711 }
712
713 public function register_poll_ays_widget() {
714 global $wpdb;
715 $poll_table = esc_sql($wpdb->prefix . "ayspoll_polls");
716 $sql = "SELECT COUNT(*) FROM ".$poll_table;
717
718 $c = $wpdb->get_var($sql);
719 if ($c == 0) {
720 return;
721 } else {
722 register_widget('Poll_Maker_Widget');
723 }
724 }
725
726 public function poll_maker_el_widgets_registered() {
727 wp_enqueue_style($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'css/admin.css', array(), $this->version, 'all');
728 // We check if the Elementor plugin has been installed / activated.
729 if ( defined( 'ELEMENTOR_PATH' ) && class_exists( 'Elementor\Widget_Base' ) ) {
730 // get our own widgets up and running:
731 // copied from widgets-manager.php
732 if ( class_exists( 'Elementor\Plugin' ) ) {
733 if ( is_callable( 'Elementor\Plugin', 'instance' ) ) {
734 $elementor = Elementor\Plugin::instance();
735 if ( isset( $elementor->widgets_manager ) ) {
736 if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
737 if ( method_exists( $elementor->widgets_manager, 'register' ) ) {
738 $widget_file = 'plugins/elementor/poll_maker_elementor.php';
739 $template_file = locate_template( $widget_file );
740 if ( !$template_file || !is_readable( $template_file ) ) {
741 $template_file = POLL_MAKER_AYS_DIR.'pb_templates/poll_maker_elementor.php';
742 }
743 if ( $template_file && is_readable( $template_file ) ) {
744 require_once $template_file;
745 Elementor\Plugin::instance()->widgets_manager->register( new Elementor\Widget_Poll_Maker_Elementor() );
746 }
747 }
748 } else {
749 if ( method_exists( $elementor->widgets_manager, 'register_widget_type' ) ) {
750 $widget_file = 'plugins/elementor/poll_maker_elementor.php';
751 $template_file = locate_template( $widget_file );
752 if ( !$template_file || !is_readable( $template_file ) ) {
753 $template_file = POLL_MAKER_AYS_DIR.'pb_templates/poll_maker_elementor.php';
754 }
755 if ( $template_file && is_readable( $template_file ) ) {
756 require_once $template_file;
757 Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Elementor\Widget_Poll_Maker_Elementor() );
758 }
759 }
760 }
761 }
762 }
763 }
764 }
765 }
766
767 public function apm_deactivate_plugin_option() {
768 // Run a security check.
769 check_ajax_referer( 'poll-maker-ajax-deactivate-plugin-nonce', sanitize_key( $_REQUEST['_ajax_nonce'] ) );
770
771 // Check for permissions.
772 if ( ! current_user_can( 'manage_options' ) ) {
773 ob_end_clean();
774 $ob_get_clean = ob_get_clean();
775 echo json_encode(array(
776 'option' => ''
777 ));
778 wp_die();
779 }
780
781 if( is_user_logged_in() ) {
782 $request_value = esc_sql( sanitize_text_field( $_REQUEST['upgrade_plugin'] ) );
783 $upgrade_option = get_option('ays_poll_maker_upgrade_plugin','');
784 if($upgrade_option === ''){
785 add_option('ays_poll_maker_upgrade_plugin',$request_value);
786 }else{
787 update_option('ays_poll_maker_upgrade_plugin',$request_value);
788 }
789 ob_end_clean();
790 $ob_get_clean = ob_get_clean();
791 echo json_encode(array(
792 'option' => get_option('ays_poll_maker_upgrade_plugin', '')
793 ));
794 wp_die();
795 } else {
796 ob_end_clean();
797 $ob_get_clean = ob_get_clean();
798 echo json_encode(array(
799 'option' => ''
800 ));
801 wp_die();
802 }
803 }
804
805 public function apm_show_results() {
806 // Run a security check.
807 check_ajax_referer( 'poll-maker-ajax-show-details-report-nonce', sanitize_key( $_REQUEST['_ajax_nonce'] ) );
808
809 // Check for permissions.
810 if ( ! current_user_can( 'manage_options' ) ) {
811 ob_end_clean();
812 $ob_get_clean = ob_get_clean();
813 echo json_encode(array("success" => false));
814 wp_die();
815 }
816
817 global $wpdb;
818 $results_table = $wpdb->prefix . "ayspoll_reports";
819 // $polls_obj = new Polls_List_Table($this->plugin_name);
820 if (isset($_POST['action']) && $_POST['action'] == 'apm_show_results') {
821
822 $id = isset($_POST['result']) ? absint($_POST['result']) : 0;
823 $is_details = isset($_POST['is_details']) && absint($_POST['is_details']) > 0 ? true : false;
824 $row = '';
825 $wpdb->update($results_table,
826 array('unread' => 0),
827 array('id' => $id),
828 array('%d'),
829 array('%d')
830 );
831 if ($id > 0 && $is_details) {
832 $result = $wpdb->get_row("SELECT * FROM $results_table WHERE id=$id", "ARRAY_A");
833 $multivote_res = false;
834 $result['multi_answer_id'] = json_decode($result['multi_answer_ids']);
835 if (isset($result['multi_answer_id']) && count($result['multi_answer_id']) > 1) {
836 $multivote_res = true;
837 }
838 $multivote_answers = array();
839 if ($multivote_res) {
840 foreach ($result['multi_answer_id'] as $m_key => $m_val) {
841 $multi_answer = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}ayspoll_answers WHERE id=".$m_val, "ARRAY_A");
842 $multivote_answers[] = $multi_answer['answer'];
843 }
844 $answ_poll_id = $multi_answer['poll_id'];
845 } else {
846 $answer = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}ayspoll_answers WHERE id={$result['answer_id']}", "ARRAY_A");
847 $multivote_answers[] = $answer['answer'];
848 $answ_poll_id = $answer['poll_id'];
849 }
850
851 $poll = $this->get_poll_by_id($answ_poll_id);
852 $user_ip = $result['user_ip'];
853 $info = ($result['other_info'] == '' || $result['other_info'] === null || $result['other_info'] === 0) ? array() : json_decode($result['other_info'], true);
854
855 $time = $result['vote_date'];
856 $user_email = $result['user_email'];
857 $country = '';
858 $region = '';
859 $city = '';
860 $json = isset($user_ip) && $user_ip != '' ? json_decode(file_get_contents("http://ipinfo.io/{$user_ip}/json")) : null;
861
862 if ($json !== null) {
863 $country = isset($json->country) && $json->country != '' ? $json->country : '';
864 $region = isset($json->region) && $json->region != '' ? $json->region : '';
865 $city = isset($json->city) && $json->city != '' ? $json->city : '';
866 }
867 $from = "$city, $region, $country, $user_ip";
868 $row = '<tr><td colspan="4"><h1>' . __('Poll Information', "poll-maker") . "</h1></td></tr>
869 <tr class='ays_result_element'>
870 <td>". __('Poll Title', "poll-maker")."</td>
871 <td>{$poll['title']}</td>
872 <td></td>
873 <td></td>
874 </tr>";
875 $row .= "<tr class='ays_result_element'>
876 <td>". __('Poll Type', "poll-maker")."</td>
877 <td>" . ucfirst($poll['type']) . "</td>
878 <td></td>
879 <td></td>
880 </tr>";
881 switch ( $poll['type'] ) {
882 case 'choosing':
883 $row .= "<tr class='ays_result_element'>
884 <td>". __('Answer', "poll-maker")."</td>
885 <td>" . (in_array($poll['answers'][0]['answer'], $multivote_answers) ? "<b><em>" . stripslashes($poll['answers'][0]['answer']) . "</em></b>" : stripslashes($poll['answers'][0]['answer'])) . "</td>
886 <td></td>
887 <td></td>
888 </tr>";
889 foreach ( $poll['answers'] as $index => $ans ) {
890 if ($index == 0) {
891 continue;
892 }
893 $row .= "<tr class='ays_result_element'>
894 <td></td>
895 <td>" . (in_array($ans['answer'], $multivote_answers) ? "<b><em>" . stripslashes($ans['answer']) . "</em></b>" : stripslashes($ans['answer'])) . "</td>
896 <td></td>
897 <td></td>
898 </tr>";
899 }
900 break;
901 case 'text':
902 $row .= "<tr class='ays_result_element'>
903 <td>". __('Answer', "poll-maker")."</td>
904 <td><b><em>" . $answer['answer'] . "</em></b></td>
905 <td></td>
906 <td></td>
907 </tr>";
908 break;
909 case 'rating':
910 $row .= "<tr class='ays_result_element'>
911 <td>". __('Answer', "poll-maker")."</td>
912 <td><div class='apm-rating-res'>";
913 if ($poll['view_type'] == 'star') {
914 foreach ( $poll['answers'] as $ans ) {
915 $row .= "<i class='" . ($ans['answer'] <= $answer['answer'] ? "ays_poll_fas" : "ays_poll_far") . " ays_poll_fa-star'></i>";
916 }
917 } elseif ('emoji') {
918 $emoji = array(
919 "ays_poll_fa-dizzy",
920 "ays_poll_fa-smile",
921 "ays_poll_fa-meh",
922 "ays_poll_fa-frown",
923 "ays_poll_fa-tired",
924 );
925 foreach ( $poll['answers'] as $i => $ans ) {
926 $index = (count($poll['answers']) / 2 - $i + 1.5);
927 $row .= "<i class='" . ($ans['answer'] == $answer['answer'] ? "ays_poll_fas " : "ays_poll_far ") . $emoji[$index] . "'></i>";
928 }
929 }
930 $row .= "</div></td>
931 <td></td>
932 <td></td>
933 </tr>";
934 break;
935 case 'voting':
936 $row .= "<tr class='ays_result_element'>
937 <td>". __('Answer', "poll-maker")."</td>
938 <td><div class='apm-rating-res'>";
939 $icons = array(
940 'hand' => array(
941 "ays_poll_fa-thumbs-up",
942 "ays_poll_fa-thumbs-down",
943 ),
944 'emoji' => array(
945 "ays_poll_fa-smile",
946 "ays_poll_fa-frown",
947 ),
948 );
949 $view = $poll['view_type'];
950 $row .= "<i class='" . (1 == $answer['answer'] ? "ays_poll_fas " : "ays_poll_far ") . $icons[$view][0] . "'></i>
951 <i class='" . (-1 == $answer['answer'] ? "ays_poll_fas " : "ays_poll_far ") . $icons[$view][1] . "'></i>";
952 $row .= "</div></td>
953 <td></td>
954 <td></td>
955 </tr>";
956 break;
957 }
958 $row .= "<tr class='ays_result_element'>
959 <td>". __('Answer Datetime', "poll-maker")."</td>
960 <td>" . (date('H:i:s d.m.Y', strtotime($time))) . "</td>
961 <td></td>
962 <td></td>
963 </tr>";
964 $row .= "<tr class='hr-line'><td colspan='4'><hr></td></tr>";
965 $row .= '<tr><td colspan="4"><h1>' . __('User Information', "poll-maker") . "</h1></td></tr>";
966 if ($json !== null) {
967 $row .= "<tr class='ays_result_element'>
968 <td>". __('User IP', "poll-maker")."</td>
969 <td>$from</td>
970 <td></td>
971 <td></td>
972 </tr>";
973 }
974 if(!empty($user_email)){
975 $row .= "<tr class='ays_result_element'>
976 <td>". __('User E-mail', "poll-maker")."</td>
977 <td>$user_email</td>
978 <td></td>
979 <td></td>
980 </tr>";
981 }
982 foreach ( $info as $key => $value ) {
983 if ( ($key == 'not_show_user_id') || ($key == 'email' && !empty($user_email)) ) {
984 continue;
985 }
986
987 $row .= "<tr class='ays_result_element'>
988 <td>". $key ."</td>
989 <td>". $value ."</td>
990 <td></td>
991 <td></td>
992 </tr>";
993 }
994 }
995 ob_end_clean();
996 $ob_get_clean = ob_get_clean();
997 echo json_encode([
998 "status" => true,
999 "rows" => $row,
1000 ]);
1001 wp_die();
1002 }
1003 }
1004
1005 public function get_poll_by_id( $id, $decode = true ) {
1006 global $wpdb;
1007
1008 $sql = "SELECT * FROM {$wpdb->prefix}ayspoll_polls WHERE id=" . absint(intval($id));
1009 $poll = $wpdb->get_row($sql, 'ARRAY_A');
1010 if (empty($poll)) {
1011 return array();
1012 }
1013 $sql = "SELECT * FROM {$wpdb->prefix}ayspoll_answers WHERE poll_id=" . absint(intval($id)) . " ORDER BY id ASC";
1014 $poll['answers'] = $wpdb->get_results($sql, 'ARRAY_A');
1015
1016 if ($decode) {
1017 $json = $poll['styles'];
1018 $poll['styles'] = !empty($poll['styles']) ? json_decode($poll['styles'], true) : array();
1019 $poll['categories'] = trim($poll['categories'], ',');
1020 $cats = explode(',', $poll['categories']);
1021 $poll['categories'] = !empty($cats) ? $cats : [];
1022 $all_fields = $this->get_all_formfields();
1023 if (isset($poll['styles']['fields'])) {
1024 $poll['fields'] = array();
1025 $fields = explode(',', $poll['styles']['fields']);
1026 foreach ( $fields as $field ) {
1027 $index = array_search($field, array_column($all_fields, 'slug'));
1028 if ($index !== false) {
1029 $poll['fields'][] = $all_fields[$index];
1030 }
1031 }
1032 }
1033 if (isset($poll['styles']['required_fields'])) {
1034 $poll['required_fields'] = array();
1035 $fields = explode(',', $poll['styles']['required_fields']);
1036 foreach ( $fields as $field ) {
1037 $index = array_search($field, array_column($all_fields, 'slug'));
1038 if ($index !== false) {
1039 $poll['required_fields'][] = $all_fields[$index];
1040 }
1041 }
1042 }
1043 }
1044
1045 return $poll;
1046 }
1047
1048 public function get_all_formfields() {
1049 global $wpdb;
1050 $all = array(
1051 array(
1052 "id" => 0,
1053 "name" => "Name",
1054 "type" => "text",
1055 "slug" => "apm-name",
1056 "published" => 1,
1057 ),
1058 array(
1059 "id" => 0,
1060 "name" => "E-mail",
1061 "type" => "email",
1062 "slug" => "apm-email",
1063 "published" => 1,
1064 ),
1065 array(
1066 "id" => 0,
1067 "name" => "Phone",
1068 "type" => "tel",
1069 "slug" => "apm_phone",
1070 "published" => 1,
1071 ),
1072 );
1073
1074 return $all;
1075 }
1076
1077 public function screen_option_settings() {
1078 $this->polls_obj = new Polls_List_Table($this->plugin_name);
1079 $this->settings_obj = new Poll_Maker_Settings_Actions($this->plugin_name);
1080 }
1081
1082 public function display_plugin_settings_page() {
1083 include_once('partials/settings/poll-maker-settings.php');
1084 }
1085
1086 public function ays_get_mailchimp_lists( $username, $api_key ) {
1087 if (!empty($api_key) && strpos($api_key, '-') !== false) {
1088 $api_postfix = explode("-", $api_key)[1];
1089
1090 $curl = curl_init();
1091
1092 curl_setopt_array($curl, array(
1093 CURLOPT_URL => "https://" . $api_postfix . ".api.mailchimp.com/3.0/lists",
1094 CURLOPT_RETURNTRANSFER => true,
1095 CURLOPT_ENCODING => "",
1096 CURLOPT_MAXREDIRS => 10,
1097 CURLOPT_TIMEOUT => 30,
1098 CURLOPT_SSL_VERIFYPEER => false,
1099 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1100 CURLOPT_CUSTOMREQUEST => "GET",
1101 CURLOPT_USERPWD => "$username:$api_key",
1102 CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
1103 // CURLOPT_POSTFIELDS => "undefined=",
1104 CURLOPT_HTTPHEADER => array(
1105 "Content-Type: application/json",
1106 "cache-control: no-cache"
1107 ),
1108 ));
1109
1110 $response = curl_exec($curl);
1111 $err = curl_error($curl);
1112
1113 curl_close($curl);
1114
1115 if ($err) {
1116 echo "cURL Error";
1117 } else {
1118 return json_decode($response, true);
1119 }
1120 }
1121
1122 return array();
1123 }
1124
1125 public function ays_poll_create_author() {
1126
1127 // Check for permissions.
1128 if ( !Poll_Maker_Data::check_user_capability() ) {
1129 ob_end_clean();
1130 $ob_get_clean = ob_get_clean();
1131 echo json_encode(array(
1132 'results' => array()
1133 ));
1134 wp_die();
1135 }
1136
1137 $search = isset($_REQUEST['search']) && $_REQUEST['search'] != '' ? sanitize_text_field($_REQUEST['search']) : null;
1138 $checked = isset($_REQUEST['val']) && $_REQUEST['val'] != '' ? sanitize_text_field($_REQUEST['val']) : null;
1139 $args = array(
1140 'fields' => array('ID', 'display_name', 'user_email', 'user_login', 'user_nicename')
1141 );
1142
1143 if ($search !== null) {
1144 $args['search'] = '*' . esc_attr($search) . '*';
1145 $args['search_columns'] = array('ID', 'user_login', 'user_nicename', 'user_email', 'display_name');
1146 }
1147
1148 $user_query = new WP_User_Query($args);
1149 $users = $user_query->get_results();
1150 $response = array(
1151 'results' => array()
1152 );
1153
1154 if(empty($args)){
1155 $reports_users = '';
1156 }
1157
1158 foreach ($users as $key => $user) {
1159 if ($checked !== null) {
1160 if ($user->ID == $checked) {
1161 continue;
1162 }else{
1163 $response['results'][] = array(
1164 'id' => $user->ID,
1165 'text' => $user->display_name
1166 );
1167 }
1168 }else{
1169 $response['results'][] = array(
1170 'id' => $user->ID,
1171 'text' => $user->display_name,
1172 );
1173 }
1174 }
1175
1176 ob_end_clean();
1177 echo json_encode($response);
1178 wp_die();
1179 }
1180
1181 public static function validateDate($date, $format = 'Y-m-d H:i:s'){
1182 $d = DateTime::createFromFormat($format, $date);
1183 return $d && $d->format($format) == $date;
1184 }
1185
1186 public static function is_classic_editor_plugin_active() {
1187 if ( ! function_exists( 'is_plugin_active' ) ) {
1188 include_once ABSPATH . 'wp-admin/includes/plugin.php';
1189 }
1190
1191 if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
1192 return true;
1193 }
1194
1195 return false;
1196 }
1197
1198 public static function is_active_gutenberg() {
1199 // Gutenberg plugin is installed and activated.
1200 $gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );
1201 // Block editor since 5.0.
1202 $block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );
1203
1204 if ( ! $gutenberg && ! $block_editor ) {
1205 return false;
1206 }
1207
1208 if ( self::is_classic_editor_plugin_active() ) {
1209 $editor_option = get_option( 'classic-editor-replace' );
1210 $block_editor_active = array( 'no-replace', 'block' );
1211
1212 return in_array( $editor_option, $block_editor_active, true );
1213 }
1214
1215 return true;
1216 }
1217
1218 public static function ays_restriction_string($type, $x, $length){
1219 $output = "";
1220 switch($type){
1221 case "char":
1222 if(strlen($x)<=$length){
1223 $output = $x;
1224 } else {
1225 $output = substr($x,0,$length) . '...';
1226 }
1227 break;
1228 case "word":
1229 $res = explode(" ", $x);
1230 if(count($res)<=$length){
1231 $output = implode(" ",$res);
1232 } else {
1233 $res = array_slice($res,0,$length);
1234 $output = implode(" ",$res) . '...';
1235 }
1236 break;
1237 }
1238 return $output;
1239 }
1240
1241 public static function get_listtables_title_length( $listtable_name ) {
1242 global $wpdb;
1243
1244 $settings_table = $wpdb->prefix . "ayspoll_settings";
1245 $sql = "SELECT meta_value FROM ".$settings_table." WHERE meta_key = 'options'";
1246 $result = $wpdb->get_var($sql);
1247 $options = ($result == "") ? array() : json_decode($result, true);
1248
1249 $listtable_title_length = 5;
1250 if(! empty($options) ){
1251 switch ( $listtable_name ) {
1252 case 'polls':
1253 $listtable_title_length = (isset($options['poll_title_length']) && intval($options['poll_title_length']) != 0) ? absint(intval($options['poll_title_length'])) : 5;
1254 break;
1255 case 'categories':
1256 $listtable_title_length = (isset($options['poll_category_title_length']) && intval($options['poll_category_title_length']) != 0) ? absint(intval($options['poll_category_title_length'])) : 5;
1257 break;
1258 case 'results':
1259 $listtable_title_length = (isset($options['poll_results_title_length']) && intval($options['poll_results_title_length']) != 0) ? absint(intval($options['poll_results_title_length'])) : 5;
1260 break;
1261 default:
1262 $listtable_title_length = 5;
1263 break;
1264 }
1265 return $listtable_title_length;
1266 }
1267 return $listtable_title_length;
1268 }
1269
1270 public function poll_maker_select_submenu($file) {
1271 global $plugin_page;
1272 if ("poll-maker-ays-results-each" == $plugin_page) {
1273 $plugin_page = $this->plugin_name."-results";
1274 }
1275
1276 return $file;
1277 }
1278
1279 protected function poll_maker_capabilities(){
1280 global $wpdb;
1281 $sql = "SELECT meta_value FROM {$wpdb->prefix}ayspoll_settings WHERE `meta_key` = 'user_roles'";
1282 $result = $wpdb->get_var($sql);
1283
1284 $capability = 'manage_options';
1285 if($result !== null){
1286 $ays_user_roles = json_decode($result, true);
1287 if(is_user_logged_in()){
1288 $current_user = wp_get_current_user();
1289 $current_user_roles = $current_user->roles;
1290 $ishmar = 0;
1291 foreach($current_user_roles as $r){
1292 if(in_array($r, $ays_user_roles)){
1293 $ishmar++;
1294 }
1295 }
1296 if($ishmar > 0){
1297 $capability = "read";
1298 }
1299 }
1300 }
1301 return $capability;
1302 }
1303
1304 public function get_next_or_prev_row_by_id( $id, $type = "next", $table = "ayspoll_polls" ) {
1305 global $wpdb;
1306
1307 if ( is_null( $table ) || empty( $table ) ) {
1308 return null;
1309 }
1310
1311 $ays_table = esc_sql( $wpdb->prefix . $table );
1312
1313 $where = array();
1314 $where_condition = "";
1315
1316 $id = (isset( $id ) && $id != "" && absint($id) != 0) ? absint( sanitize_text_field( $id ) ) : null;
1317 $type = (isset( $type ) && $type != "") ? sanitize_text_field( $type ) : "next";
1318
1319 if ( is_null( $id ) || $id == 0 ) {
1320 return null;
1321 }
1322
1323 switch ( $type ) {
1324 case 'prev':
1325 $where[] = ' `id` < ' . $id . ' ORDER BY `id` DESC ';
1326 break;
1327 case 'next':
1328 default:
1329 $where[] = ' `id` > ' . $id;
1330 break;
1331 }
1332
1333 if( ! empty($where) ){
1334 $where_condition = " WHERE " . implode( " AND ", $where );
1335 }
1336
1337 $sql = "SELECT `id` FROM {$ays_table} ". $where_condition ." LIMIT 1;";
1338 $results = $wpdb->get_row( $sql, 'ARRAY_A' );
1339
1340 return $results;
1341
1342 }
1343
1344 public function poll_maker_admin_footer($a){
1345 if(isset($_REQUEST['page'])){
1346 if(false !== strpos($_REQUEST['page'], $this->plugin_name)){
1347 ?>
1348 <div class="ays-poll-footer-support-box">
1349 <span class="ays-poll-footer-link-row"><a href="https://wordpress.org/support/plugin/poll-maker/" target="_blank"><?php echo __( "Support", "poll-maker"); ?></a></span>
1350 <span class="ays-poll-footer-slash-row">/</span>
1351 <span class="ays-poll-footer-link-row"><a href="https://ays-pro.com/wordpress-poll-maker-user-manual" target="_blank"><?php echo __( "Docs", "poll-maker"); ?></a></span>
1352 <span class="ays-poll-footer-slash-row">/</span>
1353 <span class="ays-poll-footer-link-row"><a href="https://ays-demo.com/poll-maker-plugin-survey/" target="_blank"><?php echo __( "Suggest a Feature", "poll-maker"); ?></a></span>
1354 </div>
1355 <p style="font-size:13px;text-align:center;font-style:italic;">
1356 <span style="margin-left:0px;margin-right:10px;" class="ays_heart_beat"><i class="ays_fa ays_poll_fa_heart_o animated"></i></span>
1357 <span><?php echo __( "If you love our plugin, please do big favor and rate us on WordPress.org", "poll-maker"); ?></span>
1358 <a target="_blank" class="ays-rated-link" href='http://bit.ly/3l5I2iG'>
1359 <span class="ays-dashicons ays-dashicons-star-empty"></span>
1360 <span class="ays-dashicons ays-dashicons-star-empty"></span>
1361 <span class="ays-dashicons ays-dashicons-star-empty"></span>
1362 <span class="ays-dashicons ays-dashicons-star-empty"></span>
1363 <span class="ays-dashicons ays-dashicons-star-empty"></span>
1364 </a>
1365 <span class="ays_heart_beat"><i class="ays_fa ays_poll_fa_heart_o animated"></i></span>
1366 </p>
1367 <?php
1368 }
1369 }
1370 }
1371
1372 // Sales baner function
1373 public function ays_poll_sale_baner(){
1374 if(isset($_POST['ays_poll_sale_btn_black_friday'])){
1375 $sale_date = sanitize_text_field($_POST['ays_poll_sale_btn_black_friday']);
1376 update_option('ays_poll_sale_notification_'.$sale_date, 1);
1377 update_option('ays_poll_sale_date_'.$sale_date, current_time( 'mysql' ));
1378 }
1379
1380 // if (isset($_POST['ays_poll_sale_btn']) && isset( $_POST[$this->plugin_name . '-sale-banner'] )
1381 // && wp_verify_nonce( $_POST[$this->plugin_name . '-sale-banner'], $this->plugin_name . '-sale-banner' ) && current_user_can('manage_options')) {
1382 // $sale_date = 'plugin_sale';
1383 // update_option('ays_poll_sale_btn_'.$sale_date, 1);
1384 // update_option('ays_poll_sale_date_'.$sale_date, current_time( 'mysql' ));
1385 // }
1386
1387 if(isset($_POST['ays_poll_sale_btn_poll_countdown_for_two_months'])){
1388 $sale_date = sanitize_text_field($_POST['ays_poll_sale_btn_poll_countdown_for_two_months']);
1389 $dismiss_two_months = true;
1390 update_option('ays_poll_sale_notification_two_months_'.$sale_date, 1);
1391 update_option('ays_poll_sale_date_'.$sale_date, current_time( 'mysql' ));
1392 }
1393
1394 $one_day = 60*60*24;
1395 $poll_sales = array(
1396 'plugin_sale' => array(
1397 'status' => 'active',
1398 'time' => ($one_day * 5),
1399 ),
1400 'mega_bundle' => array(
1401 'status' => 'inactive',
1402 'time' => ($one_day * 5),
1403 ),
1404 'new_mega_bundle' => array(
1405 'status' => 'inactive',
1406 'time' => ($one_day * 7),
1407 ),
1408 'small_spring' => array(
1409 'status' => 'inactive',
1410 'time' => ($one_day * 7),
1411 ),
1412 'mega_bundle_new' => array(
1413 'status' => 'inactive',
1414 'time' => ($one_day * 7),
1415 ),
1416 'business_bundle' => array(
1417 'status' => 'inactive',
1418 'time' => ($one_day * 7),
1419 ),
1420 'black_friday' => array(
1421 'status' => 'inactive',
1422 'time' => ($one_day * 5),
1423 ),
1424 'winter_bundle' => array(
1425 'status' => 'inactive',
1426 'time' => ($one_day * 5),
1427 ),
1428 'poll_countdown' => array(
1429 'status' => 'inactive',
1430 'time' => ($one_day * 5),
1431 ),
1432 'halloween_bundle' => array(
1433 'status' => 'inactive',
1434 'time' => ($one_day * 5),
1435 ),
1436 'christmas_message' => array(
1437 'status' => 'inactive',
1438 'time' => ($one_day * 7),
1439 ),
1440 );
1441
1442 if (isset($_GET['page']) && strpos($_GET['page'], POLL_MAKER_AYS_NAME) !== false) {
1443 foreach($poll_sales as $sale => $status){
1444 $ays_poll_sale_date = '';
1445 if(isset($status['status']) && $status['status'] == 'active'){
1446 $ays_poll_sale_date = get_option('ays_poll_sale_date_'.$sale);
1447 $ays_poll_two_months_flag = intval(get_option('ays_poll_sale_notification_two_months_'.$sale));
1448 $current_date = current_time( 'mysql' );
1449 $date_diff = strtotime($current_date) - intval(strtotime($ays_poll_sale_date)) ;
1450 $val = isset($status['time']) ? $status['time'] : $one_day * 5;
1451 if($ays_poll_two_months_flag > 0){
1452 $val = $one_day * 60;
1453 }
1454
1455 $days_diff = $date_diff / $val;
1456 if(intval($days_diff) > 0 ){
1457 update_option('ays_poll_sale_notification_'.$sale, 0);
1458 update_option('ays_poll_sale_btn_'.$sale, 0);
1459 update_option('ays_poll_sale_notification_two_months_'.$sale, 0);
1460 }
1461 $ays_poll_flag = intval(get_option('ays_poll_sale_notification_'.$sale));
1462 $ays_poll_flag += intval(get_option('ays_poll_sale_btn_'.$sale));
1463 $ays_poll_flag += $ays_poll_two_months_flag;
1464 if($ays_poll_flag == 0){
1465 $ays_poll_sale_message = 'ays_poll_sale_message_'.$sale;
1466 $this->ays_poll_sale_message_poll_pro();
1467 }
1468 }
1469 }
1470 }
1471 }
1472
1473 public function ays_poll_dismiss_button(){
1474
1475 $data = array(
1476 'status' => false,
1477 );
1478
1479 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'ays_poll_dismiss_button') {
1480 if( (isset( $_REQUEST['_ajax_nonce'] ) && wp_verify_nonce( $_REQUEST['_ajax_nonce'], POLL_MAKER_AYS_NAME . '-sale-banner' )) && current_user_can( 'manage_options' )){
1481 $sale_date = 'plugin_sale';
1482 update_option('ays_poll_sale_btn_'.$sale_date, 1);
1483 update_option('ays_poll_sale_date_'.$sale_date, current_time( 'mysql' ));
1484 $data['status'] = true;
1485 }
1486 }
1487
1488 ob_end_clean();
1489 $ob_get_clean = ob_get_clean();
1490 echo json_encode($data);
1491 wp_die();
1492
1493 }
1494
1495 // Poll plugin sale
1496 // public function ays_poll_sale_message($flag){
1497 // if($flag == 0){
1498
1499 // <div id="ays-poll-dicount-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info" >
1500 // <div id="ays_poll_dicount_banner" class="ays_poll_dicount_month" style="display: flex;align-items: center;justify-content: space-between;">
1501 // <div style="display: flex; align-items: center;">
1502 // <div>
1503 // <a href="https://ays-pro.com/wordpress/poll-maker" target="_blank" class="ays-poll-sale-banner-link"><img src="<?php echo POLL_MAKER_AYS_ADMIN_URL . '/images/sale.png'; " style="width: 60px;"></a>
1504 // </div>
1505 // <div style="font-size:14px; padding: 12px;">
1506 // <strong>
1507 // <?php echo __( "Limited Time <span style='color:red;'>30%</span> SALE on <a href='https://ays-pro.com/wordpress/poll-maker' target='_blank'>Poll Maker</a> premium plans!",POLL_MAKER_AYS_NAME);
1508 // </strong>
1509 // <br>
1510 // <strong style="font-size: 12px;">
1511 // <?php echo __( "Welcome to summer! Start it right with all the powerful tools you need for creating an advanced interactive website. Hurry! Ends on June 30. <a href='https://ays-pro.com/wordpress/poll-maker' target='_blank'>Check it out!</a>",POLL_MAKER_AYS_NAME);
1512 // </strong>
1513 // <form action="" method="POST">
1514 // <button class="btn btn-link ays-button" name="ays_poll_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">Dismiss ad</button>
1515 // </form>
1516 // </div>
1517 // </div>
1518 // <a href="https://ays-pro.com/wordpress/poll-maker" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank" style="height: 32px; display: flex; align-items: center; font-weight: 500; " ><?php echo __('Buy Now !',POLL_MAKER_AYS_NAME); </a>
1519
1520 // </div>
1521
1522 // </div>
1523 // <?php
1524 // }
1525 // }
1526
1527 // Mega bundle sale
1528 public function ays_poll_sale_message_mega_bundle(){
1529 ?>
1530 <div class="notice notice-success is-dismissible ays_poll_dicount_info" >
1531 <div id="ays_poll_dicount_banner" class="ays_poll_dicount_month" style="display: flex;align-items: center;justify-content: space-between;">
1532 <div style="display: flex; align-items: center;">
1533 <div>
1534 <a href="https://ays-pro.com/mega-bundle" target="_blank" class="ays-poll-sale-banner-link"><img src="<?php echo POLL_MAKER_AYS_ADMIN_URL . '/images/mega_bundle_logo_box.png';?> " style="width: 60px;"></a>
1535 </div>
1536 <div style="font-size:14px; padding:12px; width: 100%;">
1537 <strong>
1538 <?php echo __( "Limited Time <span style='color:red;'>50%</span> SALE on 3 Powerful Plugins (Quiz, Survey, Poll)!", "poll-maker");?>
1539 </strong>
1540 <br>
1541 <strong style="font-size: 12px;">
1542 <?php echo __( "Mega bundle offer for you! It consists of 3 different powerful plugins, each one allowing you to make your WordPress experience the best that could be.", "poll-maker");?>
1543 <br>
1544 <?php echo __( "Hurry up! Ends on October 15. <a href='https://ays-pro.com/mega-bundle' target='_blank'>Check it out!</a>", "poll-maker");?>
1545 </strong>
1546 <form action="" method="POST">
1547 <button class="btn btn-link ays-button" name="ays_poll_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0" value='mega_bundle'>Dismiss ad</button>
1548 </form>
1549 </div>
1550 </div>
1551 <a href="https://ays-pro.com/mega-bundle" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank" style="height: 32px; display: flex; align-items: center; font-weight: 500; " ><?php echo __('Buy Now !', "poll-maker");?> </a>
1552 </div>
1553 </div>
1554 <?php
1555 }
1556
1557 // Business bundle sale
1558 public function ays_poll_sale_message_business_bundle(){
1559 ?>
1560 <div class="notice notice-success is-dismissible ays_poll_dicount_info" >
1561 <div id="ays_poll_dicount_banner" class="ays_poll_dicount_month" style="display: flex;align-items: center;justify-content: space-between;">
1562 <div style="display: flex; align-items: center;">
1563 <div>
1564 <a href="https://ays-pro.com/business-bundle" target="_blank" class="ays-poll-sale-banner-link"><img src="<?php echo POLL_MAKER_AYS_ADMIN_URL . '/images/business_bundle_logo.png';?> " style="width: 60px;"></a>
1565 </div>
1566 <div style="font-size:14px; padding:12px; width: 100%;">
1567 <strong>
1568 <?php echo __( "Limited Time <span style='color:red;'>50%</span> SALE on 13 Powerful Plugins!", "poll-maker");?>
1569 </strong>
1570 <br>
1571 <strong style="font-size: 12px;">
1572 <?php echo __( "Business bundle offer for you! It consists of 13 different powerful plugins, each one allowing you to make your WordPress experience the best that could be.", "poll-maker");?>
1573 <br>
1574 <?php echo __( "Hurry up! Ends on October 15. <a href='https://ays-pro.com/business-bundle' target='_blank'>Check it out!</a>", "poll-maker");?>
1575 </strong>
1576 <form action="" method="POST">
1577 <button class="btn btn-link ays-button" name="ays_poll_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0" value='business_bundle'>Dismiss ad</button>
1578 </form>
1579 </div>
1580 </div>
1581 <a href="https://ays-pro.com/business-bundle" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank" style="height: 32px; display: flex; align-items: center; font-weight: 500; " ><?php echo __('Buy Now !', "poll-maker");?> </a>
1582 </div>
1583 </div>
1584 <?php
1585 }
1586
1587 // New Mega bundle sale
1588 public function ays_poll_sale_message_new_mega_bundle(){
1589 $content = array();
1590 $content[] = '<div id="ays-poll-dicount-month-main" class="notice notice-success is-dismissible ays_survey_dicount_info">';
1591 $content[] = '<div id="ays-poll-dicount-month" class="ays_survey_dicount_month">';
1592 $content[] = '<a href="https://bit.ly/3keKTm9" target="_blank" class="ays-poll-sale-banner-link"><img src="' . POLL_MAKER_AYS_ADMIN_URL . '/images/mega_bundle_logo_box.png"></a>';
1593
1594 $content[] = '<div class="ays-poll-dicount-wrap-box">';
1595
1596 $content[] = '<strong style="font-weight: bold;">';
1597 $content[] = __( "Limited Time <span style='color:#E85011;'>55%</span> SALE on <br><a href='https://bit.ly/3keKTm9' class='ays-poll-sale-banner-link-for-text' target='_blank'><span style='color:#E85011;'>Mega Bundle</span></a> (Quiz + Survey + Poll)!", "poll-maker" );
1598 $content[] = '</strong>';
1599
1600 $content[] = '<br>';
1601
1602 $content[] = '<strong>';
1603 $content[] = __( "Hurry up! Ends on November 15. <a href='https://bit.ly/3keKTm9' target='_blank'>Check it out!</a>", "poll-maker" );
1604 $content[] = '</strong>';
1605
1606 $content[] = '<form action="" method="POST">';
1607 $content[] = '<button class="btn btn-link ays-button" value="new_mega_bundle" name="ays_poll_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">Dismiss ad</button>';
1608 $content[] = '</form>';
1609
1610 $content[] = '</div>';
1611
1612 $content[] = '<div class="ays-poll-dicount-wrap-box">';
1613
1614 $content[] = '<div id="ays-poll-maker-countdown-main-container">';
1615 $content[] = '<div class="ays-poll-maker-countdown-container">';
1616
1617 $content[] = '<div id="ays-poll-countdown">';
1618 $content[] = '<ul>';
1619 $content[] = '<li><span id="ays-poll-countdown-days"></span>days</li>';
1620 $content[] = '<li><span id="ays-poll-countdown-hours"></span>Hours</li>';
1621 $content[] = '<li><span id="ays-poll-countdown-minutes"></span>Minutes</li>';
1622 $content[] = '<li><span id="ays-poll-countdown-seconds"></span>Seconds</li>';
1623 $content[] = '</ul>';
1624 $content[] = '</div>';
1625
1626 $content[] = '<div id="ays-poll-countdown-content" class="emoji">';
1627 $content[] = '<span>🚀</span>';
1628 $content[] = '<span>⌛</span>';
1629 $content[] = '<span>🔥</span>';
1630 $content[] = '<span>💣</span>';
1631 $content[] = '</div>';
1632
1633 $content[] = '</div>';
1634 $content[] = '</div>';
1635
1636 $content[] = '</div>';
1637
1638 $content[] = '<a href="https://bit.ly/3keKTm9" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank" style="height: 32px; display: flex; align-items: center; font-weight: 500; " >' . __( 'Buy Now !', "poll-maker" ) . '</a>';
1639 $content[] = '</div>';
1640 $content[] = '</div>';
1641
1642 $content = implode( '', $content );
1643 echo $content;
1644 }
1645
1646 // Black friday bundle
1647 public function ays_poll_sale_message_black_friday(){
1648 $content = array();
1649
1650 $content[] = '<div id="ays-poll-dicount-black-friday-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info">';
1651 $content[] = '<div id="ays-poll-dicount-black-friday-month" class="ays_poll_dicount_month">';
1652 $content[] = '<div class="ays-poll-dicount-black-friday-box">';
1653 $content[] = '<div class="ays-poll-dicount-black-friday-wrap-box ays-poll-dicount-black-friday-wrap-box-80" style="width: 70%;">';
1654 $content[] = '<div class="ays-poll-dicount-black-friday-title-row">' . __( 'Limited Time', "poll-maker" ) .' '. '<a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=black-friday-sale-banner" class="ays-poll-dicount-black-friday-button-sale" target="_blank">' . __( 'Sale', "poll-maker" ) . '</a>' . '</div>';
1655 $content[] = '<div class="ays-poll-dicount-black-friday-title-row">' . __( 'Poll Maker', "poll-maker" ) . '</div>';
1656 $content[] = '</div>';
1657
1658 $content[] = '<div class="ays-poll-dicount-black-friday-wrap-box ays-poll-dicount-black-friday-wrap-text-box">';
1659 $content[] = '<div class="ays-poll-dicount-black-friday-text-row">' . __( '20% off', "poll-maker" ) . '</div>';
1660 $content[] = '</div>';
1661
1662 $content[] = '<div class="ays-poll-dicount-black-friday-wrap-box" style="width: 25%;">';
1663 $content[] = '<div id="ays-poll-countdown-main-container">';
1664 $content[] = '<div class="ays-poll-countdown-container">';
1665 $content[] = '<div id="ays-poll-countdown" style="display: block;">';
1666 $content[] = '<ul>';
1667 $content[] = '<li><span id="ays-poll-countdown-days">0</span>' . __( 'Days', "poll-maker" ) . '</li>';
1668 $content[] = '<li><span id="ays-poll-countdown-hours">0</span>' . __( 'Hours', "poll-maker" ) . '</li>';
1669 $content[] = '<li><span id="ays-poll-countdown-minutes">0</span>' . __( 'Minutes', "poll-maker" ) . '</li>';
1670 $content[] = '<li><span id="ays-poll-countdown-seconds">0</span>' . __( 'Seconds', "poll-maker" ) . '</li>';
1671 $content[] = '</ul>';
1672 $content[] = '</div>';
1673 $content[] = '<div id="ays-poll-countdown-content" class="emoji" style="display: none;">';
1674 $content[] = '<span>🚀</span>';
1675 $content[] = '<span>⌛</span>';
1676 $content[] = '<span>🔥</span>';
1677 $content[] = '<span>💣</span>';
1678 $content[] = '</div>';
1679 $content[] = '</div>';
1680 $content[] = '</div>';
1681 $content[] = '</div>';
1682
1683 $content[] = '<div class="ays-poll-dicount-black-friday-wrap-box" style="width: 25%;">';
1684 $content[] = '<a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=black-friday-sale-banner" class="ays-poll-dicount-black-friday-button-buy-now" target="_blank">' . __( 'Get Your Deal', "poll-maker" ) . '</a>';
1685 $content[] = '</div>';
1686 $content[] = '</div>';
1687 $content[] = '</div>';
1688
1689 $content[] = '<div style="position: absolute;right: 0;bottom: 1px;" class="ays-poll-dismiss-buttons-container-for-form-black-friday">';
1690 $content[] = '<form action="" method="POST">';
1691 $content[] = '<div id="ays-poll-dismiss-buttons-content">';
1692 if( current_user_can( 'manage_options' ) ){
1693 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn_black_friday" style="" value="black_friday">' . __( 'Dismiss ad', "poll-maker" ) . '</button>';
1694 $content[] = wp_nonce_field( $this->plugin_name . '-sale-banner' , $this->plugin_name . '-sale-banner' );
1695 }
1696 $content[] = '</div>';
1697 $content[] = '</form>';
1698 $content[] = '</div>';
1699 $content[] = '</div>';
1700
1701 $content = implode( '', $content );
1702
1703 echo $content;
1704 }
1705
1706 // Winter bundle
1707 public function ays_poll_sale_message_winter_bundle(){
1708 $content = array();
1709 $content[] = '<div id="ays-poll-winter-dicount-main">';
1710 $content[] = '<div id="ays-poll-dicount-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info">';
1711 $content[] = '<div id="ays-poll-dicount-month" class="ays_poll_dicount_month">';
1712 $content[] = '<a href="https://ays-pro.com/mega-bundle" target="_blank" class="ays-poll-sale-banner-link"><img src="' . POLL_MAKER_AYS_ADMIN_URL . '/images/3.png"></a>';
1713
1714 $content[] = '<div class="ays-poll-dicount-wrap-box">';
1715
1716 $content[] = '<strong>';
1717 $content[] = __( "The BIGGEST <span class='ays-poll-dicount-wrap-color' style='color:#000;'>50%</span> SALE on <br><span><a href='https://ays-pro.com/mega-bundle' target='_blank' class='ays-poll-dicount-wrap-color ays-poll-dicount-wrap-text-decoration' style='display:block;color:#000'>Christmas Bundle</a></span> (Quiz+Survey+Poll)!", "poll-maker" );
1718 $content[] = '</strong>';
1719
1720 $content[] = '<br>';
1721
1722 $content[] = '<strong>';
1723 $content[] = __( "Hurry up! Ending on. <a href='https://ays-pro.com/mega-bundle' target='_blank' style='color:#000;'>Check it out!</a>", "poll-maker" );
1724 $content[] = '</strong>';
1725
1726 $content[] = '</div>';
1727
1728 $content[] = '<div class="ays-poll-dicount-wrap-box">';
1729
1730 $content[] = '<div id="ays-poll-maker-countdown-main-container">';
1731 $content[] = '<div class="ays-poll-maker-countdown-container">';
1732
1733 $content[] = '<div id="ays-poll-countdown">';
1734 $content[] = '<ul>';
1735 $content[] = '<li><span id="ays-poll-countdown-days"></span>days</li>';
1736 $content[] = '<li><span id="ays-poll-countdown-hours"></span>Hours</li>';
1737 $content[] = '<li><span id="ays-poll-countdown-minutes"></span>Minutes</li>';
1738 $content[] = '<li><span id="ays-poll-countdown-seconds"></span>Seconds</li>';
1739 $content[] = '</ul>';
1740 $content[] = '</div>';
1741
1742 $content[] = '<div id="ays-poll-countdown-content" class="emoji">';
1743 $content[] = '<span>🚀</span>';
1744 $content[] = '<span>⌛</span>';
1745 $content[] = '<span>🔥</span>';
1746 $content[] = '<span>💣</span>';
1747 $content[] = '</div>';
1748
1749 $content[] = '</div>';
1750
1751 $content[] = '<form action="" method="POST">';
1752 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn_winter" style="height: 32px;color:#000"" value="winter_bundle">Dismiss ad</button>';
1753 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn_winter_for_two_months" style="height: 32px; padding-left: 0;color:#000"" value="winter_bundle">Dismiss ad for 2 months</button>';
1754 $content[] = '</form>';
1755
1756 $content[] = '</div>';
1757
1758 $content[] = '</div>';
1759
1760 $content[] = '<a href="https://ays-pro.com/mega-bundle" class="button button-primary ays-button" id="ays-poll-button-top-buy-now" target="_blank">' . __( 'Buy Now !', "poll-maker" ) . '</a>';
1761 $content[] = '</div>';
1762 $content[] = '</div>';
1763 $content[] = '</div>';
1764 $content = implode( '', $content );
1765 echo $content;
1766 }
1767
1768 public function ays_poll_sale_message_poll_pro(){
1769 $content = array();
1770
1771 $content[] = '<div id="ays-poll-dicount-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info">';
1772 $content[] = '<div id="ays-poll-dicount-month" class="ays_poll_dicount_month">';
1773
1774 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-text-box">';
1775 $content[] = '<div>';
1776 $content[] = '<span class="ays-poll-new-poll-pro-title">';
1777 $content[] = sprintf('<span>%s <a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=sale-banner%s" target="_blank" style="color:#ffffff; text-decoration: underline;">Poll Maker</a></span>', __("Limited time 50% SALE on", "poll-maker"), $this->version);
1778 $content[] = '</span>';
1779 $content[] = '</br>';
1780 $content[] = '<div class="ays-poll-new-poll-pro-mobile-image-display-block display_none">';
1781 $content[] = '<span class="ays-poll-sale-baner-mega-bundle-sale-text">50%</span>';
1782 $content[] = '<img src="' . POLL_MAKER_AYS_ADMIN_URL . '/images/line.webp" style="width: 70px;">';
1783 $content[] = '</div>';
1784 $content[] = '<span class="ays-poll-new-poll-pro-desc">';
1785 $content[] = '<img class="ays-poll-new-poll-pro-guaranteeicon" src="' . POLL_MAKER_AYS_ADMIN_URL . '/images/poll-maker-guaranteeicon.svg" style="width:30px;margin-right:5px">';
1786 $content[] = __( "30 Days Money Back Guarantee", "poll-maker" );
1787 $content[] = '</span>';
1788 $content[] = '</div>';
1789 $content[] = '<div style="display:flex;flex-wrap:wrap;width:min-content;">';
1790 $content[] = '<span class="ays-poll-sale-baner-mega-bundle-sale-text">50%</span>';
1791 $content[] = '<img src="' . POLL_MAKER_AYS_ADMIN_URL . '/images/line.webp" class="ays-poll-new-mega-bundle-mobile-image-display-none" style="width: 70px;">';
1792 $content[] = '</div>';
1793 $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-poll-dismiss-buttons-container-for-form">';
1794
1795 $content[] = '<form action="" method="POST">';
1796 $content[] = '<div id="ays-poll-dismiss-buttons-content">';
1797 if( current_user_can( 'manage_options' ) ){
1798 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">Dismiss ad</button>';
1799 $content[] = wp_nonce_field( POLL_MAKER_AYS_NAME . '-sale-banner' , POLL_MAKER_AYS_NAME . '-sale-banner' );
1800 }
1801 $content[] = '</div>';
1802 $content[] = '</form>';
1803
1804 $content[] = '</div>';
1805
1806 $content[] = '</div>';
1807
1808 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-countdown-box">';
1809
1810 $content[] = '<div id="ays-poll-maker-countdown-main-container">';
1811 $content[] = '<div class="ays-poll-maker-countdown-container">';
1812
1813 $content[] = '<div id="ays-poll-countdown">';
1814
1815 $content[] = '<div>';
1816 $content[] = __( "Offer ends in:", "poll-maker" );
1817 $content[] = '</div>';
1818
1819 $content[] = '<ul>';
1820 $content[] = '<li><span id="ays-poll-countdown-days"></span>days</li>';
1821 $content[] = '<li><span id="ays-poll-countdown-hours"></span>Hours</li>';
1822 $content[] = '<li><span id="ays-poll-countdown-minutes"></span>Minutes</li>';
1823 $content[] = '<li><span id="ays-poll-countdown-seconds"></span>Seconds</li>';
1824 $content[] = '</ul>';
1825
1826 $content[] = '</div>';
1827
1828 $content[] = '<div id="ays-poll-countdown-content" class="emoji">';
1829 $content[] = '<span>🚀</span>';
1830 $content[] = '<span>⌛</span>';
1831 $content[] = '<span>🔥</span>';
1832 $content[] = '<span>💣</span>';
1833 $content[] = '</div>';
1834
1835 $content[] = '</div>';
1836 $content[] = '</div>';
1837
1838 $content[] = '</div>';
1839
1840 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-button-box">';
1841 $content[] = sprintf('<a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=sale-banner%s" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">%s</a>', $this->version, __('Buy Now', "poll-maker"));
1842 $content[] = '<span class="ays-poll-dicount-one-time-text">';
1843 $content[] = __( "One-time payment", "poll-maker" );
1844 $content[] = '</span>';
1845 $content[] = '</div>';
1846 $content[] = '</div>';
1847 $content[] = '</div>';
1848 $content = implode( '', $content );
1849 echo $content;
1850 }
1851
1852 // New Poll Pro 2024
1853 public function ays_poll_sale_message_poll_pro_2024() {
1854 $content = array();
1855 $content[] = '<div id="ays-poll-new-mega-bundle-dicount-month-main-2024" class="notice notice-success is-dismissible ays_poll_dicount_info">';
1856 $content[] = '<div id="ays-poll-dicount-month" class="ays_poll_dicount_month">';
1857
1858 $content[] = '<div class="ays-poll-discount-box-sale-image"></div>';
1859 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-text-box">';
1860
1861 $content[] = '<div class="ays-poll-dicount-wrap-text-box-texts">';
1862 $content[] = '<div>
1863 <a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=top-banner-50" target="_blank" style="color:#30499B;">
1864 <span class="ays-poll-new-mega-bundle-limited-text">Limited</span> Offer for Poll Maker </a> <br>
1865 </div>';
1866 $content[] = '</div>';
1867
1868 $content[] = '<div style="font-size: 17px;">';
1869 $content[] = '<img style="width: 24px;height: 24px;" src="' . esc_attr(POLL_MAKER_AYS_ADMIN_URL) . '/images/icons/guarantee-new.png">';
1870 $content[] = '<span style="padding-left: 4px; font-size: 14px; font-weight: 600;"> 30 Day Money Back Guarantee</span>';
1871
1872 $content[] = '</div>';
1873
1874
1875
1876 $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-poll-dismiss-buttons-container-for-form">';
1877
1878 $content[] = '<form action="" method="POST">';
1879 $content[] = '<div id="ays-poll-dismiss-buttons-content">';
1880 if( current_user_can( 'manage_options' ) ){
1881 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0; color: #30499B;
1882 ">Dismiss ad</button>';
1883 $content[] = wp_nonce_field( $this->plugin_name . '-sale-banner' , $this->plugin_name . '-sale-banner' );
1884 }
1885 $content[] = '</div>';
1886 $content[] = '</form>';
1887
1888 $content[] = '</div>';
1889
1890 $content[] = '</div>';
1891
1892 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-countdown-box">';
1893
1894 $content[] = '<div id="ays-poll-maker-countdown-main-container">';
1895 $content[] = '<div class="ays-poll-maker-countdown-container">';
1896
1897 $content[] = '<div id="ays-poll-countdown">';
1898
1899 $content[] = '<div style="font-weight: 500;">';
1900 $content[] = __( "Offer ends in:", "poll-maker" );
1901 $content[] = '</div>';
1902
1903 $content[] = '<ul>';
1904 $content[] = '<li><span id="ays-poll-countdown-days"></span>days</li>';
1905 $content[] = '<li><span id="ays-poll-countdown-hours"></span>Hours</li>';
1906 $content[] = '<li><span id="ays-poll-countdown-minutes"></span>Minutes</li>';
1907 $content[] = '<li><span id="ays-poll-countdown-seconds"></span>Seconds</li>';
1908 $content[] = '</ul>';
1909 $content[] = '</div>';
1910
1911 $content[] = '<div id="ays-poll-countdown-content" class="emoji">';
1912 $content[] = '<span>🚀</span>';
1913 $content[] = '<span>⌛</span>';
1914 $content[] = '<span>🔥</span>';
1915 $content[] = '<span>💣</span>';
1916 $content[] = '</div>';
1917
1918 $content[] = '</div>';
1919 $content[] = '</div>';
1920
1921 $content[] = '</div>';
1922
1923 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-button-box">';
1924 $content[] = '<a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=top-banner-50" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">' . __( 'Buy Now !', "poll-maker" ) . '</a>';
1925 $content[] = '<span >' . __( 'One-time payment', "poll-maker" ) . '</span>';
1926 $content[] = '</div>';
1927 $content[] = '</div>';
1928 $content[] = '</div>';
1929
1930 $content = implode( '', $content );
1931 echo html_entity_decode(esc_html( $content ));
1932 }
1933
1934 // Black Friday 2024
1935 public function ays_poll_black_friday_message_2024(){
1936 $content = array();
1937
1938 $content[] = '<div id="ays-poll-black-friday-bundle-dicount-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info">';
1939 $content[] = '<div id="ays-poll-dicount-month" class="ays_poll_dicount_month">';
1940
1941 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-countdown-box">';
1942
1943 $content[] = '<div id="ays-poll-maker-countdown-main-container">';
1944 $content[] = '<div class="ays-poll-maker-countdown-container">';
1945
1946 $content[] = '<div id="ays-poll-countdown">';
1947
1948 $content[] = '<div>';
1949 $content[] = __( "Offer ends in:", "poll-maker" );
1950 $content[] = '</div>';
1951
1952 $content[] = '<ul>';
1953 $content[] = '<li><span id="ays-poll-countdown-days"></span>'. __( "Days", "poll-maker" ) .'</li>';
1954 $content[] = '<li><span id="ays-poll-countdown-hours"></span>'. __( "Hours", "poll-maker" ) .'</li>';
1955 $content[] = '<li><span id="ays-poll-countdown-minutes"></span>'. __( "Minutes", "poll-maker" ) .'</li>';
1956 $content[] = '<li><span id="ays-poll-countdown-seconds"></span>'. __( "Seconds", "poll-maker" ) .'</li>';
1957 $content[] = '</ul>';
1958 $content[] = '</div>';
1959
1960 $content[] = '<div id="ays-poll-countdown-content" class="emoji">';
1961 $content[] = '<span>🚀</span>';
1962 $content[] = '<span>⌛</span>';
1963 $content[] = '<span>🔥</span>';
1964 $content[] = '<span>💣</span>';
1965 $content[] = '</div>';
1966
1967 $content[] = '</div>';
1968 $content[] = '</div>';
1969
1970 $content[] = '</div>';
1971
1972 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-text-box">';
1973 $content[] = '<div>';
1974
1975 $content[] = '<span class="ays-poll-black-friday-bundle-title">';
1976 $content[] = __( "<span><a href='https://ays-pro.com/marketing-bundle?utm_source=dashboard&utm_medium=poll-free&utm_campaign=black-friday-marketing-bundle-sale-banner' class='ays-poll-black-friday-bundle-title-link' target='_blank'>Black Friday Sale</a></span>", "poll-maker" );
1977 $content[] = '</span>';
1978
1979 $content[] = '</br>';
1980
1981 $content[] = '<span class="ays-poll-black-friday-bundle-desc">';
1982 $content[] = '<a class="ays-poll-black-friday-bundle-desc" href="https://ays-pro.com/marketing-bundle?utm_source=dashboard&utm_medium=poll-free&utm_campaign=black-friday-marketing-bundle-sale-banner" class="ays-poll-black-friday-bundle-title-link" target="_blank">';
1983 $content[] = __( "50% OFF", "poll-maker" );
1984 $content[] = '</a>';
1985 $content[] = '</span>';
1986 $content[] = '</div>';
1987
1988 $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-poll-dismiss-buttons-container-for-form">';
1989
1990 $content[] = '<form action="" method="POST">';
1991 $content[] = '<div id="ays-poll-dismiss-buttons-content">';
1992 if( current_user_can( 'manage_options' ) ){
1993 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">'. __( "Dismiss ad", "poll-maker" ) .'</button>';
1994 $content[] = wp_nonce_field( $this->plugin_name . '-sale-banner' , $this->plugin_name . '-sale-banner' );
1995 }
1996 $content[] = '</div>';
1997 $content[] = '</form>';
1998
1999 $content[] = '</div>';
2000
2001 $content[] = '</div>';
2002
2003 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-text-box">';
2004 $content[] = '<span class="ays-poll-black-friday-bundle-title">';
2005 $content[] = '<a class="ays-poll-black-friday-bundle-title-link" href="https://ays-pro.com/marketing-bundle?utm_source=dashboard&utm_medium=poll-free&utm_campaign=black-friday-marketing-bundle-sale-banner" target="_blank">';
2006 $content[] = __( 'Marketing Bundle', "ays-popup-box" );
2007 $content[] = '</a>';
2008 $content[] = '</span>';
2009 $content[] = '</div>';
2010
2011 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-button-box">';
2012 $content[] = '<a href="https://ays-pro.com/marketing-bundle?utm_source=dashboard&utm_medium=poll-free&utm_campaign=black-friday-marketing-bundle-sale-banner" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">' . __( 'Get Your Deal', "poll-maker" ) . '</a>';
2013 $content[] = '<span class="ays-poll-dicount-one-time-text">';
2014 $content[] = __( "One-time payment", "poll-maker" );
2015 $content[] = '</span>';
2016 $content[] = '</div>';
2017 $content[] = '</div>';
2018 $content[] = '</div>';
2019
2020 $content = implode( '', $content );
2021 echo $content;
2022 }
2023
2024 // Christmas Top Banner 2024
2025 public function ays_poll_christmas_top_message_2024(){
2026
2027 $content = array();
2028
2029 $content[] = '<div id="ays-poll-christmas-top-bundle-dicount-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info">';
2030 $content[] = '<div id="ays-poll-dicount-month" class="ays_poll_dicount_month">';
2031
2032 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-countdown-box">';
2033
2034 $content[] = '<div id="ays-poll-maker-countdown-main-container">';
2035 $content[] = '<div class="ays-poll-maker-countdown-container">';
2036
2037 $content[] = '<div id="ays-poll-countdown">';
2038
2039 $content[] = '<div>';
2040 $content[] = __( "Offer ends in:", "poll-maker" );
2041 $content[] = '</div>';
2042
2043 $content[] = '<ul>';
2044 $content[] = '<li><span id="ays-poll-countdown-days"></span>'. __( "Days", "poll-maker" ) .'</li>';
2045 $content[] = '<li><span id="ays-poll-countdown-hours"></span>'. __( "Hours", "poll-maker" ) .'</li>';
2046 $content[] = '<li><span id="ays-poll-countdown-minutes"></span>'. __( "Minutes", "poll-maker" ) .'</li>';
2047 $content[] = '<li><span id="ays-poll-countdown-seconds"></span>'. __( "Seconds", "poll-maker" ) .'</li>';
2048 $content[] = '</ul>';
2049 $content[] = '</div>';
2050
2051 $content[] = '<div id="ays-poll-countdown-content" class="emoji">';
2052 $content[] = '<span>🚀</span>';
2053 $content[] = '<span>⌛</span>';
2054 $content[] = '<span>🔥</span>';
2055 $content[] = '<span>💣</span>';
2056 $content[] = '</div>';
2057
2058 $content[] = '</div>';
2059 $content[] = '</div>';
2060
2061 $content[] = '</div>';
2062
2063 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-text-box">';
2064 $content[] = '<div>';
2065
2066 $content[] = '<span class="ays-poll-christmas-top-bundle-title">';
2067 $content[] = sprintf('<span><a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=christmas-sale-banner%s" class="ays-poll-christmas-top-bundle-title-link" target="_blank">%s</a></span>', $this->version, __('Christmas Sale', "poll-maker"));
2068 $content[] = '</span>';
2069
2070 $content[] = '</br>';
2071
2072 $content[] = '<span class="ays-poll-christmas-top-bundle-desc">';
2073 $content[] = sprintf('<a class="ays-poll-christmas-top-bundle-desc" href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=christmas-sale-banner%s" class="ays-poll-christmas-top-bundle-title-link" target="_blank">', $this->version);
2074 $content[] = __( "20% Extra OFF", "poll-maker" );
2075 $content[] = '</a>';
2076 $content[] = '</span>';
2077 $content[] = '</div>';
2078
2079 $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-poll-dismiss-buttons-container-for-form">';
2080
2081 $content[] = '<form action="" method="POST">';
2082 $content[] = '<div id="ays-poll-dismiss-buttons-content">';
2083 if( current_user_can( 'manage_options' ) ){
2084 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">'. __( "Dismiss ad", "poll-maker" ) .'</button>';
2085 $content[] = wp_nonce_field( "poll-maker" . '-sale-banner' , "poll-maker" . '-sale-banner' );
2086 }
2087 $content[] = '</div>';
2088 $content[] = '</form>';
2089
2090 $content[] = '</div>';
2091
2092 $content[] = '</div>';
2093
2094 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-christmas-top-bundle-coupon-text-box">';
2095 $content[] = '<div class="ays-poll-christmas-top-bundle-coupon-row">';
2096 $content[] = 'xmas20off';
2097 $content[] = '</div>';
2098
2099 $content[] = '<div class="ays-poll-christmas-top-bundle-text-row">';
2100 $content[] = __( '20% Extra Discount Coupon', "poll-maker" );
2101 $content[] = '</div>';
2102 $content[] = '</div>';
2103
2104 $content[] = '<div class="ays-poll-dicount-wrap-box ays-poll-dicount-wrap-button-box">';
2105 $content[] = sprintf('<a href="https://ays-pro.com/wordpress/poll-maker?utm_source=dashboard&utm_medium=poll-free&utm_campaign=christmas-sale-banner%s" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">%s</a>', $this->version, __('Get Your Deal', "poll-maker"));
2106 $content[] = '<span class="ays-poll-dicount-one-time-text">';
2107 $content[] = __( "One-time payment", "poll-maker" );
2108 $content[] = '</span>';
2109 $content[] = '</div>';
2110 $content[] = '</div>';
2111 $content[] = '</div>';
2112
2113 $content = implode( '', $content );
2114 echo $content;
2115
2116 }
2117
2118
2119
2120 public function add_tabs() {
2121 $screen = get_current_screen();
2122
2123 if ( ! $screen) {
2124 return;
2125 }
2126
2127 $title = __( 'General Information:', "poll-maker");
2128 $content_text = '<div>
2129 <span>The WordPress Poll Maker plugin is here to help you quickly create advanced-level online polls and make your WordPress website more interactive. Use it to conduct elections, surveys and etc. Easily generate poll types like;</span>
2130 </div>
2131 <br>
2132 <div>
2133 <span><strong>Choosing</strong> – create many options and let your users choose, or add their custom answers.</span>
2134 </div>
2135 <div>
2136 <span><strong>Rating</strong> – with this poll type, the visitors will be able to weigh via a 1-5 star rating system or emojis via the graphical interface.</span>
2137 </div>
2138 <div>
2139 <span><strong>Voting</strong> – make the participants evaluate your product by using like/dislike buttons or smiley/frown emojis.</span>
2140 </div>
2141 <div>
2142 <span><strong>Versus</strong> – Select two statements or images that are opposed to each other, and make your users choose the perfect one.</span>
2143 </div>
2144 <div>
2145 <span><strong>Range</strong> – the users will be able to choose the answer across the 0-100 scale.</span>
2146 </div>
2147 <div>
2148 <span><strong>Text</strong> – with this poll type the visitors should write down their own answers on the text boundaries.</span>
2149 </div>
2150 <div>
2151 <span><strong>Dropdown</strong> – the users will choose the multiple-choice answers from a list of answers appeared in a dropdown form.</span>
2152 </div>
2153 <br>
2154 <div>
2155 <span>Increase engagement of your website with the integrated, formatting, image, audio, video poll question types feature.</span>
2156 </div>';
2157
2158 $sidebar_content = '<p><strong>' . __( 'For more information:', "poll-maker") . '</strong></p>' .
2159 '<p>
2160 <a href="https://www.youtube.com/watch?v=RDKZXFmG6Pc" target="_blank">' . __( 'YouTube video tutorials' , "poll-maker" ) . '</a>
2161 </p>' .
2162 '<p>
2163 <a href="https://ays-pro.com/wordpress-poll-maker-user-manual" target="_blank">' . __( 'Documentation', "poll-maker" ) . '</a>
2164 </p>' .
2165 '<p>
2166 <a href="https://ays-pro.com/wordpress/poll-maker" target="_blank">' . __( 'Poll Maker plugin pro version', "poll-maker" ) . '</a>
2167 </p>' .
2168 '<p>
2169 <a href="https://poll-plugin.com/wordpress-poll-plugin-pro-demo/" target="_blank">' . __( 'Poll Maker plugin demo', "poll-maker" ) . '</a>
2170 </p>';
2171
2172
2173 $content = '<h2>' . __( 'Poll Maker Information', "poll-maker") . '</h2>';
2174 $content .= '<div>' . $content_text . '</div>';
2175
2176 $help_tab_content = array(
2177 'id' => 'survey_maker_help_tab',
2178 'title' => $title,
2179 'content' => $content
2180 );
2181
2182 $screen->add_help_tab($help_tab_content);
2183
2184 $screen->set_help_sidebar($sidebar_content);
2185 }
2186
2187 public static function ays_poll_sale_message_small_spring(){
2188 $content = array();
2189
2190 $content[] = '<div id="ays-poll-dicount-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info">';
2191 $content[] = '<div id="ays-poll-dicount-month" class="ays_poll_dicount_month">';
2192 $content[] = '<a href="https://ays-pro.com/mega-bundle" target="_blank" class="ays-poll-sale-banner-link"><img src="' . POLL_MAKER_AYS_ADMIN_URL . '/images/mega_bundle_logo_box.png"></a>';
2193
2194 $content[] = '<div class="ays-poll-dicount-wrap-box">';
2195 $content[] = '<p>';
2196 $content[] = '<strong>';
2197 $content[] = __( "Spring is here! <span class='ays-poll-dicount-wrap-color'>50%</span> SALE on <span><a href='https://ays-pro.com/mega-bundle' target='_blank' class='ays-poll-dicount-wrap-color ays-poll-dicount-wrap-text-decoration'>Mega Bundle</a></span><span style='display: block;'>Quiz + Survey + Poll</span>", "poll-maker" );
2198 $content[] = '</strong>';
2199 $content[] = '</p>';
2200 $content[] = '</div>';
2201
2202 $content[] = '<div class="ays-poll-dicount-wrap-box">';
2203
2204 $content[] = '<div id="ays-poll-countdown-main-container">';
2205
2206 $content[] = '<form action="" method="POST" class="ays-poll-btn-form">';
2207 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn_small_spring" style="height: 32px; margin-left: 0;padding-left: 0" value="small_spring">Dismiss ad</button>';
2208 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn_spring_small_for_two_months" style="height: 32px; padding-left: 0" value="small_spring">Dismiss ad for 2 months</button>';
2209 $content[] = '</form>';
2210
2211 $content[] = '</div>';
2212
2213 $content[] = '</div>';
2214
2215 $content[] = '<a href="https://ays-pro.com/mega-bundle" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">' . __( 'Buy Now !', "poll-maker" ) . '</a>';
2216 $content[] = '</div>';
2217 $content[] = '</div>';
2218
2219 $content = implode( '', $content );
2220 echo $content;
2221 }
2222
2223 public function ays_poll_sale_message_poll_countdown(){
2224 $content = array();
2225
2226 $content[] = '<div id="ays-poll-dicount-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info">';
2227 $content[] = '<div id="ays-poll-dicount-month" class="ays_poll_dicount_month">';
2228 $content[] = '<a href="https://ays-pro.com/great-bundle" target="_blank" class="ays-poll-sale-banner-link" style="display:none;"><img src="' . POLL_MAKER_AYS_ADMIN_URL . '/images/mega_bundle_logo_box.png"></a>';
2229
2230 $content[] = '<a href="https://ays-pro.com/wordpress/poll-maker" class="ays-poll-sale-banner-link" target="_blank"><img src="' . POLL_MAKER_AYS_ADMIN_URL . '/images/icons/icon-128x128.png"></a>';
2231
2232 $content[] = '<div class="ays-poll-dicount-wrap-box">';
2233
2234 $content[] = '<strong style="font-weight: bold;">';
2235 $content[] = __( "Limited Time <span class='ays-poll-dicount-wrap-color'>20%</span> SALE on <br><span><a href='https://ays-pro.com/wordpress/poll-maker/' target='_blank' class='ays-poll-dicount-wrap-color ays-poll-dicount-wrap-text-decoration' style='display:block;'>Poll Maker Premium Versions</a></span>", "poll-maker" );
2236 $content[] = '</strong>';
2237
2238 $content[] = '<strong>';
2239 $content[] = __( "Hurry up! <a href='https://ays-pro.com/wordpress/poll-maker' target='_blank'>Check it out!</a>", "poll-maker" );
2240 $content[] = '</strong>';
2241
2242 $content[] = '</div>';
2243
2244 $content[] = '<div class="ays-poll-dicount-wrap-box">';
2245
2246 $content[] = '<div id="ays-poll-maker-countdown-main-container">';
2247 $content[] = '<div class="ays-poll-maker-countdown-container">';
2248
2249 $content[] = '<div id="ays-poll-countdown">';
2250 $content[] = '<ul>';
2251 $content[] = '<li><span id="ays-poll-countdown-days"></span>days</li>';
2252 $content[] = '<li><span id="ays-poll-countdown-hours"></span>Hours</li>';
2253 $content[] = '<li><span id="ays-poll-countdown-minutes"></span>Minutes</li>';
2254 $content[] = '<li><span id="ays-poll-countdown-seconds"></span>Seconds</li>';
2255 $content[] = '</ul>';
2256 $content[] = '</div>';
2257
2258 $content[] = '<div id="ays-poll-countdown-content" class="emoji">';
2259 $content[] = '<span>🚀</span>';
2260 $content[] = '<span>⌛</span>';
2261 $content[] = '<span>🔥</span>';
2262 $content[] = '<span>💣</span>';
2263 $content[] = '</div>';
2264
2265 $content[] = '</div>';
2266
2267 $content[] = '</div>';
2268
2269 $content[] = '</div>';
2270
2271 $content[] = '<div class="ays-poll-dicount-wrap-box ays-buy-now-button-box">';
2272 $content[] = '<a href="https://ays-pro.com/wordpress/poll-maker" class="button button-primary ays-buy-now-button" id="ays-button-top-buy-now" target="_blank" style="" >' . __( 'Buy Now !', "poll-maker" ) . '</a>';
2273 $content[] = '</div>';
2274
2275 $content[] = '</div>';
2276
2277 $content[] = '<div style="position: absolute;right: 0;bottom: 1px;" class="ays-poll-dismiss-buttons-container-for-form">';
2278 $content[] = '<form action="" method="POST">';
2279 $content[] = '<div id="ays-poll-dismiss-buttons-content">';
2280 $content[] = '<button class="btn btn-link ays-button" name="ays_poll_sale_btn_poll_countdown" style="height: 32px; margin-left: 0;padding-left: 0; color:#979797" value="poll_countdown">Dismiss ad</button>';
2281 $content[] = '</div>';
2282 $content[] = '</form>';
2283 $content[] = '</div>';
2284
2285 $content[] = '</div>';
2286
2287 $content = implode( '', $content );
2288 echo $content;
2289 }
2290
2291 public static function ays_poll_halloween_bundle(){
2292 $content = array();
2293
2294 $content[] = '<div id="ays-poll-dicount-month-main-helloween" class="notice notice-success is-dismissible ays_poll_dicount_info">';
2295 $content[] = '<div id="ays-poll-dicount-month-helloween" class="ays_poll_dicount_month_helloween">';
2296 $content[] = '<div class="ays-poll-dicount-wrap-box-helloween-limited">';
2297
2298 $content[] = '<p>';
2299 $content[] = __( "Limited Time
2300 <span class='ays-poll-dicount-wrap-color-helloween' style='color:#b2ff00;'>20%</span>
2301 <span>
2302 SALE on
2303 </span>
2304 <br>
2305 <span style='' class='ays-poll-helloween-bundle'>
2306 <a href='https://ays-pro.com/wordpress/poll-maker?utm_source=poll-maker-free&utm_medium=dashboard&utm_campaign=halloween-sale-banner' target='_blank' class='ays-poll-dicount-wrap-color-helloween ays-poll-dicount-wrap-text-decoration-helloween' style='display:block; color:#b2ff00;margin-right:6px;'>
2307 Poll Maker
2308 </a>
2309 </span>", "poll-maker" );
2310 $content[] = '</p>';
2311 $content[] = '<p>';
2312 $content[] = __( "Hurry up!
2313 <a href='https://ays-pro.com/wordpress/poll-maker?utm_source=easy-form-free&utm_medium=dashboard&utm_campaign=halloween-sale-banner' target='_blank' style='color:#ffc700;'>
2314 Check it out!
2315 </a>", "poll-maker" );
2316 $content[] = '</p>';
2317
2318 $content[] = '</div>';
2319 $content[] = '<div class="ays-poll-helloween-bundle-buy-now-timer">';
2320 $content[] = '<div class="ays-poll-dicount-wrap-box-helloween-timer">';
2321 $content[] = '<div id="ays-poll-maker-countdown-main-container" class="ays-poll-countdown-main-container-helloween">';
2322 $content[] = '<div class="ays-poll-countdown-container-helloween">';
2323 $content[] = '<div id="ays-poll-countdown">';
2324 $content[] = '<ul>';
2325 $content[] = '<li><p><span id="ays-poll-countdown-days"></span><span>DAYS</span></p></li>';
2326 $content[] = '<li><p><span id="ays-poll-countdown-hours"></span><span>HOURS</span></p></li>';
2327 $content[] = '<li><p><span id="ays-poll-countdown-minutes"></span><span>MINS</span></p></li>';
2328 $content[] = '<li><p><span id="ays-poll-countdown-seconds"></span><span>SECS</span></p></li>';
2329 $content[] = '</ul>';
2330 $content[] = '</div>';
2331
2332 $content[] = '<div id="ays-poll-countdown-content" class="emoji">';
2333 $content[] = '<span>🚀</span>';
2334 $content[] = '<span>⌛</span>';
2335 $content[] = '<span>🔥</span>';
2336 $content[] = '<span>💣</span>';
2337 $content[] = '</div>';
2338
2339 $content[] = '</div>';
2340
2341 $content[] = '</div>';
2342
2343 $content[] = '</div>';
2344 $content[] = '<div class="ays-poll-dicount-wrap-box ays-buy-now-button-box-helloween">';
2345 $content[] = '<a href="https://ays-pro.com/wordpress/poll-maker?utm_source=poll-maker-free&utm_medium=dashboard&utm_campaign=halloween-sale-banner" class="button button-primary ays-buy-now-button-helloween" id="ays-button-top-buy-now-helloween" target="_blank" style="" >' . __( 'Buy Now !', "poll-maker" ) . '</a>';
2346 $content[] = '</div>';
2347 $content[] = '</div>';
2348
2349 $content[] = '</div>';
2350 $content[] = '<div style="position: absolute;right: 0;bottom: 1px;" class="ays-poll-dismiss-buttons-container-for-form-helloween">';
2351 $content[] = '<form action="" method="POST">';
2352 $content[] = '<div id="ays-poll-dismiss-buttons-content-helloween">';
2353 if( current_user_can( 'manage_options' ) ){
2354 $content[] = '<button class="btn btn-link ays-button-helloween" name="ays_poll_sale_btn_halloween_bundle" style="">Dismiss ad</button>';
2355 $content[] = wp_nonce_field( POLL_MAKER_AYS_NAME . '-sale-banner' , POLL_MAKER_AYS_NAME . '-sale-banner' );
2356 }
2357 $content[] = '</div>';
2358 $content[] = '</form>';
2359 $content[] = '</div>';
2360 $content[] = '</div>';
2361
2362 $content = implode( '', $content );
2363
2364 echo $content;
2365 }
2366
2367 // Christmas banner
2368 public static function ays_poll_sale_message_christmas_message(){
2369 $content = array();
2370
2371 $content[] = '<div id="ays-poll-dicount-christmas-month-main" class="notice notice-success is-dismissible ays_poll_dicount_info">';
2372 $content[] = '<div id="ays-poll-dicount-christmas-month" class="ays_poll_dicount_month">';
2373 $content[] = '<div class="ays-poll-dicount-christmas-box">';
2374 $content[] = '<div class="ays-poll-dicount-christmas-wrap-box ays-poll-dicount-christmas-wrap-box-80">';
2375 $content[] = '<div class="ays-poll-dicount-christmas-title-row">' . __( 'Limited Time', "poll-maker" ) .' '. '<a href="https://ays-pro.com/wordpress/poll-maker" class="ays-poll-dicount-christmas-button-sale" target="_blank">' . __( '20%', "poll-maker" ) . '</a>' . ' SALE</div>';
2376 $content[] = '<div class="ays-poll-dicount-christmas-title-row">' . __( 'Poll Maker Plugin', "poll-maker" ) . '</div>';
2377 $content[] = '</div>';
2378
2379 $content[] = '<div class="ays-poll-dicount-christmas-wrap-box" style="width: 25%;">';
2380 $content[] = '<div id="ays-poll-maker-countdown-main-container">';
2381 $content[] = '<div class="ays-poll-countdown-container">';
2382 $content[] = '<div id="ays-poll-countdown" style="display: block;">';
2383 $content[] = '<ul>';
2384 $content[] = '<li><span id="ays-poll-countdown-days"></span>' . __( 'Days', "poll-maker" ) . '</li>';
2385 $content[] = '<li><span id="ays-poll-countdown-hours"></span>' . __( 'Hours', "poll-maker" ) . '</li>';
2386 $content[] = '<li><span id="ays-poll-countdown-minutes"></span>' . __( 'Minutes', "poll-maker" ) . '</li>';
2387 $content[] = '<li><span id="ays-poll-countdown-seconds"></span>' . __( 'Seconds', "poll-maker" ) . '</li>';
2388 $content[] = '</ul>';
2389 $content[] = '</div>';
2390 $content[] = '<div id="ays-poll-countdown-content" class="emoji" style="display: none;">';
2391 $content[] = '<span>🚀</span>';
2392 $content[] = '<span>⌛</span>';
2393 $content[] = '<span>🔥</span>';
2394 $content[] = '<span>💣</span>';
2395 $content[] = '</div>';
2396 $content[] = '</div>';
2397 $content[] = '</div>';
2398 $content[] = '</div>';
2399
2400 $content[] = '<div class="ays-poll-dicount-christmas-wrap-box" style="width: 25%;">';
2401 $content[] = '<a href="https://ays-pro.com/wordpress/poll-maker" class="ays-poll-dicount-christmas-button-buy-now" target="_blank">' . __( 'BUY NOW!', "poll-maker" ) . '</a>';
2402 $content[] = '</div>';
2403 $content[] = '</div>';
2404 $content[] = '</div>';
2405
2406 $content[] = '<div style="position: absolute;right: 0;bottom: 1px;" class="ays-poll-dismiss-buttons-container-for-form-christmas">';
2407 $content[] = '<form action="" method="POST">';
2408 $content[] = '<div id="ays-poll-dismiss-buttons-content-christmas">';
2409 $content[] = '<button class="btn btn-link ays-button-christmas" name="ays_poll_sale_btn" style="">' . __( 'Dismiss ad', "poll-maker" ) . '</button>';
2410 $content[] = '</div>';
2411 $content[] = '</form>';
2412 $content[] = '</div>';
2413 $content[] = '</div>';
2414
2415 $content = implode( '', $content );
2416
2417 echo $content;
2418 }
2419
2420 /**
2421 * Recursive sanitation for an array
2422 *
2423 * @param $array
2424 *
2425 * @return mixed
2426 */
2427 public static function recursive_sanitize_text_field($array) {
2428 foreach ( $array as $key => &$value ) {
2429 if ( is_array( $value ) ) {
2430 $value = self::recursive_sanitize_text_field($value);
2431 } else {
2432 $value = sanitize_text_field( $value );
2433 }
2434 }
2435 return $array;
2436 }
2437
2438 public static function get_max_id( $table ) {
2439 global $wpdb;
2440 $db_table = $wpdb->prefix . 'ayspoll_'.$table;;
2441
2442 $sql = "SELECT MAX(id) FROM {$db_table}";
2443
2444 $result = intval( $wpdb->get_var( $sql ) );
2445
2446 return $result;
2447 }
2448
2449 public function ays_poll_generate_message_vars_html( $poll_message_vars ) {
2450 $content = array();
2451 $var_counter = 0;
2452
2453 $content[] = '<div class="ays-poll-message-vars-box">';
2454 $content[] = '<div class="ays-poll-message-vars-icon">';
2455 $content[] = '<div>';
2456 $content[] = '<i class="ays_poll_fa ays_fa_link"></i>';
2457 $content[] = '</div>';
2458 $content[] = '<div>';
2459 $content[] = '<span>'. __("Message Variables" , "poll-maker") .'</span>';
2460 $content[] = '<a class="ays_help" data-toggle="tooltip" data-html="true" title="'. __("Insert your preferred message variable into the editor by clicking." , "poll-maker") .'">';
2461 $content[] = '<i class="fas fa-info-circle"></i>';
2462 $content[] = '</a>';
2463 $content[] = '</div>';
2464 $content[] = '</div>';
2465 $content[] = '<div class="ays-poll-message-vars-data">';
2466 foreach($poll_message_vars as $var => $var_name){
2467 $var_counter++;
2468 $content[] = '<label class="ays-poll-message-vars-each-data-label">';
2469 $content[] = '<input type="radio" class="ays-poll-message-vars-each-data-checker" hidden id="ays_poll_message_var_count_'. $var_counter .'" name="ays_poll_message_var_count">';
2470 $content[] = '<div class="ays-poll-message-vars-each-data">';
2471 $content[] = '<input type="hidden" class="ays-poll-message-vars-each-var" value="'. $var .'">';
2472 $content[] = '<span>'. $var_name .'</span>';
2473 $content[] = '</div>';
2474 $content[] = '</label>';
2475 }
2476 $content[] = '</div>';
2477 $content[] = '</div>';
2478
2479 $content = implode( '', $content );
2480
2481 return $content;
2482 }
2483
2484 public function ays_poll_update_banner_time(){
2485
2486 $date = time() + ( 3 * 24 * 60 * 60 ) + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
2487 // $date = time() + ( 60 ) + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS); // for testing | 1 min
2488 $next_3_days = date('M d, Y H:i:s', $date);
2489
2490 $ays_poll_banner_time = get_option('ays_poll_banner_time');
2491
2492 if ( !$ays_poll_banner_time || is_null( $ays_poll_banner_time ) ) {
2493 update_option('ays_poll_banner_time', $next_3_days );
2494 }
2495
2496 $get_ays_poll_banner_time = get_option('ays_poll_banner_time');
2497
2498 $val = 60*60*24*0.5; // half day
2499 // $val = 60; // for testing | 1 min
2500
2501 $current_date = current_time( 'mysql' );
2502 $date_diff = strtotime($current_date) - intval(strtotime($get_ays_poll_banner_time));
2503
2504 $days_diff = $date_diff / $val;
2505 if(intval($days_diff) > 0 ){
2506 update_option('ays_poll_banner_time', $next_3_days);
2507 $get_ays_poll_banner_time = get_option('ays_poll_banner_time');
2508 }
2509
2510 return $get_ays_poll_banner_time;
2511 }
2512
2513 public static function ays_poll_check_if_current_image_exists($image_url) {
2514 global $wpdb;
2515
2516 $res = true;
2517 if( !isset($image_url) ){
2518 $res = false;
2519 }
2520
2521 if ( isset($image_url) && !empty( $image_url ) ) {
2522
2523 $re = '/-\d+[Xx]\d+\./';
2524 $subst = '.';
2525
2526 $image_url = preg_replace($re, $subst, $image_url, 1);
2527
2528 $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
2529 if ( is_null( $attachment ) || empty( $attachment ) ) {
2530 $res = false;
2531 }
2532 }
2533
2534 return $res;
2535 }
2536
2537 public function ays_poll_maker_quick_start() {
2538 global $wpdb;
2539 error_reporting(0);
2540
2541 // Run a security check.
2542 check_ajax_referer( 'poll-maker-ajax-quick-poll-nonce', sanitize_key( $_REQUEST['_ajax_nonce'] ) );
2543
2544 // Check for permissions.
2545 if ( !Poll_Maker_Data::check_user_capability() ) {
2546 ob_end_clean();
2547 $ob_get_clean = ob_get_clean();
2548 echo json_encode(array(
2549 'status' => false,
2550 'poll_id' => 0
2551 ));
2552 wp_die();
2553 }
2554
2555 $polls_table = esc_sql($wpdb->prefix . "ayspoll_polls");
2556 $answers_table = esc_sql($wpdb->prefix . "ayspoll_answers");
2557
2558 $title = stripslashes( sanitize_text_field($_REQUEST['ays-poll-title']) );
2559 $question = wp_kses_post( $_REQUEST['ays_poll_question'] );
2560
2561 $answers = self::recursive_sanitize_text_field($_REQUEST['ays-poll-answers']);
2562
2563 $allow_multivote = isset($_REQUEST['allow_multivote_switch']) && $_REQUEST['allow_multivote_switch'] == 'on' ? "on" : "off";
2564 $allow_not_vote = isset($_REQUEST['allow-not-vote']) && 'on' == $_REQUEST['allow-not-vote'] ? 1 : 0;
2565 $show_author = isset($_REQUEST['quick-poll-show_poll_author']) && 1 == $_REQUEST['quick-poll-show_poll_author'] ? 1 : 0;
2566 $show_title = isset($_REQUEST['quick-poll-show-title']) && $_REQUEST['quick-poll-show-title'] == 'off' ? 0 : 1;
2567 $show_creation_date = isset($_REQUEST['quick-poll-show-creation-date']) && $_REQUEST['quick-poll-show-creation-date'] == 'on' ? 1 : 0;
2568 $hide_results = isset($_REQUEST['quick-poll-hide-results']) && 1 == $_REQUEST['quick-poll-hide-results'] ? 1 : 0;
2569 $randomize_answers = isset($_REQUEST['quick-poll-randomize-answers']) && $_REQUEST['quick-poll-randomize-answers'] == 'on' ? 'on' : 'off';
2570 $enable_restart_button = isset($_REQUEST['quick-poll-enable-restart-button']) && $_REQUEST['quick-poll-enable-restart-button'] == 'on' ? 1 : 0;
2571 $res_rgba = isset($_REQUEST['quick-poll-res-rgba']) && $_REQUEST['quick-poll-res-rgba'] == 'on' ? 'on' : 'off';
2572
2573 if ($allow_multivote === 'on') {
2574 $multivote_min_count = sanitize_text_field($_REQUEST['quick-poll-multivote-min-count']);
2575 $multivote_max_count = sanitize_text_field($_REQUEST['quick-poll-multivote-max-count']);
2576 } else {
2577 $multivote_min_count = 1;
2578 $multivote_max_count = 1;
2579 }
2580
2581 $create_date = current_time( 'mysql' );
2582
2583 $user_id = get_current_user_id();
2584 $user = get_userdata($user_id);
2585 $author = array(
2586 'id' => $user->ID,
2587 'name' => $user->data->display_name
2588 );
2589 $options = json_encode(
2590 array(
2591 "poll_version" => POLL_MAKER_AYS_VERSION,
2592 "poll_enable_copy_protection" => "off",
2593 "poll_question_text_to_speech" => "off",
2594 "main_color" => "#0C6291",
2595 "text_color" => "#0C6291",
2596 "icon_color" => "#0C6291",
2597 "bg_color" => "#FBFEF9",
2598 "answer_bg_color" => "#FBFEF9",
2599 "answer_hover_color" => "#0C6291",
2600 "answer_border_side" => "all_sides",
2601 "title_bg_color" => "",
2602 "icon_size" => 24,
2603 "width" => 600,
2604 "width_for_mobile" => 0,
2605 "btn_text" => "Vote",
2606 "see_res_btn_text" => "See Results",
2607 "border_style" => "ridge",
2608 "border_radius" => "0",
2609 "border_width" => "1",
2610 "box_shadow_color" => "#000000",
2611 "enable_box_shadow" => "off",
2612 "enable_answer_style" => "on",
2613 "bg_image" => false,
2614 "info_form" => 0,
2615 "fields" => "apm-name,apm-email,apm_phone",
2616 "required_fields" => "apm-name,apm-email,apm_phone",
2617 "info_form_title" => "<h5>Please fill out the form:<\/h5>\n",
2618 "hide_results" => $hide_results,
2619 "hide_result_message" => 0,
2620 "hide_results_text" => "<p>Thanks for your answer!<\/p>\n",
2621 "result_message" => "",
2622 "allow_not_vote" => $allow_not_vote,
2623 "show_social" => 0,
2624 "poll_social_buttons_heading" => "",
2625 "poll_show_social_ln" => "on",
2626 "poll_show_social_fb" => "on",
2627 "poll_show_social_tr" => "on",
2628 "poll_show_social_vk" => "off",
2629 "enable_social_links" => "off",
2630 "poll_social_links_heading" => "",
2631 "social_links" => array(
2632 "linkedin_link" => "",
2633 "facebook_link" => "",
2634 "twitter_link" => "",
2635 "vkontakte_link" => "",
2636 "youtube_link" => ""
2637 ),
2638 "load_effect" => "load_gif",
2639 "load_gif" => "plg_pro1",
2640 "custom_load" => false,
2641 "limit_users" => 0,
2642 "limit_users_method" => "ip",
2643 "limitation_message" => "<p>You have already voted<\/p>\n",
2644 "redirect_url" => false,
2645 "redirection_delay" => 0,
2646 "user_role" => "",
2647 "enable_restriction_pass" => 0,
2648 "restriction_pass_message" => "<p>You don\\'t have permissions for passing the poll<\/p>\n",
2649 "enable_logged_users" => 0,
2650 "enable_logged_users_message" => "<p>You must sign in for passing the poll<\/p>\n",
2651 "notify_email_on" => 0,
2652 "notify_email" => "",
2653 "published" => 1,
2654 "enable_pass_count" => "on",
2655 "result_sort_type" => "none",
2656 "create_date" => $create_date,
2657 "redirect_users" => 0,
2658 "redirect_after_vote_url" => false,
2659 "redirect_after_vote_delay" => 0,
2660 "activeInterval" => "2022-09-17",
2661 "deactiveInterval" => "2022-09-17",
2662 "activeIntervalSec" => "",
2663 "deactiveIntervalSec" => "",
2664 "active_date_message" => "<p>The poll has expired!<\/p>\n",
2665 "active_date_message_soon" => "<p style=\\\"text-align => center;\\\">The poll will be available soon!<\/p>\n",
2666 "vote_reason" => 0,
2667 "show_chart_type" => "google_bar_chart",
2668 "active_date_check" => "",
2669 "enable_restart_button" => $enable_restart_button,
2670 "enable_vote_btn" => 1,
2671 "show_votes_count" => 1,
2672 "attempts_count" => "1",
2673 "poll_main_url" => '',
2674 "show_create_date" => $show_creation_date,
2675 "show_author" => $show_author,
2676 "author" => $author,
2677 "show_res_percent" => 1,
2678 "show_result_btn_schedule" => 0,
2679 "ays_poll_show_timer" => 0,
2680 "show_bottom_timer" => 0,
2681 "ays_show_timer_type" => "countdown",
2682 "show_login_form" => "off",
2683 "poll_allow_answer" => 0,
2684 "poll_allow_answer_require" => 1,
2685 "versus_icon_type" => "default",
2686 "versus_icon_position" => "center",
2687 "versus_answers_label" => 0,
2688 "result_in_rgba" => $res_rgba,
2689 "enable_mailchimp" => "off",
2690 "enable_background_gradient" => "off",
2691 "background_gradient_color_1" => "#103251",
2692 "background_gradient_color_2" => "#607593",
2693 "poll_gradient_direction" => "vertical",
2694 "redirect_after_submit" => 0,
2695 "mailchimp_list" => "",
2696 "poll_direction" => "ltr",
2697 "poll_allow_multivote" => $allow_multivote,
2698 "multivote_answer_min_count" => $multivote_min_count,
2699 "poll_allow_multivote_count" => $multivote_max_count,
2700 "monitor_list" => "",
2701 "enable_monitor" => "off",
2702 "slack_conversation" => "",
2703 "enable_slack" => "off",
2704 "active_camp_list" => "",
2705 "active_camp_automation" => "",
2706 "enable_active_camp" => "off",
2707 "enable_zapier" => "off",
2708 "randomize_answers" => $randomize_answers,
2709 "enable_asnwers_sound" => "off",
2710 "enable_password" => "off",
2711 "password_poll" => "",
2712 "poll_password_message" => "Please enter password",
2713 "poll_enable_password_visibility" => "off",
2714 "background_size" => "cover",
2715 "disable_answer_hover" => 0,
2716 "custom_class" => "",
2717 "enable_poll_title_text_shadow" => "off",
2718 "poll_title_text_shadow" => "rgba(255,255,255,0)",
2719 "poll_title_text_shadow_x_offset" => 2,
2720 "poll_title_text_shadow_y_offset" => 2,
2721 "poll_title_text_shadow_z_offset" => 0,
2722 "poll_bg_image_position" => "center center",
2723 "poll_bg_img_in_finish_page" => "off",
2724 "ays_add_post_for_poll" => "off",
2725 "show_answer_message" => "off",
2726 "show_answers_caption" => "on",
2727 "answers_grid_column_mobile" => "on",
2728 "enable_vote_limitation" => "off",
2729 "vote_limitation" => "",
2730 "limitation_time_period" => "minute",
2731 "enable_tackers_count" => "off",
2732 "tackers_count" => "",
2733 "ays_enable_mail_user" => "off",
2734 "vote_notification_email_msg" => "",
2735 "poll_answer_icon_check" => "off",
2736 "answers_icon" => "radio",
2737 "buttons_size" => "medium",
2738 "buttons_font_size" => "17",
2739 "poll_buttons_mobile_font_size" => "17",
2740 "buttons_left_right_padding" => "20",
2741 "buttons_top_bottom_padding" => "10",
2742 "buttons_border_radius" => "3",
2743 "redirect_after_submit_drpdwn" => 0,
2744 "user_add_answer_dropdown" => 0,
2745 "enable_google_sheets" => "off",
2746 "spreadsheet_id" => "",
2747 "enable_view_more_button" => "off",
2748 "poll_view_more_button_count" => 0,
2749 "poll_min_height" => "",
2750 "answer_sort_type" => "default",
2751 "answer_font_size" => "16",
2752 "poll_answer_font_size_mobile" => "16",
2753 "show_passed_users" => "off",
2754 "logo_image" => "",
2755 "allow_collect_user_info" => "off",
2756 "poll_send_mail_type" => "custom",
2757 "poll_sendgrid_email_from" => "",
2758 "poll_sendgrid_email_name" => "",
2759 "poll_sendgrid_template_id" => "",
2760 "enable_limit_by_country" => "off",
2761 "limit_country" => "AD",
2762 "show_votes_before_voting" => "off",
2763 "show_votes_before_voting_by" => "by_count",
2764 "fake_votes" => "off",
2765 "dont_show_poll_cont" => "off",
2766 "see_result_button" => "on",
2767 "see_result_radio" => "ays_see_result_button",
2768 "loader_font_size" => "",
2769 "show_answers_numbering" => "none",
2770 "effect_message" => "",
2771 "enable_mad_mimi" => "off",
2772 "mad_mimi_list" => "",
2773 "poll_show_passed_users_count" => 3,
2774 "question_font_size" => 16,
2775 "question_font_size_mobile" => 16,
2776 "poll_question_image_height" => "",
2777 "poll_mobile_max_width" => "",
2778 "poll_title_font_size" => "18",
2779 "poll_title_font_size_mobile" => "20",
2780 "poll_title_alignment" => "center",
2781 "poll_title_alignment_mobile" => "center",
2782 "poll_enable_answer_image_after_voting" => "off",
2783 "poll_text_type_length_enable" => "off",
2784 "poll_text_type_limit_type" => "characters",
2785 "poll_text_type_limit_length" => "",
2786 "poll_text_type_limit_message" => "off",
2787 "poll_text_type_placeholder" => "Your answer",
2788 "poll_text_type_width" => "",
2789 "poll_text_type_width_type" => "percent",
2790 "poll_answer_padding" => 10,
2791 "poll_answer_margin" => 10,
2792 "answers_border" => "on",
2793 "answers_border_width" => 1,
2794 "answers_border_style" => "solid",
2795 "answers_border_color" => "#444",
2796 "poll_answer_enable_box_shadow" => "off",
2797 "answers_box_shadow_color" => "#000",
2798 "poll_answer_box_shadow_x_offset" => 0,
2799 "poll_answer_box_shadow_y_offset" => 0,"poll_answer_box_shadow_z_offset" => 10,
2800 "poll_answer_image_height" => 150,
2801 "poll_answer_image_height_for_mobile" => "150",
2802 "poll_answer_image_border_radius" => 0,
2803 "ans_img_caption_style" => "outside",
2804 "ans_img_caption_position" => "bottom",
2805 "answers_font_size" => 15,
2806 "poll_answer_object_fit" => "cover",
2807 "answers_grid_column" => 2,
2808 "poll_answer_border_radius" => 0,
2809 "enable_getResponse" => "off",
2810 "getResponse_list" => "",
2811 "enable_mailerLite" => "off",
2812 "mailerLite_group_id" => "",
2813 "enable_convertKit" => "off",
2814 "poll_convertKit_form_id" => "",
2815 "enable_mailpoet" => "off",
2816 "mailpoet_list" => "",
2817 "poll_logo_url" => "",
2818 "poll_enable_logo_url" => "off",
2819 "poll_logo_url_new_tab" => "off",
2820 "poll_send_mail_to_site_admin" => "on",
2821 "poll_email_configuration_from_email" => "",
2822 "poll_email_configuration_from_name" => "",
2823 "poll_email_configuration_from_subject" => "",
2824 "poll_email_configuration_replyto_email" => "",
2825 "poll_email_configuration_replyto_name" => "",
2826 "display_fields_labels" => "off",
2827 "autofill_user_data" => "off",
2828 "poll_create_author" => 1
2829 ));
2830
2831 $wpdb->insert($polls_table, array(
2832 "title" => $title,
2833 "question" => $question,
2834 "type" => "choosing",
2835 "view_type" => "list",
2836 "categories" => ",1,",
2837 "show_title" => $show_title,
2838 "styles" => $options,
2839 "theme_id" => 1,
2840 ));
2841
2842 $poll_id = $wpdb->insert_id;
2843
2844 foreach ($answers as $answer_key => $answer) {
2845 $wpdb->insert($answers_table, array(
2846 "poll_id" => $poll_id,
2847 "answer" => $answer,
2848 "votes" => 0,
2849 "ordering" => (intval($answer_key) + 1),
2850 "user_added" => 0,
2851 "show_user_added" => 1,
2852 ));
2853 }
2854
2855 echo json_encode(array(
2856 'status' => true,
2857 'poll_id' => $poll_id
2858 ));
2859 wp_die();
2860 }
2861
2862 }