*/
class Poll_Maker_Ays_Admin {
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;
private $polls_obj;
private $cats_obj;
private $results_obj;
private $each_results_obj;
private $settings_obj;
private $answer_results_obj;
private $capability;
/**
* Initialize the class and set its properties.
*
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*
* @since 1.0.0
*/
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
add_filter('set-screen-option', array(__CLASS__, 'set_screen'), 10, 3);
$per_page_array = array(
'polls_per_page',
'poll_cats_per_page',
'poll_results_per_page',
);
foreach($per_page_array as $option_name){
add_filter('set_screen_option_'.$option_name, array(__CLASS__, 'set_screen'), 10, 3);
}
}
/**
* Register the styles for the admin menu area.
*
* @since 1.5.5
*/
public function admin_menu_styles() {
echo "
";
}
/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function enqueue_styles( $hook_suffix ) {
wp_enqueue_style($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'css/admin.css', array(), $this->version, 'all');
wp_enqueue_style($this->plugin_name . '-sweetalert-css', plugin_dir_url(__FILE__) . 'css/poll-maker-sweetalert2.min.css', array(), $this->version, 'all');
if (false === strpos($hook_suffix, $this->plugin_name)) {
return;
}
// wp_enqueue_style('wp-color-picker');
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Poll_Maker_Ays_Loader as all of the hooks are defined
* in that particular class.
*
* The Poll_Maker_Ays_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
// You need styling for the datepicker. For simplicity I've linked to the jQuery UI CSS on a CDN.
wp_register_style( 'jquery-ui', 'https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css' );
wp_enqueue_style( 'jquery-ui' );
wp_enqueue_style('wp-color-picker');
wp_enqueue_style('ays_poll_animate.css', plugin_dir_url(__FILE__) . 'css/animate.min.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-font-awesome', plugin_dir_url(__FILE__) . 'css/poll-maker-font-awesome-all.css', array(), $this->version, 'all');
wp_enqueue_style('ays_poll_bootstrap', plugin_dir_url(__FILE__) . 'css/bootstrap.min.css', array(), $this->version, 'all');
wp_enqueue_style($this->plugin_name.'-jquery-datetimepicker', plugin_dir_url(__FILE__) . 'css/jquery-ui-timepicker-addon.css', array(), $this->version, 'all');
wp_enqueue_style('ays-poll-select2', plugin_dir_url(__FILE__) . 'css/select2.min.css', array(), $this->version, 'all');
wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/poll-maker-ays-admin.css', array(), $this->version, 'all');
wp_enqueue_style($this->plugin_name.'popup-layer', plugin_dir_url(__FILE__) . 'css/poll-maker-ays-admin-popup-layer.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-dropdown', plugin_dir_url(__FILE__) . '/css/dropdown.min.css', array(), $this->version, 'all');
wp_enqueue_style( $this->plugin_name . '-transition', plugin_dir_url(__FILE__) . '/css/transition.min.css', array(), $this->version, 'all');
}
/**
* Register the JavaScript for the admin area.
*
* @since 1.0.0
*/
public function enqueue_scripts( $hook_suffix ) {
wp_enqueue_script( $this->plugin_name . '-dropdown-min', plugin_dir_url(__FILE__) . '/js/dropdown.min.js', array('jquery'), $this->version, true);
wp_enqueue_script( $this->plugin_name . '-transition-min', plugin_dir_url(__FILE__) . '/js/transition.min.js', array('jquery'), $this->version, true);
global $wp_version;
if (false !== strpos($hook_suffix, "plugins.php")){
wp_enqueue_script('sweetalert-js-poll', plugin_dir_url(__FILE__) . 'js/sweetalert2.all.min.js', array('jquery'), $this->version, true);
wp_enqueue_script($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'js/admin.js', array('jquery'), $this->version, true);
wp_localize_script($this->plugin_name . '-admin', 'apm_admin_ajax_obj', array('ajaxUrl' => admin_url('admin-ajax.php')));
}
$version1 = $wp_version;
$operator = '>=';
$version2 = '5.5';
$versionCompare = $this->versionCompare($version1, $operator, $version2);
if ($versionCompare) {
wp_enqueue_script( $this->plugin_name.'-wp-load-scripts', plugin_dir_url(__FILE__) . 'js/ays-wp-load-scripts.js', array(), $this->version, true);
}
if (false === strpos($hook_suffix, $this->plugin_name)) {
return;
}
$poll_banner_date = $this->ays_poll_update_banner_time();
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Poll_Maker_Ays_Loader as all of the hooks are defined
* in that particular class.
*
* The Poll_Maker_Ays_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_media();
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);
wp_enqueue_script('ays_poll_popper', plugin_dir_url(__FILE__) . 'js/popper.min.js', array('jquery'), $this->version, true);
wp_enqueue_script('ays_poll_bootstrap', plugin_dir_url(__FILE__) . 'js/bootstrap.min.js', array('jquery'), $this->version, true);
wp_enqueue_script('ays_poll_select2', plugin_dir_url(__FILE__) . 'js/select2.min.js', array('jquery'), $this->version, true);
wp_enqueue_script('sweetalert-js-poll', plugin_dir_url(__FILE__) . 'js/sweetalert2.all.min.js', array('jquery'), $this->version, true);
wp_enqueue_script( $this->plugin_name."-jquery.datetimepicker.js", plugin_dir_url( __FILE__ ) . 'js/jquery-ui-timepicker-addon.js', array( 'jquery' ), $this->version, true );
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);
wp_enqueue_script( $this->plugin_name . '-charts-google', plugin_dir_url(__FILE__) . 'js/google-chart.js', array('jquery'), $this->version, false);
wp_localize_script('ays-poll-admin-js', 'pollLangObj', array(
'pollBannerDate' => $poll_banner_date,
'errorMsg' => __( "Error", $this->plugin_name ),
'somethingWentWrong' => __( "Maybe something went wrong.", $this->plugin_name ),
'add' => __( 'Add', $this->plugin_name),
'proVersionText' => __( 'This property aviable only in pro version', $this->plugin_name),
'answersMinCount' => __( 'Sorry minimum count of answers should be 2', $this->plugin_name),
'copied' => __( 'Copied!', $this->plugin_name),
'clickForCopy' => __( 'Click for copy.', $this->plugin_name),
'nextPollPage' => __( 'Are you sure you want to go to the next poll page?', $this->plugin_name),
'prevPollPage' => __( 'Are you sure you want to go to the previous poll page?', $this->plugin_name),
'areYouSure' => __( 'Are you sure you want to redirect to another poll? Note that the changes made in this poll will not be saved.', $this->plugin_name),
'deleteAnswer' => __( 'Are you sure you want to delete this answer?', $this->plugin_name),
) );
wp_localize_script('ays-poll-admin-js', 'poll', array(
'ajax' => admin_url('admin-ajax.php'),
'pleaseEnterMore' => __( "Please select more", $this->plugin_name ),
));
$color_picker_strings = array(
'clear' => __( 'Clear', $this->plugin_name ),
'clearAriaLabel' => __( 'Clear color', $this->plugin_name ),
'defaultString' => __( 'Default', $this->plugin_name ),
'defaultAriaLabel' => __( 'Select default color', $this->plugin_name ),
'pick' => __( 'Select Color', $this->plugin_name ),
'defaultLabel' => __( 'Color value', $this->plugin_name ),
);
wp_localize_script( $this->plugin_name.'-wp-color-picker-alpha', 'wpColorPickerL10n', $color_picker_strings );
}
/**
* De-register JavaScript files for the admin area.
*
* @since 1.0.0
*/
public function disable_scripts($hook_suffix) {
if (false !== strpos($hook_suffix, $this->plugin_name)) {
if (is_plugin_active('ai-engine/ai-engine.php')) {
wp_deregister_script('mwai');
wp_deregister_script('mwai-vendor');
wp_dequeue_script('mwai');
wp_dequeue_script('mwai-vendor');
}
}
}
public function codemirror_enqueue_scripts($hook) {
if(strpos($hook, $this->plugin_name) !== false){
if(function_exists('wp_enqueue_code_editor')){
$cm_settings['codeEditor'] = wp_enqueue_code_editor(array(
'type' => 'text/css',
'codemirror' => array(
'inputStyle' => 'contenteditable',
'theme' => 'cobalt',
)
));
wp_enqueue_script('wp-theme-plugin-editor');
wp_localize_script('wp-theme-plugin-editor', 'cm_settings', $cm_settings);
wp_enqueue_style('wp-codemirror');
}
}
}
public function versionCompare($version1, $operator, $version2) {
$_fv = intval ( trim ( str_replace ( '.', '', $version1 ) ) );
$_sv = intval ( trim ( str_replace ( '.', '', $version2 ) ) );
if (strlen ( $_fv ) > strlen ( $_sv )) {
$_sv = str_pad ( $_sv, strlen ( $_fv ), 0 );
}
if (strlen ( $_fv ) < strlen ( $_sv )) {
$_fv = str_pad ( $_fv, strlen ( $_sv ), 0 );
}
return version_compare ( ( string ) $_fv, ( string ) $_sv, $operator );
}
public function add_plugin_admin_menu() {
/*
* Check unread results
*
*/
global $wpdb;
$sql = "SELECT COUNT(unread) FROM {$wpdb->prefix}ayspoll_reports WHERE unread=1";
$unread_results = $wpdb->get_var($sql);
$show = $unread_results > 0 ? '' : "apm-no-results";
/*
* Add a settings page for this plugin to the Settings menu.
*
* NOTE: Alternative menu locations are available via WordPress administration menu functions.
*
* Administration Menus: http://codex.wordpress.org/Administration_Menus
*
*/
$menu_item = ($unread_results == 0) ? 'Poll Maker' : 'Poll Maker' . '' . $unread_results . ' ';
$this->capability = $this->poll_maker_capabilities();
$capability = $this->poll_maker_capabilities();
$hook_poll = add_menu_page('Poll Maker',
$menu_item,
$capability,
$this->plugin_name,
array($this,'display_plugin_polls_page'),
POLL_MAKER_AYS_ADMIN_URL . '/images/icons/icon-poll-maker-128x128.svg', '6.33'
);
add_action("load-$hook_poll", array($this, 'screen_option_polls'));
add_action("load-$hook_poll", array($this, 'add_tabs'));
$hook_results_each = add_submenu_page(
'all_results_slug',
__('Results per poll', $this->plugin_name),
__('Results per poll', $this->plugin_name),
$capability,
$this->plugin_name . '-results-each',
array($this, 'display_plugin_results_each_page')
);
add_action("load-$hook_results_each", array($this, 'screen_option_each_results'));
}
public function add_plugin_polls_submenu() {
$capability = $this->poll_maker_capabilities();
$hook_polls = add_submenu_page(
$this->plugin_name,
__('All Polls', $this->plugin_name),
__('All Polls', $this->plugin_name),
$capability,
$this->plugin_name,
array($this, 'display_plugin_polls_page')
);
add_action("load-$hook_polls", array($this, 'screen_option_polls'));
add_action("load-$hook_polls", array($this, 'add_tabs'));
}
public function add_plugin_add_new_poll_submenu() {
$capability = $this->poll_maker_capabilities();
$hook_polls = add_submenu_page(
$this->plugin_name,
__('Add new', $this->plugin_name),
__('Add new', $this->plugin_name),
$capability,
$this->plugin_name . '-add-new',
array($this, 'display_plugin_add_new_poll_page')
);
}
public function add_plugin_categories_submenu() {
$capability = $this->poll_maker_capabilities();
$hook_cats = add_submenu_page(
$this->plugin_name,
__('Categories', $this->plugin_name),
__('Categories', $this->plugin_name),
$capability,
$this->plugin_name . '-cats',
array($this, 'display_plugin_cats_page')
);
add_action("load-$hook_cats", array($this, 'screen_option_cats'));
add_action("load-$hook_cats", array($this, 'add_tabs'));
}
public function add_plugin_results_submenu() {
/*
* Check unread results
*
*/
global $wpdb;
$sql = "SELECT COUNT(unread) FROM {$wpdb->prefix}ayspoll_reports WHERE unread=1";
$unread_results = $wpdb->get_var($sql);
$show = $unread_results > 0 ? '' : "apm-no-results";
$capability = $this->poll_maker_capabilities();
$hook_results = add_submenu_page(
$this->plugin_name,
__('Results', $this->plugin_name),
__('Results', $this->plugin_name) . " $unread_results ",
$capability,
$this->plugin_name . '-results',
array($this, 'display_plugin_results_page')
);
add_action("load-$hook_results", array($this, 'screen_option_results'));
add_action("load-$hook_results", array($this, 'add_tabs'));
$hook_all_results = add_submenu_page(
'all_results_slug',
__('Results', $this->plugin_name),
$capability,
$this->capability,
$this->plugin_name . '-all-results',
array($this, 'display_plugin_all_results_page')
);
add_action("load-$hook_all_results", array($this, 'screen_option_all_poll_results'));
add_filter('parent_file', array($this,'poll_maker_select_submenu'));
}
public function add_plugin_formfields_submenu() {
$hook_formfields = add_submenu_page(
$this->plugin_name,
__('Custom Fields', $this->plugin_name),
__('Custom Fields', $this->plugin_name),
'manage_options',
$this->plugin_name . '-formfields',
array($this, 'display_plugin_formfields_page')
);
add_action("load-$hook_formfields", array($this, 'add_tabs'));
}
public function add_plugin_general_settings_submenu() {
$hook_settings = add_submenu_page($this->plugin_name,
__('General Settings', $this->plugin_name),
__('General Settings', $this->plugin_name),
'manage_options',
$this->plugin_name . '-settings',
array($this, 'display_plugin_settings_page')
);
add_action("load-$hook_settings", array($this, 'screen_option_settings'));
add_action("load-$hook_settings", array($this, 'add_tabs'));
}
public function add_plugin_how_to_use_submenu() {
$hook_pro_features = add_submenu_page(
$this->plugin_name,
__('How to use', $this->plugin_name),
__('How to use', $this->plugin_name),
'manage_options',
$this->plugin_name . '-how-to-use',
array($this, 'display_plugin_how_to_use_page')
);
add_action("load-$hook_pro_features", array($this, 'add_tabs'));
}
public function add_plugin_pro_features_submenu() {
$hook_pro_features = add_submenu_page(
$this->plugin_name,
__('PRO features', $this->plugin_name),
__('PRO features', $this->plugin_name),
'manage_options',
$this->plugin_name . '-pro-features',
array($this, 'display_plugin_pro_features_page')
);
add_action("load-$hook_pro_features", array($this, 'add_tabs'));
}
public function add_plugin_featured_plugins_submenu(){
$hook_pro_features = add_submenu_page( $this->plugin_name,
__('Our products', $this->plugin_name),
__('Our products', $this->plugin_name),
'manage_options',
$this->plugin_name . '-featured-plugins',
array($this, 'display_plugin_featured_plugins_page')
);
add_action("load-$hook_pro_features", array($this, 'add_tabs'));
}
public function display_poll_creation_popup() {
$is_challange_enabled = get_option('ays_poll_maker_poll_creation_challange', false);
if (!$is_challange_enabled) {
return;
}
if (isset($_GET['page']) && strpos($_GET['page'], POLL_MAKER_AYS_NAME) !== false) {
?>
Add a New Poll
Name Your Poll
Add Options
Save the Poll
Copy the Shortcode
Embed in a Page
Poll Maker
plugin_name) . '">' . __('Settings', $this->plugin_name) . '',
'' . __('Demo', $this->plugin_name) . ' ',
'' . __('Upgrade 20% Sale', $this->plugin_name) . ' ',
);
return array_merge($settings_link, $links);
}
public function add_poll_row_meta( $links, $file ) {
if ( POLL_MAKER_AYS_BASENAME == $file ) {
$row_meta = array(
'ays-poll-support' => '' . esc_html__( 'Free Support', $this->plugin_name ) . ' ',
'ays-poll-documentation' => '' . esc_html__( 'Documentation', $this->plugin_name ) . ' ',
'ays-poll-rate-us' => '' . esc_html__( 'Rate us', $this->plugin_name ) . ' ',
'ays-poll-video-tutorial' => '' . esc_html__( 'Video tutorial', $this->plugin_name ) . ' ',
);
return array_merge( $links, $row_meta );
}
return $links;
}
/**
* Render the settings page for this plugin.
*
* @since 1.0.0
*/
public function display_plugin_polls_page() {
$action = (isset($_GET['action'])) ? sanitize_text_field($_GET['action']) : '';
switch ( $action ) {
case 'add':
include_once 'partials/poll-maker-ays-polls-actions.php';
break;
case 'edit':
include_once 'partials/poll-maker-ays-polls-actions.php';
break;
default:
include_once 'partials/poll-maker-ays-admin-display.php';
}
}
public function display_plugin_add_new_poll_page() {
$add_new_poll_url = admin_url('admin.php?page=' . $this->plugin_name . '&action=add');
wp_redirect($add_new_poll_url);
}
public function display_plugin_cats_page() {
$action = (isset($_GET['action'])) ? sanitize_text_field($_GET['action']) : '';
switch ( $action ) {
case 'add':
include_once 'partials/categories/actions/poll-maker-ays-categories-actions.php';
break;
case 'edit':
include_once 'partials/categories/actions/poll-maker-ays-categories-actions.php';
break;
default:
include_once 'partials/categories/poll-maker-ays-categories-display.php';
}
}
public function display_plugin_results_page() {
include_once 'partials/results/poll-maker-ays-results-display.php';
}
public function display_plugin_results_each_page() {
include_once 'partials/results/poll-maker-ays-each-results-display.php';
}
public function display_plugin_formfields_page() {
include_once 'partials/features/poll-maker-formfields_page-display.php';
}
public function display_plugin_pro_features_page() {
include_once 'partials/features/poll-maker-pro-features-display.php';
}
public function display_plugin_how_to_use_page() {
include_once 'partials/features/poll-maker-how-to-use-display.php';
}
public function display_plugin_featured_plugins_page(){
include_once('partials/features/poll-maker-featured-display.php');
}
public static function set_screen( $status, $option, $value ) {
return $value;
}
public function screen_option_polls() {
$option = 'per_page';
$args = array(
'label' => __('Polls', $this->plugin_name),
'default' => 20,
'option' => 'polls_per_page',
);
add_screen_option($option, $args);
$this->polls_obj = new Polls_List_Table($this->plugin_name);
$this->settings_obj = new Poll_Maker_Settings_Actions($this->plugin_name);
}
public function screen_option_cats() {
$option = 'per_page';
$args = array(
'label' => __('Categories', $this->plugin_name),
'default' => 5,
'option' => 'poll_cats_per_page',
);
add_screen_option($option, $args);
$this->cats_obj = new Pma_Categories_List_Table($this->plugin_name);
$this->settings_obj = new Poll_Maker_Settings_Actions($this->plugin_name);
}
public function screen_option_results() {
$option = 'per_page';
$args = array(
'label' => __('Results', $this->plugin_name),
'default' => 50,
'option' => 'poll_results_per_page',
);
add_screen_option($option, $args);
$this->results_obj = new Pma_Results_List_Table($this->plugin_name);
// $this->answer_results_obj = new Poll_Answer_Results($this->plugin_name);
}
public function screen_option_each_results() {
$option = 'per_page';
$args = array(
'label' => __('Results per poll', $this->plugin_name),
'default' => 50,
'option' => 'poll_each_results_per_page',
);
add_screen_option($option, $args);
$this->each_results_obj = new Pma_Each_Results_List_Table($this->plugin_name);
}
public function register_poll_ays_widget() {
global $wpdb;
$poll_table = esc_sql($wpdb->prefix . "ayspoll_polls");
$sql = "SELECT COUNT(*) FROM ".$poll_table;
$c = $wpdb->get_var($sql);
if ($c == 0) {
return;
} else {
register_widget('Poll_Maker_Widget');
}
}
public function poll_maker_el_widgets_registered() {
wp_enqueue_style($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'css/admin.css', array(), $this->version, 'all');
// We check if the Elementor plugin has been installed / activated.
if ( defined( 'ELEMENTOR_PATH' ) && class_exists( 'Elementor\Widget_Base' ) ) {
// get our own widgets up and running:
// copied from widgets-manager.php
if ( class_exists( 'Elementor\Plugin' ) ) {
if ( is_callable( 'Elementor\Plugin', 'instance' ) ) {
$elementor = Elementor\Plugin::instance();
if ( isset( $elementor->widgets_manager ) ) {
if ( method_exists( $elementor->widgets_manager, 'register_widget_type' ) ) {
$widget_file = 'plugins/elementor/poll_maker_elementor.php';
$template_file = locate_template( $widget_file );
if ( !$template_file || !is_readable( $template_file ) ) {
$template_file = POLL_MAKER_AYS_DIR.'pb_templates/poll_maker_elementor.php';
}
if ( $template_file && is_readable( $template_file ) ) {
require_once $template_file;
Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Elementor\Widget_Poll_Maker_Elementor() );
}
}
}
}
}
}
}
public function apm_deactivate_plugin_option() {
$request_value = esc_sql( sanitize_text_field( $_REQUEST['upgrade_plugin'] ) );
$upgrade_option = get_option('ays_poll_maker_upgrade_plugin');
if ($upgrade_option === '') {
add_option('ays_poll_maker_upgrade_plugin', $request_value);
} else {
update_option('ays_poll_maker_upgrade_plugin', $request_value);
}
ob_end_clean();
$ob_get_clean = ob_get_clean();
echo json_encode(array('option' => get_option('ays_poll_maker_upgrade_plugin')));
wp_die();
}
public function apm_show_results() {
global $wpdb;
$results_table = $wpdb->prefix . "ayspoll_reports";
// $polls_obj = new Polls_List_Table($this->plugin_name);
if (isset($_POST['action']) && $_POST['action'] == 'apm_show_results') {
$id = isset($_POST['result']) ? absint($_POST['result']) : 0;
$is_details = isset($_POST['is_details']) && absint($_POST['is_details']) > 0 ? true : false;
$row = '';
$wpdb->update($results_table,
array('unread' => 0),
array('id' => $id),
array('%d'),
array('%d')
);
if ($id > 0 && $is_details) {
$result = $wpdb->get_row("SELECT * FROM $results_table WHERE id=$id", "ARRAY_A");
$multivote_res = false;
$result['multi_answer_id'] = json_decode($result['multi_answer_ids']);
if (isset($result['multi_answer_id']) && count($result['multi_answer_id']) > 1) {
$multivote_res = true;
}
$multivote_answers = array();
if ($multivote_res) {
foreach ($result['multi_answer_id'] as $m_key => $m_val) {
$multi_answer = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}ayspoll_answers WHERE id=".$m_val, "ARRAY_A");
$multivote_answers[] = $multi_answer['answer'];
}
$answ_poll_id = $multi_answer['poll_id'];
} else {
$answer = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}ayspoll_answers WHERE id={$result['answer_id']}", "ARRAY_A");
$multivote_answers[] = $answer['answer'];
$answ_poll_id = $answer['poll_id'];
}
$poll = $this->get_poll_by_id($answ_poll_id);
$user_ip = $result['user_ip'];
$info = ($result['other_info'] == '' || $result['other_info'] === null || $result['other_info'] === 0) ? array() : json_decode($result['other_info'], true);
$time = $result['vote_date'];
$user_email = $result['user_email'];
$country = '';
$region = '';
$city = '';
$json = isset($user_ip) && $user_ip != '' ? json_decode(file_get_contents("http://ipinfo.io/{$user_ip}/json")) : null;
if ($json !== null) {
$country = isset($json->country) && $json->country != '' ? $json->country : '';
$region = isset($json->region) && $json->region != '' ? $json->region : '';
$city = isset($json->city) && $json->city != '' ? $json->city : '';
}
$from = "$city, $region, $country, $user_ip";
$row = '' . __('Poll Information', $this->plugin_name) . "
". __('Poll Title', $this->plugin_name)."
{$poll['title']}
";
$row .= "
". __('Poll Type', $this->plugin_name)."
" . ucfirst($poll['type']) . "
";
switch ( $poll['type'] ) {
case 'choosing':
case 'text':
$row .= "
". __('Answer', $this->plugin_name)."
" . (in_array($poll['answers'][0]['answer'], $multivote_answers) ? "" . stripslashes($poll['answers'][0]['answer']) . " " : stripslashes($poll['answers'][0]['answer'])) . "
";
foreach ( $poll['answers'] as $index => $ans ) {
if ($index == 0) {
continue;
}
$row .= "
" . (in_array($ans['answer'], $multivote_answers) ? "" . stripslashes($ans['answer']) . " " : stripslashes($ans['answer'])) . "
";
}
break;
case 'rating':
$row .= "
". __('Answer', $this->plugin_name)."
";
if ($poll['view_type'] == 'star') {
foreach ( $poll['answers'] as $ans ) {
$row .= " ";
}
} elseif ('emoji') {
$emoji = array(
"ays_poll_fa-dizzy",
"ays_poll_fa-smile",
"ays_poll_fa-meh",
"ays_poll_fa-frown",
"ays_poll_fa-tired",
);
foreach ( $poll['answers'] as $i => $ans ) {
$index = (count($poll['answers']) / 2 - $i + 1.5);
$row .= " ";
}
}
$row .= "
";
break;
case 'voting':
$row .= "
". __('Answer', $this->plugin_name)."
";
$icons = array(
'hand' => array(
"ays_poll_fa-thumbs-up",
"ays_poll_fa-thumbs-down",
),
'emoji' => array(
"ays_poll_fa-smile",
"ays_poll_fa-frown",
),
);
$view = $poll['view_type'];
$row .= "
";
$row .= "
";
break;
}
$row .= "
". __('Answer Datetime', $this->plugin_name)."
" . (date('H:i:s d.m.Y', strtotime($time))) . "
";
$row .= " ";
$row .= '' . __('User Information', $this->plugin_name) . " ";
if ($json !== null) {
$row .= "
". __('User IP', $this->plugin_name)."
$from
";
}
if(!empty($user_email)){
$row .= "
". __('User E-mail', $this->plugin_name)."
$user_email
";
}
foreach ( $info as $key => $value ) {
if ($key == 'not_show_user_id') {
continue;
}
$row .= "
". $key ."
". $value ."
";
}
}
ob_end_clean();
$ob_get_clean = ob_get_clean();
echo json_encode([
"status" => true,
"rows" => $row,
]);
wp_die();
}
}
public function get_poll_by_id( $id, $decode = true ) {
global $wpdb;
$sql = "SELECT * FROM {$wpdb->prefix}ayspoll_polls WHERE id=" . absint(intval($id));
$poll = $wpdb->get_row($sql, 'ARRAY_A');
if (empty($poll)) {
return array();
}
$sql = "SELECT * FROM {$wpdb->prefix}ayspoll_answers WHERE poll_id=" . absint(intval($id)) . " ORDER BY id ASC";
$poll['answers'] = $wpdb->get_results($sql, 'ARRAY_A');
if ($decode) {
$json = $poll['styles'];
$poll['styles'] = json_decode($json, true);
$poll['categories'] = trim($poll['categories'], ',');
$cats = explode(',', $poll['categories']);
$poll['categories'] = !empty($cats) ? $cats : [];
$all_fields = $this->get_all_formfields();
if (isset($poll['styles']['fields'])) {
$poll['fields'] = array();
$fields = explode(',', $poll['styles']['fields']);
foreach ( $fields as $field ) {
$index = array_search($field, array_column($all_fields, 'slug'));
if ($index !== false) {
$poll['fields'][] = $all_fields[$index];
}
}
}
if (isset($poll['styles']['required_fields'])) {
$poll['required_fields'] = array();
$fields = explode(',', $poll['styles']['required_fields']);
foreach ( $fields as $field ) {
$index = array_search($field, array_column($all_fields, 'slug'));
if ($index !== false) {
$poll['required_fields'][] = $all_fields[$index];
}
}
}
}
return $poll;
}
public function get_all_formfields() {
global $wpdb;
$all = array(
array(
"id" => 0,
"name" => "Name",
"type" => "text",
"slug" => "apm-name",
"published" => 1,
),
array(
"id" => 0,
"name" => "E-mail",
"type" => "email",
"slug" => "apm-email",
"published" => 1,
),
array(
"id" => 0,
"name" => "Phone",
"type" => "tel",
"slug" => "apm_phone",
"published" => 1,
),
);
return $all;
}
public function screen_option_settings() {
$this->polls_obj = new Polls_List_Table($this->plugin_name);
$this->settings_obj = new Poll_Maker_Settings_Actions($this->plugin_name);
}
public function display_plugin_settings_page() {
include_once('partials/settings/poll-maker-settings.php');
}
public function ays_get_mailchimp_lists( $username, $api_key ) {
if (!empty($api_key) && strpos($api_key, '-') !== false) {
$api_postfix = explode("-", $api_key)[1];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://" . $api_postfix . ".api.mailchimp.com/3.0/lists",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_USERPWD => "$username:$api_key",
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
// CURLOPT_POSTFIELDS => "undefined=",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error";
} else {
return json_decode($response, true);
}
}
return array();
}
public function ays_poll_create_author() {
$search = isset($_REQUEST['search']) && $_REQUEST['search'] != '' ? sanitize_text_field($_REQUEST['search']) : null;
$checked = isset($_REQUEST['val']) && $_REQUEST['val'] !='' ? sanitize_text_field($_REQUEST['val']) : null;
$args = array();
$arg = '';
if($search !== null){
$arg .= $search;
$arg .= '*';
$args['search'] = $arg;
}
$users = get_users( $args );
$response = array(
'results' => array()
);
if(empty($args)){
$reports_users = '';
}
foreach ($users as $key => $user) {
if ($checked !== null) {
if ($user->ID == $checked) {
continue;
}else{
$response['results'][] = array(
'id' => $user->ID,
'text' => $user->display_name
);
}
}else{
$response['results'][] = array(
'id' => $user->ID,
'text' => $user->display_name,
);
}
}
ob_end_clean();
echo json_encode($response);
wp_die();
}
public static function validateDate($date, $format = 'Y-m-d H:i:s'){
$d = DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}
public static function is_classic_editor_plugin_active() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
if ( is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
return true;
}
return false;
}
public static function is_active_gutenberg() {
// Gutenberg plugin is installed and activated.
$gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );
// Block editor since 5.0.
$block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );
if ( ! $gutenberg && ! $block_editor ) {
return false;
}
if ( self::is_classic_editor_plugin_active() ) {
$editor_option = get_option( 'classic-editor-replace' );
$block_editor_active = array( 'no-replace', 'block' );
return in_array( $editor_option, $block_editor_active, true );
}
return true;
}
public static function ays_restriction_string($type, $x, $length){
$output = "";
switch($type){
case "char":
if(strlen($x)<=$length){
$output = $x;
} else {
$output = substr($x,0,$length) . '...';
}
break;
case "word":
$res = explode(" ", $x);
if(count($res)<=$length){
$output = implode(" ",$res);
} else {
$res = array_slice($res,0,$length);
$output = implode(" ",$res) . '...';
}
break;
}
return $output;
}
public static function get_listtables_title_length( $listtable_name ) {
global $wpdb;
$settings_table = $wpdb->prefix . "ayspoll_settings";
$sql = "SELECT meta_value FROM ".$settings_table." WHERE meta_key = 'options'";
$result = $wpdb->get_var($sql);
$options = ($result == "") ? array() : json_decode($result, true);
$listtable_title_length = 5;
if(! empty($options) ){
switch ( $listtable_name ) {
case 'polls':
$listtable_title_length = (isset($options['poll_title_length']) && intval($options['poll_title_length']) != 0) ? absint(intval($options['poll_title_length'])) : 5;
break;
case 'categories':
$listtable_title_length = (isset($options['poll_category_title_length']) && intval($options['poll_category_title_length']) != 0) ? absint(intval($options['poll_category_title_length'])) : 5;
break;
case 'results':
$listtable_title_length = (isset($options['poll_results_title_length']) && intval($options['poll_results_title_length']) != 0) ? absint(intval($options['poll_results_title_length'])) : 5;
break;
default:
$listtable_title_length = 5;
break;
}
return $listtable_title_length;
}
return $listtable_title_length;
}
public function poll_maker_select_submenu($file) {
global $plugin_page;
if ("poll-maker-ays-results-each" == $plugin_page) {
$plugin_page = $this->plugin_name."-results";
}
return $file;
}
protected function poll_maker_capabilities(){
global $wpdb;
$sql = "SELECT meta_value FROM {$wpdb->prefix}ayspoll_settings WHERE `meta_key` = 'user_roles'";
$result = $wpdb->get_var($sql);
$capability = 'manage_options';
if($result !== null){
$ays_user_roles = json_decode($result, true);
if(is_user_logged_in()){
$current_user = wp_get_current_user();
$current_user_roles = $current_user->roles;
$ishmar = 0;
foreach($current_user_roles as $r){
if(in_array($r, $ays_user_roles)){
$ishmar++;
}
}
if($ishmar > 0){
$capability = "read";
}
}
}
return $capability;
}
public function get_next_or_prev_row_by_id( $id, $type = "next", $table = "ayspoll_polls" ) {
global $wpdb;
if ( is_null( $table ) || empty( $table ) ) {
return null;
}
$ays_table = esc_sql( $wpdb->prefix . $table );
$where = array();
$where_condition = "";
$id = (isset( $id ) && $id != "" && absint($id) != 0) ? absint( sanitize_text_field( $id ) ) : null;
$type = (isset( $type ) && $type != "") ? sanitize_text_field( $type ) : "next";
if ( is_null( $id ) || $id == 0 ) {
return null;
}
switch ( $type ) {
case 'prev':
$where[] = ' `id` < ' . $id . ' ORDER BY `id` DESC ';
break;
case 'next':
default:
$where[] = ' `id` > ' . $id;
break;
}
if( ! empty($where) ){
$where_condition = " WHERE " . implode( " AND ", $where );
}
$sql = "SELECT `id` FROM {$ays_table} ". $where_condition ." LIMIT 1;";
$results = $wpdb->get_row( $sql, 'ARRAY_A' );
return $results;
}
public function poll_maker_admin_footer($a){
if(isset($_REQUEST['page'])){
if(false !== strpos($_REQUEST['page'], $this->plugin_name)){
?>
plugin_name); ?>
plugin_name . '-sale-banner'] )
// && wp_verify_nonce( $_POST[$this->plugin_name . '-sale-banner'], $this->plugin_name . '-sale-banner' ) && current_user_can('manage_options')) {
// $sale_date = 'plugin_sale';
// update_option('ays_poll_sale_btn_'.$sale_date, 1);
// update_option('ays_poll_sale_date_'.$sale_date, current_time( 'mysql' ));
// }
if(isset($_POST['ays_poll_sale_btn_poll_countdown_for_two_months'])){
$sale_date = sanitize_text_field($_POST['ays_poll_sale_btn_poll_countdown_for_two_months']);
$dismiss_two_months = true;
update_option('ays_poll_sale_notification_two_months_'.$sale_date, 1);
update_option('ays_poll_sale_date_'.$sale_date, current_time( 'mysql' ));
}
$one_day = 60*60*24;
$poll_sales = array(
'plugin_sale' => array(
'status' => 'active',
'time' => ($one_day * 5),
),
'mega_bundle' => array(
'status' => 'inactive',
'time' => ($one_day * 5),
),
'new_mega_bundle' => array(
'status' => 'inactive',
'time' => ($one_day * 7),
),
'small_spring' => array(
'status' => 'inactive',
'time' => ($one_day * 7),
),
'mega_bundle_new' => array(
'status' => 'inactive',
'time' => ($one_day * 7),
),
'business_bundle' => array(
'status' => 'inactive',
'time' => ($one_day * 7),
),
'black_friday' => array(
'status' => 'inactive',
'time' => ($one_day * 5),
),
'winter_bundle' => array(
'status' => 'inactive',
'time' => ($one_day * 5),
),
'poll_countdown' => array(
'status' => 'inactive',
'time' => ($one_day * 5),
),
'halloween_bundle' => array(
'status' => 'inactive',
'time' => ($one_day * 5),
),
'christmas_message' => array(
'status' => 'inactive',
'time' => ($one_day * 7),
),
);
if (isset($_GET['page']) && strpos($_GET['page'], POLL_MAKER_AYS_NAME) !== false) {
foreach($poll_sales as $sale => $status){
$ays_poll_sale_date = '';
if(isset($status['status']) && $status['status'] == 'active'){
$ays_poll_sale_date = get_option('ays_poll_sale_date_'.$sale);
$ays_poll_two_months_flag = intval(get_option('ays_poll_sale_notification_two_months_'.$sale));
$current_date = current_time( 'mysql' );
$date_diff = strtotime($current_date) - intval(strtotime($ays_poll_sale_date)) ;
$val = isset($status['time']) ? $status['time'] : $one_day * 5;
if($ays_poll_two_months_flag > 0){
$val = $one_day * 60;
}
$days_diff = $date_diff / $val;
if(intval($days_diff) > 0 ){
update_option('ays_poll_sale_notification_'.$sale, 0);
update_option('ays_poll_sale_btn_'.$sale, 0);
update_option('ays_poll_sale_notification_two_months_'.$sale, 0);
}
$ays_poll_flag = intval(get_option('ays_poll_sale_notification_'.$sale));
$ays_poll_flag += intval(get_option('ays_poll_sale_btn_'.$sale));
$ays_poll_flag += $ays_poll_two_months_flag;
if($ays_poll_flag == 0){
$ays_poll_sale_message = 'ays_poll_sale_message_'.$sale;
$this->ays_poll_sale_message_poll_pro();
}
}
}
}
}
public function ays_poll_dismiss_button(){
$data = array(
'status' => false,
);
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'ays_poll_dismiss_button') {
if( (isset( $_REQUEST['_ajax_nonce'] ) && wp_verify_nonce( $_REQUEST['_ajax_nonce'], POLL_MAKER_AYS_NAME . '-sale-banner' )) && current_user_can( 'manage_options' )){
$sale_date = 'plugin_sale';
update_option('ays_poll_sale_btn_'.$sale_date, 1);
update_option('ays_poll_sale_date_'.$sale_date, current_time( 'mysql' ));
$data['status'] = true;
}
}
ob_end_clean();
$ob_get_clean = ob_get_clean();
echo json_encode($data);
wp_die();
}
// Poll plugin sale
// public function ays_poll_sale_message($flag){
// if($flag == 0){
//
//
//
//
//
//
//
//
// 30% SALE on Poll Maker premium plans!",POLL_MAKER_AYS_NAME);
//
//
//
// Check it out!",POLL_MAKER_AYS_NAME);
//
//
//
//
//
//
//
//
50% SALE on 3 Powerful Plugins (Quiz, Survey, Poll)!",POLL_MAKER_AYS_NAME);?>
Check it out!",POLL_MAKER_AYS_NAME);?>
50% SALE on 13 Powerful Plugins!",POLL_MAKER_AYS_NAME);?>
Check it out!",POLL_MAKER_AYS_NAME);?>
';
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "Limited Time 55% SALE on Mega Bundle (Quiz + Survey + Poll)!", POLL_MAKER_AYS_NAME );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = __( "Hurry up! Ends on November 15. Check it out! ", POLL_MAKER_AYS_NAME );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' days ';
$content[] = ' Hours ';
$content[] = ' Minutes ';
$content[] = ' Seconds ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( 'Buy Now !', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = '
';
$content[] = '';
$content = implode( '', $content );
echo $content;
}
// Black friday bundle
public function ays_poll_sale_message_black_friday(){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( 'Poll Maker', POLL_MAKER_AYS_NAME ) . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( '20% off', POLL_MAKER_AYS_NAME ) . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '0 ' . __( 'Days', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = '0 ' . __( 'Hours', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = '0 ' . __( 'Minutes', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = '0 ' . __( 'Seconds', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo $content;
}
// Winter bundle
public function ays_poll_sale_message_winter_bundle(){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "The BIGGEST 50% SALE on Christmas Bundle Quiz+Survey+Poll)!", POLL_MAKER_AYS_NAME );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = __( "Hurry up! Ending on. Check it out! ", POLL_MAKER_AYS_NAME );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' days ';
$content[] = ' Hours ';
$content[] = ' Minutes ';
$content[] = ' Seconds ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( 'Buy Now !', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo $content;
}
public function ays_poll_sale_message_poll_pro(){
$content = array();
$content[] = '';
$content[] = '
';
// $content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "Poll Maker ", POLL_MAKER_AYS_NAME );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' ';
$content[] = __( "30 Days Money Back Guarantee", POLL_MAKER_AYS_NAME );
$content[] = ' ';
// $content[] = '
';
// $content[] = '
';
// $content[] = __( "Hurry up! Check it out! ", POLL_MAKER_AYS_ADMIN_URL );
// $content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "Offer ends in:", POLL_MAKER_AYS_NAME );
$content[] = '
';
$content[] = '
';
$content[] = ' days ';
$content[] = ' Hours ';
$content[] = ' Minutes ';
$content[] = ' Seconds ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo $content;
}
public function add_tabs() {
$screen = get_current_screen();
if ( ! $screen) {
return;
}
$title = __( 'General Information:', $this->plugin_name);
$content_text = '
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;
Choosing – create many options and let your users choose, or add their custom answers.
Rating – with this poll type, the visitors will be able to weigh via a 1-5 star rating system or emojis via the graphical interface.
Voting – make the participants evaluate your product by using like/dislike buttons or smiley/frown emojis.
Versus – Select two statements or images that are opposed to each other, and make your users choose the perfect one.
Range – the users will be able to choose the answer across the 0-100 scale.
Text – with this poll type the visitors should write down their own answers on the text boundaries.
Dropdown – the users will choose the multiple-choice answers from a list of answers appeared in a dropdown form.
Increase engagement of your website with the integrated, formatting, image, audio, video poll question types feature.
';
$sidebar_content = '' . __( 'For more information:', $this->plugin_name) . '
' .
'
' . __( 'Youtube video tutorials' , $this->plugin_name ) . '
' .
'
' . __( 'Documentation', $this->plugin_name ) . '
' .
'
' . __( 'Poll Maker plugin pro version', $this->plugin_name ) . '
' .
'
' . __( 'Poll Maker plugin demo', $this->plugin_name ) . '
';
$content = '' . __( 'Poll Maker Information', $this->plugin_name) . ' '
.'' .sprintf(__( '%s', $this->plugin_name ), $content_text).'
';
$help_tab_content = array(
'id' => 'survey_maker_help_tab',
'title' => $title,
'content' => $content
);
$screen->add_help_tab($help_tab_content);
$screen->set_help_sidebar($sidebar_content);
}
public static function ays_poll_sale_message_small_spring(){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '';
$content[] = __( "Spring is here! 50% SALE on Mega Bundle Quiz + Survey + Poll ", POLL_MAKER_AYS_NAME );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( 'Buy Now !', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo $content;
}
public function ays_poll_sale_message_poll_countdown(){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "Limited Time 20% SALE on Poll Maker Premium Versions ", POLL_MAKER_AYS_NAME );
$content[] = ' ';
$content[] = '
';
$content[] = __( "Hurry up! Check it out! ", POLL_MAKER_AYS_NAME );
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' days ';
$content[] = ' Hours ';
$content[] = ' Minutes ';
$content[] = ' Seconds ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo $content;
}
public static function ays_poll_halloween_bundle(){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = __( "Limited Time
20%
SALE on
Poll Maker
", POLL_MAKER_AYS_NAME );
$content[] = '
';
$content[] = '
';
$content[] = __( "Hurry up!
Check it out!
", POLL_MAKER_AYS_NAME );
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = 'DAYS
';
$content[] = 'HOURS
';
$content[] = 'MINS
';
$content[] = 'SECS
';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo $content;
}
// Christmas banner
public static function ays_poll_sale_message_christmas_message(){
$content = array();
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
' . __( 'Poll Maker Plugin', POLL_MAKER_AYS_NAME ) . '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = ' ' . __( 'Days', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = ' ' . __( 'Hours', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = ' ' . __( 'Minutes', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = ' ' . __( 'Seconds', POLL_MAKER_AYS_NAME ) . ' ';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '🚀 ';
$content[] = '⌛ ';
$content[] = '🔥 ';
$content[] = '💣 ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
echo $content;
}
public static function get_max_id( $table ) {
global $wpdb;
$db_table = $wpdb->prefix . 'ayspoll_'.$table;;
$sql = "SELECT MAX(id) FROM {$db_table}";
$result = intval( $wpdb->get_var( $sql ) );
return $result;
}
public function ays_poll_generate_message_vars_html( $poll_message_vars ) {
$content = array();
$var_counter = 0;
$content[] = '';
$content[] = '
';
$content[] = '
';
$content[] = ' ';
$content[] = '
';
$content[] = '
';
$content[] = '
';
$content[] = '
';
foreach($poll_message_vars as $var => $var_name){
$var_counter++;
$content[] = '
';
$content[] = ' ';
$content[] = '';
$content[] = ' ';
$content[] = ''. $var_name .' ';
$content[] = '
';
$content[] = ' ';
}
$content[] = '
';
$content[] = '
';
$content = implode( '', $content );
return $content;
}
public function ays_poll_update_banner_time(){
$date = time() + ( 3 * 24 * 60 * 60 ) + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
// $date = time() + ( 60 ) + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS); // for testing | 1 min
$next_3_days = date('M d, Y H:i:s', $date);
$ays_poll_banner_time = get_option('ays_poll_banner_time');
if ( !$ays_poll_banner_time || is_null( $ays_poll_banner_time ) ) {
update_option('ays_poll_banner_time', $next_3_days );
}
$get_ays_poll_banner_time = get_option('ays_poll_banner_time');
$val = 60*60*24*0.5; // half day
// $val = 60; // for testing | 1 min
$current_date = current_time( 'mysql' );
$date_diff = strtotime($current_date) - intval(strtotime($get_ays_poll_banner_time));
$days_diff = $date_diff / $val;
if(intval($days_diff) > 0 ){
update_option('ays_poll_banner_time', $next_3_days);
$get_ays_poll_banner_time = get_option('ays_poll_banner_time');
}
return $get_ays_poll_banner_time;
}
}