mystickymenu
Last commit date
css
5 years ago
fonts
7 years ago
images
5 years ago
js
5 years ago
languages
5 years ago
class-review-box.php
5 years ago
index.php
8 years ago
mystickymenu-affiliate.php
5 years ago
mystickymenu-deactivate-form.php
5 years ago
mystickymenu-fonts.php
5 years ago
mystickymenu-popup.php
5 years ago
mystickymenu.php
5 years ago
mystickymeny-new-welcomebar.php
5 years ago
readme.txt
5 years ago
recommended-plugins.php
5 years ago
uninstall.php
5 years ago
update.php
5 years ago
upgrade-to-pro.php
5 years ago
welcome-bar.php
5 years ago
mystickymenu.php
1416 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: myStickymenu |
| 4 | Plugin URI: https://premio.io/ |
| 5 | Description: Simple sticky (fixed on top) menu implementation for navigation menu and Welcome bar for announcements and promotion. After install go to Settings / myStickymenu and change Sticky Class to .your_navbar_class or #your_navbar_id. |
| 6 | Version: 2.5 |
| 7 | Author: Premio |
| 8 | Author URI: https://premio.io/downloads/mystickymenu/ |
| 9 | Text Domain: mystickymenu |
| 10 | Domain Path: /languages |
| 11 | License: GPLv2 or later |
| 12 | */ |
| 13 | |
| 14 | defined('ABSPATH') or die("Cannot access pages directly."); |
| 15 | define( 'MYSTICKY_VERSION', '2.5' ); |
| 16 | define('MYSTICKYMENU_URL', plugins_url('/', __FILE__)); // Define Plugin URL |
| 17 | define('MYSTICKYMENU_PATH', plugin_dir_path(__FILE__)); // Define Plugin Directory Path |
| 18 | |
| 19 | require_once("mystickymenu-fonts.php"); |
| 20 | require_once("welcome-bar.php"); |
| 21 | |
| 22 | if( is_admin() ) { |
| 23 | include_once 'class-review-box.php'; |
| 24 | } |
| 25 | |
| 26 | class MyStickyMenuBackend |
| 27 | { |
| 28 | private $options; |
| 29 | |
| 30 | public function __construct() |
| 31 | { |
| 32 | add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); |
| 33 | add_action( 'admin_init', array( $this, 'mysticky_load_transl') ); |
| 34 | |
| 35 | add_action( 'admin_init', array( $this, 'mysticky_default_options' ) ); |
| 36 | add_action( 'admin_enqueue_scripts', array( $this, 'mysticky_admin_script' ) ); |
| 37 | |
| 38 | add_filter( 'plugin_action_links_mystickymenu/mystickymenu.php', array( $this, 'mystickymenu_settings_link' ) ); |
| 39 | |
| 40 | add_action( 'activated_plugin', array( $this, 'mystickymenu_activation_redirect' ) ); |
| 41 | |
| 42 | add_action("wp_ajax_sticky_menu_update_status", array($this, 'sticky_menu_update_status')); |
| 43 | |
| 44 | add_action("wp_ajax_mystickymenu_update_popup_status", array($this, 'mystickymenu_popup_status')); |
| 45 | |
| 46 | add_action( 'admin_footer', array( $this, 'mystickymenu_deactivate' ) ); |
| 47 | add_action( 'wp_ajax_mystickymenu_plugin_deactivate', array( $this, 'mystickymenu_plugin_deactivate' ) ); |
| 48 | } |
| 49 | |
| 50 | public function mystickymenu_popup_status() { |
| 51 | if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'mystickymenu_update_popup_status')) { |
| 52 | update_option("mystickymenu_intro_box", "hide"); |
| 53 | } |
| 54 | echo esc_attr("1"); |
| 55 | die; |
| 56 | } |
| 57 | |
| 58 | public function sticky_menu_update_status() { |
| 59 | if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'myStickymenu_update_nonce')) { |
| 60 | $status = self::sanitize_options($_REQUEST['status']); |
| 61 | $email = self::sanitize_options($_REQUEST['email']); |
| 62 | update_option("mystickymenu_update_message", 2); |
| 63 | if($status == 1) { |
| 64 | $url = 'https://go.premio.io/api/update.php?email='.$email.'&plugin=myStickymenu'; |
| 65 | $handle = curl_init(); |
| 66 | curl_setopt($handle, CURLOPT_URL, $url); |
| 67 | curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); |
| 68 | $response = curl_exec($handle); |
| 69 | curl_close($handle); |
| 70 | } |
| 71 | } |
| 72 | echo "1"; |
| 73 | die; |
| 74 | } |
| 75 | |
| 76 | public function mystickymenu_settings_link($links){ |
| 77 | $settings_link = '<a href="admin.php?page=my-stickymenu-welcomebar">Settings</a>'; |
| 78 | $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;">'.__( 'Upgrade', 'stars-testimonials' ).'</a>'; |
| 79 | array_unshift($links, $settings_link); |
| 80 | return $links; |
| 81 | } |
| 82 | |
| 83 | public function mystickymenu_activation_redirect( $plugin) { |
| 84 | if( $plugin == plugin_basename( __FILE__ ) ) { |
| 85 | $is_shown = get_option("mystickymenu_update_message"); |
| 86 | if($is_shown === false) { |
| 87 | add_option("mystickymenu_update_message", 1); |
| 88 | } |
| 89 | $option = get_option("mystickymenu_intro_box"); |
| 90 | if($option === false) { |
| 91 | add_option("mystickymenu_intro_box", "show"); |
| 92 | } |
| 93 | wp_redirect( admin_url( 'admin.php?page=my-stickymenu-welcomebar' ) ) ; |
| 94 | exit; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | public function mysticky_admin_script($hook) { |
| 99 | |
| 100 | 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-stickymenu-upgrade' && $_GET['page'] != 'msm-recommended-plugins' )) { |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | wp_enqueue_style('mystickymenuAdminStyle', plugins_url('/css/mystickymenu-admin.css', __FILE__), array(), MYSTICKY_VERSION ); |
| 105 | wp_enqueue_style( 'wp-color-picker' ); |
| 106 | //wp_enqueue_script( 'wp-color-picker-alpha', plugins_url('/js/wp-color-picker-alpha.min.js', __FILE__), array( 'wp-color-picker' ), MYSTICKY_VERSION ); |
| 107 | wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
| 108 | wp_enqueue_style('jquery-ui'); |
| 109 | |
| 110 | wp_enqueue_script('jquery-ui'); |
| 111 | wp_enqueue_script('jquery-ui-slider'); |
| 112 | //wp_enqueue_script('jquery-ui-datepicker'); |
| 113 | wp_enqueue_script( 'jquery-ui-dialog' ); |
| 114 | wp_enqueue_script( 'my-script-handle', plugins_url('js/iris-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true ); |
| 115 | |
| 116 | if($hook == "mystickymenu_page_my-stickymenu-upgrade") { |
| 117 | wp_enqueue_script( 'my-select2', plugins_url('js/select2.min.js', __FILE__ ), array( 'wp-color-picker' ), false, true ); |
| 118 | wp_enqueue_style('my-css-select2', plugins_url('css/select2.min.css', __FILE__), array(), MYSTICKY_VERSION ); |
| 119 | wp_enqueue_style('my-css-admin-settings', plugins_url('css/admin-setting.css', __FILE__), array(), MYSTICKY_VERSION ); |
| 120 | } |
| 121 | |
| 122 | wp_enqueue_script('mystickymenuAdminScript', plugins_url('/js/mystickymenu-admin.js', __FILE__), array( 'jquery', 'jquery-ui-slider' ), MYSTICKY_VERSION); |
| 123 | } |
| 124 | |
| 125 | public function mysticky_load_transl(){ |
| 126 | load_plugin_textdomain('mystickymenu', FALSE, dirname(plugin_basename(__FILE__)).'/languages/'); |
| 127 | } |
| 128 | |
| 129 | function sanitize_options($value) { |
| 130 | $value = stripslashes($value); |
| 131 | $value = filter_var($value, FILTER_SANITIZE_STRING); |
| 132 | return $value; |
| 133 | } |
| 134 | |
| 135 | public function add_plugin_page(){ |
| 136 | if ( isset($_GET['hide_msmrecommended_plugin']) && $_GET['hide_msmrecommended_plugin'] == 1) { |
| 137 | update_option('hide_msmrecommended_plugin',true); |
| 138 | } |
| 139 | $hide_msmrecommended_plugin = get_option('hide_msmrecommended_plugin'); |
| 140 | // This page will be under "Settings" |
| 141 | add_menu_page( |
| 142 | 'Settings Admin', |
| 143 | 'myStickymenu', |
| 144 | 'manage_options', |
| 145 | 'my-stickymenu-welcomebar', |
| 146 | array( $this, 'mystickystickymenu_admin_welcomebar_page' ) |
| 147 | ); |
| 148 | add_submenu_page( |
| 149 | 'my-stickymenu-welcomebar', |
| 150 | 'Settings Admin', |
| 151 | 'Welcome Bar', |
| 152 | 'manage_options', |
| 153 | 'my-stickymenu-welcomebar', |
| 154 | array( $this, 'mystickystickymenu_admin_welcomebar_page' ) |
| 155 | ); |
| 156 | |
| 157 | add_submenu_page( |
| 158 | 'my-stickymenu-welcomebar', |
| 159 | 'Settings Admin', |
| 160 | '+ Create New Welcome Bar', |
| 161 | 'manage_options', |
| 162 | 'my-stickymenu-new-welcomebar', |
| 163 | array( $this, 'mystickystickymenu_admin_new_welcomebar_page' ) |
| 164 | ); |
| 165 | |
| 166 | add_submenu_page( |
| 167 | 'my-stickymenu-welcomebar', |
| 168 | 'Settings Admin', |
| 169 | 'Sticky menu settings', |
| 170 | 'manage_options', |
| 171 | 'my-stickymenu-settings', |
| 172 | array( $this, 'create_admin_page' ) |
| 173 | ); |
| 174 | |
| 175 | |
| 176 | if ( !$hide_msmrecommended_plugin){ |
| 177 | add_submenu_page( |
| 178 | 'my-stickymenu-welcomebar', |
| 179 | 'msm-recommended-plugins', |
| 180 | 'Recommended Plugins', |
| 181 | 'manage_options', |
| 182 | 'msm-recommended-plugins', |
| 183 | array( $this, 'mystickymenu_recommended_plugins' ) |
| 184 | ); |
| 185 | } |
| 186 | add_submenu_page( |
| 187 | 'my-stickymenu-welcomebar', |
| 188 | 'Upgrade to Pro', |
| 189 | 'Upgrade to Pro', |
| 190 | 'manage_options', |
| 191 | 'my-stickymenu-upgrade', |
| 192 | array( $this, 'mystickymenu_admin_upgrade_to_pro' ) |
| 193 | ); |
| 194 | } |
| 195 | |
| 196 | public function create_admin_page(){ |
| 197 | |
| 198 | $upgarde_url = admin_url("admin.php?page=my-stickymenu-upgrade"); |
| 199 | // Set class property |
| 200 | if (isset($_POST['mysticky_option_name']) && !empty($_POST['mysticky_option_name']) && isset($_POST['nonce'])) { |
| 201 | if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'mysticky_option_backend_update')) { |
| 202 | $post = $_POST['mysticky_option_name']; |
| 203 | foreach($post as $key=>$value) { |
| 204 | $post[$key] = self::sanitize_options($value); |
| 205 | } |
| 206 | |
| 207 | $post['device_desktop'] = 'on'; |
| 208 | $post['device_mobile'] = 'on'; |
| 209 | update_option( 'mysticky_option_name', $post); |
| 210 | $this->mysticky_clear_all_caches(); |
| 211 | echo '<div class="updated settings-error notice is-dismissible "><p><strong>' . esc_html__('Settings saved.','mystickymenu'). '</p></strong></div>'; |
| 212 | } else { |
| 213 | wp_verify_nonce($_GET['nonce'], 'wporg_frontend_delete'); |
| 214 | echo '<div class="error settings-error notice is-dismissible "><p><strong>' . esc_html__('Unable to complete your request','mystickymenu'). '</p></strong></div>'; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | $mysticky_options = get_option( 'mysticky_option_name'); |
| 219 | $is_old = get_option("has_sticky_header_old_version"); |
| 220 | $is_old = ($is_old == "yes")?true:false; |
| 221 | $nonce = wp_create_nonce('mysticky_option_backend_update'); |
| 222 | $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=2199&edd_options[price_id]="; |
| 223 | |
| 224 | $is_shown = get_option("mystickymenu_update_message"); |
| 225 | if($is_shown == 1) { |
| 226 | |
| 227 | include_once MYSTICKYMENU_PATH . '/update.php'; |
| 228 | } else { |
| 229 | |
| 230 | $option = get_option("mystickymenu_intro_box"); |
| 231 | if($option == "show") { |
| 232 | include_once dirname(__FILE__) . "/mystickymenu-popup.php"; |
| 233 | } |
| 234 | ?> |
| 235 | <style> |
| 236 | div#wpcontent { |
| 237 | background: rgba(101,114,219,1); |
| 238 | background: -moz-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 239 | 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))); |
| 240 | background: -webkit-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 241 | background: -o-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 242 | background: -ms-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 243 | background: linear-gradient(135deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 244 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6572db', endColorstr='#ee86c6', GradientType=1 ); |
| 245 | } |
| 246 | </style> |
| 247 | <div id="mystickymenu" class="wrap mystickymenu"> |
| 248 | <div class="sticky-header-menu"> |
| 249 | <ul> |
| 250 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-welcomebar' ) ?>" ><?php _e('Welcome Bar', 'mystickymenu'); ?></a></li> |
| 251 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-settings' ) ?>" class="active" ><?php _e('Sticky Menu', 'mystickymenu'); ?></a></li> |
| 252 | |
| 253 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-upgrade' ) ?>"><?php _e('Upgrade to Pro', 'mystickymenu'); ?></a></li> |
| 254 | </ul> |
| 255 | </div> |
| 256 | <div id="sticky-header-settings" class="sticky-header-content"> |
| 257 | <div class="mystickymenu-heading"> |
| 258 | <div class="myStickymenu-header-title"> |
| 259 | <h3><?php esc_attr_e('How To Make a Sticky Header', 'mystickymenu'); ?></h3> |
| 260 | </div> |
| 261 | <p><?php _e("Add sticky menu / header to any theme. <br />Simply change 'Sticky Class' to HTML element class desired to be sticky (div id can be used as well).", 'mystickymenu'); ?></p> |
| 262 | </div> |
| 263 | |
| 264 | <form class="mysticky-form" method="post" action="#"> |
| 265 | <div class="mystickymenu-content-section sticky-class-sec"> |
| 266 | <table> |
| 267 | <tr> |
| 268 | <td> |
| 269 | <label class="mysticky_title"><?php _e("Sticky Class", 'mystickymenu')?></label> |
| 270 | <br /><br /> |
| 271 | <?php $nav_menus = wp_get_nav_menus(); |
| 272 | $menu_locations = get_nav_menu_locations(); |
| 273 | $locations = get_registered_nav_menus(); |
| 274 | ?> |
| 275 | <select name="mysticky_option_name[mysticky_class_id_selector]" id="mystickymenu-select"> |
| 276 | <option value=""><?php _e( 'Select Sticky Menu', 'mystickymenu' ); ?></option> |
| 277 | |
| 278 | <?php foreach ( (array) $nav_menus as $_nav_menu ) : ?> |
| 279 | <option value="<?php echo esc_attr( $_nav_menu->slug ); ?>" <?php selected( $_nav_menu->slug, $mysticky_options['mysticky_class_id_selector'] ); ?>> |
| 280 | <?php |
| 281 | echo esc_html( $_nav_menu->name ); |
| 282 | |
| 283 | if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations ) ) { |
| 284 | $locations_assigned_to_this_menu = array(); |
| 285 | foreach ( array_keys( $menu_locations, $_nav_menu->term_id ) as $menu_location_key ) { |
| 286 | if ( isset( $locations[ $menu_location_key ] ) ) { |
| 287 | $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ]; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Filters the number of locations listed per menu in the drop-down select. |
| 293 | * |
| 294 | * @since 3.6.0 |
| 295 | * |
| 296 | * @param int $locations Number of menu locations to list. Default 3. |
| 297 | */ |
| 298 | $assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) ); |
| 299 | |
| 300 | // Adds ellipses following the number of locations defined in $assigned_locations. |
| 301 | if ( ! empty( $assigned_locations ) ) { |
| 302 | printf( |
| 303 | ' (%1$s%2$s)', |
| 304 | implode( ', ', $assigned_locations ), |
| 305 | count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : '' |
| 306 | ); |
| 307 | } |
| 308 | } |
| 309 | ?> |
| 310 | </option> |
| 311 | <?php endforeach; ?> |
| 312 | <option value="custom" <?php selected( 'custom', $mysticky_options['mysticky_class_id_selector'] ); ?>><?php esc_html_e( 'Other Class Or ID', 'mystickymenu' );?></option> |
| 313 | </select> |
| 314 | |
| 315 | <input type="text" size="18" id="mysticky_class_selector" class="mystickyinput" name="mysticky_option_name[mysticky_class_selector]" value="<?php echo $mysticky_options['mysticky_class_selector'];?>" /> |
| 316 | |
| 317 | <p class="description mystuckymenu-class-id"> |
| 318 | <span class="dashicons dashicons-info"></span> |
| 319 | <span> |
| 320 | <?php echo sprintf(__('Need help finding your ID/Class? Install <a href="%s" target="_blank">CSS Peeper</a> to quickly get your navigation menu ID/Class. Here\'s a quick <a href="%s" target="_blank">video <span class="dashicons dashicons-controls-play"></span></a> of how you can do it.', 'mystickymenu'), 'https://chrome.google.com/webstore/detail/css-peeper/mbnbehikldjhnfehhnaidhjhoofhpehk?hl=en', 'https://www.youtube.com/watch?v=uuNqSkBPnLU');?> |
| 321 | </span> |
| 322 | </p> |
| 323 | </td> |
| 324 | <td> |
| 325 | <div class="mysticky_device_upgrade"> |
| 326 | <label class="mysticky_title"><?php _e("Devices", 'mystickymenu')?></label> |
| 327 | <span class="myStickymenu-upgrade"><a class="sticky-header-upgrade" href="<?php echo esc_url($upgarde_url); ?>" target="_blank"><?php _e( 'Upgrade Now', 'mystickymenu' );?></a></span> |
| 328 | |
| 329 | <ul class="mystickymenu-input-multicheckbox"> |
| 330 | <li> |
| 331 | <label> |
| 332 | <input id="disable_css" name="mysticky_option_name[device_desktop]" type="checkbox" checked disabled /> |
| 333 | <?php _e( 'Desktop', 'mystickymenu' );?> |
| 334 | </label> |
| 335 | </li> |
| 336 | <li> |
| 337 | <label> |
| 338 | <input id="disable_css" name="mysticky_option_name[device_mobile]" type="checkbox" checked disabled /> |
| 339 | <?php _e( 'Mobile', 'mystickymenu' );?> |
| 340 | </label> |
| 341 | </li> |
| 342 | </ul> |
| 343 | </div> |
| 344 | </td> |
| 345 | </tr> |
| 346 | </table> |
| 347 | </div> |
| 348 | |
| 349 | |
| 350 | <div class="mystickymenu-content-section"> |
| 351 | <h3><?php esc_html_e( 'Settings', 'mystickymenu' );?></h3> |
| 352 | <table class="form-table"> |
| 353 | <tr> |
| 354 | <td> |
| 355 | <label for="myfixed_zindex" class="mysticky_title"><?php _e("Sticky z-index", 'mystickymenu')?></label> |
| 356 | </td> |
| 357 | <td> |
| 358 | <input type="number" min="0" max="2147483647" step="1" class="mysticky-number" id="myfixed_zindex" name="mysticky_option_name[myfixed_zindex]" value="<?php echo $mysticky_options['myfixed_zindex'];?>" /> |
| 359 | </td> |
| 360 | <td> |
| 361 | <label class="mysticky_title myssticky-remove-hand"><?php _e("Fade or slide effect", 'mystickymenu')?></label> |
| 362 | </td> |
| 363 | <td> |
| 364 | <label> |
| 365 | <input name="mysticky_option_name[myfixed_fade]" value= "slide" type="radio" <?php checked( @$mysticky_options['myfixed_fade'], 'slide' );?> /> |
| 366 | <?php _e("Slide", 'mystickymenu'); ?> |
| 367 | </label> |
| 368 | <label> |
| 369 | <input name="mysticky_option_name[myfixed_fade]" value="fade" type="radio" <?php checked( @$mysticky_options['myfixed_fade'], 'fade' );?> /> |
| 370 | <?php _e("Fade", 'mystickymenu'); ?> |
| 371 | </label> |
| 372 | </td> |
| 373 | </tr> |
| 374 | <tr> |
| 375 | <td> |
| 376 | <label for="myfixed_disable_small_screen" class="mysticky_title"><?php _e("Disable at Small Screen Sizes", 'mystickymenu')?></label> |
| 377 | <p class="description"><?php esc_attr_e('Less than chosen screen width, set 0 to disable','mystickymenu');?></p> |
| 378 | </td> |
| 379 | <td> |
| 380 | <div class="px-wrap"> |
| 381 | <input type="number" class="" min="0" step="1" id="myfixed_disable_small_screen" name="mysticky_option_name[myfixed_disable_small_screen]" value="<?php echo $mysticky_options['myfixed_disable_small_screen'];?>" /> |
| 382 | <span class="input-px">PX</span> |
| 383 | </div> |
| 384 | </td> |
| 385 | <td> |
| 386 | <label for="mysticky_active_on_height" class="mysticky_title"><?php _e("Make visible on Scroll", 'mystickymenu')?></label> |
| 387 | <p class="description"><?php esc_attr_e('If set to 0 auto calculate will be used.','mystickymenu');?></p> |
| 388 | </td> |
| 389 | <td> |
| 390 | <div class="px-wrap"> |
| 391 | <input type="number" class="small-text" min="0" step="1" id="mysticky_active_on_height" name="mysticky_option_name[mysticky_active_on_height]" value="<?php echo $mysticky_options['mysticky_active_on_height'];?>" /> |
| 392 | <span class="input-px">PX</span> |
| 393 | </div> |
| 394 | </td> |
| 395 | </tr> |
| 396 | <tr> |
| 397 | <td> |
| 398 | <label for="mysticky_active_on_height_home" class="mysticky_title"><?php _e("Make visible on Scroll at homepage", 'mystickymenu')?></label> |
| 399 | <p class="description"><?php _e( 'If set to 0 it will use initial Make visible on Scroll value.', 'mystickymenu' );?></p> |
| 400 | </td> |
| 401 | <td> |
| 402 | <div class="px-wrap"> |
| 403 | <input type="number" class="small-text" min="0" step="1" id="mysticky_active_on_height_home" name="mysticky_option_name[mysticky_active_on_height_home]" value="<?php echo $mysticky_options['mysticky_active_on_height_home'];?>" /> |
| 404 | <span class="input-px">PX</span> |
| 405 | </div> |
| 406 | </td> |
| 407 | <td> |
| 408 | <label for="myfixed_bgcolor" class="mysticky_title myssticky-remove-hand"><?php _e("Sticky Background Color", 'mystickymenu')?></label> |
| 409 | </td> |
| 410 | <td> |
| 411 | <input type="text" id="myfixed_bgcolor" name="mysticky_option_name[myfixed_bgcolor]" class="my-color-field" data-alpha="true" value="<?php echo $mysticky_options['myfixed_bgcolor'];?>" /> |
| 412 | |
| 413 | </td> |
| 414 | </tr> |
| 415 | <tr> |
| 416 | <td> |
| 417 | <label for="myfixed_transition_time" class="mysticky_title"><?php _e("Sticky Transition Time", 'mystickymenu')?></label> |
| 418 | </td> |
| 419 | <td> |
| 420 | <input type="number" class="small-text" min="0" step="0.1" id="myfixed_transition_time" name="mysticky_option_name[myfixed_transition_time]" value="<?php echo $mysticky_options['myfixed_transition_time'];?>" /> |
| 421 | </td> |
| 422 | <td> |
| 423 | <label for="myfixed_textcolor" class="mysticky_title myssticky-remove-hand"><?php _e("Sticky Text Color", 'mystickymenu')?></label> |
| 424 | </td> |
| 425 | <td> |
| 426 | <input type="text" id="myfixed_textcolor" name="mysticky_option_name[myfixed_textcolor]" class="my-color-field" data-alpha="true" value="<?php echo (isset($mysticky_options['myfixed_textcolor'])) ? $mysticky_options['myfixed_textcolor'] : '';?>" /> |
| 427 | |
| 428 | </td> |
| 429 | </tr> |
| 430 | <tr> |
| 431 | <td> |
| 432 | <label for="myfixed_opacity" class="mysticky_title myssticky-remove-hand"><?php _e("Sticky Opacity", 'mystickymenu')?></label> |
| 433 | <p class="description"><?php _e( 'numbers 1-100.', 'mystickymenu');?></p> |
| 434 | </td> |
| 435 | <td> |
| 436 | <input type="hidden" class="small-text mysticky-slider" min="0" step="1" max="100" id="myfixed_opacity" name="mysticky_option_name[myfixed_opacity]" value="<?php echo $mysticky_options['myfixed_opacity'];?>" /> |
| 437 | <div id="slider"> |
| 438 | <div id="custom-handle" class="ui-slider-handle"><?php //echo $mysticky_options['myfixed_opacity'];?></div> |
| 439 | </div> |
| 440 | |
| 441 | </td> |
| 442 | </tr> |
| 443 | </table> |
| 444 | </div> |
| 445 | |
| 446 | <div class="mystickymenu-content-section <?php echo !$is_old?"mystickymenu-content-upgrade":""?>" > |
| 447 | |
| 448 | <div class="mystickymenu-content-option"> |
| 449 | <label class="mysticky_title css-style-title"><?php _e("Hide on Scroll Down", 'mystickymenu'); ?></label> |
| 450 | <?php if(!$is_old) { ?><span class="myStickymenu-upgrade"><a class="sticky-header-upgrade" href="<?php echo esc_url($upgarde_url); ?>" target="_blank"><?php _e( 'Upgrade Now', 'mystickymenu' );?></a></span><?php } ?> |
| 451 | <p> |
| 452 | <label class="mysticky_text"> |
| 453 | <input id="myfixed_disable_scroll_down" name="mysticky_option_name[myfixed_disable_scroll_down]" type="checkbox" <?php checked( @$mysticky_options['myfixed_disable_scroll_down'], 'on' );?> <?php echo !$is_old?"disabled":"" ?> /> |
| 454 | <?php _e("Disable sticky menu at scroll down", 'mystickymenu'); ?> |
| 455 | </label> |
| 456 | </p> |
| 457 | </div> |
| 458 | <div class="mysticky-page-target-setting mystickymenu-content-option"> |
| 459 | <label class="mysticky_title"><?php esc_attr_e('Page targeting', 'myStickymenu'); ?></label> |
| 460 | <div class="mystickymenu-input-section mystickymenu-page-target-wrap"> |
| 461 | <div class="mysticky-welcomebar-setting-content-right"> |
| 462 | <div class="mysticky-page-options" id="mysticky-welcomebar-page-options"> |
| 463 | <?php $page_option = (isset($mysticky_options['mysticky_page_settings'])) ? $mysticky_options['mysticky_page_settings'] : array(); |
| 464 | $url_options = array( |
| 465 | 'page_contains' => 'pages that contain', |
| 466 | 'page_has_url' => 'a specific page', |
| 467 | 'page_start_with' => 'pages starting with', |
| 468 | 'page_end_with' => 'pages ending with', |
| 469 | ); |
| 470 | |
| 471 | if(!empty($page_option) && is_array($page_option)) { |
| 472 | $count = 0; |
| 473 | foreach($page_option as $k=>$option) { |
| 474 | $count++; |
| 475 | ?> |
| 476 | <div class="mysticky-page-option <?php echo $k==count($page_option)?"last":""; ?>"> |
| 477 | <div class="url-content"> |
| 478 | <div class="mysticky-welcomebar-url-select"> |
| 479 | <select name="mysticky_option_name[mysticky_page_settings][<?php echo $count; ?>][shown_on]" id="url_shown_on_<?php echo $count ?>_option"> |
| 480 | <option value="show_on" <?php echo $option['shown_on']=="show_on"?"selected":"" ?> ><?php esc_html_e( 'Show on', 'mysticky' )?></option> |
| 481 | <option value="not_show_on" <?php echo $option['shown_on']=="not_show_on"?"selected":"" ?>><?php esc_html_e( "Don't show on", "mysticky" );?></option> |
| 482 | </select> |
| 483 | </div> |
| 484 | <div class="mysticky-welcomebar-url-option"> |
| 485 | <select class="mysticky-url-options" name="mysticky_option_name[mysticky_page_settings][<?php echo $count; ?>][option]" id="url_rules_<?php echo $count ?>_option"> |
| 486 | <option disabled value=""><?php esc_html_e( "Select Rule", "mysticky" );?></option> |
| 487 | <?php foreach($url_options as $key=>$value) { |
| 488 | $selected = ( isset($option['option']) && $option['option']==$key )?" selected='selected' ":""; |
| 489 | echo '<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
| 490 | } ?> |
| 491 | </select> |
| 492 | </div> |
| 493 | <div class="mysticky-welcomebar-url-box"> |
| 494 | <span class='mysticky-welcomebar-url'><?php echo site_url("/"); ?></span> |
| 495 | </div> |
| 496 | <div class="mysticky-welcomebar-url-values"> |
| 497 | <input type="text" value="<?php echo $option['value'] ?>" name="mysticky_option_name[mysticky_page_settings][<?php echo $count; ?>][value]" id="url_rules_<?php echo $count; ?>_value" /> |
| 498 | </div> |
| 499 | <div class="mysticky-welcomebar-url-buttons"> |
| 500 | <a class="mysticky-remove-rule" href="javascript:;">x</a> |
| 501 | </div> |
| 502 | <div class="clear"></div> |
| 503 | </div> |
| 504 | </div> |
| 505 | <?php |
| 506 | } |
| 507 | } |
| 508 | ?> |
| 509 | </div> |
| 510 | <a href="javascript:void(0);" class="create-rule" id="mysticky_create-rule"><?php esc_html_e( "Add Rule", "mystickymenu" );?></a> |
| 511 | </div> |
| 512 | <input type="hidden" id="mysticky_welcomebar_site_url" value="<?php echo site_url("/") ?>" /> |
| 513 | <div class="mysticky-page-options-html" style="display: none;"> |
| 514 | <div class="mysticky-page-option"> |
| 515 | <div class="url-content"> |
| 516 | <div class="mysticky-welcomebar-url-select"> |
| 517 | <select name="" id="url_shown_on___count___option"> |
| 518 | <option value="show_on"><?php esc_html_e("Show on", "mysticky" );?></option> |
| 519 | <option value="not_show_on"><?php esc_html_e("Don't show on", "mysticky" );?></option> |
| 520 | </select> |
| 521 | </div> |
| 522 | <div class="mysticky-welcomebar-url-option"> |
| 523 | <select class="mysticky-url-options" name="" id="url_rules___count___option"> |
| 524 | <option selected="selected" disabled value=""><?php esc_html_e("Select Rule", "mysticky" );?></option> |
| 525 | <?php foreach($url_options as $key=>$value) { |
| 526 | echo '<option value="'.$key.'">'.$value.'</option>'; |
| 527 | } ?> |
| 528 | </select> |
| 529 | </div> |
| 530 | <div class="mysticky-welcomebar-url-box"> |
| 531 | <span class='mysticky-welcomebar-url'><?php echo site_url("/"); ?></span> |
| 532 | </div> |
| 533 | <div class="mysticky-welcomebar-url-values"> |
| 534 | <input type="text" value="" name="mysticky_option_name[mysticky_page_settings][__count__][value]" id="url_rules___count___value" disabled /> |
| 535 | </div> |
| 536 | <div class="clear"></div> |
| 537 | </div> |
| 538 | <span class="myStickymenu-upgrade"><a class="sticky-header-upgrade" href="<?php echo esc_url($upgarde_url); ?>" target="_blank"><?php _e( 'Upgrade Now', 'mystickymenu' );?></a></span> |
| 539 | </div> |
| 540 | </div> |
| 541 | </div> |
| 542 | </div> |
| 543 | <div class="mystickymenu-content-option"> |
| 544 | <label class="mysticky_title css-style-title"><?php _e("CSS style", 'mystickymenu'); ?></label> |
| 545 | <span class="mysticky_text"><?php _e( 'Add/edit CSS style. Leave it blank for default style.', 'mystickymenu');?></span> |
| 546 | <div class="mystickymenu-input-section"> |
| 547 | <textarea type="text" rows="4" cols="60" id="myfixed_cssstyle" name="mysticky_option_name[myfixed_cssstyle]" <?php echo !$is_old?"disabled":"" ?> ><?php echo @$mysticky_options['myfixed_cssstyle'];?></textarea> |
| 548 | </div> |
| 549 | <p><?php esc_html_e( "CSS ID's and Classes to use:", "mystickymenu" );?></p> |
| 550 | <p> |
| 551 | #mysticky-wrap { }<br/> |
| 552 | #mysticky-nav.wrapfixed { }<br/> |
| 553 | #mysticky-nav.wrapfixed.up { }<br/> |
| 554 | #mysticky-nav.wrapfixed.down { }<br/> |
| 555 | #mysticky-nav .navbar { }<br/> |
| 556 | #mysticky-nav .navbar.myfixed { }<br/> |
| 557 | </p> |
| 558 | </div> |
| 559 | |
| 560 | <div class="mystickymenu-content-option"> |
| 561 | <label class="mysticky_title" for="disable_css"><?php _e("Disable CSS style", 'mystickymenu'); ?></label> |
| 562 | <div class="mystickymenu-input-section"> |
| 563 | <label> |
| 564 | <input id="disable_css" name="mysticky_option_name[disable_css]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['disable_css'], 'on' );?> /> |
| 565 | <?php _e( 'Use this option if you plan to include CSS Style manually', 'mystickymenu' );?> |
| 566 | </label> |
| 567 | </div> |
| 568 | <p></p> |
| 569 | </div> |
| 570 | |
| 571 | <div class="mystickymenu-content-option"> |
| 572 | <label class="mysticky_title"><?php _e("Disable at", 'mystickymenu'); ?></label> |
| 573 | <?php if(!$is_old) { ?><span class="myStickymenu-upgrade"><a class="sticky-header-upgrade" href="<?php echo esc_url($upgarde_url); ?>" target="_blank"><?php _e( 'Upgrade Now', 'mystickymenu' );?></a></span><?php } ?> |
| 574 | <div class="mystickymenu-input-section"> |
| 575 | <ul class="mystickymenu-input-multicheckbox"> |
| 576 | <li> |
| 577 | <label> |
| 578 | <input id="mysticky_disable_at_front_home" name="mysticky_option_name[mysticky_disable_at_front_home]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_front_home'], 'on' );?>/> |
| 579 | <span><?php esc_attr_e('front page', 'mystickymenu' );?></span> |
| 580 | </label> |
| 581 | </li> |
| 582 | <li> |
| 583 | <label> |
| 584 | <input id="mysticky_disable_at_blog" name="mysticky_option_name[mysticky_disable_at_blog]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_blog'], 'on' );?>/> |
| 585 | <span><?php esc_attr_e('blog page', 'mystickymenu' );?></span> |
| 586 | </label> |
| 587 | </li> |
| 588 | <li> |
| 589 | <label> |
| 590 | <input id="mysticky_disable_at_page" name="mysticky_option_name[mysticky_disable_at_page]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_page'], 'on' );?> /> |
| 591 | <span><?php esc_attr_e('pages', 'mystickymenu' );?> </span> |
| 592 | </label> |
| 593 | </li> |
| 594 | <li> |
| 595 | <label> |
| 596 | <input id="mysticky_disable_at_tag" name="mysticky_option_name[mysticky_disable_at_tag]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_tag'], 'on' );?> /> |
| 597 | <span><?php esc_attr_e('tags', 'mystickymenu' );?> </span> |
| 598 | </label> |
| 599 | </li> |
| 600 | <li> |
| 601 | <label> |
| 602 | <input id="mysticky_disable_at_category" name="mysticky_option_name[mysticky_disable_at_category]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_category'], 'on' );?>/> |
| 603 | <span><?php esc_attr_e('categories', 'mystickymenu' );?></span> |
| 604 | </label> |
| 605 | </li> |
| 606 | <li> |
| 607 | <label> |
| 608 | <input id="mysticky_disable_at_single" name="mysticky_option_name[mysticky_disable_at_single]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_single'], 'on' );?> /> |
| 609 | <span><?php esc_attr_e('posts', 'mystickymenu' );?> </span> |
| 610 | </label> |
| 611 | </li> |
| 612 | <li> |
| 613 | <label> |
| 614 | <input id="mysticky_disable_at_archive" name="mysticky_option_name[mysticky_disable_at_archive]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_archive'], 'on' );?> /> |
| 615 | <span><?php esc_attr_e('archives', 'mystickymenu' );?> </span> |
| 616 | </label> |
| 617 | </li> |
| 618 | <li> |
| 619 | <label> |
| 620 | <input id="mysticky_disable_at_search" name="mysticky_option_name[mysticky_disable_at_search]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_search'], 'on' );?> /> |
| 621 | <span><?php esc_attr_e('search', 'mystickymenu' );?> </span> |
| 622 | </label> |
| 623 | </li> |
| 624 | <li> |
| 625 | <label> |
| 626 | <input id="mysticky_disable_at_404" name="mysticky_option_name[mysticky_disable_at_404]" type="checkbox" <?php echo !$is_old?"disabled":"" ?> <?php checked( @$mysticky_options['mysticky_disable_at_404'], 'on' );?>/> |
| 627 | <span><?php esc_attr_e('404', 'mystickymenu' );?> </span> |
| 628 | </label> |
| 629 | </li> |
| 630 | </ul> |
| 631 | |
| 632 | <?php |
| 633 | if (isset ( $mysticky_options['mysticky_disable_at_page'] ) == true ) { |
| 634 | echo '<div class="mystickymenu-input-section">'; |
| 635 | _e('<span class="description"><strong>Except for this pages:</strong> </span>', 'mystickymenu'); |
| 636 | |
| 637 | printf( |
| 638 | '<input type="text" size="26" class="mystickymenu_normal_text" id="mysticky_enable_at_pages" name="mysticky_option_name[mysticky_enable_at_pages]" value="%s" /> ', |
| 639 | isset( $mysticky_options['mysticky_enable_at_pages'] ) ? esc_attr( $mysticky_options['mysticky_enable_at_pages']) : '' |
| 640 | ); |
| 641 | |
| 642 | _e('<span class="description">Comma separated list of pages to enable. It should be page name, id or slug. Example: about-us, 1134, Contact Us. Leave blank if you realy want to disable sticky menu for all pages.</span>', 'mystickymenu'); |
| 643 | echo '</div>'; |
| 644 | } |
| 645 | |
| 646 | if (isset ( $mysticky_options['mysticky_disable_at_single'] ) == true ) { |
| 647 | |
| 648 | echo '<div class="mystickymenu-input-section">'; |
| 649 | _e('<span class="description"><strong>Except for this posts:</strong> </span>', 'mystickymenu'); |
| 650 | |
| 651 | printf( |
| 652 | '<input type="text" size="26" class="mystickymenu_normal_text" id="mysticky_enable_at_posts" name="mysticky_option_name[mysticky_enable_at_posts]" value="%s" /> ', |
| 653 | isset( $mysticky_options['mysticky_enable_at_posts'] ) ? esc_attr( $mysticky_options['mysticky_enable_at_posts']) : '' |
| 654 | ); |
| 655 | |
| 656 | _e('<span class="description">Comma separated list of posts to enable. It should be post name, id or slug. Example: about-us, 1134, Contact Us. Leave blank if you realy want to disable sticky menu for all posts.</span>', 'mystickymenu'); |
| 657 | echo '</div>'; |
| 658 | |
| 659 | } |
| 660 | ?> |
| 661 | <p></p> |
| 662 | </div> |
| 663 | </div> |
| 664 | |
| 665 | </div> |
| 666 | <p class="submit"> |
| 667 | <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e('Save', 'mystickymenu');?>"> |
| 668 | </p> |
| 669 | <input type="hidden" name="nonce" value="<?php echo $nonce ?>"> |
| 670 | </form> |
| 671 | <form class="mysticky-hideformreset" method="post" action=""> |
| 672 | <input name="reset_mysticky_options" class="button button-secondary confirm" type="submit" value="<?php esc_attr_e('Reset', 'mystickymenu');?>" > |
| 673 | <input type="hidden" name="action" value="reset" /> |
| 674 | <?php $nonce = wp_create_nonce('mysticky_option_backend_reset_nonce'); ?> |
| 675 | <input type="hidden" name="nonce" value="<?php echo $nonce ?>"> |
| 676 | </form> |
| 677 | <p class="myStickymenu-review"><a href="https://wordpress.org/support/plugin/mystickymenu/reviews/" target="_blank"><?php esc_attr_e('Leave a review','mystickymenu'); ?></a></p> |
| 678 | </div> |
| 679 | </div> |
| 680 | <?php } |
| 681 | } |
| 682 | public function mystickystickymenu_admin_new_welcomebar_page() { |
| 683 | ?> |
| 684 | <div id="mystickymenu" class="wrap mystickymenu mystickymenu-new-widget-wrap"> |
| 685 | <?php include_once dirname(__FILE__) . '/mystickymeny-new-welcomebar.php';?> |
| 686 | </div> |
| 687 | <?php |
| 688 | } |
| 689 | |
| 690 | public function mystickystickymenu_admin_welcomebar_page() { |
| 691 | |
| 692 | $is_shown = get_option("mystickymenu_update_message"); |
| 693 | if($is_shown == 1) { |
| 694 | |
| 695 | include_once MYSTICKYMENU_PATH . '/update.php'; |
| 696 | return; |
| 697 | } |
| 698 | |
| 699 | /* welcome bar save data */ |
| 700 | if (isset($_POST['mysticky_option_welcomebar']) && !empty($_POST['mysticky_option_welcomebar']) && isset($_POST['nonce'])) { |
| 701 | if(!empty($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'mysticky_option_welcomebar_update')) { |
| 702 | $mysticky_option_welcomebar = filter_var_array( $_POST['mysticky_option_welcomebar'], FILTER_SANITIZE_STRING ); |
| 703 | $mysticky_option_welcomebar['mysticky_welcomebar_bar_text'] = $_POST['mysticky_option_welcomebar']['mysticky_welcomebar_bar_text']; |
| 704 | $mysticky_option_welcomebar['mysticky_welcomebar_height'] = 60; |
| 705 | $mysticky_option_welcomebar['mysticky_welcomebar_device_desktop'] = 'desktop'; |
| 706 | $mysticky_option_welcomebar['mysticky_welcomebar_device_mobile'] = 'mobile'; |
| 707 | $mysticky_option_welcomebar['mysticky_welcomebar_trigger'] = 'after_a_few_seconds'; |
| 708 | $mysticky_option_welcomebar['mysticky_welcomebar_triggersec'] = '0'; |
| 709 | $mysticky_option_welcomebar['mysticky_welcomebar_expirydate'] = ''; |
| 710 | $mysticky_option_welcomebar['mysticky_welcomebar_page_settings'] = ''; |
| 711 | update_option( 'mysticky_option_welcomebar', $mysticky_option_welcomebar); |
| 712 | $this->mysticky_clear_all_caches(); |
| 713 | echo '<div class="updated settings-error notice is-dismissible "><p><strong>' . esc_html__('Settings saved.','mystickymenu'). '</p></strong></div>'; |
| 714 | } else { |
| 715 | wp_verify_nonce($_GET['nonce'], 'wporg_frontend_delete'); |
| 716 | echo '<div class="error settings-error notice is-dismissible "><p><strong>' . esc_html__('Unable to complete your request','mystickymenu'). '</p></strong></div>'; |
| 717 | } |
| 718 | } |
| 719 | if (isset($_POST['mysticky_welcomebar_reset']) && !empty($_POST['mysticky_welcomebar_reset']) && isset($_POST['nonce_reset'])) { |
| 720 | if(!empty($_POST['nonce_reset']) && wp_verify_nonce($_POST['nonce_reset'], 'mysticky_option_welcomebar_reset')) { |
| 721 | $mysticky_option_welcomebar_reset = mysticky_welcomebar_pro_widget_default_fields(); |
| 722 | update_option( 'mysticky_option_welcomebar', $mysticky_option_welcomebar_reset); |
| 723 | $this->mysticky_clear_all_caches(); |
| 724 | echo '<div class="updated settings-error notice is-dismissible "><p><strong>' . esc_html__('Reset Settings saved.','mystickymenu'). '</p></strong></div>'; |
| 725 | } else { |
| 726 | wp_verify_nonce($_GET['nonce'], 'wporg_frontend_delete'); |
| 727 | echo '<div class="error settings-error notice is-dismissible "><p><strong>' . esc_html__('Unable to complete your request','mystickymenu'). '</p></strong></div>'; |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | $mysticky_options = get_option( 'mysticky_option_name'); |
| 732 | $is_old = get_option("has_sticky_header_old_version"); |
| 733 | $is_old = ($is_old == "yes")?true:false; |
| 734 | $nonce = wp_create_nonce('mysticky_option_backend_update'); |
| 735 | $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=2199&edd_options[price_id]="; |
| 736 | |
| 737 | ?> |
| 738 | <style> |
| 739 | div#wpcontent { |
| 740 | background: rgba(101,114,219,1); |
| 741 | background: -moz-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 742 | 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))); |
| 743 | background: -webkit-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 744 | background: -o-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 745 | background: -ms-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 746 | background: linear-gradient(135deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 747 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6572db', endColorstr='#ee86c6', GradientType=1 ); |
| 748 | } |
| 749 | </style> |
| 750 | <div id="mystickymenu" class="wrap mystickymenu"> |
| 751 | <div class="sticky-header-menu"> |
| 752 | <ul> |
| 753 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-welcomebar' ) ?>" class="active" ><?php _e('Welcome Bar', 'mystickymenu'); ?></a></li> |
| 754 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-settings' ) ?>"><?php _e('Sticky Menu', 'mystickymenu'); ?></a></li> |
| 755 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-upgrade' ) ?>"><?php _e('Upgrade to Pro', 'mystickymenu'); ?></a></li> |
| 756 | </ul> |
| 757 | </div> |
| 758 | <div id="sticky-header-welcome-bar" class="sticky-header-content"> |
| 759 | <?php mysticky_welcome_bar_backend(); ?> |
| 760 | </div> |
| 761 | </div> |
| 762 | <?php |
| 763 | } |
| 764 | public function mystickymenu_recommended_plugins() { |
| 765 | include_once 'recommended-plugins.php'; |
| 766 | } |
| 767 | public function mystickymenu_admin_upgrade_to_pro() { |
| 768 | $pro_url = "https://go.premio.io/checkount/?edd_action=add_to_cart&download_id=2199&edd_options[price_id]="; |
| 769 | ?> |
| 770 | <style> |
| 771 | div#wpcontent { |
| 772 | background: rgba(101,114,219,1); |
| 773 | background: -moz-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 774 | 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))); |
| 775 | background: -webkit-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 776 | background: -o-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 777 | background: -ms-linear-gradient(-45deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 778 | background: linear-gradient(135deg, rgba(101,114,219,1) 0%, rgba(238,134,198,1) 67%, rgba(238,134,198,1) 100%); |
| 779 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6572db', endColorstr='#ee86c6', GradientType=1 ); |
| 780 | } |
| 781 | </style> |
| 782 | <div id="mystickymenu" class="wrap mystickymenu"> |
| 783 | <div class="sticky-header-menu"> |
| 784 | <ul> |
| 785 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-welcomebar' ) ?>" ><?php _e('Welcome Bar', 'mystickymenu'); ?></a></li> |
| 786 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-settings' ) ?>"><?php _e('Sticky Menu', 'mystickymenu'); ?></a></li> |
| 787 | <li><a href="<?php echo admin_url( 'admin.php?page=my-stickymenu-upgrade' ) ?>" class="active" ><?php _e('Upgrade to Pro', 'mystickymenu'); ?></a></li> |
| 788 | </ul> |
| 789 | </div> |
| 790 | <?php include_once "upgrade-to-pro.php"; ?> |
| 791 | </div> |
| 792 | <?php |
| 793 | } |
| 794 | |
| 795 | public function mysticky_default_options() { |
| 796 | |
| 797 | global $options; |
| 798 | $menu_locations = get_nav_menu_locations(); |
| 799 | $menu_object = isset($menu_locations['menu-1']) ? wp_get_nav_menu_object( $menu_locations['menu-1'] ) : array(); |
| 800 | |
| 801 | if ( is_object($menu_object) && $menu_object->slug != '' ) { |
| 802 | $mysticky_class_id_selector = $menu_object->slug; |
| 803 | } else { |
| 804 | $mysticky_class_id_selector = 'custom'; |
| 805 | } |
| 806 | |
| 807 | $mystickyClass = '.navbar'; |
| 808 | $template_name = get_template(); |
| 809 | switch( $template_name ){ |
| 810 | case 'ashe': |
| 811 | $mysticky_class_id_selector = 'custom'; |
| 812 | $mystickyClass = '#main-nav'; |
| 813 | break; |
| 814 | case 'astra': |
| 815 | case 'hello-elementor': |
| 816 | case 'sydney': |
| 817 | case 'twentysixteen': |
| 818 | $mysticky_class_id_selector = 'custom'; |
| 819 | $mystickyClass = 'header.site-header'; |
| 820 | break; |
| 821 | case 'generatepress': |
| 822 | $mysticky_class_id_selector = 'custom'; |
| 823 | $mystickyClass = 'nav.main-navigation'; |
| 824 | break; |
| 825 | case 'transportex': |
| 826 | $mysticky_class_id_selector = 'custom'; |
| 827 | $mystickyClass = '.transportex-menu-full'; |
| 828 | break; |
| 829 | case 'hestia': |
| 830 | case 'neve': |
| 831 | $mysticky_class_id_selector = 'custom'; |
| 832 | $mystickyClass = 'header.header'; |
| 833 | break; |
| 834 | case 'mesmerize': |
| 835 | $mysticky_class_id_selector = 'custom'; |
| 836 | $mystickyClass = '.navigation-bar'; |
| 837 | break; |
| 838 | case 'oceanwp': |
| 839 | $mysticky_class_id_selector = 'custom'; |
| 840 | $mystickyClass = 'header#site-header'; |
| 841 | break; |
| 842 | case 'shapely': |
| 843 | $mysticky_class_id_selector = 'custom'; |
| 844 | $mystickyClass = '#site-navigation'; |
| 845 | break; |
| 846 | case 'storefront': |
| 847 | $mysticky_class_id_selector = 'custom'; |
| 848 | $mystickyClass = '.storefront-primary-navigation'; |
| 849 | break; |
| 850 | case 'twentynineteen': |
| 851 | $mysticky_class_id_selector = 'custom'; |
| 852 | $mystickyClass = '#site-navigation'; |
| 853 | break; |
| 854 | case 'twentyseventeen': |
| 855 | $mysticky_class_id_selector = 'custom'; |
| 856 | $mystickyClass = '.navigation-top'; |
| 857 | break; |
| 858 | default: |
| 859 | break; |
| 860 | } |
| 861 | |
| 862 | |
| 863 | $default = array( |
| 864 | 'mysticky_class_id_selector' => $mysticky_class_id_selector, |
| 865 | 'mysticky_class_selector' => $mystickyClass, |
| 866 | 'device_desktop' => 'on', |
| 867 | 'device_mobile' => 'on', |
| 868 | 'myfixed_zindex' => '99990', |
| 869 | 'myfixed_bgcolor' => '#f7f5e7', |
| 870 | 'myfixed_opacity' => '90', |
| 871 | 'myfixed_transition_time' => '0.3', |
| 872 | 'myfixed_disable_small_screen' => '0', |
| 873 | 'myfixed_disable_large_screen' => '0', |
| 874 | 'mysticky_active_on_height' => '0', |
| 875 | 'mysticky_active_on_height_home'=> '0', |
| 876 | 'myfixed_fade' => 'slide', |
| 877 | 'myfixed_cssstyle' => '#mysticky-nav .myfixed { margin:0 auto; float:none; border:0px; background:none; max-width:100%; }' |
| 878 | ); |
| 879 | |
| 880 | if ( get_option('mysticky_option_name') == false && current_user_can( 'manage_options' ) ) { |
| 881 | $status = get_option("sticky_header_status"); |
| 882 | if($status == false) { |
| 883 | update_option("sticky_header_status", "done"); |
| 884 | update_option("has_sticky_header_old_version", "no"); |
| 885 | } |
| 886 | update_option( 'mysticky_option_name', $default ); |
| 887 | } else { |
| 888 | $status = get_option("sticky_header_status"); |
| 889 | if($status == false) { |
| 890 | update_option("sticky_header_status", "done"); |
| 891 | update_option("has_sticky_header_old_version", "yes"); |
| 892 | } |
| 893 | } |
| 894 | |
| 895 | if(isset($_POST['reset_mysticky_options']) && current_user_can( 'manage_options' )) { |
| 896 | if(isset($_REQUEST['nonce']) && !empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'mysticky_option_backend_reset_nonce')) { |
| 897 | update_option('mysticky_option_name', $default); |
| 898 | } else { |
| 899 | |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | if ( !get_option( 'update_mysticky_version_2_6') && current_user_can( 'manage_options' )) { |
| 904 | $mysticky_option_name = get_option( 'mysticky_option_name' ); |
| 905 | $mysticky_option_name['mysticky_class_id_selector'] = 'custom'; |
| 906 | if ($mysticky_option_name['myfixed_fade'] == 'on'){ |
| 907 | $mysticky_option_name['myfixed_fade'] = 'slide'; |
| 908 | }else{ |
| 909 | $mysticky_option_name['myfixed_fade'] = 'fade'; |
| 910 | } |
| 911 | update_option( 'mysticky_option_name', $mysticky_option_name ); |
| 912 | update_option( 'update_mysticky_version_2_6', true ); |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | /* |
| 917 | * clear cache when any option is updated |
| 918 | * |
| 919 | */ |
| 920 | public function mysticky_clear_all_caches(){ |
| 921 | |
| 922 | try { |
| 923 | global $wp_fastest_cache; |
| 924 | |
| 925 | // if W3 Total Cache is being used, clear the cache |
| 926 | if (function_exists('w3tc_flush_all')) { |
| 927 | w3tc_flush_all(); |
| 928 | } |
| 929 | /* if WP Super Cache is being used, clear the cache */ |
| 930 | if (function_exists('wp_cache_clean_cache')) { |
| 931 | global $file_prefix, $supercachedir; |
| 932 | if (empty($supercachedir) && function_exists('get_supercache_dir')) { |
| 933 | $supercachedir = get_supercache_dir(); |
| 934 | } |
| 935 | wp_cache_clean_cache($file_prefix); |
| 936 | } |
| 937 | |
| 938 | if (class_exists('WpeCommon')) { |
| 939 | //be extra careful, just in case 3rd party changes things on us |
| 940 | if (method_exists('WpeCommon', 'purge_memcached')) { |
| 941 | //WpeCommon::purge_memcached(); |
| 942 | } |
| 943 | if (method_exists('WpeCommon', 'clear_maxcdn_cache')) { |
| 944 | //WpeCommon::clear_maxcdn_cache(); |
| 945 | } |
| 946 | if (method_exists('WpeCommon', 'purge_varnish_cache')) { |
| 947 | //WpeCommon::purge_varnish_cache(); |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | if (method_exists('WpFastestCache', 'deleteCache') && !empty($wp_fastest_cache)) { |
| 952 | $wp_fastest_cache->deleteCache(); |
| 953 | } |
| 954 | if (function_exists('rocket_clean_domain')) { |
| 955 | rocket_clean_domain(); |
| 956 | // Preload cache. |
| 957 | if (function_exists('run_rocket_sitemap_preload')) { |
| 958 | run_rocket_sitemap_preload(); |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | if (class_exists("autoptimizeCache") && method_exists("autoptimizeCache", "clearall")) { |
| 963 | autoptimizeCache::clearall(); |
| 964 | } |
| 965 | |
| 966 | if (class_exists("LiteSpeed_Cache_API") && method_exists("autoptimizeCache", "purge_all")) { |
| 967 | LiteSpeed_Cache_API::purge_all(); |
| 968 | } |
| 969 | |
| 970 | if ( class_exists( '\Hummingbird\Core\Utils' ) ) { |
| 971 | |
| 972 | $modules = \Hummingbird\Core\Utils::get_active_cache_modules(); |
| 973 | foreach ( $modules as $module => $name ) { |
| 974 | $mod = \Hummingbird\Core\Utils::get_module( $module ); |
| 975 | |
| 976 | if ( $mod->is_active() ) { |
| 977 | if ( 'minify' === $module ) { |
| 978 | $mod->clear_files(); |
| 979 | } else { |
| 980 | $mod->clear_cache(); |
| 981 | } |
| 982 | } |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | } catch (Exception $e) { |
| 987 | return 1; |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | public function mystickymenu_deactivate() { |
| 992 | global $pagenow; |
| 993 | |
| 994 | if ( 'plugins.php' !== $pagenow ) { |
| 995 | return; |
| 996 | } |
| 997 | include dirname(__FILE__) . "/mystickymenu-deactivate-form.php"; |
| 998 | } |
| 999 | public function mystickymenu_plugin_deactivate() { |
| 1000 | global $current_user; |
| 1001 | if ( ! current_user_can( 'manage_options' ) ) { |
| 1002 | wp_die(0); |
| 1003 | } |
| 1004 | check_ajax_referer( 'mystickymenu_deactivate_nonce', 'nonce' ); |
| 1005 | |
| 1006 | $postData = $_POST; |
| 1007 | $errorCounter = 0; |
| 1008 | $response = array(); |
| 1009 | $response['status'] = 0; |
| 1010 | $response['message'] = ""; |
| 1011 | $response['valid'] = 1; |
| 1012 | if(!isset($postData['reason']) || empty($postData['reason'])) { |
| 1013 | $errorCounter++; |
| 1014 | $response['message'] = "Please provide reason"; |
| 1015 | } else if(!isset($postData['reason']) || empty($postData['reason'])) { |
| 1016 | $errorCounter++; |
| 1017 | $response['message'] = "Please provide reason"; |
| 1018 | } else { |
| 1019 | $nonce = $postData['nonce']; |
| 1020 | if(!wp_verify_nonce($nonce, 'mystickymenu_deactivate_nonce')) { |
| 1021 | $response['message'] = __("Your request is not valid", "mystickymenu"); |
| 1022 | $errorCounter++; |
| 1023 | $response['valid'] = 0; |
| 1024 | } |
| 1025 | } |
| 1026 | if($errorCounter == 0) { |
| 1027 | global $current_user; |
| 1028 | $plugin_info = get_plugin_data( dirname(__FILE__) . "/mystickymenu.php" ); |
| 1029 | $postData = $_POST; |
| 1030 | $email = "none@none.none"; |
| 1031 | |
| 1032 | if (isset($postData['email_id']) && !empty($postData['email_id']) && filter_var($postData['email_id'], FILTER_VALIDATE_EMAIL)) { |
| 1033 | $email = $postData['email_id']; |
| 1034 | } |
| 1035 | $domain = site_url(); |
| 1036 | $user_name = $current_user->first_name . " " . $current_user->last_name; |
| 1037 | $subject = "My Sticky Menu was removed from {$domain}"; |
| 1038 | $headers = "MIME-Version: 1.0\r\n"; |
| 1039 | $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; |
| 1040 | $headers .= 'From: ' . $user_name . ' <' . $email . '>' . PHP_EOL; |
| 1041 | $headers .= 'Reply-To: ' . $user_name . ' <' . $email . '>' . PHP_EOL; |
| 1042 | $headers .= 'X-Mailer: PHP/' . phpversion(); |
| 1043 | ob_start(); |
| 1044 | ?> |
| 1045 | <table border="0" cellspacing="0" cellpadding="5"> |
| 1046 | <tr> |
| 1047 | <th>Plugin</th> |
| 1048 | <td>My Sticky Menu</td> |
| 1049 | </tr> |
| 1050 | <tr> |
| 1051 | <th>Plugin Version</th> |
| 1052 | <td><?php echo $plugin_info['Version']; ?></td> |
| 1053 | </tr> |
| 1054 | <tr> |
| 1055 | <th>Domain</th> |
| 1056 | <td><?php echo $domain ?></td> |
| 1057 | </tr> |
| 1058 | <tr> |
| 1059 | <th>Email</th> |
| 1060 | <td><?php echo $email ?></td> |
| 1061 | </tr> |
| 1062 | <tr> |
| 1063 | <th>Reason</th> |
| 1064 | <td><?php echo nl2br($postData['reason']) ?></td> |
| 1065 | </tr> |
| 1066 | <tr> |
| 1067 | <th>WordPress Version</th> |
| 1068 | <td><?php echo get_bloginfo('version') ?></td> |
| 1069 | </tr> |
| 1070 | <tr> |
| 1071 | <th>PHP Version</th> |
| 1072 | <td><?php echo PHP_VERSION ?></td> |
| 1073 | </tr> |
| 1074 | </table> |
| 1075 | <?php |
| 1076 | $content = ob_get_clean(); |
| 1077 | $to = "gal@premio.io,karina@premio.io"; |
| 1078 | wp_mail($to, $subject, $content, $headers); |
| 1079 | $response['status'] = 1; |
| 1080 | } |
| 1081 | echo json_encode($response); |
| 1082 | wp_die(); |
| 1083 | } |
| 1084 | } |
| 1085 | |
| 1086 | |
| 1087 | |
| 1088 | class MyStickyMenuFrontend |
| 1089 | { |
| 1090 | |
| 1091 | public function __construct() |
| 1092 | { |
| 1093 | add_action( 'wp_head', array( $this, 'mysticky_build_stylesheet_content' ) ); |
| 1094 | add_action( 'wp_enqueue_scripts', array( $this, 'mysticky_disable_at' ) ); |
| 1095 | } |
| 1096 | |
| 1097 | public function mysticky_build_stylesheet_content() { |
| 1098 | |
| 1099 | $mysticky_options = get_option( 'mysticky_option_name' ); |
| 1100 | |
| 1101 | if (isset($mysticky_options['disable_css'])) { |
| 1102 | //do nothing |
| 1103 | } else { |
| 1104 | $mysticky_options['disable_css'] = false; |
| 1105 | } |
| 1106 | |
| 1107 | if ($mysticky_options ['disable_css'] == false ) { |
| 1108 | |
| 1109 | echo '<style id="mystickymenu" type="text/css">'; |
| 1110 | echo '#mysticky-nav { width:100%; position: static; }'; |
| 1111 | echo '#mysticky-nav.wrapfixed { position:fixed; left: 0px; margin-top:0px; z-index: '. $mysticky_options ['myfixed_zindex'] .'; -webkit-transition: ' . $mysticky_options ['myfixed_transition_time'] . 's; -moz-transition: ' . $mysticky_options ['myfixed_transition_time'] . 's; -o-transition: ' . $mysticky_options ['myfixed_transition_time'] . 's; transition: ' . $mysticky_options ['myfixed_transition_time'] . 's; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . $mysticky_options ['myfixed_opacity'] . ')"; filter: alpha(opacity=' . $mysticky_options ['myfixed_opacity'] . '); opacity:' . $mysticky_options ['myfixed_opacity'] / 100 . '; background-color: ' . $mysticky_options ['myfixed_bgcolor'] . ';}'; |
| 1112 | |
| 1113 | echo '#mysticky-nav.wrapfixed .myfixed{ background-color: ' . $mysticky_options ['myfixed_bgcolor'] . '; position: relative;top: auto;left: auto;right: auto;}'; |
| 1114 | |
| 1115 | if ( isset($mysticky_options ['myfixed_textcolor']) && $mysticky_options ['myfixed_textcolor'] != '' ) { |
| 1116 | echo '#mysticky-nav.wrapfixed ul li.menu-item a { color: ' . $mysticky_options ['myfixed_textcolor'] . ';}'; |
| 1117 | } |
| 1118 | |
| 1119 | |
| 1120 | if ($mysticky_options ['myfixed_disable_small_screen'] > 0 ){ |
| 1121 | //echo '@media (max-width: '.$mysticky_options['myfixed_disable_small_screen'].'px) {#mysticky-nav.wrapfixed {position: static;} }'; |
| 1122 | }; |
| 1123 | if ( !isset( $mysticky_options['myfixed_cssstyle'] ) ) { |
| 1124 | echo '#mysticky-nav .myfixed { margin:0 auto; float:none; border:0px; background:none; max-width:100%; }'; |
| 1125 | } |
| 1126 | if ( isset( $mysticky_options['myfixed_cssstyle'] ) && $mysticky_options['myfixed_cssstyle'] != '' ) { |
| 1127 | echo $mysticky_options ['myfixed_cssstyle']; |
| 1128 | } |
| 1129 | echo '</style>'; |
| 1130 | $template_name = get_template(); |
| 1131 | ?> |
| 1132 | <style type="text/css"> |
| 1133 | <?php if( $template_name == 'hestia' ) { ?> |
| 1134 | #mysticky-nav.wrapfixed {box-shadow: 0 1px 10px -6px #0000006b,0 1px 10px 0 #0000001f,0 4px 5px -2px #0000001a;} |
| 1135 | #mysticky-nav.wrapfixed .navbar {position: relative;background-color: transparent;box-shadow: none;} |
| 1136 | <?php } ?> |
| 1137 | <?php if( $template_name == 'shapely' ) { ?> |
| 1138 | #mysticky-nav.wrapfixed #site-navigation {position: relative;} |
| 1139 | <?php } ?> |
| 1140 | <?php if( $template_name == 'storefront' ) { ?> |
| 1141 | #mysticky-nav.wrapfixed > .site-header {margin-bottom: 0;} |
| 1142 | #mysticky-nav.wrapfixed > .storefront-primary-navigation {padding: 10px 0;} |
| 1143 | <?php } ?> |
| 1144 | <?php if( $template_name == 'transportex' ) { ?> |
| 1145 | #mysticky-nav.wrapfixed > .transportex-menu-full {margin: 0 auto;} |
| 1146 | .transportex-headwidget #mysticky-nav.wrapfixed .navbar-wp {top: 0;} |
| 1147 | <?php } ?> |
| 1148 | <?php if( $template_name == 'twentynineteen' ) { ?> |
| 1149 | #mysticky-nav.wrapfixed {padding: 10px;} |
| 1150 | <?php } ?> |
| 1151 | <?php if( $template_name == 'twentysixteen' ) { ?> |
| 1152 | #mysticky-nav.wrapfixed > .site-header {padding-top: 0;padding-bottom: 0;} |
| 1153 | <?php } ?> |
| 1154 | <?php if( $template_name == 'twentytwenty' ) { ?> |
| 1155 | #site-header {background: transparent;} |
| 1156 | <?php } ?> |
| 1157 | </style> |
| 1158 | <?php |
| 1159 | } |
| 1160 | } |
| 1161 | |
| 1162 | public function mystickymenu_google_fonts_url() { |
| 1163 | $welcomebar = get_option( 'mysticky_option_welcomebar' ); |
| 1164 | |
| 1165 | $default_fonts = array('Arial', 'Tahoma', 'Verdana', 'Helvetica', 'Times New Roman', 'Trebuchet MS', 'Georgia' ); |
| 1166 | $fonts_url = ''; |
| 1167 | $fonts = array(); |
| 1168 | $font_args = array(); |
| 1169 | $base_url = "https://fonts.googleapis.com/css"; |
| 1170 | $fonts['family']['Lato'] = 'Lato:400,500,600,700'; |
| 1171 | if ( isset($welcomebar['mysticky_welcomebar_font']) && $welcomebar['mysticky_welcomebar_font'] !='' && !in_array( $welcomebar['mysticky_welcomebar_font'], $default_fonts) ) { |
| 1172 | $fonts['family'][$welcomebar['mysticky_welcomebar_font']] = $welcomebar['mysticky_welcomebar_font'] . ':400,500,600,700'; |
| 1173 | } |
| 1174 | if ( isset($welcomebar['mysticky_welcomebar_btnfont']) && $welcomebar['mysticky_welcomebar_btnfont'] !='' && !in_array( $welcomebar['mysticky_welcomebar_btnfont'], $default_fonts) ) { |
| 1175 | $fonts['family'][$welcomebar['mysticky_welcomebar_btnfont']] = $welcomebar['mysticky_welcomebar_btnfont'] . ':400,500,600,700'; |
| 1176 | } |
| 1177 | |
| 1178 | /* Prepapre URL if font family defined. */ |
| 1179 | if( !empty( $fonts['family'] ) ) { |
| 1180 | |
| 1181 | /* format family to string */ |
| 1182 | if( is_array($fonts['family']) ){ |
| 1183 | $fonts['family'] = implode( '|', $fonts['family'] ); |
| 1184 | } |
| 1185 | |
| 1186 | $font_args['family'] = urlencode( trim( $fonts['family'] ) ); |
| 1187 | |
| 1188 | if( !empty( $fonts['subsets'] ) ){ |
| 1189 | |
| 1190 | /* format subsets to string */ |
| 1191 | if( is_array( $fonts['subsets'] ) ){ |
| 1192 | $fonts['subsets'] = implode( ',', $fonts['subsets'] ); |
| 1193 | } |
| 1194 | |
| 1195 | $font_args['subsets'] = urlencode( trim( $fonts['subsets'] ) ); |
| 1196 | } |
| 1197 | |
| 1198 | $fonts_url = add_query_arg( $font_args, $base_url ); |
| 1199 | } |
| 1200 | |
| 1201 | return esc_url_raw( $fonts_url ); |
| 1202 | } |
| 1203 | |
| 1204 | public function mystickymenu_script() { |
| 1205 | |
| 1206 | $mysticky_options = get_option( 'mysticky_option_name' ); |
| 1207 | |
| 1208 | if ( is_admin_bar_showing() ) { |
| 1209 | $top = "true"; |
| 1210 | } else { |
| 1211 | $top = "false"; |
| 1212 | } |
| 1213 | |
| 1214 | $welcomebar = get_option( 'mysticky_option_welcomebar' ); |
| 1215 | if ( isset($welcomebar['mysticky_welcomebar_enable']) && $welcomebar['mysticky_welcomebar_enable'] == 1 ) { |
| 1216 | wp_enqueue_style('google-fonts', $this->mystickymenu_google_fonts_url(),array(), MYSTICKY_VERSION ); |
| 1217 | } |
| 1218 | |
| 1219 | // needed for update 1.7 => 1.8 ... will be removed in the future () |
| 1220 | if (isset($mysticky_options['mysticky_active_on_height_home'])) { |
| 1221 | //do nothing |
| 1222 | } else { |
| 1223 | $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height']; |
| 1224 | } |
| 1225 | |
| 1226 | |
| 1227 | if ($mysticky_options['mysticky_active_on_height_home'] == 0 ) { |
| 1228 | $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height']; |
| 1229 | } |
| 1230 | |
| 1231 | |
| 1232 | if ( is_front_page() && is_home() ) { |
| 1233 | |
| 1234 | $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home']; |
| 1235 | |
| 1236 | } elseif ( is_front_page()){ |
| 1237 | |
| 1238 | $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home']; |
| 1239 | |
| 1240 | } |
| 1241 | wp_register_script('detectmobilebrowser', plugins_url( 'js/detectmobilebrowser.js', __FILE__ ), array('jquery'), MYSTICKY_VERSION, true); |
| 1242 | wp_enqueue_script( 'detectmobilebrowser' ); |
| 1243 | |
| 1244 | wp_register_script('mystickymenu', plugins_url( 'js/mystickymenu.min.js', __FILE__ ), array('jquery'), MYSTICKY_VERSION, true); |
| 1245 | wp_enqueue_script( 'mystickymenu' ); |
| 1246 | |
| 1247 | $myfixed_disable_scroll_down = isset($mysticky_options['myfixed_disable_scroll_down']) ? $mysticky_options['myfixed_disable_scroll_down'] : 'false'; |
| 1248 | $mystickyTransition = isset($mysticky_options['myfixed_fade']) ? $mysticky_options['myfixed_fade'] : 'fade'; |
| 1249 | $mystickyDisableLarge = isset($mysticky_options['myfixed_disable_large_screen']) ? $mysticky_options['myfixed_disable_large_screen'] : '0'; |
| 1250 | |
| 1251 | $mystickyClass = ( $mysticky_options['mysticky_class_id_selector'] != 'custom') ? '.menu-' . $mysticky_options['mysticky_class_id_selector'] .'-container' : $mysticky_options['mysticky_class_selector']; |
| 1252 | |
| 1253 | if ( $mysticky_options['mysticky_class_id_selector'] != 'custom' ) { |
| 1254 | $template_name = get_template(); |
| 1255 | switch( $template_name ){ |
| 1256 | case 'ashe': |
| 1257 | $mystickyClass = '#main-nav'; |
| 1258 | break; |
| 1259 | case 'astra': |
| 1260 | case 'hello-elementor': |
| 1261 | case 'sydney': |
| 1262 | case 'twentysixteen': |
| 1263 | $mystickyClass = 'header.site-header'; |
| 1264 | break; |
| 1265 | case 'generatepress': |
| 1266 | $mystickyClass = 'nav.main-navigation'; |
| 1267 | break; |
| 1268 | case 'transportex': |
| 1269 | $mystickyClass = '.transportex-menu-full'; |
| 1270 | break; |
| 1271 | case 'hestia': |
| 1272 | case 'neve': |
| 1273 | $mystickyClass = 'header.header'; |
| 1274 | break; |
| 1275 | case 'mesmerize': |
| 1276 | $mystickyClass = '.navigation-bar'; |
| 1277 | break; |
| 1278 | case 'oceanwp': |
| 1279 | $mystickyClass = 'header#site-header'; |
| 1280 | break; |
| 1281 | case 'shapely': |
| 1282 | $mystickyClass = '#site-navigation'; |
| 1283 | break; |
| 1284 | case 'storefront': |
| 1285 | $mystickyClass = '.storefront-primary-navigation'; |
| 1286 | break; |
| 1287 | case 'twentynineteen': |
| 1288 | $mystickyClass = '#site-navigation'; |
| 1289 | break; |
| 1290 | case 'twentyseventeen': |
| 1291 | $mystickyClass = '.navigation-top'; |
| 1292 | break; |
| 1293 | default: |
| 1294 | break; |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | |
| 1299 | $mysticky_translation_array = array( |
| 1300 | 'mystickyClass' => $mystickyClass, |
| 1301 | 'activationHeight' => $mysticky_options['mysticky_active_on_height'], |
| 1302 | 'disableWidth' => $mysticky_options['myfixed_disable_small_screen'], |
| 1303 | 'disableLargeWidth' => $mystickyDisableLarge, |
| 1304 | 'adminBar' => $top, |
| 1305 | 'device_desktop' => true, |
| 1306 | 'device_mobile' => true, |
| 1307 | 'mystickyTransition' => $mystickyTransition, |
| 1308 | 'mysticky_disable_down' => $myfixed_disable_scroll_down, |
| 1309 | |
| 1310 | |
| 1311 | ); |
| 1312 | wp_localize_script( 'mystickymenu', 'option', $mysticky_translation_array ); |
| 1313 | } |
| 1314 | |
| 1315 | public function mysticky_disable_at() { |
| 1316 | |
| 1317 | |
| 1318 | $mysticky_options = get_option( 'mysticky_option_name' ); |
| 1319 | |
| 1320 | $mysticky_disable_at_front_home = isset($mysticky_options['mysticky_disable_at_front_home']); |
| 1321 | $mysticky_disable_at_blog = isset($mysticky_options['mysticky_disable_at_blog']); |
| 1322 | $mysticky_disable_at_page = isset($mysticky_options['mysticky_disable_at_page']); |
| 1323 | $mysticky_disable_at_tag = isset($mysticky_options['mysticky_disable_at_tag']); |
| 1324 | $mysticky_disable_at_category = isset($mysticky_options['mysticky_disable_at_category']); |
| 1325 | $mysticky_disable_at_single = isset($mysticky_options['mysticky_disable_at_single']); |
| 1326 | $mysticky_disable_at_archive = isset($mysticky_options['mysticky_disable_at_archive']); |
| 1327 | $mysticky_disable_at_search = isset($mysticky_options['mysticky_disable_at_search']); |
| 1328 | $mysticky_disable_at_404 = isset($mysticky_options['mysticky_disable_at_404']); |
| 1329 | $mysticky_enable_at_pages = isset($mysticky_options['mysticky_enable_at_pages']) ? $mysticky_options['mysticky_enable_at_pages'] : ''; |
| 1330 | $mysticky_enable_at_posts = isset($mysticky_options['mysticky_enable_at_posts']) ? $mysticky_options['mysticky_enable_at_posts'] : ''; |
| 1331 | |
| 1332 | // Trim input to ignore empty spaces |
| 1333 | $mysticky_enable_at_pages_exp = array_map('trim', explode(',', $mysticky_enable_at_pages)); |
| 1334 | $mysticky_enable_at_posts_exp = array_map('trim', explode(',', $mysticky_enable_at_posts)); |
| 1335 | |
| 1336 | |
| 1337 | |
| 1338 | |
| 1339 | if ( is_front_page() && is_home() ) { /* Default homepage */ |
| 1340 | |
| 1341 | if ( $mysticky_disable_at_front_home == false ) { |
| 1342 | $this->mystickymenu_script(); |
| 1343 | } |
| 1344 | } elseif ( is_front_page()){ /* Static homepage */ |
| 1345 | |
| 1346 | if ( $mysticky_disable_at_front_home == false ) { |
| 1347 | $this->mystickymenu_script(); |
| 1348 | } |
| 1349 | |
| 1350 | } elseif ( is_home()){ /* Blog page */ |
| 1351 | |
| 1352 | if ( $mysticky_disable_at_blog == false ) { |
| 1353 | $this->mystickymenu_script(); |
| 1354 | } |
| 1355 | |
| 1356 | } elseif ( is_page() ){ /* Single page*/ |
| 1357 | |
| 1358 | if ( $mysticky_disable_at_page == false ) { |
| 1359 | $this->mystickymenu_script(); |
| 1360 | } |
| 1361 | if ( is_page( $mysticky_enable_at_pages_exp ) ){ |
| 1362 | $this->mystickymenu_script(); |
| 1363 | } |
| 1364 | |
| 1365 | } elseif ( is_tag()){ /* Tag page */ |
| 1366 | |
| 1367 | if ( $mysticky_disable_at_tag == false ) { |
| 1368 | $this->mystickymenu_script(); |
| 1369 | } |
| 1370 | |
| 1371 | } elseif ( is_category()){ /* Category page */ |
| 1372 | |
| 1373 | if ( $mysticky_disable_at_category == false ) { |
| 1374 | $this->mystickymenu_script(); |
| 1375 | } |
| 1376 | |
| 1377 | } elseif ( is_single()){ /* Single post */ |
| 1378 | |
| 1379 | if ( $mysticky_disable_at_single == false ) { |
| 1380 | $this->mystickymenu_script(); |
| 1381 | } |
| 1382 | |
| 1383 | if ( is_single( $mysticky_enable_at_posts_exp ) ){ |
| 1384 | $this->mystickymenu_script(); |
| 1385 | } |
| 1386 | |
| 1387 | } elseif ( is_archive()){ /* Archive */ |
| 1388 | |
| 1389 | if ( $mysticky_disable_at_archive == false ) { |
| 1390 | $this->mystickymenu_script(); |
| 1391 | } |
| 1392 | |
| 1393 | } elseif ( is_search()){ /* Search */ |
| 1394 | |
| 1395 | if ( $mysticky_disable_at_search == false ) { |
| 1396 | $this->mystickymenu_script(); |
| 1397 | } |
| 1398 | |
| 1399 | } elseif ( is_404()){ /* 404 */ |
| 1400 | |
| 1401 | if ( $mysticky_disable_at_404 == false ) { |
| 1402 | $this->mystickymenu_script(); |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | } |
| 1407 | |
| 1408 | } |
| 1409 | |
| 1410 | if( is_admin() ) { |
| 1411 | new MyStickyMenuBackend(); |
| 1412 | require_once 'mystickymenu-affiliate.php'; |
| 1413 | |
| 1414 | } else { |
| 1415 | new MyStickyMenuFrontend(); |
| 1416 | } |