set_vars(); if ($this->check_condition()) /* checks the banner is active now */ { $this->banner_message = sprintf(__("💡Your feedback matters! Help Shape the Future of 'Related Products for WooCommerce' Plugin by taking Our quick Survey. Thank you for being an essential part of our community!", 'wt-woocommerce-related-products'), '', ''); /* button texts */ $this->never_btn_text = __("Not interested", 'wt-woocommerce-related-products'); $this->survey_btn_text = __("Lets take the survey", 'wt-woocommerce-related-products'); add_action('admin_notices', array($this, 'show_banner')); /* show banner */ add_action('admin_print_footer_scripts', array($this, 'add_banner_scripts')); /* add banner scripts */ add_action('wp_ajax_' . $this->ajax_action_name, array($this, 'process_user_action')); /* process banner user action */ } } /** * Set config vars */ public function set_vars() { $this->ajax_action_name = $this->plugin_prefix . '_process_user_survey_action'; $this->banner_state_option_name = $this->plugin_prefix . "_survey_request"; $this->banner_css_class = $this->plugin_prefix . "_survey_request"; $banner_state = absint(get_option($this->banner_state_option_name)); $this->current_banner_state = ($banner_state === 0 ? $this->current_banner_state : $banner_state); } /** * Update the banner state */ private function update_banner_state($val) { update_option($this->banner_state_option_name, $val); } /** * Prints the banner */ public function show_banner() { if(isset($_GET['page']) && 'wt-woocommerce-related-products' === $_GET['page'] && current_user_can('manage_options')) { $this->update_banner_state(1); /* update banner active state */ ?>
webtoffee_logo_url != "") { ?>

plugin_title, 'wt-woocommerce-related-products'); ?>

banner_message; ?>

never_btn_text ); ?> survey_btn_text ); ?>

plugin_prefix); $nonce = (isset($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''); if("" !== $nonce && wp_verify_nonce($nonce, $this->plugin_prefix)) { if (isset($_POST['wt_survey_action_type'])) { $action_type = sanitize_text_field($_POST['wt_survey_action_type']); /* current action is in allowed action list */ if (in_array($action_type, $this->allowed_action_type_arr)) { if ($action_type == 'never' || $action_type == 'closed') { $new_banner_state = 3; } elseif ($action_type == 'survey') { $new_banner_state = 4; } $this->update_banner_state($new_banner_state); } } } exit(); } /** * Add banner JS to admin footer */ public function add_banner_scripts() { $ajax_url = admin_url('admin-ajax.php'); $nonce = wp_create_nonce($this->plugin_prefix); ?> current_banner_state === 1) /* currently showing */ { $day_to_stop = strtotime('21 November 2023'); if( strtotime(date("Y/m/d")) >= $day_to_stop ) { /* current day is after 21th nov ,hide banner */ $this->update_banner_state(4); return false; } return true; } return false; } } new WT_CRP_Survey_Request();