mystickymenu
Last commit date
admin
1 week ago
dist
1 week ago
images
1 year ago
languages
1 week ago
class-email-signup.php
7 months ago
class-help.php
1 month ago
class-review-box.php
1 month ago
class-upgrade-box.php
1 month ago
index.php
8 years ago
mystickymenu-admin-widgetanalytics.php
1 week ago
mystickymenu-contact-leads.php
1 week ago
mystickymenu-deactivate-form.php
1 month ago
mystickymenu-fonts.php
2 years ago
mystickymenu-leads.php
1 week ago
mystickymenu-popup.php
1 month ago
mystickymenu-review-popup.php
9 months ago
mystickymenu.php
1 week ago
mystickymeny-new-welcomebar.php
1 week ago
readme.txt
1 week ago
recommended-plugins.php
7 months ago
uninstall.php
2 years ago
upgrade-to-pro.php
1 month ago
welcome-bar.php
1 week ago
class-email-signup.php
164 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Update Popup Class |
| 4 | * |
| 5 | * @author : Premio <contact@premio.io> |
| 6 | * @license : GPL2 |
| 7 | * */ |
| 8 | |
| 9 | if (defined('ABSPATH') === false) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * Class myStickyMenu_SIGNUP_CLASS |
| 15 | * |
| 16 | * Handles signup modal status, update actions, and manages display configurations |
| 17 | * for the My Sticky Elements plugin update-related content. |
| 18 | */ |
| 19 | class myStickyMenu_SIGNUP_CLASS { |
| 20 | |
| 21 | /** |
| 22 | * Option name used to store the update message for the "mystickymenu" feature. |
| 23 | */ |
| 24 | private static $update_message_option = 'mystickymenu_update_message'; |
| 25 | |
| 26 | /** |
| 27 | * Option name used to store the date for the next signup related to the "mystickymenu" feature. |
| 28 | */ |
| 29 | private static $next_signup_date = 'mystickymenu_next_signup_date'; |
| 30 | |
| 31 | /** |
| 32 | * Stores the status of the modal to be shown. |
| 33 | */ |
| 34 | private static $show_modal_name = 'mystickymenu_show_signup_modal'; |
| 35 | |
| 36 | /** |
| 37 | * Constructor method for the class. |
| 38 | * |
| 39 | * Initializes the MSE_UPDATE_POPUP_CONTENT constant with predefined array values |
| 40 | * containing plugin metadata, asset URLs, and visual elements. |
| 41 | * Also registers the WordPress AJAX callback for updating status. |
| 42 | * |
| 43 | * @return void |
| 44 | */ |
| 45 | public function __construct() { |
| 46 | // ajax callback |
| 47 | add_action( 'wp_ajax_sticky_menu_update_status', array($this, 'update_status')); |
| 48 | |
| 49 | |
| 50 | }//end __construct() |
| 51 | |
| 52 | |
| 53 | public static function load_signup_settings() |
| 54 | { |
| 55 | if(defined('MYSTICKYMENU_UPDATE_POPUP_CONTENT')) { |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | define('MYSTICKYMENU_UPDATE_POPUP_CONTENT', array( |
| 60 | 'plugin_name' => esc_html__('My Sticky Elements', 'mystickymenu'), |
| 61 | 'trust_user' => esc_html__('Join the list 100,000+ users trust', 'mystickymenu'), |
| 62 | 'website_owners' => esc_html__('100,000+', 'mystickymenu'), |
| 63 | 'rating' => esc_html__('4.9/5 Rating', 'mystickymenu'), |
| 64 | 'review' => esc_html__('Based on 1,000+ Reviews', 'mystickymenu'), |
| 65 | 'plugin_logo' => MYSTICKYMENU_URL . "images/signup/my-sticky-bar.png", |
| 66 | 'trust_user_img' => MYSTICKYMENU_URL . "images/signup/user-trust.svg", |
| 67 | 'font_url' => MYSTICKYMENU_URL . "fonts/Lato-Regular.woff", |
| 68 | 'background_image' => MYSTICKYMENU_URL . "images/signup/premio-update-bg.svg", |
| 69 | 'shape_bottom' => MYSTICKYMENU_URL . "images/signup/premio-update-bg-btm.png", |
| 70 | 'shape_bottom_right' => MYSTICKYMENU_URL . "images/signup/premio-update-bg-right.png", |
| 71 | 'mail_icon' => MYSTICKYMENU_URL . "images/signup/mail-icon.svg", |
| 72 | 'user_icon' => MYSTICKYMENU_URL . "images/signup/users.svg", |
| 73 | 'slash_icon' => MYSTICKYMENU_URL . "images/signup/slash.svg", |
| 74 | 'star_icon' => MYSTICKYMENU_URL . "images/signup/star.svg", |
| 75 | 'arrow_right' => MYSTICKYMENU_URL . "images/signup/arrow-right.svg", |
| 76 | 'check_circle' => MYSTICKYMENU_URL . "images/signup/check-circle.svg", |
| 77 | 'pre_loader' => MYSTICKYMENU_URL . "images/signup/pre-loader.svg", |
| 78 | )); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | /** |
| 83 | * Checks the status of a modal and determines whether it should be displayed. |
| 84 | * |
| 85 | * This method evaluates various conditions, such as predefined options and the HTTP referrer, |
| 86 | * to decide if the modal should be shown. It may also update specific modal-related options |
| 87 | * based on the results of these checks. |
| 88 | * |
| 89 | * @return bool Returns true if the modal should be displayed; otherwise, false. |
| 90 | */ |
| 91 | public static function check_modal_status() { |
| 92 | if(get_option(self::$update_message_option) == -1 || get_option(self::$update_message_option) == 2) { |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | $referer = isset($_SERVER['HTTP_REFERER']) ? sanitize_text_field($_SERVER['HTTP_REFERER']) : ''; |
| 97 | |
| 98 | if (!str_contains($referer, 'my-stickymenu') && !str_contains($referer, 'my-sticky-menu') && !str_contains($referer, 'install-poptin-plugin')) { |
| 99 | |
| 100 | $widgets = get_option( 'mysticky_option_welcomebar' ); |
| 101 | if(!empty($widgets) && $widgets != false){ |
| 102 | add_option(self::$show_modal_name, 1); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | if (get_option(self::$show_modal_name)) { |
| 107 | $next_signup_date = get_option(self::$next_signup_date); |
| 108 | if($next_signup_date === false) { |
| 109 | self::load_signup_settings(); |
| 110 | return true; |
| 111 | } else { |
| 112 | if($next_signup_date < date('Y-m-d')) { |
| 113 | self::load_signup_settings(); |
| 114 | return true; |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Handles the AJAX request to update the status of the plugin. |
| 124 | * |
| 125 | * Verifies the nonce for security, processes the provided status and email, |
| 126 | * and executes specific actions based on the status, including sending data |
| 127 | * to an external API or updating WordPress options. |
| 128 | * |
| 129 | * @return void |
| 130 | */ |
| 131 | public function update_status() { |
| 132 | if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'myStickymenu_update_nonce')) { |
| 133 | $status = sanitize_text_field($_REQUEST['status']); |
| 134 | $email = sanitize_text_field($_REQUEST['email']); |
| 135 | if($status == 1) { |
| 136 | update_option(self::$update_message_option, -1); |
| 137 | $url = 'https://premioapps.com/premio/signup/email.php'; |
| 138 | $apiParams = [ |
| 139 | 'plugin' => 'myStickymenu', |
| 140 | 'email' => $email, |
| 141 | ]; |
| 142 | |
| 143 | // Signup Email for Chaty |
| 144 | $apiResponse = wp_safe_remote_post($url, ['body' => $apiParams, 'timeout' => 15, 'sslverify' => true]); |
| 145 | |
| 146 | if (is_wp_error($apiResponse)) { |
| 147 | wp_safe_remote_post($url, ['body' => $apiParams, 'timeout' => 15, 'sslverify' => false]); |
| 148 | } |
| 149 | } else { |
| 150 | $next_date = date('Y-m-d', strtotime('+7 days')); |
| 151 | $next_signup_date = get_option(self::$next_signup_date); |
| 152 | if($next_signup_date === false) { |
| 153 | add_option(self::$next_signup_date, $next_date); |
| 154 | } else { |
| 155 | update_option(self::$update_message_option, -1); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | echo "1"; |
| 160 | die; |
| 161 | } |
| 162 | |
| 163 | } |
| 164 | new myStickyMenu_SIGNUP_CLASS(); |