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
mystickymenu.php
1908 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: My Sticky Bar |
| 4 | Plugin URI: https://premio.io/ |
| 5 | Description: Create a notification bar for your website with My Sticky Bar. You can customize the design, collect leads, and enjoy other advanced features. You can also make your menu sticky using My Sticky Bar. |
| 6 | Version: 2.9.1 |
| 7 | Author: Premio |
| 8 | Author URI: https://premio.io/downloads/mystickymenu/ |
| 9 | Text Domain: mystickymenu |
| 10 | Domain Path: /languages |
| 11 | License: GPLv3 |
| 12 | */ |
| 13 | |
| 14 | defined('ABSPATH') or die("Cannot access pages directly."); |
| 15 | define('MYSTICKY_VERSION', '2.9.1'); |
| 16 | define('MYSTICKYMENU_URL', plugins_url('/', __FILE__)); // Define Plugin URL |
| 17 | define('MYSTICKYMENU_PATH', plugin_dir_path(__FILE__)); // Define Plugin Directory Path |
| 18 | define('MYSTICKYMENU_BASE', plugin_basename(__FILE__)); |
| 19 | |
| 20 | require_once("mystickymenu-fonts.php"); |
| 21 | require_once("welcome-bar.php"); |
| 22 | |
| 23 | if( is_admin() ) { |
| 24 | //include_once 'class-review-box.php'; |
| 25 | include_once 'class-upgrade-box.php'; |
| 26 | include_once 'class-email-signup.php'; |
| 27 | include_once 'class-help.php'; |
| 28 | |
| 29 | } |
| 30 | |
| 31 | class MyStickyMenuBackend |
| 32 | { |
| 33 | private $options; |
| 34 | |
| 35 | public function __construct() |
| 36 | { |
| 37 | add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); |
| 38 | add_action( 'admin_init', array( $this, 'mysticky_load_transl') ); |
| 39 | add_action( 'admin_init', array( $this, 'mysticky_default_options' ) ); |
| 40 | add_action( 'admin_head', array( $this, 'mystickymenu_admin_head' ) ); |
| 41 | add_action( 'admin_enqueue_scripts', array( $this, 'mysticky_admin_script' ) ); |
| 42 | add_filter( 'plugin_action_links_'.MYSTICKYMENU_BASE, array( $this, 'mystickymenu_settings_link' ) ); |
| 43 | add_action( 'activated_plugin', array( $this, 'mystickymenu_activation_redirect' ) ); |
| 44 | add_action( "wp_ajax_mystickymenu_update_popup_status", array($this, 'mystickymenu_popup_status')); |
| 45 | add_action( 'admin_footer', array( $this, 'mystickymenu_deactivate' ) ); |
| 46 | add_action( 'wp_ajax_mystickymenu_plugin_deactivate', array( $this, 'mystickymenu_plugin_deactivate' ) ); |
| 47 | add_action( 'wp_ajax_stickymenu_widget_delete', array( $this, 'stickymenu_widget_delete' ) ); |
| 48 | add_action( 'wp_ajax_mystickymenu_widget_status', array( $this, 'mystickymenu_widget_status' ) ); |
| 49 | add_action( 'wp_ajax_stickymenu_status_update', array( $this, 'stickymenu_status_update' ) ); |
| 50 | add_action( 'wp_ajax_mystickymenu_delete_contact_lead', array( $this, 'mystickymenu_delete_contact_lead' ) ); |
| 51 | add_action( 'wp_ajax_my_sticky_menu_bulks', array( $this, 'my_sticky_menu_bulks' ) ); |
| 52 | |
| 53 | add_action( 'wp_ajax_mystickymenu_admin_send_message_to_owner', array( $this, 'mystickymenu_admin_send_message_to_owner' ) ); |
| 54 | |
| 55 | add_action( 'wp_ajax_mystickymenu_review_box', [$this, "mystickymenu_review_box"]); |
| 56 | add_action( 'wp_ajax_mystickymenu_review_box_message', [$this, "mystickymenu_review_box_message"]); |
| 57 | add_action( 'admin_init' , [$this, 'check_for_redirection']); |
| 58 | |
| 59 | } |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | public function stickymenu_status_update(){ |
| 65 | if (!current_user_can('manage_options')) { |
| 66 | wp_die(0); |
| 67 | } |
| 68 | check_ajax_referer( 'mystickymenu', 'wpnonce' ); |
| 69 | $mysticky_options = get_option( 'mysticky_option_name' ); |
| 70 | if( isset($_POST['stickymenu_status']) && $_POST['stickymenu_status'] != '' ){ |
| 71 | |
| 72 | $stickymenu_status = $_POST['stickymenu_status']; |
| 73 | $mysticky_options['stickymenu_enable'] = $stickymenu_status; |
| 74 | update_option('mysticky_option_name',$mysticky_options); |
| 75 | } |
| 76 | wp_die(); |
| 77 | } |
| 78 | |
| 79 | public function mystickymenu_popup_status() { |
| 80 | if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'mystickymenu_update_popup_status')) { |
| 81 | update_option("mystickymenu_intro_box", "hide"); |
| 82 | } |
| 83 | echo esc_attr("1"); |
| 84 | die; |
| 85 | } |
| 86 | |
| 87 | public function mystickymenu_widget_status() { |
| 88 | if (!current_user_can('manage_options')) { |
| 89 | wp_die(0); |
| 90 | } |
| 91 | check_ajax_referer( 'mystickymenu', 'wpnonce' ); |
| 92 | |
| 93 | if ( isset($_POST['widget_id']) && $_POST['widget_id'] != '' && isset($_POST['widget_status']) && $_POST['widget_status'] != '' ) { |
| 94 | $welcomebars_widgets = get_option( 'mystickymenu-welcomebars' ); |
| 95 | $widget_id = $_POST['widget_id']; |
| 96 | $welcomebars_widget_no = '-' . $widget_id ; |
| 97 | |
| 98 | if( $widget_id == 0 || $welcomebars_widgets[$widget_id] == 'default' ){ |
| 99 | $stickymenu_widget = get_option('mysticky_option_welcomebar'); |
| 100 | $welcomebars_widget_no = ''; |
| 101 | } |
| 102 | $widget_status = $_POST['widget_status']; |
| 103 | $stickymenu_widget['mysticky_welcomebar_enable'] = $widget_status; |
| 104 | |
| 105 | update_option( 'mysticky_option_welcomebar',$stickymenu_widget); |
| 106 | } |
| 107 | wp_die(); |
| 108 | } |
| 109 | |
| 110 | public function stickymenu_widget_delete(){ |
| 111 | if (!current_user_can('manage_options')) { |
| 112 | wp_die(0); |
| 113 | } |
| 114 | check_ajax_referer( 'mystickymenu', 'wpnonce' ); |
| 115 | if ( isset($_POST['widget_id']) && $_POST['widget_id'] != '' && isset($_POST['widget_delete']) && $_POST['widget_delete'] == 1 ) { |
| 116 | $welcomebars_widgets = get_option( 'mystickymenu-welcomebars' ); |
| 117 | $widget_id = $_POST['widget_id']; |
| 118 | foreach( $welcomebars_widgets as $key => $widget_value ){ |
| 119 | $element_widget_no = ''; |
| 120 | if ( $key != 0 ) { |
| 121 | $element_widget_no = '-' . $key; |
| 122 | } |
| 123 | delete_option( 'mysticky_option_welcomebar' . $element_widget_no ); |
| 124 | } |
| 125 | |
| 126 | delete_option( 'mystickymenu-welcomebars' ); |
| 127 | } |
| 128 | wp_die(); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | public function mystickymenu_delete_contact_lead(){ |
| 135 | global $wpdb; |
| 136 | if ( ! current_user_can( 'manage_options' ) ) { |
| 137 | wp_die(0); |
| 138 | } |
| 139 | check_ajax_referer( 'mystickymenu', 'wpnonce' ); |
| 140 | |
| 141 | if ( isset($_POST['ID']) && $_POST['ID'] != '' ) { |
| 142 | $ID = sanitize_text_field($_POST['ID']); |
| 143 | $table = $wpdb->prefix . 'mystickymenu_contact_lists'; |
| 144 | $delete_sql = $wpdb->prepare("DELETE FROM {$table} WHERE id = %d",$ID); |
| 145 | $delete = $wpdb->query($delete_sql); |
| 146 | } |
| 147 | |
| 148 | if ( isset($_POST['all_leads']) && $_POST['all_leads'] == 1 ) { |
| 149 | $table = $wpdb->prefix . 'mystickymenu_contact_lists'; |
| 150 | $delete = $wpdb->query("TRUNCATE TABLE $table"); |
| 151 | } |
| 152 | wp_die(); |
| 153 | |
| 154 | } |
| 155 | |
| 156 | |
| 157 | public function my_sticky_menu_bulks(){ |
| 158 | global $wpdb; |
| 159 | if (!current_user_can('manage_options')) { |
| 160 | wp_die(0); |
| 161 | } |
| 162 | check_ajax_referer( 'mystickymenu', 'wpnonce' ); |
| 163 | if( isset($_POST['wpnonce']) ){ |
| 164 | $bulks = isset($_POST['bulks']) ? $_POST['bulks'] : array(); |
| 165 | foreach( $bulks as $key => $bulk ){ |
| 166 | $ID = sanitize_text_field($bulk); |
| 167 | $table = $wpdb->prefix . 'mystickymenu_contact_lists'; |
| 168 | $delete_sql = $wpdb->prepare("DELETE FROM {$table} WHERE id = %d",$ID); |
| 169 | $delete = $wpdb->query($delete_sql); |
| 170 | } |
| 171 | } |
| 172 | wp_die(); |
| 173 | } |
| 174 | |
| 175 | public function mystickymenu_admin_send_message_to_owner() { |
| 176 | if (!current_user_can('manage_options')) { |
| 177 | wp_die(0); |
| 178 | } |
| 179 | $response = array(); |
| 180 | $response['status'] = 0; |
| 181 | $response['error'] = 0; |
| 182 | $response['errors'] = array(); |
| 183 | $response['message'] = ""; |
| 184 | $errorArray = []; |
| 185 | $errorMessage = __("%1\$s is required", "mystickymenu"); |
| 186 | $postData = $_POST; |
| 187 | if(!isset($postData['textarea_text']) || trim($postData['textarea_text']) == "") { |
| 188 | $error = array( |
| 189 | "key" => "textarea_text", |
| 190 | "message" => __("Please enter your message","mystickymenu") |
| 191 | ); |
| 192 | $errorArray[] = $error; |
| 193 | } |
| 194 | if(!isset($postData['user_email']) || trim($postData['user_email']) == "") { |
| 195 | $error = array( |
| 196 | "key" => "user_email", |
| 197 | "message" => sprintf($errorMessage,__("Email","mystickymenu")) |
| 198 | ); |
| 199 | $errorArray[] = $error; |
| 200 | } else if(!filter_var($postData['user_email'], FILTER_VALIDATE_EMAIL)) { |
| 201 | $error = array( |
| 202 | 'key' => "user_email", |
| 203 | "message" => "Email is not valid" |
| 204 | ); |
| 205 | $errorArray[] = $error; |
| 206 | } |
| 207 | if(empty($errorArray)) { |
| 208 | if(!isset($_REQUEST['nonce']) || empty($_REQUEST['nonce'])) { |
| 209 | $error = array( |
| 210 | 'key' => "nonce", |
| 211 | "message" => "Your request is not valid" |
| 212 | ); |
| 213 | $errorArray[] = $error; |
| 214 | } else if(!wp_verify_nonce($_REQUEST['nonce'], "mystickymenu_send_message_to_owner")) { |
| 215 | $error = array( |
| 216 | 'key' => "nonce", |
| 217 | "message" => "Your request is not valid" |
| 218 | ); |
| 219 | $errorArray[] = $error; |
| 220 | } |
| 221 | } |
| 222 | if(empty($errorArray)) { |
| 223 | global $current_user; |
| 224 | $text_message = $postData['textarea_text']; |
| 225 | $email = $postData['user_email']; |
| 226 | $domain = site_url(); |
| 227 | $user_name = $current_user->first_name." ".$current_user->last_name; |
| 228 | |
| 229 | $response['status'] = 1; |
| 230 | |
| 231 | /* sending message to Crisp */ |
| 232 | $post_message = array(); |
| 233 | |
| 234 | $message_data = array(); |
| 235 | $message_data['key'] = "Plugin"; |
| 236 | $message_data['value'] = "My Sticky Bar"; |
| 237 | $post_message[] = $message_data; |
| 238 | |
| 239 | $message_data = array(); |
| 240 | $message_data['key'] = "Domain"; |
| 241 | $message_data['value'] = $domain; |
| 242 | $post_message[] = $message_data; |
| 243 | |
| 244 | $message_data = array(); |
| 245 | $message_data['key'] = "Email"; |
| 246 | $message_data['value'] = $email; |
| 247 | $post_message[] = $message_data; |
| 248 | |
| 249 | $message_data = array(); |
| 250 | $message_data['key'] = "Message"; |
| 251 | $message_data['value'] = $text_message; |
| 252 | $post_message[] = $message_data; |
| 253 | |
| 254 | $api_params = array( |
| 255 | 'domain' => $domain, |
| 256 | 'email' => $email, |
| 257 | 'url' => site_url(), |
| 258 | 'name' => $user_name, |
| 259 | 'message' => $post_message, |
| 260 | 'plugin' => "My Sticky Bar", |
| 261 | 'type' => "Need Help", |
| 262 | ); |
| 263 | |
| 264 | /* Sending message to Crisp API */ |
| 265 | |
| 266 | $crisp_response = wp_safe_remote_post("https://premioapps.com/premio/send-message-api.php", array('body' => $api_params, 'timeout' => 15, 'sslverify' => true)); |
| 267 | |
| 268 | if (is_wp_error($crisp_response)) { |
| 269 | wp_safe_remote_post("https://premioapps.com/premio/send-message-api.php", array('body' => $api_params, 'timeout' => 15, 'sslverify' => false)); |
| 270 | } |
| 271 | } else { |
| 272 | $response['error'] = 1; |
| 273 | $response['errors'] = $errorArray; |
| 274 | } |
| 275 | wp_send_json($response); |
| 276 | wp_die(); |
| 277 | } |
| 278 | |
| 279 | |
| 280 | public function mystickymenu_settings_link($links){ |
| 281 | $settings_link = '<a href="admin.php?page=my-stickymenu-welcomebar">'.esc_html__('Settings', 'mystickymenu').'</a>'; |
| 282 | |
| 283 | $links['need_help'] = '<a href="https://premio.io/help/mystickymenu/" target="_blank">'.esc_html__( 'Need help?', 'mystickymenu' ).'</a>'; |
| 284 | |
| 285 | $links['go_pro'] = '<a href="'. admin_url("admin.php?page=my-stickymenu-upgrade&type=upgrade").'" style="color: #FF5983; font-weight: bold; display: inline-block; border: solid 1px #FF5983; border-radius: 4px; padding: 0 5px;">'.esc_html__( 'Upgrade', 'mystickymenu' ).'</a>'; |
| 286 | array_unshift($links, $settings_link); |
| 287 | return $links; |
| 288 | } |
| 289 | |
| 290 | public function mystickymenu_activation_redirect( $plugin) { |
| 291 | if( $plugin == plugin_basename( __FILE__ ) ) { |
| 292 | |
| 293 | $option = get_option("mystickymenu_intro_box"); |
| 294 | if($option === false) { |
| 295 | add_option("mystickymenu_intro_box", "show"); |
| 296 | } |
| 297 | if(!defined( 'DOING_AJAX' )) { |
| 298 | add_option("msm_redirection", 1); |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | public function check_for_redirection() |
| 304 | { |
| 305 | if(!defined( 'DOING_AJAX' )) { |
| 306 | $status = get_option("msm_redirection"); |
| 307 | if($status) { |
| 308 | delete_option("msm_redirection"); |
| 309 | $welcomebar_widgets = get_option("mysticky_option_welcomebar"); |
| 310 | if ($welcomebar_widgets) { |
| 311 | wp_redirect(admin_url('admin.php?page=my-stickymenu-welcomebar')); |
| 312 | } else { |
| 313 | wp_redirect(admin_url('admin.php?page=my-stickymenu-welcomebar&widget=0')); |
| 314 | } |
| 315 | exit; |
| 316 | } |
| 317 | $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
| 318 | if($page == 'my-sticky-menu-leads'){ |
| 319 | $total_leads = $this->total_my_sticky_bar_contact_list(); // Total number of my sticky bar contact form leads |
| 320 | $contact_form_channel_active = $this->is_welcomebar_contact_form_enabled(); // True if contact form is enabled, false otherwise |
| 321 | if($total_leads == 0 && !$contact_form_channel_active){ |
| 322 | wp_redirect(admin_url('admin.php?page=my-stickymenu-welcomebar')); |
| 323 | exit; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | public function mysticky_admin_script($hook) { |
| 331 | |
| 332 | if ( !isset($_GET['page']) || ( isset($_GET['page']) && $_GET['page'] != 'my-stickymenu-settings' && $_GET['page'] != 'my-stickymenu-welcomebar' && $_GET['page'] != 'my-stickymenu-new-welcomebar' && $_GET['page'] != 'my-sticky-menu-analytics' && $_GET['page'] != 'my-stickymenu-upgrade' && $_GET['page'] != 'msm-recommended-plugins' && $_GET['page'] != 'my-sticky-menu-leads' )) { |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | wp_enqueue_style( |
| 337 | 'mystickymenuAdminStyle', |
| 338 | plugins_url("/dist/css/mystickymenu-admin.css", __FILE__), |
| 339 | array(), |
| 340 | MYSTICKY_VERSION |
| 341 | ); |
| 342 | wp_enqueue_style( |
| 343 | 'mystickybar-style', |
| 344 | plugins_url("/dist/css/mystickybar-admin.css", __FILE__), |
| 345 | array(), |
| 346 | MYSTICKY_VERSION |
| 347 | ); |
| 348 | wp_enqueue_style( |
| 349 | 'mystickybar-app', |
| 350 | plugins_url("/dist/css/app.css", __FILE__), |
| 351 | array(), |
| 352 | MYSTICKY_VERSION |
| 353 | ); |
| 354 | |
| 355 | wp_enqueue_style( |
| 356 | 'mystickymenuHelpStyle', |
| 357 | plugins_url("/dist/css/mystickymenu-help.css", __FILE__), |
| 358 | array(), |
| 359 | MYSTICKY_VERSION |
| 360 | ); |
| 361 | wp_enqueue_style( 'wp-color-picker' ); |
| 362 | wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
| 363 | wp_enqueue_style('jquery-ui'); |
| 364 | |
| 365 | wp_enqueue_script('jquery-ui'); |
| 366 | wp_enqueue_script('jquery-ui-slider'); |
| 367 | wp_enqueue_script( 'jquery-ui-dialog' ); |
| 368 | |
| 369 | if ( isset($_GET['page']) && $_GET['page'] == 'my-stickymenu-upgrade' ) { |
| 370 | wp_enqueue_script( 'my-select2', plugins_url('dist/js/select2.js', __FILE__ ), array( 'wp-color-picker' ), MYSTICKY_VERSION, ['strategy' => 'defer', 'in_footer'=> true ] ); |
| 371 | wp_enqueue_style('my-css-select2', plugins_url('dist/css/select2.css', __FILE__), array(), MYSTICKY_VERSION ); |
| 372 | |
| 373 | wp_enqueue_style('stickymenu-pricing-table', plugins_url("/dist/css/pricing-table.css", __FILE__), [], MYSTICKY_VERSION); |
| 374 | $queryArgs = [ |
| 375 | 'family' => 'Poppins:wght@400;500;600;700&display=swap', |
| 376 | 'subset' => 'latin,latin-ext', |
| 377 | ]; |
| 378 | wp_enqueue_style('google-poppins-fonts', add_query_arg($queryArgs, "//fonts.googleapis.com/css2"), [], MYSTICKY_VERSION); |
| 379 | |
| 380 | wp_enqueue_script('stickymenu-slick', plugins_url('/dist/js/slick.js', __FILE__), ['jquery'], MYSTICKY_VERSION, ['strategy' => 'defer', 'in_footer'=> true ]); |
| 381 | } |
| 382 | |
| 383 | wp_enqueue_style("mystickyelements-star-rating-svg-css", plugins_url("/dist/css/star-rating-svg.css", __FILE__), [], MYSTICKY_VERSION ); |
| 384 | wp_enqueue_script("mystickyelements-star-rating-svg-js", plugins_url('/dist/js/star-rating-svg.js', __FILE__), ['jquery'], MYSTICKY_VERSION, ['strategy' => 'defer', 'in_footer'=> true ]); |
| 385 | |
| 386 | wp_enqueue_script( |
| 387 | 'morphext-js', |
| 388 | plugins_url("/dist/js/morphext.js", __FILE__), |
| 389 | array('jquery'), |
| 390 | MYSTICKY_VERSION, |
| 391 | ['strategy' => 'defer', 'in_footer'=> true ] |
| 392 | ); |
| 393 | |
| 394 | wp_enqueue_script( 'mailcheck-js', plugins_url("/dist/js/mailcheck.js", __FILE__), ['jquery'], MYSTICKY_VERSION, true); |
| 395 | wp_enqueue_script('autocomplete-email-js', plugins_url("/dist/js/email-autocomplete.js", __FILE__), ['jquery'], MYSTICKY_VERSION, true); |
| 396 | wp_enqueue_script('mystickymenuAdminScript', plugins_url("/dist/js/mystickymenu-admin.js", __FILE__), array( 'jquery', 'jquery-ui-slider', 'wp-color-picker' ), MYSTICKY_VERSION,['strategy' => 'defer', 'in_footer'=> true ]); |
| 397 | wp_enqueue_script('msb-app', plugins_url("/dist/js/app.js", __FILE__), array( 'jquery', 'jquery-ui-slider', 'wp-color-picker' ), MYSTICKY_VERSION,['strategy' => 'defer', 'in_footer'=> true ]); |
| 398 | |
| 399 | $locale_settings = array( |
| 400 | 'ajaxurl' => admin_url('admin-ajax.php'), |
| 401 | 'mystickymenu_url' => MYSTICKYMENU_URL, |
| 402 | 'ajax_nonce' => wp_create_nonce('mystickymenu'), |
| 403 | ); |
| 404 | |
| 405 | wp_localize_script('mystickymenuAdminScript', 'mystickymenu', $locale_settings); |
| 406 | |
| 407 | } |
| 408 | |
| 409 | public function mysticky_load_transl(){ |
| 410 | load_plugin_textdomain('mystickymenu', FALSE, dirname(plugin_basename(__FILE__)).'/languages/'); |
| 411 | } |
| 412 | |
| 413 | function sanitize_options($value) { |
| 414 | $value = stripslashes($value); |
| 415 | $value = sanitize_textarea_field($value); |
| 416 | return $value; |
| 417 | } |
| 418 | |
| 419 | |
| 420 | public function add_plugin_page(){ |
| 421 | if ( isset($_GET['hide_msmrecommended_plugin']) && $_GET['hide_msmrecommended_plugin'] == 1) { |
| 422 | update_option('hide_msmrecommended_plugin',true); |
| 423 | } |
| 424 | |
| 425 | $mysticky_option_welcomebar = get_option('mysticky_option_welcomebar'); |
| 426 | |
| 427 | |
| 428 | $total_leads = $this->total_my_sticky_bar_contact_list(); // Total number of my sticky bar contact form leads |
| 429 | $contact_form_channel_active = $this->is_welcomebar_contact_form_enabled(); // True if contact form is enabled, false otherwise |
| 430 | $hide_msmrecommended_plugin = get_option('hide_msmrecommended_plugin'); |
| 431 | // echo "<pre>"; |
| 432 | // // print_r($total_leads); |
| 433 | // print_r($contact_form_channel_active); |
| 434 | // echo "</pre>"; |
| 435 | // exit; |
| 436 | // This page will be under "Settings" |
| 437 | add_menu_page( |
| 438 | esc_html__('Settings Admin', 'mystickymenu'), |
| 439 | esc_html__('My Sticky Bar', 'mystickymenu'), |
| 440 | 'manage_options', |
| 441 | 'my-stickymenu-welcomebar', |
| 442 | array( $this, 'mystickystickymenu_admin_welcomebar_page' ) |
| 443 | ); |
| 444 | if(!empty($mysticky_option_welcomebar)) { |
| 445 | add_submenu_page( |
| 446 | 'my-stickymenu-welcomebar', |
| 447 | esc_html__('Settings Admin', 'mystickymenu'), |
| 448 | esc_html__('Dashboard', 'mystickymenu'), |
| 449 | 'manage_options', |
| 450 | 'my-stickymenu-welcomebar', |
| 451 | array( $this, 'mystickystickymenu_admin_welcomebar_page' ) |
| 452 | ); |
| 453 | } |
| 454 | add_submenu_page( |
| 455 | 'my-stickymenu-welcomebar', |
| 456 | esc_html__('Settings Admin', 'mystickymenu'), |
| 457 | esc_html__('+ Create New Bar', 'mystickymenu'), |
| 458 | 'manage_options', |
| 459 | 'my-stickymenu-new-welcomebar', |
| 460 | array( $this, 'mystickystickymenu_admin_new_welcomebar_page' ) |
| 461 | ); |
| 462 | |
| 463 | |
| 464 | if( class_exists( 'POPTIN_Plugin_Base' ) ) { |
| 465 | add_submenu_page( |
| 466 | 'my-stickymenu-welcomebar', |
| 467 | esc_html__('Settings Admin', 'mystickymenu'), |
| 468 | esc_html__('Poptin Popups', 'mystickymenu'), |
| 469 | 'manage_options', |
| 470 | 'manage-poptin-plugin', |
| 471 | array( $this, 'mystickymenu_manage_poptin_plugin' ) |
| 472 | ); |
| 473 | } else { |
| 474 | add_submenu_page( |
| 475 | 'my-stickymenu-welcomebar', |
| 476 | esc_html__('Settings Admin', 'mystickymenu'), |
| 477 | esc_html__('Poptin Popups', 'mystickymenu'), |
| 478 | 'manage_options', |
| 479 | 'install-poptin-plugin', |
| 480 | array( $this, 'mystickymenu_install_poptin_plugin' ) |
| 481 | ); |
| 482 | } |
| 483 | |
| 484 | add_submenu_page( |
| 485 | 'my-stickymenu-welcomebar', |
| 486 | esc_html__('Settings Admin', 'mystickymenu'), |
| 487 | esc_html__('Widget Analytics', 'mystickymenu'), |
| 488 | 'manage_options', |
| 489 | 'my-sticky-menu-analytics', |
| 490 | array( $this, 'mystickymenu_admin_widget_analytics_page' ) |
| 491 | ); |
| 492 | |
| 493 | add_submenu_page( |
| 494 | 'my-stickymenu-welcomebar', |
| 495 | esc_html__('Settings Admin', 'mystickymenu'), |
| 496 | esc_html__('Contact Form Leads', 'mystickymenu'), |
| 497 | 'manage_options', |
| 498 | 'my-sticky-menu-leads', |
| 499 | array( $this, 'mystickymenu_admin_leads_page' ) |
| 500 | ); |
| 501 | |
| 502 | add_submenu_page( |
| 503 | 'my-stickymenu-welcomebar', |
| 504 | esc_html__('Settings Admin', 'mystickymenu'), |
| 505 | esc_html__('Sticky Menu Settings', 'mystickymenu'), |
| 506 | 'manage_options', |
| 507 | 'my-stickymenu-settings', |
| 508 | array( $this, 'create_admin_page' ) |
| 509 | ); |
| 510 | |
| 511 | |
| 512 | if ( !$hide_msmrecommended_plugin){ |
| 513 | add_submenu_page( |
| 514 | 'my-stickymenu-welcomebar', |
| 515 | 'msm-recommended-plugins', |
| 516 | esc_html__('Recommended Plugins', 'mystickymenu'), |
| 517 | 'manage_options', |
| 518 | 'msm-recommended-plugins', |
| 519 | array( $this, 'mystickymenu_recommended_plugins' ) |
| 520 | ); |
| 521 | } |
| 522 | add_submenu_page( |
| 523 | 'my-stickymenu-welcomebar', |
| 524 | esc_html__('Upgrade to Pro ⭐️', 'mystickymenu'), |
| 525 | esc_html__('Upgrade to Pro ⭐️', 'mystickymenu'), |
| 526 | 'manage_options', |
| 527 | 'my-stickymenu-upgrade', |
| 528 | array( $this, 'mystickymenu_admin_upgrade_to_pro' ) |
| 529 | ); |
| 530 | } |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | public function mystickymenu_admin_head(){ |
| 536 | global $submenu; |
| 537 | $parent_slug = 'my-stickymenu-welcomebar'; |
| 538 | $welcomebar_widgets = get_option( 'mysticky_option_welcomebar' ); |
| 539 | $total_leads = $this->total_my_sticky_bar_contact_list(); // Total number of my sticky bar contact form leads |
| 540 | $contact_form_channel_active = $this->is_welcomebar_contact_form_enabled(); // True if contact form is enabled, false otherwise |
| 541 | // echo "<pre>"; |
| 542 | // print_r($submenu[$parent_slug]); |
| 543 | // print_r($total_leads); |
| 544 | // echo "</pre>"; |
| 545 | // exit; |
| 546 | |
| 547 | if (isset($submenu[$parent_slug])) { |
| 548 | foreach ($submenu[$parent_slug] as &$item) { |
| 549 | if (isset($item[2]) && $item[2] === 'my-sticky-menu-leads') { |
| 550 | |
| 551 | $item[4] = 'msb-admin-menu-leads'; // add your class here |
| 552 | } |
| 553 | if (isset($item[2]) && $item[2] === 'my-sticky-menu-leads') { |
| 554 | |
| 555 | $item[4] = 'msb-admin-menu-leads'; // add your class here |
| 556 | } |
| 557 | if (isset($item[2]) && $item[2] === 'my-stickymenu-new-welcomebar' && !empty($welcomebar_widgets)) { |
| 558 | $item[4] = 'msb-admin-menu-upgrade'; // add your class here |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | ?> |
| 564 | <style> |
| 565 | .mse-admin-menu-upgrade { |
| 566 | display: none !important; |
| 567 | } |
| 568 | <?php |
| 569 | if( empty($welcomebar_widgets) ){ |
| 570 | echo '#toplevel_page_my-stickymenu-welcomebar ul.wp-submenu .wp-first-item { |
| 571 | display: none !important; |
| 572 | }'; |
| 573 | } |
| 574 | if( !empty($welcomebar_widgets) ){ |
| 575 | echo '#toplevel_page_my-stickymenu-welcomebar ul.wp-submenu .msb-admin-menu-upgrade { |
| 576 | display: none !important; |
| 577 | }'; |
| 578 | } |
| 579 | if( $total_leads == 0 && !$contact_form_channel_active) { |
| 580 | |
| 581 | echo '#toplevel_page_my-stickymenu-welcomebar ul.wp-submenu .msb-admin-menu-leads { |
| 582 | display: none !important; |
| 583 | }'; |
| 584 | } |
| 585 | ?> |
| 586 | </style> |
| 587 | <?php |
| 588 | } |
| 589 | |
| 590 | /** |
| 591 | * Total number of my sticky bar contact form leads |
| 592 | * |
| 593 | * @return int Total number of contact form leads |
| 594 | */ |
| 595 | public function total_my_sticky_bar_contact_list() { |
| 596 | global $wpdb; |
| 597 | $tableName = $wpdb->prefix . 'mystickymenu_contact_lists'; |
| 598 | $total_leads = 0; |
| 599 | // Check if table exists using prepared statement for security |
| 600 | $table_check = $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $tableName)); |
| 601 | if ($table_check === $tableName) { |
| 602 | // Use prepared statement with identifier placeholder for table name |
| 603 | $total_leads = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM %i", $tableName)); |
| 604 | $total_leads = absint($total_leads); |
| 605 | } |
| 606 | return $total_leads; |
| 607 | } |
| 608 | |
| 609 | public function is_welcomebar_contact_form_enabled() { |
| 610 | $welcomebar = get_option('mysticky_option_welcomebar', []); |
| 611 | |
| 612 | return !empty($welcomebar['mysticky_welcomebar_enable_lead']) |
| 613 | && intval($welcomebar['mysticky_welcomebar_enable_lead']) === 1; |
| 614 | } |
| 615 | |
| 616 | public function create_admin_page(){ |
| 617 | |
| 618 | |
| 619 | $is_shown = myStickyMenu_SIGNUP_CLASS::check_modal_status(); |
| 620 | if($is_shown) { |
| 621 | include_once MYSTICKYMENU_PATH . 'admin/email-signup.php'; |
| 622 | return; |
| 623 | } |
| 624 | |
| 625 | $upgarde_url = admin_url("admin.php?page=my-stickymenu-upgrade"); |
| 626 | // Set class property |
| 627 | if (isset($_POST['mysticky_option_name']) && !empty($_POST['mysticky_option_name']) && isset($_POST['nonce'])) { |
| 628 | if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'mysticky_option_backend_update')) { |
| 629 | $post = $_POST['mysticky_option_name']; |
| 630 | foreach($post as $key=>$value) { |
| 631 | $post[$key] = self::sanitize_options($value); |
| 632 | } |
| 633 | |
| 634 | $post['device_desktop'] = 'on'; |
| 635 | $post['device_mobile'] = 'on'; |
| 636 | update_option( 'mysticky_option_name', $post); |
| 637 | $this->mysticky_clear_all_caches(); |
| 638 | if(isset($_POST['submit_dashboard']) && !empty($_POST['submit_dashboard'])) { |
| 639 | ?> |
| 640 | <script> |
| 641 | window.location.href = '<?php echo esc_url(admin_url("admin.php?page=my-stickymenu-welcomebar"));?>'; |
| 642 | </script> |
| 643 | <?php |
| 644 | exit; |
| 645 | } |
| 646 | echo '<div class="updated settings-error notice is-dismissible "><p><strong>' . esc_html__('Settings saved.','mystickymenu'). '</p></strong></div>'; |
| 647 | } else { |
| 648 | wp_verify_nonce($_GET['nonce'], 'wporg_frontend_delete'); |
| 649 | echo '<div class="error settings-error notice is-dismissible "><p><strong>' . esc_html__('Unable to complete your request','mystickymenu'). '</p></strong></div>'; |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | $is_shown = myStickyMenu_SIGNUP_CLASS::check_modal_status(); |
| 654 | if($is_shown) { |
| 655 | include_once MYSTICKYMENU_PATH . 'admin/email-signup.php'; |
| 656 | return; |
| 657 | } else { |
| 658 | $option = get_option("mystickymenu_intro_box"); |
| 659 | if($option == "show") { |
| 660 | include_once dirname(__FILE__) . "/mystickymenu-popup.php"; |
| 661 | } |
| 662 | include_once MYSTICKYMENU_PATH . 'admin/sticky-header-settings.php'; |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | |
| 667 | public function mystickystickymenu_admin_welcomebar_page() { |
| 668 | |
| 669 | $is_shown = myStickyMenu_SIGNUP_CLASS::check_modal_status(); |
| 670 | if($is_shown) { |
| 671 | include_once MYSTICKYMENU_PATH . 'admin/email-signup.php'; |
| 672 | return; |
| 673 | } |
| 674 | |
| 675 | |
| 676 | /* |
| 677 | DATE : 2022-08-04 |
| 678 | Welcome bar save data function |
| 679 | */ |
| 680 | if (isset($_POST['mysticky_option_welcomebar']) && !empty($_POST['mysticky_option_welcomebar']) && isset($_POST['nonce'])) { |
| 681 | if(!empty($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'mysticky_option_welcomebar_update')) { |
| 682 | |
| 683 | |
| 684 | $widgets = get_option( 'mysticky_option_welcomebar' ); |
| 685 | |
| 686 | $is_first_widget = 0; |
| 687 | if( isset($widgets) && $widgets == '' ){ |
| 688 | $is_first_widget = 1; |
| 689 | } |
| 690 | |
| 691 | |
| 692 | |
| 693 | $welcomebars_widgets[0] = 'Bar #0'; |
| 694 | update_option( 'mystickymenu-welcomebars', $welcomebars_widgets ); |
| 695 | |
| 696 | $mysticky_option_welcomebar = mysticky_bar_sanitize_options( $_POST['mysticky_option_welcomebar'] ); |
| 697 | $allowed_tags = [ |
| 698 | 'a' => array( |
| 699 | 'href' => array(), |
| 700 | 'title' => array(), |
| 701 | 'rel' => array(), |
| 702 | 'target' => array() |
| 703 | ), |
| 704 | 'p' => array( |
| 705 | 'style' => array(), |
| 706 | ), |
| 707 | 'br' => array(), |
| 708 | 'em' => array(), |
| 709 | 'u' => array(), |
| 710 | 'strong' => array(), |
| 711 | ]; |
| 712 | |
| 713 | $mysticky_option_welcomebar['mysticky_welcomebar_bar_text'] = wp_kses(stripslashes($_POST['mysticky_option_welcomebar']['mysticky_welcomebar_bar_text']), $allowed_tags); |
| 714 | $mysticky_option_welcomebar['mysticky_welcomebar_thankyou_screen_text'] = wp_kses(stripslashes($_POST['mysticky_option_welcomebar']['mysticky_welcomebar_thankyou_screen_text']) , $allowed_tags); |
| 715 | $mysticky_option_welcomebar['mysticky_welcomebar_height'] = 60; |
| 716 | $mysticky_option_welcomebar['mysticky_welcomebar_device_desktop'] = 'desktop'; |
| 717 | $mysticky_option_welcomebar['mysticky_welcomebar_device_mobile'] = 'mobile'; |
| 718 | $mysticky_option_welcomebar['mysticky_welcomebar_trigger'] = 'after_a_few_seconds'; |
| 719 | $mysticky_option_welcomebar['mysticky_welcomebar_triggersec'] = '0'; |
| 720 | $mysticky_option_welcomebar['mysticky_welcomebar_expirydate'] = ''; |
| 721 | $mysticky_option_welcomebar['mysticky_welcomebar_page_settings'] = ''; |
| 722 | $mysticky_option_welcomebar['mysticky_welcomebar_text_type'] = 'static_text'; |
| 723 | $button_text = $_POST['mysticky_option_welcomebar']['mysticky_welcomebar_btn_text']; |
| 724 | $mysticky_option_welcomebar['mysticky_welcomebar_btn_text'] = wp_kses(htmlspecialchars_decode(stripslashes($button_text)) , [ |
| 725 | 'p' => array( |
| 726 | 'style' => array(), |
| 727 | ), |
| 728 | 'br' => array(), |
| 729 | 'em' => array(), |
| 730 | 'span' => array( |
| 731 | 'style' => array(), |
| 732 | ), |
| 733 | 'u' => array(), |
| 734 | 'strong' => array(), |
| 735 | 'underline' => array(), |
| 736 | ]); |
| 737 | |
| 738 | update_option( 'mysticky_option_welcomebar', $mysticky_option_welcomebar); |
| 739 | |
| 740 | $this->mysticky_clear_all_caches(); |
| 741 | $button = esc_html__('Save & View Dashboard', 'mystickymenu'); |
| 742 | if(isset($_POST['submit']) && ( $_POST['submit'] == $button || $_POST['submit']== '' ) ){ |
| 743 | if ( isset($is_first_widget) && $is_first_widget == 1 ) { ?> |
| 744 | <script> |
| 745 | window.location.href = '<?php echo admin_url("admin.php?page=my-stickymenu-welcomebar&first_widget=".$is_first_widget);?>'; |
| 746 | </script> |
| 747 | <?php } else { ?> |
| 748 | <script> |
| 749 | window.location.href = '<?php echo admin_url("admin.php?page=my-stickymenu-welcomebar");?>'; |
| 750 | </script> |
| 751 | <?php |
| 752 | } |
| 753 | } else { |
| 754 | |
| 755 | if ( isset($is_first_widget) && $is_first_widget == 1 ) { ?> |
| 756 | <script> |
| 757 | window.location.href = '<?php echo admin_url("admin.php?page=my-stickymenu-welcomebar&widget=0&isedit=1&first_widget=".$is_first_widget);?>'; |
| 758 | </script> |
| 759 | <?php } else { ?> |
| 760 | <script> |
| 761 | window.location.href = '<?php echo admin_url("admin.php?page=my-stickymenu-welcomebar&widget=0&isedit=1");?>'; |
| 762 | </script> |
| 763 | <?php |
| 764 | } |
| 765 | } |
| 766 | echo '<div class="updated settings-error notice is-dismissible "><p><strong>' . esc_html__('Settings saved.','mystickymenu'). '</p></strong></div>'; |
| 767 | } else { |
| 768 | wp_verify_nonce($_GET['nonce'], 'wporg_frontend_delete'); |
| 769 | echo '<div class="error settings-error notice is-dismissible "><p><strong>' . esc_html__('Unable to complete your request','mystickymenu'). '</p></strong></div>'; |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | |
| 774 | |
| 775 | if (isset($_POST['mysticky_welcomebar_reset']) && !empty($_POST['mysticky_welcomebar_reset']) && isset($_POST['nonce_reset'])) { |
| 776 | if(!empty($_POST['nonce_reset']) && wp_verify_nonce($_POST['nonce_reset'], 'mysticky_option_welcomebar_reset')) { |
| 777 | $mysticky_option_welcomebar_reset = mysticky_welcomebar_pro_widget_default_fields(); |
| 778 | update_option( 'mysticky_option_welcomebar', $mysticky_option_welcomebar_reset); |
| 779 | $this->mysticky_clear_all_caches(); |
| 780 | echo '<div class="updated settings-error notice is-dismissible "><p><strong>' . esc_html__('Reset Settings saved.','mystickymenu'). '</p></strong></div>'; |
| 781 | } else { |
| 782 | wp_verify_nonce($_GET['nonce'], 'wporg_frontend_delete'); |
| 783 | echo '<div class="error settings-error notice is-dismissible "><p><strong>' . esc_html__('Unable to complete your request','mystickymenu'). '</p></strong></div>'; |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | |
| 788 | |
| 789 | $mysticky_options = get_option( 'mysticky_option_name'); |
| 790 | $is_old = get_option("has_sticky_header_old_version"); |
| 791 | $is_old = ($is_old == "yes") ? true : false; |
| 792 | $nonce = wp_create_nonce('mysticky_option_backend_update'); |
| 793 | $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=2199&edd_options[price_id]="; |
| 794 | |
| 795 | ?> |
| 796 | <style> |
| 797 | div#wpcontent { |
| 798 | background: rgba(101,114,219,1); |
| 799 | background: -moz-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 800 | background: -webkit-gradient(left top, right bottom, color-stop(0%, rgba(101,114,219,1)), color-stop(67%, rgba(238,134,198,1)), color-stop(100%, rgba(238,134,198,1))); |
| 801 | background: -webkit-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 802 | background: -o-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 803 | background: -ms-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 804 | background: linear-gradient(135deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 805 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6572db', endColorstr='#ee86c6', GradientType=1 ); |
| 806 | } |
| 807 | </style> |
| 808 | <div id="mystickymenu" class="wrap mystickymenu"> |
| 809 | |
| 810 | <div id="sticky-header-welcome-bar" class="sticky-header-content"> |
| 811 | <?php |
| 812 | |
| 813 | $welcomebars_widgets = get_option( 'mysticky_option_welcomebar' ); |
| 814 | if ( !isset($_GET['widget']) && isset( $_GET['page'] ) && $_GET['page'] == 'my-stickymenu-welcomebar' ) { |
| 815 | include_once( 'admin/stickymenu-dashboard.php'); |
| 816 | }elseif ( !isset($_GET['isedit']) && !isset($_GET['save']) && isset($welcomebars_widgets) && !empty($welcomebars_widgets) ) { |
| 817 | ?> |
| 818 | <div class="wrap mystickymenu"> |
| 819 | <?php include_once dirname(__FILE__) . '/mystickymeny-new-welcomebar.php';?> |
| 820 | </div> |
| 821 | <?php |
| 822 | }else{ |
| 823 | include_once( 'admin/bar-settings.php'); |
| 824 | //mysticky_welcome_bar_backend(); |
| 825 | } |
| 826 | |
| 827 | if( isset($_GET['first_widget']) && $_GET['first_widget'] == 1 ) : ?> |
| 828 | |
| 829 | <div class="main-popup-mystickymenu-bg first-widget-popup"> |
| 830 | <div class="main-popup-mystickymenu-bg mystickymenu_container_popupbox"> |
| 831 | <div class="firstwidget-popup-contain"> |
| 832 | <img class="mx-auto" src="<?php echo esc_url( MYSTICKYMENU_URL .'/images/firstwidget_congratulations.svg');?>"> |
| 833 | <h4>Congratulations! 🎉</h4> |
| 834 | <p> <?php esc_html_e('Your first widget is now up and running on your website!', 'mystickymenu'); ?></p> |
| 835 | <div class="first-widget-popup-contant"> |
| 836 | <h4><?php esc_html_e('Upgrade to pro today','mystickymenu'); ?></h4> |
| 837 | <p> <?php esc_html_e('🎨 Display coupon codes and add sliding text to the widget.','mystickymenu') ?> </p> |
| 838 | <p> <?php esc_html_e('📱 Create multiple widgets for different devices, pages and languages.','mystickymenu') ?> </p> |
| 839 | <p> <?php esc_html_e('🎯 Targeting by country, page, and device','mystickymenu') ?> </p> |
| 840 | <p> <?php esc_html_e('⏱️ Add a countdown timer to increase the conversion rate','mystickymenu') ?> </p> |
| 841 | </div> |
| 842 | <a href="<?php echo esc_url(admin_url("admin.php?page=my-stickymenu-upgrade"));?>" class="mystickymenu btn-black btn-back-dashboard"><?php esc_html_e('Upgrade to Pro','mystickymenu');?></a><br> |
| 843 | <a href="#" class="mystickymenu btn-black btn-dashboard btn-close-dashboard"><?php esc_html_e('Close','mystickymenu');?></a> |
| 844 | </div> |
| 845 | <div class="popup-modul-close-btn firstwidget-model"> |
| 846 | <a href="#" class="close-chaty-maxvisitor-popup" id="close-first-popup"> |
| 847 | <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15 5L5 15" stroke="#4A4A4A" stroke-width="2.08" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 5L15 15" stroke="#4A4A4A" stroke-width="2.08" stroke-linecap="round" stroke-linejoin="round"/></svg> |
| 848 | </a> |
| 849 | </div> |
| 850 | </div> |
| 851 | </div> |
| 852 | <div class="mystickymenupopup-overlay" id="first_widget_overlay" style="display:block;"></div> |
| 853 | |
| 854 | <?php endif; ?> |
| 855 | </div> |
| 856 | </div> |
| 857 | <?php |
| 858 | require_once MYSTICKYMENU_PATH . 'mystickymenu-review-popup.php'; |
| 859 | } |
| 860 | |
| 861 | public function mystickystickymenu_admin_new_welcomebar_page() { |
| 862 | |
| 863 | $is_shown = myStickyMenu_SIGNUP_CLASS::check_modal_status(); |
| 864 | if($is_shown) { |
| 865 | include_once MYSTICKYMENU_PATH . 'admin/email-signup.php'; |
| 866 | return; |
| 867 | } |
| 868 | |
| 869 | $welcomebars_widgets = get_option( 'mysticky_option_welcomebar' ); |
| 870 | if( isset($welcomebars_widgets) && !empty($welcomebars_widgets)){ |
| 871 | ?> |
| 872 | <div class="wrap mystickymenu mystickymenu-new-widget-wrap"> |
| 873 | <?php include_once dirname(__FILE__) . '/mystickymeny-new-welcomebar.php';?> |
| 874 | </div> |
| 875 | <?php |
| 876 | }else{ ?> |
| 877 | <div id="mystickymenu" class="wrap mystickymenu"> |
| 878 | <div id="sticky-header-welcome-bar" class="sticky-header-content"> |
| 879 | <?php |
| 880 | include_once( 'admin/bar-settings.php'); |
| 881 | //mysticky_welcome_bar_backend(); ?> |
| 882 | </div> |
| 883 | </div> |
| 884 | <?php |
| 885 | } |
| 886 | |
| 887 | } |
| 888 | public function mystickymenu_manage_poptin_plugin() { |
| 889 | ?> |
| 890 | <script> |
| 891 | window.location.href= '<?php echo admin_url( "admin.php?page=poptin" )?>' |
| 892 | </script> |
| 893 | <?php |
| 894 | exit; |
| 895 | } |
| 896 | public function mystickymenu_install_poptin_plugin() { |
| 897 | include_once 'admin/poptin-plugin.php'; |
| 898 | } |
| 899 | public function mystickymenu_admin_widget_analytics_page(){ |
| 900 | |
| 901 | $is_shown = myStickyMenu_SIGNUP_CLASS::check_modal_status(); |
| 902 | if($is_shown) { |
| 903 | include_once MYSTICKYMENU_PATH . 'admin/email-signup.php'; |
| 904 | return; |
| 905 | } else { |
| 906 | include('mystickymenu-admin-widgetanalytics.php'); |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | public function mystickymenu_recommended_plugins() { |
| 911 | $is_shown = myStickyMenu_SIGNUP_CLASS::check_modal_status(); |
| 912 | if($is_shown) { |
| 913 | include_once MYSTICKYMENU_PATH . 'admin/email-signup.php'; |
| 914 | return; |
| 915 | } else { |
| 916 | include_once 'recommended-plugins.php'; |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | public function mystickymenu_admin_upgrade_to_pro() { |
| 921 | $is_shown = myStickyMenu_SIGNUP_CLASS::check_modal_status(); |
| 922 | if($is_shown) { |
| 923 | include_once MYSTICKYMENU_PATH . 'admin/email-signup.php'; |
| 924 | return; |
| 925 | } else { |
| 926 | |
| 927 | $pro_url = "https://go.premio.io/checkount/?edd_action=add_to_cart&download_id=2199&edd_options[price_id]="; |
| 928 | ?> |
| 929 | <style> |
| 930 | div#wpcontent { |
| 931 | background: rgba(101,114,219,1); |
| 932 | background: -moz-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 933 | background: -webkit-gradient(left top, right bottom, color-stop(0%, rgba(101,114,219,1)), color-stop(67%, rgba(238,134,198,1)), color-stop(100%, rgba(238,134,198,1))); |
| 934 | background: -webkit-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 935 | background: -o-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 936 | background: -ms-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 937 | background: linear-gradient(135deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 938 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6572db', endColorstr='#ee86c6', GradientType=1 ); |
| 939 | } |
| 940 | </style> |
| 941 | <div id="mystickymenu" class="wrap mystickymenu"> |
| 942 | <?php include_once "upgrade-to-pro.php"; ?> |
| 943 | </div> |
| 944 | <?php |
| 945 | } |
| 946 | |
| 947 | } |
| 948 | |
| 949 | public function mysticky_default_options() { |
| 950 | |
| 951 | global $options; |
| 952 | $menu_locations = get_nav_menu_locations(); |
| 953 | $menu_object = isset($menu_locations['menu-1']) ? wp_get_nav_menu_object( $menu_locations['menu-1'] ) : array(); |
| 954 | |
| 955 | if ( is_object($menu_object) && $menu_object->slug != '' ) { |
| 956 | $mysticky_class_id_selector = $menu_object->slug; |
| 957 | } else { |
| 958 | $mysticky_class_id_selector = 'custom'; |
| 959 | } |
| 960 | |
| 961 | $mystickyClass = '.navbar'; |
| 962 | $template_name = get_template(); |
| 963 | switch( $template_name ){ |
| 964 | case 'ashe': |
| 965 | $mysticky_class_id_selector = 'custom'; |
| 966 | $mystickyClass = '#main-nav'; |
| 967 | break; |
| 968 | case 'astra': |
| 969 | case 'hello-elementor': |
| 970 | case 'sydney': |
| 971 | case 'twentysixteen': |
| 972 | $mysticky_class_id_selector = 'custom'; |
| 973 | $mystickyClass = 'header.site-header'; |
| 974 | break; |
| 975 | case 'generatepress': |
| 976 | $mysticky_class_id_selector = 'custom'; |
| 977 | $mystickyClass = 'nav.main-navigation'; |
| 978 | break; |
| 979 | case 'transportex': |
| 980 | $mysticky_class_id_selector = 'custom'; |
| 981 | $mystickyClass = '.transportex-menu-full'; |
| 982 | break; |
| 983 | case 'hestia': |
| 984 | case 'neve': |
| 985 | $mysticky_class_id_selector = 'custom'; |
| 986 | $mystickyClass = 'header.header'; |
| 987 | break; |
| 988 | case 'mesmerize': |
| 989 | $mysticky_class_id_selector = 'custom'; |
| 990 | $mystickyClass = '.navigation-bar'; |
| 991 | break; |
| 992 | case 'oceanwp': |
| 993 | $mysticky_class_id_selector = 'custom'; |
| 994 | $mystickyClass = 'header#site-header'; |
| 995 | break; |
| 996 | case 'shapely': |
| 997 | $mysticky_class_id_selector = 'custom'; |
| 998 | $mystickyClass = '#site-navigation'; |
| 999 | break; |
| 1000 | case 'storefront': |
| 1001 | $mysticky_class_id_selector = 'custom'; |
| 1002 | $mystickyClass = '.storefront-primary-navigation'; |
| 1003 | break; |
| 1004 | case 'twentynineteen': |
| 1005 | $mysticky_class_id_selector = 'custom'; |
| 1006 | $mystickyClass = '#site-navigation'; |
| 1007 | break; |
| 1008 | case 'twentyseventeen': |
| 1009 | $mysticky_class_id_selector = 'custom'; |
| 1010 | $mystickyClass = '.navigation-top'; |
| 1011 | break; |
| 1012 | default: |
| 1013 | break; |
| 1014 | } |
| 1015 | |
| 1016 | $default = array( |
| 1017 | 'mysticky_class_id_selector' => $mysticky_class_id_selector, |
| 1018 | 'mysticky_class_selector' => $mystickyClass, |
| 1019 | 'device_desktop' => 'on', |
| 1020 | 'device_mobile' => 'on', |
| 1021 | 'myfixed_zindex' => '99990', |
| 1022 | 'myfixed_bgcolor' => '#f7f5e7', |
| 1023 | 'myfixed_opacity' => '90', |
| 1024 | 'myfixed_transition_time' => '0.3', |
| 1025 | 'myfixed_disable_small_screen' => '0', |
| 1026 | 'myfixed_disable_large_screen' => '0', |
| 1027 | 'mysticky_active_on_height' => '0', |
| 1028 | 'mysticky_active_on_height_home'=> '0', |
| 1029 | 'myfixed_fade' => 'slide', |
| 1030 | 'myfixed_cssstyle' => '#mysticky-nav .myfixed { margin:0 auto; float:none; border:0px; background:none; max-width:100%; }' |
| 1031 | ); |
| 1032 | |
| 1033 | if ( get_option('mysticky_option_name') == false && current_user_can( 'manage_options' ) ) { |
| 1034 | $status = get_option("sticky_header_status"); |
| 1035 | if($status == false) { |
| 1036 | update_option("sticky_header_status", "done"); |
| 1037 | update_option("has_sticky_header_old_version", "no"); |
| 1038 | } |
| 1039 | update_option( 'mysticky_option_name', $default ); |
| 1040 | } else { |
| 1041 | $status = get_option("sticky_header_status"); |
| 1042 | if($status == false) { |
| 1043 | update_option("sticky_header_status", "done"); |
| 1044 | update_option("has_sticky_header_old_version", "yes"); |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | if(isset($_POST['reset_mysticky_options']) && current_user_can( 'manage_options' )) { |
| 1049 | if(isset($_REQUEST['nonce']) && !empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'mysticky_option_backend_reset_nonce')) { |
| 1050 | update_option('mysticky_option_name', $default); |
| 1051 | } else { |
| 1052 | |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | if ( !get_option( 'update_mysticky_version_2_6') && current_user_can( 'manage_options' )) { |
| 1057 | $mysticky_option_name = get_option( 'mysticky_option_name' ); |
| 1058 | $mysticky_option_name['mysticky_class_id_selector'] = 'custom'; |
| 1059 | if ($mysticky_option_name['myfixed_fade'] == 'on'){ |
| 1060 | $mysticky_option_name['myfixed_fade'] = 'slide'; |
| 1061 | }else{ |
| 1062 | $mysticky_option_name['myfixed_fade'] = 'fade'; |
| 1063 | } |
| 1064 | update_option( 'mysticky_option_name', $mysticky_option_name ); |
| 1065 | update_option( 'update_mysticky_version_2_6', true ); |
| 1066 | } |
| 1067 | |
| 1068 | if ( !get_option( 'update_mysticky_version_2_5_7') && current_user_can( 'manage_options' )) { |
| 1069 | $mysticky_option_name = get_option( 'mysticky_option_name' ); |
| 1070 | $mysticky_option_name['stickymenu_enable'] = 1; |
| 1071 | update_option( 'mysticky_option_name', $mysticky_option_name ); |
| 1072 | update_option( 'update_mysticky_version_2_5_7', true ); |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | /* |
| 1077 | * clear cache when any option is updated |
| 1078 | * |
| 1079 | */ |
| 1080 | public function mysticky_clear_all_caches(){ |
| 1081 | |
| 1082 | try { |
| 1083 | global $wp_fastest_cache; |
| 1084 | |
| 1085 | // if W3 Total Cache is being used, clear the cache |
| 1086 | if (function_exists('w3tc_flush_all')) { |
| 1087 | w3tc_flush_all(); |
| 1088 | } |
| 1089 | /* if WP Super Cache is being used, clear the cache */ |
| 1090 | if (function_exists('wp_cache_clean_cache')) { |
| 1091 | global $file_prefix, $supercachedir; |
| 1092 | if (empty($supercachedir) && function_exists('get_supercache_dir')) { |
| 1093 | $supercachedir = get_supercache_dir(); |
| 1094 | } |
| 1095 | wp_cache_clean_cache($file_prefix); |
| 1096 | } |
| 1097 | |
| 1098 | if (class_exists('WpeCommon')) { |
| 1099 | //be extra careful, just in case 3rd party changes things on us |
| 1100 | if (method_exists('WpeCommon', 'purge_memcached')) { |
| 1101 | //WpeCommon::purge_memcached(); |
| 1102 | } |
| 1103 | if (method_exists('WpeCommon', 'clear_maxcdn_cache')) { |
| 1104 | //WpeCommon::clear_maxcdn_cache(); |
| 1105 | } |
| 1106 | if (method_exists('WpeCommon', 'purge_varnish_cache')) { |
| 1107 | //WpeCommon::purge_varnish_cache(); |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | if (method_exists('WpFastestCache', 'deleteCache') && !empty($wp_fastest_cache)) { |
| 1112 | $wp_fastest_cache->deleteCache(); |
| 1113 | } |
| 1114 | if (function_exists('rocket_clean_domain')) { |
| 1115 | rocket_clean_domain(); |
| 1116 | // Preload cache. |
| 1117 | if (function_exists('run_rocket_sitemap_preload')) { |
| 1118 | run_rocket_sitemap_preload(); |
| 1119 | } |
| 1120 | } |
| 1121 | |
| 1122 | if (class_exists("autoptimizeCache") && method_exists("autoptimizeCache", "clearall")) { |
| 1123 | autoptimizeCache::clearall(); |
| 1124 | } |
| 1125 | |
| 1126 | if (class_exists("LiteSpeed_Cache_API") && method_exists("autoptimizeCache", "purge_all")) { |
| 1127 | LiteSpeed_Cache_API::purge_all(); |
| 1128 | } |
| 1129 | |
| 1130 | if ( class_exists( '\Hummingbird\Core\Utils' ) ) { |
| 1131 | |
| 1132 | $modules = \Hummingbird\Core\Utils::get_active_cache_modules(); |
| 1133 | foreach ( $modules as $module => $name ) { |
| 1134 | $mod = \Hummingbird\Core\Utils::get_module( $module ); |
| 1135 | |
| 1136 | if ( $mod->is_active() ) { |
| 1137 | if ( 'minify' === $module ) { |
| 1138 | $mod->clear_files(); |
| 1139 | } else { |
| 1140 | $mod->clear_cache(); |
| 1141 | } |
| 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | } catch (Exception $e) { |
| 1147 | return 1; |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | public function mystickymenu_deactivate() { |
| 1152 | global $pagenow; |
| 1153 | |
| 1154 | if ( 'plugins.php' !== $pagenow ) { |
| 1155 | return; |
| 1156 | } |
| 1157 | include dirname(__FILE__) . "/mystickymenu-deactivate-form.php"; |
| 1158 | } |
| 1159 | public function mystickymenu_plugin_deactivate() { |
| 1160 | global $current_user; |
| 1161 | if ( ! current_user_can( 'manage_options' ) ) { |
| 1162 | wp_die(0); |
| 1163 | } |
| 1164 | check_ajax_referer( 'mystickymenu_deactivate_nonce', 'nonce' ); |
| 1165 | |
| 1166 | $postData = $_POST; |
| 1167 | $errorCounter = 0; |
| 1168 | $response = array(); |
| 1169 | $response['status'] = 0; |
| 1170 | $response['message'] = ""; |
| 1171 | $response['valid'] = 1; |
| 1172 | if(!isset($postData['reason']) || empty($postData['reason'])) { |
| 1173 | $errorCounter++; |
| 1174 | $response['message'] = "Please provide reason"; |
| 1175 | } else if(!isset($postData['reason']) || empty($postData['reason'])) { |
| 1176 | $errorCounter++; |
| 1177 | $response['message'] = "Please provide reason"; |
| 1178 | } else { |
| 1179 | $nonce = $postData['nonce']; |
| 1180 | if(!wp_verify_nonce($nonce, 'mystickymenu_deactivate_nonce')) { |
| 1181 | $response['message'] = __("Your request is not valid", "mystickymenu"); |
| 1182 | $errorCounter++; |
| 1183 | $response['valid'] = 0; |
| 1184 | } |
| 1185 | } |
| 1186 | if($errorCounter == 0) { |
| 1187 | global $current_user; |
| 1188 | $plugin_info = get_plugin_data( dirname(__FILE__) . "/mystickymenu.php" ); |
| 1189 | $postData = $_POST; |
| 1190 | $email = "none@none.none"; |
| 1191 | |
| 1192 | if (isset($postData['email_id']) && !empty($postData['email_id']) && filter_var($postData['email_id'], FILTER_VALIDATE_EMAIL)) { |
| 1193 | $email = $postData['email_id']; |
| 1194 | } |
| 1195 | $domain = site_url(); |
| 1196 | $user_name = $current_user->first_name . " " . $current_user->last_name; |
| 1197 | |
| 1198 | $response['status'] = 1; |
| 1199 | |
| 1200 | /* sending message to Crisp */ |
| 1201 | $post_message = array(); |
| 1202 | |
| 1203 | $message_data = array(); |
| 1204 | $message_data['key'] = "Plugin"; |
| 1205 | $message_data['value'] = "My Sticky Bar"; |
| 1206 | $post_message[] = $message_data; |
| 1207 | |
| 1208 | $message_data = array(); |
| 1209 | $message_data['key'] = "Plugin Version"; |
| 1210 | $message_data['value'] = $plugin_info['Version']; |
| 1211 | $post_message[] = $message_data; |
| 1212 | |
| 1213 | $message_data = array(); |
| 1214 | $message_data['key'] = "Domain"; |
| 1215 | $message_data['value'] = $domain; |
| 1216 | $post_message[] = $message_data; |
| 1217 | |
| 1218 | $message_data = array(); |
| 1219 | $message_data['key'] = "Email"; |
| 1220 | $message_data['value'] = $email; |
| 1221 | $post_message[] = $message_data; |
| 1222 | |
| 1223 | $message_data = array(); |
| 1224 | $message_data['key'] = "WordPress Version"; |
| 1225 | $message_data['value'] = esc_attr(get_bloginfo('version')); |
| 1226 | $post_message[] = $message_data; |
| 1227 | |
| 1228 | $message_data = array(); |
| 1229 | $message_data['key'] = "PHP Version"; |
| 1230 | $message_data['value'] = PHP_VERSION; |
| 1231 | $post_message[] = $message_data; |
| 1232 | |
| 1233 | $message_data = array(); |
| 1234 | $message_data['key'] = "Message"; |
| 1235 | $message_data['value'] = $postData['reason']; |
| 1236 | $post_message[] = $message_data; |
| 1237 | |
| 1238 | $api_params = array( |
| 1239 | 'domain' => $domain, |
| 1240 | 'email' => $email, |
| 1241 | 'url' => site_url(), |
| 1242 | 'name' => $user_name, |
| 1243 | 'message' => $post_message, |
| 1244 | 'plugin' => "My Sticky Bar", |
| 1245 | 'type' => "Uninstall", |
| 1246 | ); |
| 1247 | |
| 1248 | /* Sending message to Crisp API */ |
| 1249 | $crisp_response = wp_safe_remote_post("https://premioapps.com/premio/send-message-api.php", array('body' => $api_params, 'timeout' => 15, 'sslverify' => true)); |
| 1250 | |
| 1251 | if (is_wp_error($crisp_response)) { |
| 1252 | wp_safe_remote_post("https://premioapps.com/premio/send-message-api.php", array('body' => $api_params, 'timeout' => 15, 'sslverify' => false)); |
| 1253 | } |
| 1254 | } |
| 1255 | echo json_encode($response); |
| 1256 | wp_die(); |
| 1257 | } |
| 1258 | |
| 1259 | /* * |
| 1260 | * Mysticky Menu : Contact Lead function for show all the lead which send by user. |
| 1261 | * DATE : 2022-08-04 |
| 1262 | * */ |
| 1263 | |
| 1264 | public function mystickymenu_admin_leads_page(){ |
| 1265 | include_once MYSTICKYMENU_PATH . 'mystickymenu-leads.php'; |
| 1266 | } |
| 1267 | |
| 1268 | public function mystickymenu_review_box() { |
| 1269 | |
| 1270 | if (current_user_can('manage_options')) { |
| 1271 | $nonce = filter_input(INPUT_POST, 'nonce'); |
| 1272 | $days = filter_input(INPUT_POST, 'days'); |
| 1273 | if (!empty($nonce) && wp_verify_nonce($nonce, 'mystickymenu')) { |
| 1274 | if ($days == -1) { |
| 1275 | add_option("my-sticky-menu_hide_review_box", "1"); |
| 1276 | update_option("get_mystickybar_page_views", -1); |
| 1277 | } else { |
| 1278 | $date = date("Y-m-d", strtotime("+".$days." days")); |
| 1279 | update_option("my-sticky-menu_show_review_box_after", $date); |
| 1280 | update_option("get_mystickybar_page_views", 4); |
| 1281 | } |
| 1282 | } |
| 1283 | } |
| 1284 | wp_die(); |
| 1285 | } |
| 1286 | |
| 1287 | public function mystickymenu_review_box_message (){ |
| 1288 | if (current_user_can('manage_options')) { |
| 1289 | $nonce = filter_input(INPUT_POST, 'nonce'); |
| 1290 | if (!empty($nonce) && wp_verify_nonce($nonce, 'mystickymenu')) { |
| 1291 | add_option("my-sticky-menu_hide_review_box", "1"); |
| 1292 | update_option("get_mystickybar_page_views", -1); |
| 1293 | $rating = filter_input(INPUT_POST, 'rating'); |
| 1294 | $message = filter_input(INPUT_POST, 'message'); |
| 1295 | |
| 1296 | if ( $message != '' ) { |
| 1297 | global $current_user; |
| 1298 | $postMessage = []; |
| 1299 | |
| 1300 | $domain = site_url(); |
| 1301 | $user_name = $current_user->first_name." ".$current_user->last_name; |
| 1302 | $email = $current_user->user_email; |
| 1303 | |
| 1304 | $messageData = []; |
| 1305 | $messageData['key'] = "email"; |
| 1306 | $messageData['value'] = $email; |
| 1307 | $postMessage[] = $messageData; |
| 1308 | |
| 1309 | $messageData = []; |
| 1310 | $messageData['key'] = "website"; |
| 1311 | $messageData['value'] = $domain; |
| 1312 | $postMessage[] = $messageData; |
| 1313 | |
| 1314 | $messageData = []; |
| 1315 | $messageData['key'] = "message"; |
| 1316 | $messageData['value'] = $message; |
| 1317 | $postMessage[] = $messageData; |
| 1318 | |
| 1319 | $messageData = []; |
| 1320 | $messageData['key'] = "rating"; |
| 1321 | $messageData['value'] = $rating; |
| 1322 | $postMessage[] = $messageData; |
| 1323 | |
| 1324 | $apiParams = [ |
| 1325 | 'title' => 'Review for My Sticky Bar WordPress', |
| 1326 | 'domain' => $domain, |
| 1327 | 'email' => "contact@premio.io", |
| 1328 | 'url' => site_url(), |
| 1329 | 'name' => $user_name, |
| 1330 | 'message' => $postMessage, |
| 1331 | 'plugin' => 'My Sticky Bar', |
| 1332 | 'type' => "Review", |
| 1333 | ]; |
| 1334 | |
| 1335 | // Sending message to Crisp API |
| 1336 | $apiResponse = wp_safe_remote_post("https://premioapps.com/premio/send-feedback-api.php", ['body' => $apiParams, 'timeout' => 15, 'sslverify' => true]); |
| 1337 | |
| 1338 | if (is_wp_error($apiResponse)) { |
| 1339 | wp_safe_remote_post("https://premioapps.com/premio/send-feedback-api.php", ['body' => $apiParams, 'timeout' => 15, 'sslverify' => false]); |
| 1340 | } |
| 1341 | } |
| 1342 | } |
| 1343 | wp_die(); |
| 1344 | } |
| 1345 | } |
| 1346 | } |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | class MyStickyMenuFrontend |
| 1351 | { |
| 1352 | |
| 1353 | public function __construct() |
| 1354 | { |
| 1355 | add_action( 'wp_head', array( $this, 'mysticky_build_stylesheet_content' ) ); |
| 1356 | add_action( 'wp_enqueue_scripts', array( $this, 'mysticky_disable_at' ) ); |
| 1357 | |
| 1358 | add_action('wp_ajax_stickymenu_contact_lead_form', array($this, 'stickymenu_contact_lead_form')); |
| 1359 | add_action('wp_ajax_nopriv_stickymenu_contact_lead_form', array($this, 'stickymenu_contact_lead_form')); |
| 1360 | } |
| 1361 | |
| 1362 | public function mysticky_build_stylesheet_content() { |
| 1363 | |
| 1364 | $mysticky_options = get_option( 'mysticky_option_name' ); |
| 1365 | |
| 1366 | if (isset($mysticky_options['disable_css'])) { |
| 1367 | //do nothing |
| 1368 | } else { |
| 1369 | $mysticky_options['disable_css'] = false; |
| 1370 | } |
| 1371 | |
| 1372 | if ($mysticky_options ['disable_css'] == false ) { |
| 1373 | |
| 1374 | echo '<style id="mystickymenu" type="text/css">'; |
| 1375 | echo '#mysticky-nav { width:100%; position: static; height: auto !important; }'; |
| 1376 | echo '#mysticky-nav.wrapfixed { position:fixed; left: 0px; margin-top:0px; z-index: '. esc_attr($mysticky_options ['myfixed_zindex']) .'; -webkit-transition: ' . esc_attr($mysticky_options ['myfixed_transition_time']) . 's; -moz-transition: ' . esc_attr($mysticky_options ['myfixed_transition_time']) . 's; -o-transition: ' . esc_attr($mysticky_options ['myfixed_transition_time']) . 's; transition: ' . esc_attr($mysticky_options ['myfixed_transition_time']) . 's; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . esc_attr($mysticky_options ['myfixed_opacity']) . ')"; filter: alpha(opacity=' . esc_attr($mysticky_options ['myfixed_opacity']) . '); opacity:' . esc_attr($mysticky_options ['myfixed_opacity']) / 100 . '; background-color: ' . esc_attr($mysticky_options ['myfixed_bgcolor']) . ';}'; |
| 1377 | |
| 1378 | echo '#mysticky-nav.wrapfixed .myfixed{ background-color: ' . esc_attr($mysticky_options ['myfixed_bgcolor']) . '; position: relative;top: auto;left: auto;right: auto;}'; |
| 1379 | |
| 1380 | if ( isset($mysticky_options ['myfixed_textcolor']) && $mysticky_options ['myfixed_textcolor'] != '' ) { |
| 1381 | echo '#mysticky-nav.wrapfixed ul li.menu-item a { color: ' . esc_attr($mysticky_options ['myfixed_textcolor']) . ';}'; |
| 1382 | } |
| 1383 | |
| 1384 | |
| 1385 | if ($mysticky_options ['myfixed_disable_small_screen'] > 0 ){ |
| 1386 | //echo '@media (max-width: '.$mysticky_options['myfixed_disable_small_screen'].'px) {#mysticky-nav.wrapfixed {position: static;} }'; |
| 1387 | }; |
| 1388 | if ( !isset( $mysticky_options['myfixed_cssstyle'] ) ) { |
| 1389 | echo '#mysticky-nav .myfixed { margin:0 auto; float:none; border:0px; background:none; max-width:100%; }'; |
| 1390 | } |
| 1391 | if ( isset( $mysticky_options['myfixed_cssstyle'] ) && $mysticky_options['myfixed_cssstyle'] != '' ) { |
| 1392 | echo esc_attr($mysticky_options ['myfixed_cssstyle']); |
| 1393 | } |
| 1394 | echo '</style>'; |
| 1395 | $template_name = get_template(); |
| 1396 | ?> |
| 1397 | <style type="text/css"> |
| 1398 | <?php if( $template_name == 'hestia' ) { ?> |
| 1399 | #mysticky-nav.wrapfixed {box-shadow: 0 1px 10px -6px #0000006b,0 1px 10px 0 #0000001f,0 4px 5px -2px #0000001a;} |
| 1400 | #mysticky-nav.wrapfixed .navbar {position: relative;background-color: transparent;box-shadow: none;} |
| 1401 | <?php } ?> |
| 1402 | <?php if( $template_name == 'shapely' ) { ?> |
| 1403 | #mysticky-nav.wrapfixed #site-navigation {position: relative;} |
| 1404 | <?php } ?> |
| 1405 | <?php if( $template_name == 'storefront' ) { ?> |
| 1406 | #mysticky-nav.wrapfixed > .site-header {margin-bottom: 0;} |
| 1407 | #mysticky-nav.wrapfixed > .storefront-primary-navigation {padding: 10px 0;} |
| 1408 | <?php } ?> |
| 1409 | <?php if( $template_name == 'transportex' ) { ?> |
| 1410 | #mysticky-nav.wrapfixed > .transportex-menu-full {margin: 0 auto;} |
| 1411 | .transportex-headwidget #mysticky-nav.wrapfixed .navbar-wp {top: 0;} |
| 1412 | <?php } ?> |
| 1413 | <?php if( $template_name == 'twentynineteen' ) { ?> |
| 1414 | #mysticky-nav.wrapfixed {padding: 10px;} |
| 1415 | <?php } ?> |
| 1416 | <?php if( $template_name == 'twentysixteen' ) { ?> |
| 1417 | #mysticky-nav.wrapfixed > .site-header {padding-top: 0;padding-bottom: 0;} |
| 1418 | <?php } ?> |
| 1419 | <?php if( $template_name == 'twentytwenty' ) { ?> |
| 1420 | #site-header {background: transparent;} |
| 1421 | <?php } ?> |
| 1422 | </style> |
| 1423 | <?php |
| 1424 | } |
| 1425 | } |
| 1426 | |
| 1427 | public function mystickymenu_google_fonts_url() { |
| 1428 | $welcomebar = get_option( 'mysticky_option_welcomebar' ); |
| 1429 | |
| 1430 | $default_fonts = array('System Stack','Arial', 'Tahoma', 'Verdana', 'Helvetica', 'Times New Roman', 'Trebuchet MS', 'Georgia' ); |
| 1431 | $fonts_url = ''; |
| 1432 | $fonts = array(); |
| 1433 | $font_args = array(); |
| 1434 | $base_url = "https://fonts.googleapis.com/css"; |
| 1435 | $fonts['family']['Lato'] = 'Lato:400,500,600,700'; |
| 1436 | if ( isset($welcomebar['mysticky_welcomebar_font']) && $welcomebar['mysticky_welcomebar_font'] !='' && !in_array( $welcomebar['mysticky_welcomebar_font'], $default_fonts) ) { |
| 1437 | $fonts['family'][$welcomebar['mysticky_welcomebar_font']] = $welcomebar['mysticky_welcomebar_font'] . ':400,500,600,700'; |
| 1438 | } |
| 1439 | if ( isset($welcomebar['mysticky_welcomebar_btnfont']) && $welcomebar['mysticky_welcomebar_btnfont'] !='' && !in_array( $welcomebar['mysticky_welcomebar_btnfont'], $default_fonts) ) { |
| 1440 | $fonts['family'][$welcomebar['mysticky_welcomebar_btnfont']] = $welcomebar['mysticky_welcomebar_btnfont'] . ':400,500,600,700'; |
| 1441 | } |
| 1442 | |
| 1443 | /* Prepapre URL if font family defined. */ |
| 1444 | if( !empty( $fonts['family'] ) ) { |
| 1445 | |
| 1446 | /* format family to string */ |
| 1447 | if( is_array($fonts['family']) ){ |
| 1448 | $fonts['family'] = implode( '|', $fonts['family'] ); |
| 1449 | } |
| 1450 | |
| 1451 | $font_args['family'] = urlencode( trim( $fonts['family'] ) ); |
| 1452 | |
| 1453 | if( !empty( $fonts['subsets'] ) ){ |
| 1454 | |
| 1455 | /* format subsets to string */ |
| 1456 | if( is_array( $fonts['subsets'] ) ){ |
| 1457 | $fonts['subsets'] = implode( ',', $fonts['subsets'] ); |
| 1458 | } |
| 1459 | |
| 1460 | $font_args['subsets'] = urlencode( trim( $fonts['subsets'] ) ); |
| 1461 | } |
| 1462 | |
| 1463 | $fonts_url = add_query_arg( $font_args, $base_url ); |
| 1464 | } |
| 1465 | |
| 1466 | return esc_url_raw( $fonts_url ); |
| 1467 | } |
| 1468 | |
| 1469 | public function mystickymenu_script() { |
| 1470 | |
| 1471 | wp_enqueue_script( 'jquery' ); |
| 1472 | |
| 1473 | $mysticky_options = get_option( 'mysticky_option_name' ); |
| 1474 | |
| 1475 | if ( is_admin_bar_showing() ) { |
| 1476 | $top = "true"; |
| 1477 | } else { |
| 1478 | $top = "false"; |
| 1479 | } |
| 1480 | |
| 1481 | $welcomebar = get_option( 'mysticky_option_welcomebar' ); |
| 1482 | if ( isset($welcomebar['mysticky_welcomebar_enable']) && $welcomebar['mysticky_welcomebar_enable'] == 1 ) { |
| 1483 | if(!isset($welcomebar['load_fonts_from_google']) || $welcomebar['load_fonts_from_google'] == 1) { |
| 1484 | wp_enqueue_style('google-fonts', $this->mystickymenu_google_fonts_url(), array(), MYSTICKY_VERSION); |
| 1485 | } |
| 1486 | } |
| 1487 | |
| 1488 | wp_enqueue_script( |
| 1489 | 'morphext-js', |
| 1490 | plugins_url("/dist/js/morphext.js", __FILE__), |
| 1491 | array('jquery'), |
| 1492 | MYSTICKY_VERSION, |
| 1493 | ['strategy' => 'defer', 'in_footer'=> true ] |
| 1494 | ); |
| 1495 | wp_register_script('welcomebar-frontjs', plugins_url("/dist/js/welcomebar-front.js", __FILE__), array( 'jquery', 'morphext-js' ), MYSTICKY_VERSION, ['strategy' => 'defer', 'in_footer'=> true ]); |
| 1496 | wp_enqueue_script('welcomebar-frontjs'); |
| 1497 | |
| 1498 | wp_localize_script( 'welcomebar-frontjs', 'welcomebar_frontjs', |
| 1499 | array( |
| 1500 | 'ajaxurl' => admin_url( 'admin-ajax.php' ) , |
| 1501 | 'days' => __( 'Days', 'mystickymenu' ), |
| 1502 | 'hours' => __( 'Hours', 'mystickymenu' ), |
| 1503 | 'minutes' => __( 'Minutes', 'mystickymenu' ), |
| 1504 | 'seconds' => __( 'Seconds', 'mystickymenu' ), |
| 1505 | 'ajax_nonce' => wp_create_nonce('mystickymenu'), |
| 1506 | ) |
| 1507 | ); |
| 1508 | |
| 1509 | wp_enqueue_style( 'msb-front', plugins_url("dist/css/mystickymenu-front.css", __FILE__), array(), MYSTICKY_VERSION ); |
| 1510 | |
| 1511 | if( !isset($mysticky_options['stickymenu_enable']) || isset($mysticky_options['stickymenu_enable']) && $mysticky_options['stickymenu_enable'] == 0){ |
| 1512 | return; |
| 1513 | } |
| 1514 | // needed for update 1.7 => 1.8 ... will be removed in the future () |
| 1515 | if (isset($mysticky_options['mysticky_active_on_height_home'])) { |
| 1516 | //do nothing |
| 1517 | } else { |
| 1518 | $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height']; |
| 1519 | } |
| 1520 | |
| 1521 | |
| 1522 | if ($mysticky_options['mysticky_active_on_height_home'] == 0 ) { |
| 1523 | $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height']; |
| 1524 | } |
| 1525 | |
| 1526 | |
| 1527 | if ( is_front_page() && is_home() ) { |
| 1528 | $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home']; |
| 1529 | } elseif ( is_front_page()){ |
| 1530 | $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home']; |
| 1531 | } |
| 1532 | |
| 1533 | wp_register_script('detectmobilebrowser', plugins_url( "dist/js/detectmobilebrowser.js", __FILE__ ), array('jquery'), MYSTICKY_VERSION, ['strategy' => 'defer', 'in_footer'=> true ]); |
| 1534 | wp_enqueue_script( 'detectmobilebrowser' ); |
| 1535 | |
| 1536 | wp_register_script( |
| 1537 | 'mystickymenu', |
| 1538 | plugins_url("/dist/js/mystickymenu.js", __FILE__), |
| 1539 | array('jquery'), |
| 1540 | MYSTICKY_VERSION, |
| 1541 | ['strategy' => 'defer', 'in_footer'=> true ] |
| 1542 | ); |
| 1543 | wp_enqueue_script( 'mystickymenu' ); |
| 1544 | |
| 1545 | $myfixed_disable_scroll_down = isset($mysticky_options['myfixed_disable_scroll_down']) ? esc_attr($mysticky_options['myfixed_disable_scroll_down']) : 'false'; |
| 1546 | $mystickyTransition = isset($mysticky_options['myfixed_fade']) ? esc_attr($mysticky_options['myfixed_fade']) : 'fade'; |
| 1547 | $mystickyDisableLarge = isset($mysticky_options['myfixed_disable_large_screen']) ? esc_attr($mysticky_options['myfixed_disable_large_screen']) : '0'; |
| 1548 | |
| 1549 | $mystickyClass = ( $mysticky_options['mysticky_class_id_selector'] != 'custom') ? '.menu-' . $mysticky_options['mysticky_class_id_selector'] .'-container' : $mysticky_options['mysticky_class_selector']; |
| 1550 | |
| 1551 | if ( $mysticky_options['mysticky_class_id_selector'] != 'custom' ) { |
| 1552 | $template_name = get_template(); |
| 1553 | switch( $template_name ){ |
| 1554 | case 'ashe': |
| 1555 | $mystickyClass = '#main-nav'; |
| 1556 | break; |
| 1557 | case 'astra': |
| 1558 | case 'hello-elementor': |
| 1559 | case 'sydney': |
| 1560 | case 'twentysixteen': |
| 1561 | $mystickyClass = 'header.site-header'; |
| 1562 | break; |
| 1563 | case 'generatepress': |
| 1564 | $mystickyClass = 'nav.main-navigation'; |
| 1565 | break; |
| 1566 | case 'transportex': |
| 1567 | $mystickyClass = '.transportex-menu-full'; |
| 1568 | break; |
| 1569 | case 'hestia': |
| 1570 | case 'neve': |
| 1571 | $mystickyClass = 'header.header'; |
| 1572 | break; |
| 1573 | case 'mesmerize': |
| 1574 | $mystickyClass = '.navigation-bar'; |
| 1575 | break; |
| 1576 | case 'oceanwp': |
| 1577 | $mystickyClass = 'header#site-header'; |
| 1578 | break; |
| 1579 | case 'shapely': |
| 1580 | $mystickyClass = '#site-navigation'; |
| 1581 | break; |
| 1582 | case 'storefront': |
| 1583 | $mystickyClass = '.storefront-primary-navigation'; |
| 1584 | break; |
| 1585 | case 'twentynineteen': |
| 1586 | $mystickyClass = '#site-navigation'; |
| 1587 | break; |
| 1588 | case 'twentyseventeen': |
| 1589 | $mystickyClass = '.navigation-top'; |
| 1590 | break; |
| 1591 | default: |
| 1592 | break; |
| 1593 | } |
| 1594 | } |
| 1595 | |
| 1596 | |
| 1597 | $mysticky_translation_array = array( |
| 1598 | 'mystickyClass' => $mystickyClass, |
| 1599 | 'activationHeight' => $mysticky_options['mysticky_active_on_height'], |
| 1600 | 'disableWidth' => $mysticky_options['myfixed_disable_small_screen'], |
| 1601 | 'disableLargeWidth' => $mystickyDisableLarge, |
| 1602 | 'adminBar' => $top, |
| 1603 | 'device_desktop' => true, |
| 1604 | 'device_mobile' => true, |
| 1605 | 'mystickyTransition' => $mystickyTransition, |
| 1606 | 'mysticky_disable_down' => $myfixed_disable_scroll_down, |
| 1607 | ); |
| 1608 | wp_localize_script( 'mystickymenu', 'option', $mysticky_translation_array ); |
| 1609 | } |
| 1610 | |
| 1611 | public function mysticky_disable_at() { |
| 1612 | $mysticky_options = get_option( 'mysticky_option_name' ); |
| 1613 | $mysticky_disable_at_front_home = isset($mysticky_options['mysticky_disable_at_front_home']); |
| 1614 | $mysticky_disable_at_blog = isset($mysticky_options['mysticky_disable_at_blog']); |
| 1615 | $mysticky_disable_at_page = isset($mysticky_options['mysticky_disable_at_page']); |
| 1616 | $mysticky_disable_at_tag = isset($mysticky_options['mysticky_disable_at_tag']); |
| 1617 | $mysticky_disable_at_category = isset($mysticky_options['mysticky_disable_at_category']); |
| 1618 | $mysticky_disable_at_single = isset($mysticky_options['mysticky_disable_at_single']); |
| 1619 | $mysticky_disable_at_archive = isset($mysticky_options['mysticky_disable_at_archive']); |
| 1620 | $mysticky_disable_at_search = isset($mysticky_options['mysticky_disable_at_search']); |
| 1621 | $mysticky_disable_at_404 = isset($mysticky_options['mysticky_disable_at_404']); |
| 1622 | $mysticky_enable_at_pages = isset($mysticky_options['mysticky_enable_at_pages']) ? esc_attr($mysticky_options['mysticky_enable_at_pages']) : ''; |
| 1623 | $mysticky_enable_at_posts = isset($mysticky_options['mysticky_enable_at_posts']) ? esc_attr($mysticky_options['mysticky_enable_at_posts']) : ''; |
| 1624 | |
| 1625 | // Trim input to ignore empty spaces |
| 1626 | $mysticky_enable_at_pages_exp = array_map('trim', explode(',', $mysticky_enable_at_pages)); |
| 1627 | $mysticky_enable_at_posts_exp = array_map('trim', explode(',', $mysticky_enable_at_posts)); |
| 1628 | |
| 1629 | if ( is_front_page() && is_home() ) { /* Default homepage */ |
| 1630 | if ( $mysticky_disable_at_front_home == false ) { |
| 1631 | $this->mystickymenu_script(); |
| 1632 | } |
| 1633 | } elseif ( is_front_page()){ /* Static homepage */ |
| 1634 | if ( $mysticky_disable_at_front_home == false ) { |
| 1635 | $this->mystickymenu_script(); |
| 1636 | } |
| 1637 | } elseif ( is_home()){ /* Blog page */ |
| 1638 | if ( $mysticky_disable_at_blog == false ) { |
| 1639 | $this->mystickymenu_script(); |
| 1640 | } |
| 1641 | } elseif ( is_page() ){ /* Single page*/ |
| 1642 | if ( $mysticky_disable_at_page == false ) { |
| 1643 | $this->mystickymenu_script(); |
| 1644 | } |
| 1645 | if ( is_page( $mysticky_enable_at_pages_exp ) ){ |
| 1646 | $this->mystickymenu_script(); |
| 1647 | } |
| 1648 | } elseif ( is_tag()){ /* Tag page */ |
| 1649 | if ( $mysticky_disable_at_tag == false ) { |
| 1650 | $this->mystickymenu_script(); |
| 1651 | } |
| 1652 | } elseif ( is_category()){ /* Category page */ |
| 1653 | if ( $mysticky_disable_at_category == false ) { |
| 1654 | $this->mystickymenu_script(); |
| 1655 | } |
| 1656 | } elseif ( is_single()){ /* Single post */ |
| 1657 | if ( $mysticky_disable_at_single == false ) { |
| 1658 | $this->mystickymenu_script(); |
| 1659 | } |
| 1660 | if ( is_single( $mysticky_enable_at_posts_exp ) ){ |
| 1661 | $this->mystickymenu_script(); |
| 1662 | } |
| 1663 | } elseif ( is_archive()){ /* Archive */ |
| 1664 | if ( $mysticky_disable_at_archive == false ) { |
| 1665 | $this->mystickymenu_script(); |
| 1666 | } |
| 1667 | } elseif ( is_search()){ /* Search */ |
| 1668 | if ( $mysticky_disable_at_search == false ) { |
| 1669 | $this->mystickymenu_script(); |
| 1670 | } |
| 1671 | } elseif ( is_404()){ /* 404 */ |
| 1672 | if ( $mysticky_disable_at_404 == false ) { |
| 1673 | $this->mystickymenu_script(); |
| 1674 | } |
| 1675 | } |
| 1676 | } |
| 1677 | |
| 1678 | /** |
| 1679 | * Mysticky Menu: Contact Form Lead Submission Function |
| 1680 | * DATE : 2022-08-04 |
| 1681 | * */ |
| 1682 | |
| 1683 | public function stickymenu_contact_lead_form(){ |
| 1684 | global $wpdb; |
| 1685 | global $wp; |
| 1686 | $stickymenus_widgets = get_option( 'mystickymenu-welcomebars' ); |
| 1687 | $errors = array(); |
| 1688 | $element_widget_no = $_POST['widget_id']; |
| 1689 | |
| 1690 | $element_widget_name = (isset($stickymenus_widgets[$element_widget_no]) && $stickymenus_widgets[$element_widget_no] != '' ) ? esc_html($stickymenus_widgets[$element_widget_no]) : ''; |
| 1691 | |
| 1692 | $flag = true; |
| 1693 | if( isset($element_widget_name) && $element_widget_name != ''){ |
| 1694 | if( !isset($_POST['contact_name']) || $_POST['contact_name'] == ''){ |
| 1695 | $error = array( |
| 1696 | 'key' => "contact-form-name", |
| 1697 | 'message' => __( "This field is required", "mystickymenu" ) |
| 1698 | ); |
| 1699 | $errors[] = $error; |
| 1700 | $flag = false; |
| 1701 | }else{ |
| 1702 | $contact_lists_table = $wpdb->prefix . 'mystickymenu_contact_lists'; |
| 1703 | $postArr = $_POST; |
| 1704 | |
| 1705 | if( $element_widget_no == 0 ){ |
| 1706 | $element_widget_no = ''; |
| 1707 | } |
| 1708 | |
| 1709 | $allowed_keys = ['contact_name', 'contact_email', 'contact_phone', 'page_link']; |
| 1710 | $params = []; |
| 1711 | foreach ($allowed_keys as $key) { |
| 1712 | if (isset($_POST[$key]) && $_POST[$key] !== '') { |
| 1713 | $params[$key] = sanitize_text_field($_POST[$key]); |
| 1714 | } |
| 1715 | } |
| 1716 | |
| 1717 | if(!empty($params)) { |
| 1718 | $params["widget_id"] = esc_sql(sanitize_text_field($element_widget_no)); |
| 1719 | $params["widget_name"] = esc_sql(sanitize_text_field($element_widget_name)); |
| 1720 | $params["message_date"] = date('Y-m-d H:i:s'); |
| 1721 | $params["contact_email"] = (isset($params["contact_email"]) && $params["contact_email"] != '') ? sanitize_email($params["contact_email"]) : ''; |
| 1722 | |
| 1723 | $wpdb->insert($contact_lists_table, $params); |
| 1724 | die; |
| 1725 | } |
| 1726 | } |
| 1727 | } |
| 1728 | |
| 1729 | if( $flag != true ){ |
| 1730 | echo json_encode(array("status" => 0, "error" => 1, "errors" => $errors, "message" => $errors['message'])); |
| 1731 | } |
| 1732 | die; |
| 1733 | } |
| 1734 | |
| 1735 | } |
| 1736 | |
| 1737 | new MyStickyMenuBackend(); |
| 1738 | new MyStickyMenuFrontend(); |
| 1739 | |
| 1740 | register_activation_hook( __FILE__, 'mystickymenu_activate' ); |
| 1741 | |
| 1742 | function mystickymenu_activate() { |
| 1743 | update_option( 'update_mysticky_version_2_5_7', true ); |
| 1744 | |
| 1745 | global $wpdb; |
| 1746 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 1747 | $charset_collate = $wpdb->get_charset_collate(); |
| 1748 | |
| 1749 | $contact_lists_table = $wpdb->prefix . 'mystickymenu_contact_lists'; |
| 1750 | |
| 1751 | if ($wpdb->get_var("show tables like '$contact_lists_table'") != $contact_lists_table) { |
| 1752 | |
| 1753 | $contact_lists_table_sql = "CREATE TABLE $contact_lists_table ( |
| 1754 | ID int(11) NOT NULL AUTO_INCREMENT, |
| 1755 | widget_id INT(11) NULL, |
| 1756 | contact_name varchar(255) NULL, |
| 1757 | contact_phone varchar(255) NULL, |
| 1758 | contact_email varchar(255) NULL, |
| 1759 | widget_name varchar(255) NULL, |
| 1760 | page_link varchar(522) NULL, |
| 1761 | message_date DATETIME NOT NULL default '0000-00-00 00:00:00', |
| 1762 | PRIMARY KEY (ID) |
| 1763 | ) $charset_collate;"; |
| 1764 | dbDelta($contact_lists_table_sql); |
| 1765 | } |
| 1766 | } |
| 1767 | |
| 1768 | |
| 1769 | add_action( 'admin_init' , 'mystickymenu_admin_init' ); |
| 1770 | |
| 1771 | function mystickymenu_admin_init(){ |
| 1772 | |
| 1773 | global $wpdb; |
| 1774 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 1775 | $charset_collate = $wpdb->get_charset_collate(); |
| 1776 | |
| 1777 | $contact_lists_table = $wpdb->prefix . 'mystickymenu_contact_lists'; |
| 1778 | |
| 1779 | if ($wpdb->get_var("show tables like '$contact_lists_table'") != $contact_lists_table) { |
| 1780 | |
| 1781 | $contact_lists_table_sql = "CREATE TABLE $contact_lists_table ( |
| 1782 | ID int(11) NOT NULL AUTO_INCREMENT, |
| 1783 | widget_id INT(11) NULL, |
| 1784 | contact_name varchar(255) NULL, |
| 1785 | contact_phone varchar(255) NULL, |
| 1786 | contact_email varchar(255) NULL, |
| 1787 | widget_name varchar(255) NULL, |
| 1788 | page_link varchar(522) NULL, |
| 1789 | message_date DATETIME NOT NULL default '0000-00-00 00:00:00', |
| 1790 | PRIMARY KEY (ID) |
| 1791 | ) $charset_collate;"; |
| 1792 | dbDelta($contact_lists_table_sql); |
| 1793 | } |
| 1794 | |
| 1795 | if(get_option('msb_cl_widget_id_exists', false) == false){ |
| 1796 | // Check if the column already exists |
| 1797 | |
| 1798 | $column_exists = $wpdb->get_results( |
| 1799 | $wpdb->prepare( |
| 1800 | "SHOW COLUMNS FROM $contact_lists_table LIKE %s", |
| 1801 | 'widget_id' |
| 1802 | ) |
| 1803 | ); |
| 1804 | |
| 1805 | if (empty($column_exists)) { |
| 1806 | update_option('msb_cl_widget_id_exists', true); |
| 1807 | $wpdb->query( |
| 1808 | "ALTER TABLE $contact_lists_table ADD COLUMN widget_id INT(11) NULL AFTER ID" |
| 1809 | ); |
| 1810 | } |
| 1811 | } |
| 1812 | |
| 1813 | } |
| 1814 | |
| 1815 | function mystickymenu_change_menu_text() { |
| 1816 | global $submenu; |
| 1817 | if(isset($submenu['my-stickymenu-welcomebar'])) { |
| 1818 | $totalItems = count($submenu['my-stickymenu-welcomebar'])-1; |
| 1819 | if(isset($submenu['my-stickymenu-welcomebar'][$totalItems][0])) { |
| 1820 | $submenu['my-stickymenu-welcomebar'][$totalItems][0] = '<span><svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| 1821 | <path d="M13.0518 4.01946C12.9266 3.91499 12.7747 3.84781 12.6132 3.82557C12.4517 3.80333 12.2872 3.82693 12.1385 3.89367L9.3713 5.12414L7.76349 2.22571C7.68664 2.09039 7.5753 1.97785 7.44081 1.89956C7.30632 1.82127 7.15348 1.78003 6.99786 1.78003C6.84224 1.78003 6.6894 1.82127 6.55491 1.89956C6.42042 1.97785 6.30908 2.09039 6.23224 2.22571L4.62442 5.12414L1.85724 3.89367C1.70822 3.82703 1.54352 3.8034 1.38178 3.82545C1.22003 3.84751 1.06768 3.91437 0.941941 4.01849C0.816207 4.1226 0.722106 4.25982 0.670275 4.41461C0.618444 4.56941 0.610951 4.73562 0.648642 4.89446L2.0377 10.8171C2.06427 10.9318 2.11383 11.0399 2.18339 11.1348C2.25295 11.2297 2.34107 11.3096 2.44239 11.3695C2.57957 11.4516 2.73642 11.495 2.8963 11.4952C2.97402 11.4951 3.05133 11.484 3.12599 11.4624C5.65792 10.7624 8.33233 10.7624 10.8643 11.4624C11.0955 11.5232 11.3413 11.4898 11.5479 11.3695C11.6498 11.3103 11.7384 11.2307 11.8081 11.1357C11.8777 11.0406 11.9269 10.9321 11.9525 10.8171L13.3471 4.89446C13.3843 4.73558 13.3764 4.56945 13.3243 4.41482C13.2721 4.2602 13.1777 4.12326 13.0518 4.01946V4.01946Z" fill="white"/> |
| 1822 | </svg></span> '.esc_html__( 'Upgrade to Pro' , 'mystickymenu'); |
| 1823 | } |
| 1824 | } |
| 1825 | } |
| 1826 | add_action('admin_init', 'mystickymenu_change_menu_text'); |
| 1827 | |
| 1828 | add_action('admin_footer', 'mystickymenu_admin_footer_style'); |
| 1829 | function mystickymenu_admin_footer_style() { |
| 1830 | ?> |
| 1831 | <style> |
| 1832 | #adminmenu .toplevel_page_my-stickymenu-welcomebar > ul > li:last-child { |
| 1833 | padding: 5px 10px; |
| 1834 | } |
| 1835 | #adminmenu .toplevel_page_my-stickymenu-welcomebar > ul > li:last-child a { |
| 1836 | display: flex; |
| 1837 | background-color: #B78DEB; |
| 1838 | border-radius: 6px; |
| 1839 | font-size: 12px; |
| 1840 | gap: 4px; |
| 1841 | padding: 4px 8px; |
| 1842 | color: #ffffff; |
| 1843 | align-items: center; |
| 1844 | transition: all 0.2s linear; |
| 1845 | font-weight: normal; |
| 1846 | box-shadow: 0px 6px 8px 0px #B78DEB3D; |
| 1847 | justify-content: center; |
| 1848 | } |
| 1849 | #adminmenu .toplevel_page_my-stickymenu-welcomebar > ul > li:last-child a:hover, #adminmenu .toplevel_page_my-stickymenu-welcomebar > ul > li:last-child a.current { |
| 1850 | box-shadow: 0px 6px 8px 0px #B78DEB3D; |
| 1851 | color: #ffffff; |
| 1852 | background-color: #9565d0; |
| 1853 | font-weight: normal; |
| 1854 | } |
| 1855 | #adminmenu .toplevel_page_my-stickymenu-welcomebar > ul > li:last-child a span { |
| 1856 | flex: 0 0 16px; |
| 1857 | height: 16px; |
| 1858 | background-color: #c5a4ef; |
| 1859 | border-radius: 4px; |
| 1860 | padding: 2px; |
| 1861 | display: inline-flex; |
| 1862 | transition: all 0.2s linear; |
| 1863 | } |
| 1864 | #adminmenu .toplevel_page_my-stickymenu-welcomebar > ul > li:last-child a:hover span { |
| 1865 | background-color: #B78DEB; |
| 1866 | } |
| 1867 | #adminmenu .toplevel_page_my-stickymenu-welcomebar > ul > li:last-child a span svg { |
| 1868 | width: 100%; |
| 1869 | height: 100%; |
| 1870 | } |
| 1871 | </style> |
| 1872 | <?php |
| 1873 | } |
| 1874 | |
| 1875 | |
| 1876 | /* |
| 1877 | * Sanitize Sticky Bar option fields |
| 1878 | * Return $sanitized_array Sanitize array |
| 1879 | * |
| 1880 | * @since 2.7.3 |
| 1881 | */ |
| 1882 | function mysticky_bar_sanitize_options( $welcomebar_options ) { |
| 1883 | $sanitized_array = []; |
| 1884 | foreach ($welcomebar_options as $key => $value) { |
| 1885 | |
| 1886 | if (is_array($value)) { |
| 1887 | $sanitized_array[$key] = mysticky_bar_sanitize_options( $value ); // Recursive call for nested arrays |
| 1888 | } else { |
| 1889 | |
| 1890 | switch ($key) { |
| 1891 | case 'sender_email': |
| 1892 | $sanitized_array[$key] = sanitize_email($value); |
| 1893 | break; |
| 1894 | case 'mysticky_welcomebar_redirect': |
| 1895 | $sanitized_array[$key] = sanitize_url($value); |
| 1896 | break; |
| 1897 | case 'mysticky_welcomebar_bar_text': |
| 1898 | case 'mysticky_welcomebar_thankyou_screen_text': |
| 1899 | $sanitized_array[$key] = sanitize_textarea_field($value); |
| 1900 | break; |
| 1901 | default: |
| 1902 | $sanitized_array[$key] = sanitize_text_field($value); |
| 1903 | } |
| 1904 | |
| 1905 | } |
| 1906 | } |
| 1907 | return $sanitized_array; |
| 1908 | } |