version = $this->get_plugin_version(); $this->plugin_dir = plugin_dir_path(__FILE__); $this->plugin_url = plugin_dir_url(__FILE__); $this->load_options(); $options = $this->get_options(); $this->theme_id = isset($_GET['theme_id']) && array_key_exists($_GET['theme_id'], $options['themes']) ? wp_unslash($_GET['theme_id']) : $options['theme_global']; //phpcs:ignore $this->theme = $options['themes'][$this->theme_id]; //Admin Interface add_action('admin_menu', array($this, 'admin_menu')); add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_filter('plugin_row_meta', array($this, 'plugin_meta_links'), 10, 2); add_filter('admin_footer_text', array($this, 'admin_footer_text')); add_action('wp_before_admin_bar_render', array($this, 'admin_bar')); add_action('wp_head', array($this, 'admin_bar_style')); add_action('admin_head', array($this, 'admin_bar_style')); //Admin actions add_action('admin_action_mtnc_change_status', array($this, 'change_status')); add_action('admin_action_mtnc_install_wpfssl', array(&$this, 'install_wpfssl')); add_action('admin_action_mtnc_install_wpcaptcha', array(&$this, 'install_wpcaptcha')); add_action('admin_action_mtnc_install_weglot', array(&$this, 'install_weglot')); add_action('admin_action_mtnc_install_weglot', array(&$this, 'install_weglot')); add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'plugin_action_links')); add_action('admin_action_mtnc_reset_settings', array($this, 'mtnc_reset_settings')); //AJAX add_action('wp_ajax_mtnc_action', array($this, 'ajax_action')); add_action('wp_ajax_maintenance_dismiss_notice', array($this, 'ajax_dismiss_notice')); //Frontend add_action('template_include', array($this, 'template_include'), 999999); } // __construct /** * Get plugin version from file header * * @return string */ public function get_plugin_version() { $plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin'); return $plugin_data['version']; } // get_plugin_version // add settings link to plugins page static function plugin_action_links($links) { $settings_link = 'Configure'; $pro_link = 'Get PRO'; array_unshift($links, $pro_link); array_unshift($links, $settings_link); return $links; } // plugin_action_links /** * Load and prepare the options array. If needed create a new DB entry. * * @return array */ private function load_options() { $options = get_option('mtnc-options', array('options' => array())); $change = false; if (!is_array($options)) { $options = array('options' => array()); } if (!is_array($options['options'])) { $options['options'] = array(); } if (empty($options['meta'])) { $options['meta'] = array('first_version' => $this->version, 'first_install' => current_time('timestamp', true)); $change = true; } if (!isset($options['dismissed_notices']) || !is_array($options['dismissed_notices'])) { $options['dismissed_notices'] = array(); $change = true; } $default_theme_id = md5(time() . 'default'); $def_options = array( 'theme_global' => $default_theme_id, 'themes' => array($default_theme_id => json_decode( '{ "modules":{}, "modules_order":[], "name":"Default", "theme_thumbnail":"", "theme_status":"", "body_font_size":"16", "body_font_color":"FFFFFF", "body_font":"Orbitron", "body_link_color":"0096ff", "body_link_hover_color":"57baff", "background_type":"image", "background_video":"", "background_video_fallback":"", "background_video_filter":"", "background_size_opt":"cover", "background_position":"center center", "background_image_filter":"", "background_blur":"", "background_image":"' . trailingslashit(MTNC_URL) . 'img/mountain-bg.jpg", "preloader_background_image":"", "background_color":"FFFFFF", "login_background_color":"000000", "content_overlay":"1", "content_width":"600", "content_overlay_color":"#rgba(0,0,0,0.2)", "content_overlay_shadow_color":"rgba(0,0,0,0.2)", "content_position":"middle", "modules_spacing":"10", "custom_css":"" }' )), 'status' => '0', 'mode' => 'layout', 'mtnc_page' => 0, 'header_text' => 'Our site is under maintenance!', //SEO 'title' => get_bloginfo('name') . ' is under maintenance', 'description' => 'We are doing some work on our site. Please come back later. We\'ll be up and running in no time.', 'target_keyword' => 'maintenance', 'excludese' => '0', 'blockse' => '0', 'favicon' => '', 'social_preview' => '', 'analytics' => '', 'tracking_pixel' => '', 'twitter_site' => '', 'facebook_site' => '', //Access 'show_logged_in' => '1', 'ip_whitelist' => '', 'per_url_settings' => '', 'per_url_enable_disable' => '', 'direct_access_link' => '', 'custom_login_url' => '', 'login_button' => '1', 'wplogin_button_tooltip' => 'Access WordPress admin', 'maintenance_password' => '', 'site_password' => '', 'password_button' => '0', 'login_button_text' => 'Access the Site', 'login_message' => 'Please enter the password to access the site', 'login_wrong_password_text' => 'Wrong password', 'login_button_tooltip' => 'Direct Access login', //Advanced 'no_cache_headers' => '1', 'disable_toolbar_menu' => '', 'force_ssl' => '', 'enable_rest' => '', 'custom_wp_maintenance' => '', 'custom_wp_maintenance_title' => '', 'custom_wp_maintenance_content' => '', ); if (sizeof($options['options']) < sizeof($def_options)) { $options['options'] = array_merge($def_options, (array) $options['options']); $change = true; } /* Detect upgrade from free */ $mtnc_free_options = get_option('maintenance_options', false); if ($mtnc_free_options !== false && array_key_exists('state', $mtnc_free_options) && !array_key_exists('upgraded', $options)) { if(!empty($mtnc_free_options['state']) && $mtnc_free_options['state'] == '1'){ $options['options']['status'] = '1'; } else { $options['options']['status'] = '0'; } $options['options']['theme_global'] = $default_theme_id; $options['options']['themes'] = []; $options['options']['themes'][$default_theme_id] = json_decode('{"modules":{"logo-ea1e7873":{"name":"Logo","type":"logo","groups":{"logo":{"name":"Logo","active":true,"fields":{"logo":{"type":"image","name":"logo","label":"Logo","value":"","class":"","desc":""},"title":{"type":"text","name":"title","label":"Logo Title","value":"","class":"full-width","desc":""},"width":{"type":"number","name":"width","label":"Width","value":"","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","desc":"Leave blank for auto"},"height":{"type":"number","name":"height","label":"Height","value":"","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","desc":"Leave blank for auto"}}},"layout":{"name":"Layout","fields":{"padding_label":{"type":"label","name":"padding_label","label":"Padding"},"padding_top":{"type":"number","name":"padding_top","label":"Top","image_label":"MTNCURL\/img\/icons\/padding_top.png","value":"10","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_bottom":{"type":"number","name":"padding_bottom","label":"Bottom","image_label":"MTNCURL\/img\/icons\/padding_bottom.png","value":"10","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_left":{"type":"number","name":"padding_left","label":"Left","image_label":"MTNCURL\/img\/icons\/padding_left.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_right":{"type":"number","name":"padding_right","label":"Right","image_label":"MTNCURL\/img\/icons\/padding_right.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_label":{"type":"label","name":"margin_label","label":"Margin"},"margin_top":{"type":"number","name":"margin_top","label":"Top","image_label":"MTNCURL\/img\/icons\/margin_top.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_bottom":{"type":"number","name":"margin_bottom","label":"Bottom","image_label":"MTNCURL\/img\/icons\/margin_bottom.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_left":{"type":"number","name":"margin_left","label":"Left","image_label":"MTNCURL\/img\/icons\/margin_left.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_right":{"type":"number","name":"margin_right","label":"Right","image_label":"MTNCURL\/img\/icons\/margin_right.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"background_label":{"type":"label","name":"background_label","label":"Background"},"background_color":{"type":"color","name":"background_color","nolabel":true,"value":"rgba(255,255,255,0)","desc":""},"background":{"type":"image","name":"background","nolabel":true,"value":"","class":"","desc":""}}}}},"content-a60d7054":{"name":"Content","type":"content","groups":{"col1":{"name":"Footer","active":true,"fields":{"text":{"type":"textarea","name":"text","label":"Text","value":"Site will be available soon. Thank you for your patience!<\/span>","class":"full-width","desc":""},"font_size":{"type":"number","name":"font_size","label":"Font Size","value":"14","class":"number_small","units":{"px":"px","pt":"pt","em":"em"},"unit_value":"px"},"color":{"type":"color","name":"text_color","label":"Color","value":"rgba(255,255,255,1)","desc":""},"font":{"type":"font","name":"font","label":"Font","value":"Arial","class":"full-width","desc":""},"line_height":{"type":"number","name":"line_height","label":"Line Height","value":"1","units":{"px":"px","percent":"%","em":"em"},"unit_value":"em","class":"number_small","desc":""}}},"layout":{"name":"Layout","fields":{"padding_label":{"type":"label","name":"padding_label","label":"Padding"},"padding_top":{"type":"number","name":"padding_top","label":"Top","image_label":"MTNCURL\/img\/icons\/padding_top.png","value":"10","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_bottom":{"type":"number","name":"padding_bottom","label":"Bottom","image_label":"MTNCURL\/img\/icons\/padding_bottom.png","value":"10","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_left":{"type":"number","name":"padding_left","label":"Left","image_label":"MTNCURL\/img\/icons\/padding_left.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_right":{"type":"number","name":"padding_right","label":"Right","image_label":"MTNCURL\/img\/icons\/padding_right.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_label":{"type":"label","name":"margin_label","label":"Margin"},"margin_top":{"type":"number","name":"margin_top","label":"Top","image_label":"MTNCURL\/img\/icons\/margin_top.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_bottom":{"type":"number","name":"margin_bottom","label":"Bottom","image_label":"MTNCURL\/img\/icons\/margin_bottom.png","value":"80","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_left":{"type":"number","name":"margin_left","label":"Left","image_label":"MTNCURL\/img\/icons\/margin_left.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_right":{"type":"number","name":"margin_right","label":"Right","image_label":"MTNCURL\/img\/icons\/margin_right.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"background_label":{"type":"label","name":"background_label","label":"Background"},"background_color":{"type":"color","name":"background_color","nolabel":true,"value":"rgba(255,255,255,0)","desc":""},"background":{"type":"image","name":"background","nolabel":true,"value":"","class":"","desc":""}}}}},"header-4b5742b4":{"name":"Header","type":"header","groups":{"header":{"name":"Header","active":true,"fields":{"text":{"type":"text","name":"text","label":"Text","value":"Maintenance mode is on","class":"full-width","desc":""},"text_align":{"type":"radio","name":"text_align","label":"Text Align","class":"","values":{"left":"Left","center":"Center","right":"Right"},"value":"center"},"font_size":{"type":"range","name":"font_size","label":"Font Size","value":"30","min":6,"max":120,"class":"","units":{"px":"px","pt":"pt","em":"em"},"unit_value":"px"},"color":{"type":"color","name":"text_color","label":"Color","value":"rgba(255,255,255,1)","desc":""},"font":{"type":"font","name":"font","label":"Font","value":"Arial","class":"full-width","desc":""},"line_height":{"type":"number","name":"line_height","label":"Line Height","value":"1","units":{"px":"px","percent":"%","em":"em"},"unit_value":"em","class":"number_small","desc":""}}},"layout":{"name":"Layout","fields":{"padding_label":{"type":"label","name":"padding_label","label":"Padding"},"padding_top":{"type":"number","name":"padding_top","label":"Top","image_label":"MTNCURL\/img\/icons\/padding_top.png","value":"10","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_bottom":{"type":"number","name":"padding_bottom","label":"Bottom","image_label":"MTNCURL\/img\/icons\/padding_bottom.png","value":"10","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_left":{"type":"number","name":"padding_left","label":"Left","image_label":"MTNCURL\/img\/icons\/padding_left.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_right":{"type":"number","name":"padding_right","label":"Right","image_label":"MTNCURL\/img\/icons\/padding_right.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_label":{"type":"label","name":"margin_label","label":"Margin"},"margin_top":{"type":"number","name":"margin_top","label":"Top","image_label":"MTNCURL\/img\/icons\/margin_top.png","value":"80","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_bottom":{"type":"number","name":"margin_bottom","label":"Bottom","image_label":"MTNCURL\/img\/icons\/margin_bottom.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_left":{"type":"number","name":"margin_left","label":"Left","image_label":"MTNCURL\/img\/icons\/margin_left.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_right":{"type":"number","name":"margin_right","label":"Right","image_label":"MTNCURL\/img\/icons\/margin_right.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"background_label":{"type":"label","name":"background_label","label":"Background"},"background_color":{"type":"color","name":"background_color","nolabel":true,"value":"rgba(255,255,255,0)","desc":""},"background":{"type":"image","name":"background","nolabel":true,"value":"","class":"","desc":""}}}}},"footer-b527dd0c":{"name":"Footer","type":"footer","groups":{"col1":{"name":"Footer","active":true,"fields":{"text":{"type":"textarea","name":"text","label":"Text","value":"
\u00a9 Maintenance 2022
<\/div>","class":"full-width","desc":""},"font_size":{"type":"number","name":"font_size","label":"Font Size","value":"14","class":"number_small","units":{"px":"px","pt":"pt","em":"em"},"unit_value":"px"},"color":{"type":"color","name":"text_color","label":"Color","value":"rgba(255,255,255,1)","desc":""},"font":{"type":"font","name":"font","label":"Font","value":"Arial","class":"full-width","desc":""},"line_height":{"type":"number","name":"line_height","label":"Line Height","value":"1","units":{"px":"px","percent":"%","em":"em"},"unit_value":"em","class":"number_small","desc":""}}},"layout":{"name":"Layout","fields":{"padding_label":{"type":"label","name":"padding_label","label":"Padding"},"padding_top":{"type":"number","name":"padding_top","label":"Top","image_label":"MTNCURL\/img\/icons\/padding_top.png","value":"10","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_bottom":{"type":"number","name":"padding_bottom","label":"Bottom","image_label":"MTNCURL\/img\/icons\/padding_bottom.png","value":"10","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_left":{"type":"number","name":"padding_left","label":"Left","image_label":"MTNCURL\/img\/icons\/padding_left.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"padding_right":{"type":"number","name":"padding_right","label":"Right","image_label":"MTNCURL\/img\/icons\/padding_right.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_label":{"type":"label","name":"margin_label","label":"Margin"},"margin_top":{"type":"number","name":"margin_top","label":"Top","image_label":"MTNCURL\/img\/icons\/margin_top.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_bottom":{"type":"number","name":"margin_bottom","label":"Bottom","image_label":"MTNCURL\/img\/icons\/margin_bottom.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_left":{"type":"number","name":"margin_left","label":"Left","image_label":"MTNCURL\/img\/icons\/margin_left.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"margin_right":{"type":"number","name":"margin_right","label":"Right","image_label":"MTNCURL\/img\/icons\/margin_right.png","value":"0","class":"number_small","units":{"px":"px","percent":"%","em":"em"},"unit_value":"px","wrapper_class":"col-4"},"background_label":{"type":"label","name":"background_label","label":"Background"},"background_color":{"type":"color","name":"background_color","nolabel":true,"value":"rgba(255,255,255,0)","desc":""},"background":{"type":"image","name":"background","nolabel":true,"value":"","class":"","desc":""}}}}}},"modules_order":{"logo-ea1e7873":"logo-ea1e7873","header-4b5742b4":"header-4b5742b4","content-a60d7054":"content-a60d7054","footer-b527dd0c":"footer-b527dd0c"},"name":"My Theme","body_font_size":"16","body_font_color":"#FFFFFF","body_font":"Orbitron","body_link_color":"#0096FF","body_link_hover_color":"#57BAFF","background_type":"image","background_video":"","background_video_fallback":"","background_video_filter":"","background_size_opt":"cover","background_position":"center center","background_image_filter":"","background_image":"","background_color":"rgba(64,64,64,1)","content_overlay":"","content_width":600,"content_overlay_color":"rgba(0,0,0,0.2)","content_overlay_shadow_color":"rgba(0,0,0,0)","content_position":"middle","modules_spacing":10,"custom_css":"","theme_thumbnail":"","theme_status":"","background_blur":10,"preloader_background_image":""}'); $logo_src = wp_get_attachment_image_src($mtnc_free_options['logo'], 'full'); $options['options']['themes'][$default_theme_id]->modules->{'logo-ea1e7873'}->groups->logo->fields->logo->value = esc_url($logo_src[0]); $options['options']['themes'][$default_theme_id]->modules->{'logo-ea1e7873'}->groups->logo->fields->width->value = $mtnc_free_options['logo_width']; $options['options']['themes'][$default_theme_id]->modules->{'logo-ea1e7873'}->groups->logo->fields->height->value = $mtnc_free_options['logo_height']; //SEO $options['options']['title'] = $mtnc_free_options['page_title']; $options['options']['description'] = $mtnc_free_options['description']; //Access $options['options']['login_button'] = $mtnc_free_options['is_login']; //Design $old_bg = wp_get_attachment_image_src($mtnc_free_options['body_bg'], 'full'); $options['options']['themes'][$default_theme_id]->background_image = esc_url($old_bg[0]); $options['options']['themes'][$default_theme_id]->background_blur = $mtnc_free_options['blur_intensity']; $options['options']['themes'][$default_theme_id]->background_color = $mtnc_free_options['body_bg_color']; $options['options']['themes'][$default_theme_id]->login_background_color = $mtnc_free_options['controls_bg_color']; $options['options']['themes'][$default_theme_id]->body_font_color = $mtnc_free_options['font_color']; $options['options']['themes'][$default_theme_id]->body_font = $mtnc_free_options['body_font_family']; $options['options']['themes'][$default_theme_id]->background_color = $mtnc_free_options['body_bg_color']; $options['options']['themes'][$default_theme_id]->custom_css = 'body,h2{font-weight:300;}'; $options['options']['themes'][$default_theme_id]->modules->{'header-4b5742b4'}->groups->header->fields->text->value = '' . $mtnc_free_options['heading'] . ''; $options['options']['themes'][$default_theme_id]->modules->{'header-4b5742b4'}->groups->header->fields->font_size->value = 45; $options['options']['themes'][$default_theme_id]->modules->{'header-4b5742b4'}->groups->header->fields->font->value = $mtnc_free_options['body_font_family']; $options['options']['themes'][$default_theme_id]->modules->{'header-4b5742b4'}->groups->layout->fields->margin_top->value = 80; $options['options']['themes'][$default_theme_id]->modules->{'content-a60d7054'}->groups->col1->fields->text->value = '' . $mtnc_free_options['description'] . ''; $options['options']['themes'][$default_theme_id]->modules->{'content-a60d7054'}->groups->col1->fields->font_size->value = 16; $options['options']['themes'][$default_theme_id]->modules->{'content-a60d7054'}->groups->col1->fields->font->value = $mtnc_free_options['body_font_family']; $options['options']['themes'][$default_theme_id]->modules->{'content-a60d7054'}->groups->layout->fields->margin_bottom->value = 80; $options['options']['themes'][$default_theme_id]->modules->{'footer-b527dd0c'}->groups->col1->fields->text->value = '' . $mtnc_free_options['footer_text'] . ''; $options['options']['themes'][$default_theme_id]->modules->{'footer-b527dd0c'}->groups->col1->fields->font_size->value = 16; $options['options']['themes'][$default_theme_id]->modules->{'footer-b527dd0c'}->groups->col1->fields->font->value = $mtnc_free_options['body_font_family']; $options['upgraded'] = time(); $change = true; } if ($change) { update_option('mtnc-options', $options, true); } $this->options = $options; return $options; } // load_options // change status via admin bar public function change_status() { check_admin_referer('mtnc_change_status'); if (empty($_GET['new_status'])) { wp_safe_redirect(admin_url()); exit; } $options = $this->get_options(); if ($_GET['new_status'] == 'enabled') { $options['status'] = '1'; } else { $options['status'] = '0'; } $this->update_options('options', $options); if (!empty($_GET['redirect'])) { wp_safe_redirect(wp_unslash($_GET['redirect'])); } else { wp_safe_redirect(admin_url()); } exit; } // change_status /** * Dismiss notice via AJAX call * * @return null */ function ajax_dismiss_notice() { check_ajax_referer('maintenance_dismiss_notice'); if (!current_user_can('manage_options')) { wp_send_json_error('You are not allowed to run this action.'); } $notice_name = trim(sanitize_text_field(wp_unslash($_GET['notice_name'] ?? ''))); if (!$this->dismiss_notice($notice_name)) { wp_send_json_error('Notice is already dismissed.'); } else { wp_send_json_success(); } } // ajax_dismiss_notice /** * Dismiss notice by adding it to dismissed_notices options array * * @param string $notice_name Notice to dismiss. * * @return bool */ function dismiss_notice($notice_name) { if ($this->get_dismissed_notices($notice_name)) { return false; } else { $notices = $this->get_dismissed_notices(); $notices[$notice_name] = true; $this->update_options('dismissed_notices', $notices); return true; } } // dismiss_notice /** * Get all dismissed notices, or check for one specific notice * * @param string $notice_name Optional. Check if specified notice is dismissed. * * @return bool|array */ function get_dismissed_notices($notice_name = '') { $notices = $this->options['dismissed_notices']; if (empty($notice_name)) { return $notices; } else { if (empty($notices[$notice_name])) { return false; } else { return true; } } } // get_dismissed_notices /** * Retrieve available modules * * @return array */ public function get_modules() { $modules = array(); $modules['logo'] = array('name' => 'Logo', 'pro' => false); $modules['header'] = array('name' => 'Header', 'pro' => false); $modules['footer'] = array('name' => 'Footer', 'pro' => false); $modules['content'] = array('name' => 'Content', 'pro' => false); $modules['content2col'] = array('name' => 'Content 2 Column', 'pro' => true); $modules['content3col'] = array('name' => 'Content 3 Column', 'pro' => true); $modules['form'] = array('name' => 'Form', 'pro' => true); $modules['video'] = array('name' => 'Video', 'pro' => true); $modules['countdown'] = array('name' => 'Countdown', 'pro' => true); $modules['progressbar'] = array('name' => 'Progress Bar', 'pro' => true); $modules['social'] = array('name' => 'Social Icons', 'pro' => true); $modules['map'] = array('name' => 'Map', 'pro' => true); $modules['html'] = array('name' => 'Custom HTML', 'pro' => true); $modules['divider'] = array('name' => 'Divider', 'pro' => true); $modules = apply_filters('mtnc_modules_list', $modules); return $modules; } /** * Get meta part of plugin options * * @return array */ public function get_meta() { return $this->options['meta']; } // get_meta public function get_fonts() { $fonts = array('Arial', 'Helvetica', 'Georgia', 'Times New Roman', 'Tahoma', 'Verdana', 'Geneva', 'ABeeZee', 'Abel', 'Abhaya Libre', 'Abril Fatface', 'Aclonica', 'Acme', 'Actor', 'Adamina', 'Advent Pro', 'Aguafina Script', 'Akronim', 'Aladin', 'Aldrich', 'Alef', 'Alegreya', 'Alegreya SC', 'Alegreya Sans', 'Alegreya Sans SC', 'Alex Brush', 'Alfa Slab One', 'Alice', 'Alike', 'Alike Angular', 'Allan', 'Allerta', 'Allerta Stencil', 'Allura', 'Almendra', 'Almendra Display', 'Almendra SC', 'Amarante', 'Amaranth', 'Amatic SC', 'Amethysta', 'Amiko', 'Amiri', 'Amita', 'Anaheim', 'Andada', 'Andika', 'Angkor', 'Annie Use Your Telescope', 'Anonymous Pro', 'Antic', 'Antic Didone', 'Antic Slab', 'Anton', 'Arapey', 'Arbutus', 'Arbutus Slab', 'Architects Daughter', 'Archivo', 'Archivo Black', 'Archivo Narrow', 'Aref Ruqaa', 'Arima Madurai', 'Arimo', 'Arizonia', 'Armata', 'Arsenal', 'Artifika', 'Arvo', 'Arya', 'Asap', 'Asap Condensed', 'Asar', 'Asset', 'Assistant', 'Astloch', 'Asul', 'Athiti', 'Atma', 'Atomic Age', 'Aubrey', 'Audiowide', 'Autour One', 'Average', 'Average Sans', 'Averia Gruesa Libre', 'Averia Libre', 'Averia Sans Libre', 'Averia Serif Libre', 'Bad Script', 'Bahiana', 'Baloo', 'Baloo Bhai', 'Baloo Bhaijaan', 'Baloo Bhaina', 'Baloo Chettan', 'Baloo Da', 'Baloo Paaji', 'Baloo Tamma', 'Baloo Tammudu', 'Baloo Thambi', 'Balthazar', 'Bangers', 'Barlow', 'Barlow Condensed', 'Barlow Semi Condensed', 'Barrio', 'Basic', 'Battambang', 'Baumans', 'Bayon', 'Belgrano', 'Bellefair', 'Belleza', 'BenchNine', 'Bentham', 'Berkshire Swash', 'Bevan', 'Bigelow Rules', 'Bigshot One', 'Bilbo', 'Bilbo Swash Caps', 'BioRhyme', 'BioRhyme Expanded', 'Biryani', 'Bitter', 'Black Ops One', 'Bokor', 'Bonbon', 'Boogaloo', 'Bowlby One', 'Bowlby One SC', 'Brawler', 'Bree Serif', 'Bubblegum Sans', 'Bubbler One', 'Buda', 'Buenard', 'Bungee', 'Bungee Hairline', 'Bungee Inline', 'Bungee Outline', 'Bungee Shade', 'Butcherman', 'Butterfly Kids', 'Cabin', 'Cabin Condensed', 'Cabin Sketch', 'Caesar Dressing', 'Cagliostro', 'Cairo', 'Calligraffitti', 'Cambay', 'Cambo', 'Candal', 'Cantarell', 'Cantata One', 'Cantora One', 'Capriola', 'Cardo', 'Carme', 'Carrois Gothic', 'Carrois Gothic SC', 'Carter One', 'Catamaran', 'Caudex', 'Caveat', 'Caveat Brush', 'Cedarville Cursive', 'Ceviche One', 'Changa', 'Changa One', 'Chango', 'Chathura', 'Chau Philomene One', 'Chela One', 'Chelsea Market', 'Chenla', 'Cherry Cream Soda', 'Cherry Swash', 'Chewy', 'Chicle', 'Chivo', 'Chonburi', 'Cinzel', 'Cinzel Decorative', 'Clicker Script', 'Coda', 'Coda Caption', 'Codystar', 'Coiny', 'Combo', 'Comfortaa', 'Maintenance', 'Concert One', 'Condiment', 'Content', 'Contrail One', 'Convergence', 'Cookie', 'Copse', 'Corben', 'Cormorant', 'Cormorant Garamond', 'Cormorant Infant', 'Cormorant SC', 'Cormorant Unicase', 'Cormorant Upright', 'Courgette', 'Cousine', 'Coustard', 'Covered By Your Grace', 'Crafty Girls', 'Creepster', 'Crete Round', 'Crimson Text', 'Croissant One', 'Crushed', 'Cuprum', 'Cutive', 'Cutive Mono', 'Damion', 'Dancing Script', 'Dangrek', 'David Libre', 'Dawning of a New Day', 'Days One', 'Dekko', 'Delius', 'Delius Swash Caps', 'Delius Unicase', 'Della Respira', 'Denk One', 'Devonshire', 'Dhurjati', 'Didact Gothic', 'Diplomata', 'Diplomata SC', 'Domine', 'Donegal One', 'Doppio One', 'Dorsa', 'Dosis', 'Dr Sugiyama', 'Duru Sans', 'Dynalight', 'EB Garamond', 'Eagle Lake', 'Eater', 'Economica', 'Eczar', 'El Messiri', 'Electrolize', 'Elsie', 'Elsie Swash Caps', 'Emblema One', 'Emilys Candy', 'Encode Sans', 'Encode Sans Condensed', 'Encode Sans Expanded', 'Encode Sans Semi Condensed', 'Encode Sans Semi Expanded', 'Engagement', 'Englebert', 'Enriqueta', 'Erica One', 'Esteban', 'Euphoria Script', 'Ewert', 'Exo', 'Exo 2', 'Expletus Sans', 'Fanwood Text', 'Farsan', 'Fascinate', 'Fascinate Inline', 'Faster One', 'Fasthand', 'Fauna One', 'Faustina', 'Federant', 'Federo', 'Felipa', 'Fenix', 'Finger Paint', 'Fira Mono', 'Fira Sans', 'Fira Sans Condensed', 'Fira Sans Extra Condensed', 'Fjalla One', 'Fjord One', 'Flamenco', 'Flavors', 'Fondamento', 'Fontdiner Swanky', 'Forum', 'Francois One', 'Frank Ruhl Libre', 'Freckle Face', 'Fredericka the Great', 'Fredoka One', 'Freehand', 'Fresca', 'Frijole', 'Fruktur', 'Fugaz One', 'GFS Didot', 'GFS Neohellenic', 'Gabriela', 'Gafata', 'Galada', 'Galdeano', 'Galindo', 'Gentium Basic', 'Gentium Book Basic', 'Geo', 'Geostar', 'Geostar Fill', 'Germania One', 'Gidugu', 'Gilda Display', 'Give You Glory', 'Glass Antiqua', 'Glegoo', 'Gloria Hallelujah', 'Goblin One', 'Gochi Hand', 'Gorditas', 'Goudy Bookletter 1911', 'Graduate', 'Grand Hotel', 'Gravitas One', 'Great Vibes', 'Griffy', 'Gruppo', 'Gudea', 'Gurajada', 'Habibi', 'Halant', 'Hammersmith One', 'Hanalei', 'Hanalei Fill', 'Handlee', 'Hanuman', 'Happy Monkey', 'Harmattan', 'Headland One', 'Heebo', 'Henny Penny', 'Herr Von Muellerhoff', 'Hind', 'Hind Guntur', 'Hind Madurai', 'Hind Siliguri', 'Hind Vadodara', 'Holtwood One SC', 'Homemade Apple', 'Homenaje', 'IBM Plex Mono', 'IBM Plex Sans', 'IBM Plex Sans Condensed', 'IBM Plex Serif', 'IM Fell DW Pica', 'IM Fell DW Pica SC', 'IM Fell Double Pica', 'IM Fell Double Pica SC', 'IM Fell English', 'IM Fell English SC', 'IM Fell French Canon', 'IM Fell French Canon SC', 'IM Fell Great Primer', 'IM Fell Great Primer SC', 'Iceberg', 'Iceland', 'Imprima', 'Inconsolata', 'Inder', 'Indie Flower', 'Inika', 'Inknut Antiqua', 'Irish Grover', 'Istok Web', 'Italiana', 'Italianno', 'Itim', 'Jacques Francois', 'Jacques Francois Shadow', 'Jaldi', 'Jim Nightshade', 'Jockey One', 'Jolly Lodger', 'Jomhuria', 'Josefin Sans', 'Josefin Slab', 'Joti One', 'Judson', 'Julee', 'Julius Sans One', 'Junge', 'Jura', 'Just Another Hand', 'Just Me Again Down Here', 'Kadwa', 'Kalam', 'Kameron', 'Kanit', 'Kantumruy', 'Karla', 'Karma', 'Katibeh', 'Kaushan Script', 'Kavivanar', 'Kavoon', 'Kdam Thmor', 'Keania One', 'Kelly Slab', 'Kenia', 'Khand', 'Khmer', 'Khula', 'Kite One', 'Knewave', 'Kotta One', 'Koulen', 'Kranky', 'Kreon', 'Kristi', 'Krona One', 'Kumar One', 'Kumar One Outline', 'Kurale', 'La Belle Aurore', 'Laila', 'Lakki Reddy', 'Lalezar', 'Lancelot', 'Lateef', 'Lato', 'League Script', 'Leckerli One', 'Ledger', 'Lekton', 'Lemon', 'Lemonada', 'Libre Barcode 128', 'Libre Barcode 128 Text', 'Libre Barcode 39', 'Libre Barcode 39 Extended', 'Libre Barcode 39 Extended Text', 'Libre Barcode 39 Text', 'Libre Baskerville', 'Libre Franklin', 'Life Savers', 'Lilita One', 'Lily Script One', 'Limelight', 'Linden Hill', 'Lobster', 'Lobster Two', 'Londrina Outline', 'Londrina Shadow', 'Londrina Sketch', 'Londrina Solid', 'Lora', 'Love Ya Like A Sister', 'Loved by the King', 'Lovers Quarrel', 'Luckiest Guy', 'Lusitana', 'Lustria', 'Macondo', 'Macondo Swash Caps', 'Mada', 'Magra', 'Maiden Orange', 'Maitree', 'Mako', 'Mallanna', 'Mandali', 'Manuale', 'Marcellus', 'Marcellus SC', 'Marck Script', 'Margarine', 'Marko One', 'Marmelad', 'Martel', 'Martel Sans', 'Marvel', 'Mate', 'Mate SC', 'Maven Pro', 'McLaren', 'Meddon', 'MedievalSharp', 'Medula One', 'Meera Inimai', 'Megrim', 'Meie Script', 'Merienda', 'Merienda One', 'Merriweather', 'Merriweather Sans', 'Metal', 'Metal Mania', 'Metamorphous', 'Metrophobic', 'Michroma', 'Milonga', 'Miltonian', 'Miltonian Tattoo', 'Mina', 'Miniver', 'Miriam Libre', 'Mirza', 'Miss Fajardose', 'Mitr', 'Modak', 'Modern Antiqua', 'Mogra', 'Molengo', 'Molle', 'Monda', 'Monofett', 'Monoton', 'Monsieur La Doulaise', 'Montaga', 'Montez', 'Montserrat', 'Montserrat Alternates', 'Montserrat Subrayada', 'Moul', 'Moulpali', 'Mountains of Christmas', 'Mouse Memoirs', 'Mr Bedfort', 'Mr Dafoe', 'Mr De Haviland', 'Mrs Saint Delafield', 'Mrs Sheppards', 'Mukta', 'Mukta Mahee', 'Mukta Malar', 'Mukta Vaani', 'Muli', 'Mystery Quest', 'NTR', 'Nanum Brush Script', 'Nanum Gothic', 'Nanum Gothic Coding', 'Nanum Myeongjo', 'Nanum Pen Script', 'Neucha', 'Neuton', 'New Rocker', 'News Cycle', 'Niconne', 'Nixie One', 'Nobile', 'Nokora', 'Norican', 'Nosifer', 'Nothing You Could Do', 'Noticia Text', 'Noto Sans', 'Noto Serif', 'Nova Cut', 'Nova Flat', 'Nova Mono', 'Nova Oval', 'Nova Round', 'Nova Script', 'Nova Slim', 'Nova Square', 'Numans', 'Nunito', 'Nunito Sans', 'Odor Mean Chey', 'Offside', 'Old Standard TT', 'Oldenburg', 'Oleo Script', 'Oleo Script Swash Caps', 'Open Sans', 'Open Sans Condensed', 'Oranienbaum', 'Orbitron', 'Oregano', 'Orienta', 'Original Surfer', 'Oswald', 'Over the Rainbow', 'Overlock', 'Overlock SC', 'Overpass', 'Overpass Mono', 'Ovo', 'Oxygen', 'Oxygen Mono', 'PT Mono', 'PT Sans', 'PT Sans Caption', 'PT Sans Narrow', 'PT Serif', 'PT Serif Caption', 'Pacifico', 'Padauk', 'Palanquin', 'Palanquin Dark', 'Pangolin', 'Paprika', 'Parisienne', 'Passero One', 'Passion One', 'Pathway Gothic One', 'Patrick Hand', 'Patrick Hand SC', 'Pattaya', 'Patua One', 'Pavanam', 'Paytone One', 'Peddana', 'Peralta', 'Permanent Marker', 'Petit Formal Script', 'Petrona', 'Philosopher', 'Piedra', 'Pinyon Script', 'Pirata One', 'Plaster', 'Play', 'Playball', 'Playfair Display', 'Playfair Display SC', 'Podkova', 'Poiret One', 'Poller One', 'Poly', 'Pompiere', 'Pontano Sans', 'Poppins', 'Port Lligat Sans', 'Port Lligat Slab', 'Pragati Narrow', 'Prata', 'Preahvihear', 'Press Start 2P', 'Pridi', 'Princess Sofia', 'Prociono', 'Prompt', 'Prosto One', 'Proza Libre', 'Puritan', 'Purple Purse', 'Quando', 'Quantico', 'Quattrocento', 'Quattrocento Sans', 'Questrial', 'Quicksand', 'Quintessential', 'Qwigley', 'Racing Sans One', 'Radley', 'Rajdhani', 'Rakkas', 'Raleway', 'Raleway Dots', 'Ramabhadra', 'Ramaraja', 'Rambla', 'Rammetto One', 'Ranchers', 'Rancho', 'Ranga', 'Rasa', 'Rationale', 'Ravi Prakash', 'Redressed', 'Reem Kufi', 'Reenie Beanie', 'Revalia', 'Rhodium Libre', 'Ribeye', 'Ribeye Marrow', 'Righteous', 'Risque', 'Roboto', 'Roboto Condensed', 'Roboto Mono', 'Roboto Slab', 'Rochester', 'Rock Salt', 'Rokkitt', 'Romanesco', 'Ropa Sans', 'Rosario', 'Rosarivo', 'Rouge Script', 'Rozha One', 'Rubik', 'Rubik Mono One', 'Ruda', 'Rufina', 'Ruge Boogie', 'Ruluko', 'Rum Raisin', 'Ruslan Display', 'Russo One', 'Ruthie', 'Rye', 'Sacramento', 'Sahitya', 'Sail', 'Saira', 'Saira Condensed', 'Saira Extra Condensed', 'Saira Semi Condensed', 'Salsa', 'Sanchez', 'Sancreek', 'Sansita', 'Sarala', 'Sarina', 'Sarpanch', 'Satisfy', 'Scada', 'Scheherazade', 'Schoolbell', 'Scope One', 'Seaweed Script', 'Secular One', 'Sedgwick Ave', 'Sedgwick Ave Display', 'Sevillana', 'Seymour One', 'Shadows Into Light', 'Shadows Into Light Two', 'Shanti', 'Share', 'Share Tech', 'Share Tech Mono', 'Shojumaru', 'Short Stack', 'Shrikhand', 'Siemreap', 'Sigmar One', 'Signika', 'Signika Negative', 'Simonetta', 'Sintony', 'Sirin Stencil', 'Six Caps', 'Skranji', 'Slabo 13px', 'Slabo 27px', 'Slackey', 'Smokum', 'Smythe', 'Sniglet', 'Snippet', 'Snowburst One', 'Sofadi One', 'Sofia', 'Sonsie One', 'Sorts Mill Goudy', 'Source Code Pro', 'Source Sans Pro', 'Source Serif Pro', 'Space Mono', 'Special Elite', 'Spectral', 'Spectral SC', 'Spicy Rice', 'Spinnaker', 'Spirax', 'Squada One', 'Sree Krushnadevaraya', 'Sriracha', 'Stalemate', 'Stalinist One', 'Stardos Stencil', 'Stint Ultra Condensed', 'Stint Ultra Expanded', 'Stoke', 'Strait', 'Sue Ellen Francisco', 'Suez One', 'Sumana', 'Sunshiney', 'Supermercado One', 'Sura', 'Suranna', 'Suravaram', 'Suwannaphum', 'Swanky and Moo Moo', 'Syncopate', 'Tangerine', 'Taprom', 'Tauri', 'Taviraj', 'Teko', 'Telex', 'Tenali Ramakrishna', 'Tenor Sans', 'Text Me One', 'The Girl Next Door', 'Tienne', 'Tillana', 'Timmana', 'Tinos', 'Titan One', 'Titillium Web', 'Trade Winds', 'Trirong', 'Trocchi', 'Trochut', 'Trykker', 'Tulpen One', 'Ubuntu', 'Ubuntu Condensed', 'Ubuntu Mono', 'Ultra', 'Uncial Antiqua', 'Underdog', 'Unica One', 'UnifrakturCook', 'UnifrakturMaguntia', 'Unkempt', 'Unlock', 'Unna', 'VT323', 'Vampiro One', 'Varela', 'Varela Round', 'Vast Shadow', 'Vesper Libre', 'Vibur', 'Vidaloka', 'Viga', 'Voces', 'Volkhov', 'Vollkorn', 'Vollkorn SC', 'Voltaire', 'Waiting for the Sunrise', 'Wallpoet', 'Walter Turncoat', 'Warnes', 'Wellfleet', 'Wendy One', 'Wire One', 'Work Sans', 'Yanone Kaffeesatz', 'Yantramanav', 'Yatra One', 'Yellowtail', 'Yeseva One', 'Yesteryear', 'Yrsa', 'Zeyada', 'Zilla Slab', 'Zilla Slab Highlight'); return $fonts; } /** * Get options part of plugin options * * @return array */ public function get_options() { return $this->options['options']; } // get_options /** * Get all plugin options * * @return array */ public function get_all_options() { return $this->options; } // get_all_options /** * Update specified plugin options key * * @param string $key Data to save. * @param string $data Option key. * * @return bool */ public function update_options($key, $data) { if (false === in_array($key, array('meta', 'dismissed_notices', 'options'))) { user_error('Unknown options key.', E_USER_ERROR); return false; } $this->options[$key] = $data; $tmp = update_option('mtnc-options', $this->options); return $tmp; } // set_options /** * Add plugin menu entry under Tools menu * * @return null */ public function admin_menu() { add_menu_page('Maintenance', 'Maintenance', 'manage_options', 'maintenance', array($this, 'plugin_page'), $this->plugin_url . 'img/icon-small.png'); } // admin_menu /** * Returns all WP pointers * * @return array */ function get_pointers() { $pointers = array(); $pointers['welcome'] = array('target' => '#toplevel_page_maintenance', 'edge' => 'left', 'align' => 'right', 'content' => 'Thank you for installing the Maintenance plugin!
Open Maintenance to access Maintenance settings.'); return $pointers; } // get_pointers /** * Enqueue CSS and JS files * * @return null */ public function admin_enqueue_scripts($hook) { $options = $this->get_options(); $pointers = $this->get_pointers(); $dismissed_notices = $this->get_dismissed_notices(); foreach ($dismissed_notices as $notice_name => $tmp) { if ($tmp) { unset($pointers[$notice_name]); } } if (!empty($pointers) && !$this->is_plugin_page() && current_user_can('manage_options')) { $pointers['_nonce_dismiss_pointer'] = wp_create_nonce('maintenance_dismiss_notice'); wp_enqueue_style('wp-pointer'); wp_enqueue_script('maintenance-pointers', $this->plugin_url . 'js/pointers.js', array('jquery'), $this->version, true); wp_enqueue_script('wp-pointer'); wp_localize_script('wp-pointer', 'mtnc_pointers', $pointers); } if (!$this->is_plugin_page()) { return; } $this->dismiss_notice('welcome'); $js_localize = array( 'undocumented_error' => esc_html__('An undocumented error has occurred. Please refresh the page and try again.', 'maintenance'), 'documented_error' => esc_html__('An error has occurred.', 'maintenance'), 'plugin_name' => 'Maintenance', 'url' => MTNC_URL, 'icon_url' => $this->plugin_url . 'img/loader-icon.png', 'nonce_action' => wp_create_nonce('mtnc_action'), 'theme_global' => $options['theme_global'], 'theme' => $this->theme, 'theme_id' => $this->theme_id, 'fonts' => $this->get_fonts(), 'max_upload_size' => wp_max_upload_size(), 'settings_url' => admin_url('admin.php?page=maintenance'), 'is_plugin_page' => $this->is_plugin_page(), 'wpfssl_install_url' => add_query_arg( array( 'action' => 'mtnc_install_wpfssl', '_wpnonce' => wp_create_nonce('install_wpfssl'), 'rnd' => wp_rand() ), admin_url('admin.php') ), 'wpcaptcha_install_url' => add_query_arg( array( 'action' => 'mtnc_install_wpcaptcha', '_wpnonce' => wp_create_nonce('install_wpcaptcha'), 'rnd' => wp_rand() ), admin_url('admin.php') ), 'weglot_install_url' => add_query_arg( array( 'action' => 'mtnc_install_weglot', '_wpnonce' => wp_create_nonce('install_weglot'), 'rnd' => wp_rand() ), admin_url('admin.php') ), 'weglot_dialog_upsell_title' => '' . esc_attr__('Weglot', 'maintenance') . '', ); if ($this->is_plugin_page()) { wp_enqueue_style('maintenance-admin', $this->plugin_url . 'css/maintenance-admin.css', array(), $this->version); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-position'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_style('wp-jquery-ui-dialog'); wp_enqueue_script('jquery-ui-dialog'); wp_enqueue_style('maintenance-summernote', $this->plugin_url . 'css/summernote-lite.min.css', array(), $this->version); wp_enqueue_script('maintenance-summernote', $this->plugin_url . 'js/summernote-lite.min.js', array('jquery'), $this->version, true); //WYSIWYG Module Editor wp_enqueue_style('maintenance-fonticonpicker', $this->plugin_url . 'css/jquery.fonticonpicker.min.css', array(), $this->version); wp_enqueue_style('maintenance-font-roboto', 'https://fonts.bunny.net/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap', array(), $this->version); wp_enqueue_style('maintenance-material-icons', 'https://fonts.googleapis.com/icon?family=Material+Icons', array(), $this->version); wp_enqueue_style('maintenance-sweetalert2', $this->plugin_url . 'css/sweetalert2.min.css', array(), $this->version); wp_enqueue_style('maintenance-select2', $this->plugin_url . 'css/select2.css', array(), $this->version); wp_enqueue_script('maintenance-sweetalert2', $this->plugin_url . 'js/maintenance-sweetalert2.min.js', array('jquery'), $this->version, true); wp_enqueue_script('maintenance-select2', $this->plugin_url . 'js/select2.min.js', array('jquery'), $this->version, true); wp_enqueue_script('maintenance-colorpicker', $this->plugin_url . 'js/colorpicker/jscolor.js', false, $this->version, true); wp_enqueue_script('maintenance', $this->plugin_url . 'js/maintenance-admin.js', array('jquery'), $this->version, true); wp_enqueue_script('maintenance-fonticonpicker', $this->plugin_url . 'js/jquery.fonticonpicker.min.js', array('jquery'), $this->version, true); wp_enqueue_script('maintenance-ace-editor', $this->plugin_url . 'js/editor/ace.js', false, $this->version, true); // Custom CSS Editor wp_enqueue_script('maintenance-webfonts', $this->plugin_url . 'js/webfont.js', false, $this->version, true); //Visual font picker preview wp_localize_script('maintenance', 'mtnc', $js_localize); wp_enqueue_media(); wp_dequeue_style('uiStyleSheet'); wp_dequeue_style('wpcufpnAdmin'); wp_dequeue_style('unifStyleSheet'); wp_dequeue_style('wpcufpn_codemirror'); wp_dequeue_style('wpcufpn_codemirrorTheme'); wp_dequeue_style('collapse-admin-css'); wp_dequeue_style('jquery-ui-css'); wp_dequeue_style('tribe-common-admin'); wp_dequeue_style('file-manager__jquery-ui-css'); wp_dequeue_style('file-manager__jquery-ui-css-theme'); wp_dequeue_style('wpmegmaps-jqueryui'); wp_dequeue_style('wp-botwatch-css'); } } // admin_enqueue_scripts function frontend_login() { global $wp_query, $error; $mt_options = $this->get_options(); $user_connect = false; if (!is_array($wp_query->query_vars)) { $wp_query->query_vars = array(); } $error_message = $user_login = $user_pass = $error = ''; $class_login = 'user-icon'; $class_password = 'pass-icon'; if (isset($_POST['is_custom_login'])) { $user_login = ''; if (isset($_POST['log']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['mtnc_login_check'] ?? '')), 'mtnc_login')) { $user_login = sanitize_user(wp_unslash($_POST['log'])); } $user_login = sanitize_user($user_login); $user_pass = ''; if (isset($_POST['pwd']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['mtnc_login_check'] ?? '')), 'mtnc_login')) { $user_pass = trim(sanitize_text_field(wp_unslash($_POST['pwd']))); } $access = array(); $access['user_login'] = esc_attr($user_login); $access['user_password'] = $user_pass; $access['remember'] = true; $user = null; $user = new WP_User(0, $user_login); if (is_ssl()) { $ssl = true; } else { $ssl = false; } $user_connect = wp_signon($access, $ssl); if (is_wp_error($user_connect)) { if ($user_connect->get_error_code() === 'invalid_username') { $error_message = esc_html__('Login is incorrect!', 'maintenance'); $class_login = 'error'; $class_password = 'error'; } elseif ($user_connect->get_error_code() === 'incorrect_password') { $error_message = esc_html__('Password is incorrect!', 'maintenance'); $class_password = 'error'; } else { $error_message = esc_html__('Login and password are incorrect!', 'maintenance'); $class_login = 'error'; $class_password = 'error'; } } else { wp_safe_redirect(home_url('/')); exit; } } return array($error_message, $class_login, $class_password, $user_login); } // frontend_login public function admin_bar_style() { $options = $this->get_options(); // admin bar has to be anabled, user an admin and custom filter true if ($options['disable_toolbar_menu'] || false === is_admin_bar_showing() || false === current_user_can('manage_options')) { return; } // no sense in loading a new CSS file for 2 lines of CSS $custom_css = ''; self::wp_kses_wf($custom_css); } // admin_bar_style // add admin bar menu and status public function admin_bar() { global $wp_admin_bar; $options = $this->get_options(); // only show to admins if ($options['disable_toolbar_menu'] || false === current_user_can('manage_options')) { return; } $plugin_name = 'Maintenance'; $plugin_logo = MTNC_URL . '/img/icon-transparent.png'; $request_uri = sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'] ?? '')); if ($options['status'] == '1') { $main_label = 'Maintenance mode is enabled' . $plugin_name . ' '; $class = 'mtnc-enabled'; $action_url = add_query_arg(array('action' => 'mtnc_change_status', 'new_status' => 'disabled', 'redirect' => urlencode($request_uri)), admin_url('admin.php')); $action_url = wp_nonce_url($action_url, 'mtnc_change_status'); $action = 'Maintenance mode'; $action .= 'OFFON'; } else { $main_label = 'Maintenance mode is enabled' . $plugin_name . ' '; $class = 'mtnc-disabled'; $action_url = add_query_arg(array('action' => 'mtnc_change_status', 'new_status' => 'enabled', 'redirect' => urlencode($request_uri)), admin_url('admin.php')); $action_url = wp_nonce_url($action_url, 'mtnc_change_status'); $action = 'Maintenance mode'; $action .= 'OFFON'; } $wp_admin_bar->add_menu(array( 'parent' => '', 'id' => 'mtnc', 'title' => $main_label, 'href' => admin_url('admin.php?page=maintenance'), 'meta' => array('class' => $class), )); $wp_admin_bar->add_node(array( 'id' => 'mtnc-status', 'title' => $action, 'href' => false, 'parent' => 'mtnc', )); $wp_admin_bar->add_node(array( 'id' => 'mtnc-preview', 'title' => 'Preview', 'href' => home_url('/') . '?maintenance-preview', 'parent' => 'mtnc', 'meta' => array('target' => '_blank'), )); $wp_admin_bar->add_node(array( 'id' => 'mtnc-settings', 'title' => 'Settings', 'href' => admin_url('admin.php?page=maintenance'), 'parent' => 'mtnc', )); } // admin_bar /** * Perform an action via AJAX * * @return bool */ public function ajax_action() { check_ajax_referer('mtnc_action'); if (!current_user_can('manage_options')) { wp_send_json_error(__('You are not allowed to run this action.', 'maintenance')); } $options = $this->get_options(); $action = trim(wp_unslash($_REQUEST['mtnc_action'] ?? '')); //phpcs:ignore $extra_data = wp_unslash($_REQUEST['extra_data'] ?? ''); //phpcs:ignore if (is_string($extra_data)) { parse_str($extra_data, $extra_data); } elseif (is_array($extra_data)) { $extra_data = array_slice($extra_data, 0, 20); } else { $extra_data = false; } switch ($action) { case 'save': $new_options = array( 'theme_global' => $options['theme_global'], 'themes' => $options['themes'], 'status' => @absint($extra_data['mtnc_status']), 'mode' => 'layout', 'mtnc_page' => 0, //SEO 'title' => strip_tags($extra_data['title']), 'analytics' => strip_tags($this->convert_ga($extra_data['analytics'])), //Access 'per_url_settings' => wp_strip_all_tags($extra_data['per_url_settings']), 'per_url_enable_disable' => wp_strip_all_tags($extra_data['per_url_enable_disable']), 'login_button' => @absint($extra_data['login_button']), 'wplogin_button_tooltip' => wp_strip_all_tags($extra_data['wplogin_button_tooltip']), ); $new_options['theme_global'] = sanitize_text_field(wp_unslash($_REQUEST['theme_global'] ?? '')); //theme JSON will get broken by sanitization through wp_kses_post or normal functions, fields will be escaped when rendering on front-end $theme = $_REQUEST['theme']; //phpcs:ignore $theme_id = sanitize_text_field(wp_unslash($_REQUEST['theme_id'] ?? '')); $theme_new = sanitize_text_field(wp_unslash($_REQUEST['theme_new'] ?? '')); $theme_name = sanitize_text_field(wp_unslash($_REQUEST['theme_name'] ?? '')); if (isset($_REQUEST['theme_new']) && $theme_new == true) { $theme_id = md5(time() . $theme_name); } $new_options['themes'][$theme_id] = json_decode(stripslashes($theme)); $new_options['themes'][$theme_id]->name = $theme_name; //Design General if (isset($extra_data['theme_thumbnail'])) { $new_options['themes'][$theme_id]->theme_thumbnail = wp_strip_all_tags($extra_data['theme_thumbnail']); } if (isset($extra_data['theme_status'])) { $new_options['themes'][$theme_id]->theme_status = wp_strip_all_tags($extra_data['theme_status']); } $new_options['themes'][$theme_id]->body_font_size = wp_strip_all_tags($extra_data['body_font_size']); $new_options['themes'][$theme_id]->body_font_color = wp_strip_all_tags($extra_data['body_font_color']); $new_options['themes'][$theme_id]->body_font = wp_strip_all_tags($extra_data['body_font']); $new_options['themes'][$theme_id]->body_link_color = wp_strip_all_tags($extra_data['body_link_color']); $new_options['themes'][$theme_id]->body_link_hover_color = wp_strip_all_tags($extra_data['body_link_hover_color']); //Design General $new_options['themes'][$theme_id]->background_type = wp_strip_all_tags($extra_data['background_type']); $new_options['themes'][$theme_id]->background_video = wp_strip_all_tags($extra_data['background_video']); $new_options['themes'][$theme_id]->background_video_fallback = isset($extra_data['background_video_fallback']) ? wp_strip_all_tags($extra_data['background_video_fallback']) : ''; $new_options['themes'][$theme_id]->background_video_filter = wp_strip_all_tags($extra_data['background_video_filter']); $new_options['themes'][$theme_id]->background_size_opt = wp_strip_all_tags($extra_data['background_size_opt']); $new_options['themes'][$theme_id]->background_position = wp_strip_all_tags($extra_data['background_position']); $new_options['themes'][$theme_id]->background_image_filter = wp_strip_all_tags($extra_data['background_image_filter']); $new_options['themes'][$theme_id]->background_image = wp_strip_all_tags($extra_data['background_image']); $new_options['themes'][$theme_id]->background_blur = (int)$extra_data['background_blur']; $new_options['themes'][$theme_id]->login_background_color = wp_strip_all_tags($extra_data['login_background_color']); $new_options['themes'][$theme_id]->preloader_background_image = wp_strip_all_tags($extra_data['preloader_background_image']); $new_options['themes'][$theme_id]->background_color = wp_strip_all_tags($extra_data['background_color']); $new_options['themes'][$theme_id]->content_overlay = isset($extra_data['content_overlay']) ? wp_strip_all_tags($extra_data['content_overlay']) : ''; $new_options['themes'][$theme_id]->content_width = (int) $extra_data['content_width']; $new_options['themes'][$theme_id]->content_overlay_color = wp_strip_all_tags($extra_data['content_overlay_color']); $new_options['themes'][$theme_id]->content_overlay_shadow_color = wp_strip_all_tags($extra_data['content_overlay_shadow_color']); $new_options['themes'][$theme_id]->content_position = wp_strip_all_tags($extra_data['content_position']); $new_options['themes'][$theme_id]->modules_spacing = (int) $extra_data['modules_spacing']; $new_options['themes'][$theme_id]->custom_css = wp_strip_all_tags($extra_data['custom_css']); $this->update_options('options', $new_options); wp_send_json_success(array('theme_id' => $theme_id, 'theme' => $new_options['themes'][$theme_id])); break; } } /** * Test if we're on Maintenance's admin page * * @return bool */ public function is_plugin_page() { if (!function_exists('get_current_screen')) { return false; } $current_screen = get_current_screen(); if (!empty($current_screen) && $current_screen->id == 'toplevel_page_maintenance') { return true; } else { return false; } } // is_plugin_page /** * Main/starter function for displaying plugin's admin page * * @return null */ public function plugin_page() { $options = $this->get_options(); // double check for admin privileges if (!current_user_can('manage_options')) { wp_die(esc_html__('Sorry, you are not allowed to access this page.', 'maintenance')); } echo '
'; echo '
'; echo '
'; $mtnc_notice = get_transient('mtnc_notice_' . get_current_user_id()); delete_transient('mtnc_notice_' . get_current_user_id()); if ($mtnc_notice !== false) { self::wp_kses_wf($mtnc_notice); } echo '
Loading. Please wait.
'; echo '
'; // Tab ID should be level1 or level1-level2 separated by dash, for example "welcome" or "design-background" echo '
'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; // tabs echo '
'; // mtnc-form-body echo '
'; // mtnc-tabs-wrapper echo '
'; echo ''; if (!defined('WPCAPTCHA_PLUGIN_FILE')) { echo ''; } if (!$this->is_weglot_active()) { echo ''; } if (0 && !defined('WPFSSL_OPTIONS_KEY')) { echo ''; } echo ''; echo '
'; // mtnc-sidebar-wrapper echo '
'; // mtnc-body echo '
'; // wrap self::wp_kses_wf($this->pro_dialog()); } // plugin_page function is_weglot_active() { if (!function_exists('is_plugin_active') || !function_exists('get_plugin_data')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } if (is_plugin_active('weglot/weglot.php')) { $weglot_info = get_plugin_data(ABSPATH . 'wp-content/plugins/weglot/weglot.php'); if (version_compare($weglot_info['Version'], '2.5', '<')) { return false; } else { return true; } } else { return false; } } // mtcn_is_weglot_active // check if Weglot is completely set up function is_weglot_setup() { if (!$this->is_weglot_active()) { return false; } $active_languages = weglot_get_destination_languages(); if (!empty($active_languages)) { return true; } else { return false; } } // is_weglot_setup function pro_dialog() { $out = ''; $out .= ''; // weglot install dialog $out .= ''; // weglot install dialog return $out; } // pro_dialog public function tab_footer($tab = false) { echo ''; } /** * Echoes content for themes tab * * @return null */ private function tab_themes_premade() { echo '
Themes
'; echo '

Are you in a hurry? Looking for something that looks great for your site? Pick one of +200 premium pre-built themes and be done in 5 minutes! Our PRO plugin comes with built-in SEO analyzer, a collection of over 7 million images and it can connect to any mailing system like Mailchimp so you can start collecting emails from day one! Did we mention you can rebrand the plugin and control all client sites from the plugin\'s centralized Dashboard?

'; $options = $this->get_options(); echo '
'; $themes = [ '5f2f8c65307b6f3097f2ca4d25d5cb26' => 'Adventure Blog', '883f61d5131f6c7b558ccde9c5d1f411' => 'Analytics', '00cf8a2ca9efec1e8aea483568e2a8d8' => 'Baby Store', 'ccdbb99fd1dfecd36e13d5a4cff45d21' => 'Burger Palace', '0a0c5efe1e95f91a42bc9e6e6ca884dd' => 'Business', '781cb3af776a041533735bdfc59e811a' => 'Car Repair', 'e8e6f070f05eae0367699e6dc7963439' => 'Design Agency', '06142f926b2da71d8dddfba3254a78cb' => 'Digital Marketing Agency', 'd41b1b0a6d4cb304e886121b3118cfa0' => 'Fashion', '7f96d3918bd5840258a6dce654f4b0dc' => 'Flower Shop', 'b6e3012a316272608e1bbfac4d6b5a78' => 'Food Recommendation', '310e65d9600903508451d5670ab0c33f' => 'Freelance', '1c498ed60de01a93c2a4cac0ab50ddc2' => 'Gaming', 'da24f016888540131b49800c7b8cb07e' => 'Health Service', '4dc670fa8069dd1293b85cf6235ceb25' => 'Hiking', 'bb9f78a54648fe776fe7cdce018d4649' => 'Interior Design', '0888b7c6cfdfde868ad842b76f47dbdc' => 'Jewelry Shop', '9dd2a18f38bcfdcb6fce7b037c22e1ec' => 'Marketing', 'bce5308440264fa4a8ce9cf1b38f3242' => 'Mobile App', 'b20f2da4e5cd0753638723ff12383378' => 'Non-Profit Organization', '2c6c47a437172cf970e9027ab7c4f680' => 'Photography', 'ea2584e286d8e0304994f4d9d9e4d335' => 'Podcast', 'f7432f296c75f398c018ebbd0118cf1f' => 'Product Marketing', '274bd92fd91aadc05fe0637f614633d8' => 'Restaurant', '1ff8ca16c5010eec8797eb5416373c6d' => 'Skincare', 'eb668b7221bb4ed50c8edc8aebb68ba4' => 'Sport', 'a61a5890d7db6cef943729dc082f24e0' => 'Tech Conference', '1e26f176878e01991d42463cce0d3182' => 'Training', '906d50132e2caf64ad57d9c76b07f78c' => 'Travel Vlog', 'd1dd1f82d0d557460f22ac7058c291e0' => 'Wedding', '35b404155b3be97d198dadf05ddfc960' => 'Wellness', '293e20f552ddd1e851351a93408be322' => 'Winery', ]; echo '
'; echo '
'; echo '
'; echo 'Default Theme'; echo '
'; echo '
'; $request_uri = sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'] ?? '')); echo 'Reset theme'; echo '
'; echo '
'; foreach ($themes as $theme_id => $theme_name) { echo '
'; echo '
'; echo '
'; echo esc_html(substr($theme_name, 0, 30)); echo '
'; echo '
'; echo 'Install'; echo 'Preview'; echo '
'; echo '
'; echo '
'; } echo '
'; $this->tab_footer(); } // tab_themes /** * Echoes content for access tab * * @return null */ private function tab_access() { $options = $this->get_options(); echo '
Access
'; echo '

By default, if Maintenance mode is enabled, all site visitors except the logged in ones (regardless of their user role) will see the Maintenance page instead of the "normal" site.
The easiest way to show the site to clients or friends is to share the Secret Access Link, or whitelist their IP address if it doesn\'t change too often.

'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

Logged in users (regardless of their user role) will not be affected by the maintenance mode and will see the "normal" site.

'; echo '
'; echo '
'; echo ''; echo ''; $ip_address = sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'] ?? '')); echo '

Noted IPs will not be affected by the maintenance mode, and their users will see the "normal" site.
Write one IP per line. Wildcards are not supported. If the user\'s IP changes, he will no longer be whitelisted. Your IP address is: ' . esc_html($ip_address) . '

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

Use this option to set per-URL rules and enable maintenance mode on the entire site except for selected pages, or enable it on just some pages and leave all others accessible to visitors. If the second option is used, all other access rules apply too.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

Enter one URL per line. Start and end URLs with a forward slash (/).

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo '' . esc_url(trailingslashit(get_home_url())) . '?'; echo '

Share this link with people who need to see the normal site behind the maintenance page.

'; echo '
'; echo '
'; echo ''; echo '' . esc_url(trailingslashit(get_home_url())) . '?'; echo '

If you\'re using a custom login URL and can\'t access it, enter the custom login URL here. That URL will never be affected by the maintenance mode.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

Show a discrete button that links to the WordPress login page in the lower right corner of the maintenance page.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

Text for the "Access WordPress admin" button tooltip.

'; echo '
'; echo '
'; $this->tab_footer(); } // tab_access /** * Echoes content for access password tab * * @return null */ private function tab_access_password() { $options = $this->get_options(); echo '
Password Protection
'; echo '

By default, if Maintenance mode is enabled, all site visitors except the logged in ones (regardless of their user role) will see the Maintenance page instead of the "normal" site.
The easiest way to show the site to clients or friends is to share the Secret Access Link, or whitelist their IP address if it doesn\'t change too often.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

Direct Access Password is a user-friendly way (especially when working with clients) to give selected visitors access to the "normal" site. Enter the password and send users the following link: ' . esc_url(get_home_url()) . '/#access-site-form or enable the option on the right to show the password form button.
The password has to be at least 4 characters long

'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

Show a discrete button to the direct access password form in the lower right corner of the maintenance page.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

Protect the entire site with a password you choose. Only those with the password can view the maintenance page.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

The password has to be at least 4 characters long.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

The message displayed in the password popup above the password input.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

Text for the password popup button.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

Text for the "Wrong Password" message.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

Text for the "Direct Access login" button tooltip.

'; echo '
'; echo '
'; $this->tab_footer(); } // tab_access_password /** * Admin footer text * * @since 5.0 * * @return null */ public function admin_footer_text($text) { if (!$this->is_plugin_page()) { return $text; } $text = 'Thank you for creating with Maintenance v' . $this->version . ''; return $text; } // admin_footer_text /** * Add links to plugin's description in plugins table * * @param array $links Initial list of links. * @param string $file Basename of current plugin. * * @return array */ function plugin_meta_links($links, $file) { if ($file !== plugin_basename(__FILE__)) { return $links; } $support_link = 'Support'; $home_link = 'Plugin Homepage'; $links[] = $support_link; $links[] = $home_link; return $links; } // plugin_meta_links /** * Helper function for generating UTM tagged links * * @param string $placement Optional. UTM content param. * @param string $page Optional. Page to link to. * @param array $params Optional. Extra URL params. * @param string $anchor Optional. URL anchor part. * * @return string */ public function generate_web_link($placement = '', $page = '/', $params = array(), $anchor = '') { $base_url = 'https://wpmaintenancemode.com'; if ('/' != $page) { $page = '/' . trim($page, '/') . '/'; } if ($page == '//') { $page = '/'; } $parts = array_merge(array('utm_source' => 'maintenance-free', 'utm_content' => $placement), $params); if (!empty($anchor)) { $anchor = '#' . trim($anchor, '#'); } $out = $base_url . $page . '?' . http_build_query($parts, '', '&') . $anchor; return $out; } // generate_web_link function generate_dashboard_link($placement = '', $page = '/', $params = array(), $anchor = '') { $base_url = 'https://dashboard.wpmaintenancemode.com'; if ('/' != $page) { $page = '/' . trim($page, '/') . '/'; } if ($page == '//') { $page = '/'; } $parts = array_merge(array('utm_source' => 'maintenance-free', 'utm_medium' => 'plugin', 'utm_content' => $placement, 'utm_campaign' => 'maintenance-free-v' . $this->version), $params); if (!empty($anchor)) { $anchor = '#' . trim($anchor, '#'); } $out = $base_url . $page . '?' . http_build_query($parts, '', '&') . $anchor; return $out; } // generate_dashboard_link /** * Echoes content for design header such as theme name * * @return null */ private function design_header() { $options = $this->get_options(); echo '
'; if ($options['theme_global'] == $this->theme_id) { echo ''; } echo 'Editing theme ' . esc_html($this->theme->name) . ''; echo 'switch theme'; echo '
'; } /** * Echoes content for design-general tab * * @return null */ private function tab_design_general() { $fonts = $this->get_fonts(); $options = $this->get_options(); echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '

55% of online visitors prefer to browse in their mother tongue. If you have an audience speaking multiple languages, making your website multilingual is a must-have. To instantly translate your website and your maintenance, install the Weglot plugin (free plan and free trial available). It seamlessly integrates with Maintenance and is compatible with all themes & plugins.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo '' . esc_attr($this->theme->body_font_size) . 'px'; echo '

Don\'t be afraid to make to font a bit bigger. Default: 16px;

'; echo '
'; echo '
'; echo ''; echo ''; echo '

Make sure the contrast is good. Whiteish text on a dark background is always a good pick.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

' . esc_html__('This is how the content font is going to look!', 'maintenance') . '

'; echo '

Choose from over 700 Fonts. Make sure other modules use the same, or matching fonts. Maintenance now uses Bunny Fonts instead of Google fonts. Bunny Fonts is an open-source, privacy-first web font platform designed to put privacy back into the internet. With a zero-tracking and no-logging policy, Bunny Fonts helps you stay fully GDPR compliant and puts your user\'s personal data into their own hands. Additionally, you can enjoy lightning-fast load times thanks to bunny.net\'s global CDN network to help improve SEO and deliver a better user experience.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

Make sure it stands out but make it fit your color scheme.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

Generally it\'s a lighter or darker variation of the normal link color.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo 'theme->content_overlay, false) . '>'; echo ''; echo '

If enabled, applies a transparent background to the entire content section of the page.

'; echo '
'; echo '
'; echo '
'; echo ''; $content_positions = array( 'left' => 'Top Left', 'right' => 'Top Right', 'center' => 'Top Center', 'middle' => 'Middle Center', 'bottom' => 'Bottom Center', ); echo ''; echo '

Content box position on the page.

'; echo '
'; echo '
'; echo '
'; echo '
theme->content_overlay ? 'style="display:none;"' : '') . '>'; echo ''; echo ''; echo '

Background color for the content overlay.

'; echo '
'; echo '
theme->content_overlay ? 'style="display:none;"' : '') . '>'; echo ''; echo ''; echo '

Shadow color for the content overlay.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo '' . esc_attr($this->theme->content_width) . 'px'; echo '

Maximum content width. Default: 600px.

'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo '' . esc_attr($this->theme->modules_spacing) . 'px'; echo '

Vertical spacing between design modules. The selected value is added to both top and bottom margins of the module. Default: 10px.

'; echo '
'; echo '
'; $this->tab_footer('design'); } // tab_design_general /** * Echoes content for design-background tab * * @return null */ private function tab_design_background() { $options = $this->get_options(); $filters = array( array('val' => '', 'label' => 'No Filter'), array('label' => '1977', 'val' => ' _1977'), array('label' => 'Aden', 'val' => ' aden'), array('label' => 'Black & White', 'val' => ' blackwhite'), array('label' => 'Brannan', 'val' => ' brannan'), array('label' => 'Brooklyn', 'val' => ' brooklyn'), array('label' => 'Clarendon', 'val' => ' clarendon'), array('label' => 'Earlybird', 'val' => ' earlybird'), array('label' => 'Gingham', 'val' => ' gingham'), array('label' => 'Hudson', 'val' => ' hudson'), array('label' => 'Inkwell', 'val' => ' inkwell'), array('label' => 'Kelvin', 'val' => ' kelvin'), array('label' => 'Lark', 'val' => ' lark'), array('label' => 'Lo-Fi', 'val' => ' lofi'), array('label' => 'Maven', 'val' => ' maven'), array('label' => 'Mayfair', 'val' => ' mayfair'), array('label' => 'Moon', 'val' => ' moon'), array('label' => 'Nashville', 'val' => ' nashville'), array('label' => 'Perpetua', 'val' => ' perpetua'), array('label' => 'Reyes', 'val' => ' reyes'), array('label' => 'Rise', 'val' => ' rise'), array('label' => 'Slumber', 'val' => ' slumber'), array('label' => 'Stinson', 'val' => ' stinson'), array('label' => 'Toaster', 'val' => ' toaster'), array('label' => 'Valencia', 'val' => ' valencia'), array('label' => 'Walden', 'val' => ' walden'), array('label' => 'Willow', 'val' => ' willow'), array('label' => 'X-pro II', 'val' => ' xpro2'), ); echo '
Background
'; echo '

The background image makes or breaks the whole page. Take your time to choose a perfect image from our gallery of 400,000+ images and then make it pop by using filters. If you don\'t have much content to show, then choose a video background.

'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

Video background draws attention away from the content, so use it wisely, only in situations when you don\'t have much content to put on the page. In all other cases, an image background is a better choice.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

Only YouTube videos are supported. Enter only the video ID, ie: UFHQzF593ak, found in the YouTube URL. Video is played muted and looped.
If the video ID is valid a preview will be shown below.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

The filter is immediately applied to the video preview.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; if (stripos($this->theme->background_video_fallback, 'undefined index') !== false) { $this->theme->background_video_fallback = ''; } if (!empty($this->theme->background_video_fallback)) { echo ''; } else { echo 'Select an image from our 400,000+ images gallery, or upload your own'; } echo ''; echo ''; echo ''; if (!empty($this->theme->background_video_fallback)) { echo ' ' . esc_html__('Remove', 'maintenance') . ''; } echo ''; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '
theme->background_image) ? 'style="background-image:url(\'' . esc_attr($this->theme->background_image) . '\')"' : '') . '>'; if (empty($this->theme->background_image)) { echo ''; echo 'Select an image from our 400,000+ images gallery, or upload your own'; } echo ''; if (!empty($this->theme->background_image)) { echo ''; } echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

Auto - display image in original size; Contain - resize the image so it\'s fully visible; Cover - resize the image to cover the entire screen.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

The filter is immediately applied to the background image thumbnail above for a preview.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

If defined, the position defines the screen and image corners that will be aligned. It works best with the "cover" size option.

'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo '' . (isset($this->theme->background_blur) ? esc_attr($this->theme->background_blur) : '') . 'px'; echo '

Blur the background image to make the content more visible

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '

If the background image is set, the color will not be visible once the image is loaded.

'; echo '
'; echo '
'; echo ''; echo ''; echo '

Background color of the login sidebar.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '
theme->preloader_background_image) ? 'style="background-image:url(\'' . esc_attr($this->theme->preloader_background_image) . '\')"' : '') . '>'; if (empty($this->theme->preloader_background_image)) { echo ''; echo 'Select an image from our 400,000+ images gallery, or upload your own'; } echo ''; if (!empty($this->theme->preloader_background_image)) { echo ''; } echo '
'; echo '
'; echo '
'; echo '

Preloader image to replace the default gear icon.

'; echo '
'; echo '
'; echo '
'; $this->tab_footer('design'); } // tab_design_background /** * Echoes content for design-layout tab * * @return null */ private function tab_design_layout() { $modules = $this->get_modules(); // Modules echo '
Available Modules'; echo '
    '; foreach ($modules as $module => $module_properties) { echo '
  • '; if ($module_properties['pro'] === true) { echo '
    PRO
    '; } echo '
    '; echo '' . esc_html($module_properties['name']) . ''; echo '
    ' . esc_html($module_properties['name']) . ''; echo ''; echo ''; echo ''; echo ''; echo '
  • '; } echo '
'; //Layout echo '
'; echo '
'; echo '
navigate_before navigate_next refresh
'; echo '
    '; echo '
'; echo '
'; $this->tab_footer('design'); echo '
'; echo ''; } // tab_design_layout /** * Echoes content for design-css tab * * @return null */ public function tab_design_css() { echo '
Custom CSS
'; echo '

Custom CSS applies to current theme only. Please double-check any custom code you enter in the settings below. Any typos or mistakes will affect the appearance of the page.

'; echo '
'; echo ''; echo '

Write only the CSS code. Do not include the <style> tags. Code is placed in the page\'s <head> tag.

'; $this->tab_footer('design'); } //tab_design_css /** * Echoes content for settings tab * * @return null */ private function tab_seo() { $options = $this->get_options(); echo '
SEO
'; echo '

Carefully craft your content in order to rank your site as best as possible from day one. Use the SEO Analysis tool to improve weak areas.

'; //SEO Preview and Analysis echo '
'; echo '
'; echo '
SEO Snippet Preview
'; echo '
'; echo '
'; echo '

' . esc_attr(stripslashes($options['title'])) . '

'; echo '' . esc_url(home_url()) . ''; echo '
' . esc_attr(stripslashes($options['description'])) . '
'; echo '
'; echo ''; echo ''; echo '
Created with Raphaël 2.2.0Page SEO Score550100
'; echo '
'; echo '
'; echo '
SEO Analysis
'; echo '
'; echo '
Problems:
  • Target keyword does not appear in page meta description.
  • Keyword density in content is 4.76%, which is over the advised 2% maximum; the keyword was found 1 times in content.
  • Target keyword does not appear in the logo title.
  • Target keyword does not appear in the page header.
Potential Improvements:
  • Page SEO title is too short. Keep the length between 40 and 60 characters.
Good Results:
  • The page is not blocking search engines.
  • Target keyword appears in the page title.
  • Page meta description length is good.
  • Target keyword appears in the page URL.
  • Target keyword is set.
'; echo '
'; echo '
'; echo '
'; //SEO Title echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo '

Recommended format: Primary Keyword - Secondary Keyword - Brand Name with length up to 60 characters.
Use %sitetitle% and %sitetagline% to grab settings from WP.

'; echo '
'; //Meta Description echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo '

Write for humans, not search engines! This text will incite people to click on your site on Google. The length should be 50 - 300 characters.

'; echo '
'; echo '
'; echo '
'; //Show normal website to Search Engines? echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

If enabled, search engines will always see your normal page, never the maintenance one. We do not recommend enabling this feature.

'; echo '
'; //Discourage Search Engine crawlers echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

If your site is already indexed and you\'re just taking it down for a while, enable this option. It temporarily discourages search engines from crawling the site by telling them it\'s unavailable by sending a 503 Service Unavailable response.

'; echo '
'; echo '
'; echo '
'; //Favicon echo '
'; echo '
'; echo ''; echo ''; echo '
'; if (empty($options['favicon'])) { echo ''; } echo ''; echo '
'; echo '

Make sure the image is square (1:1 ratio). PNG will do just fine, about 64x64px. Don\'t go over 256x256px.

'; echo '
'; echo '
'; //Social Preview Image echo '
'; echo '
'; echo ''; echo ''; echo '
'; if (empty($options['social_preview'])) { echo ''; } echo ''; echo '
'; echo '

Image ratio should be 1:2. Facebook recommends 1200x630px. Minimum should be 600x315px.

'; echo '
'; echo '
'; echo '
'; echo '
'; //Google Analytics Tracking ID echo '
'; echo ''; echo ''; echo '

Enter only the Google Analytics Profile ID, ie: UA-123456-99. You\'ll find it in the GA tracking code.

'; echo '
'; //Tracking Pixel and 3rd Party Analytics Code echo '
'; echo ''; echo ''; echo '

Copy&paste the complete code, including the opening and closing <script> tags. The code is outputted in the page\'s header section.

'; echo '
'; echo '
'; echo '
'; //Facebook Page URL echo '
'; echo ''; echo '

Full URL to your Facebook page, including the https:// prefix.

'; echo '
'; //Twitter @username echo '
'; echo ''; echo '

X (Twitter) handle name including the @ sign, ie: @john.

'; echo '
'; echo '
'; $this->tab_footer(); } // tab_seo /** * Echoes content for advanced tab * * @return null */ private function tab_advanced() { $options = $this->get_options(); echo '
Advanced
'; echo '

Please double-check any custom code you enter in the settings below. Any typos or mistakes will affect the appearance of the page.

'; echo '
'; echo '
'; echo 'Export Settings PRO'; echo '

All settings are exported except themes. If you would like to export themes, please go to the Themes tab. You can safely transfer (export and then import) settings between different domains/sites.

'; echo '
'; echo '
'; echo '
Import Settings PRO
'; echo '

All settings are imported and overwritten. Themes are not imported. If you want to import themes go to the Themes tab.

'; echo '
'; echo '
'; echo '
'; echo '
'; $request_uri = sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'] ?? '')); echo 'Reset Settings'; echo '

All settings are reset to default values. There is NO undo.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

If you don\'t want the maintenance page\'s preview to be cached by Facebook and other social media, enable this option. Once you switch to the normal site, social media preview (visible when sharing the site\'s link) will immediately be refreshed. Normal visitors won\'t notice any differences with the option enabled.

'; echo '
'; $plugin_name = 'Maintenance'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

By default, a helpful ' . esc_html($plugin_name) . ' menu and status are added to the admin and front-end toolbar. If your toolbar is too crowded, disable the menu.

'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

If you have a valid SSL certificate installed on your site but people are still visiting the non-secure HTTP version, you can redirect them to HTTPS. The redirection only works for the maintenance page, not for the entire site and not for the preview.
DO NOT enable this option unless you have a valid SSL certificate installed. Check if you do by opening your site via the HTTPS protocol - ' . esc_html(str_ireplace('http://', 'https://', home_url('/'))) . '.

'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

Allow WordPress REST API calls while maintenance mode is enabled.

'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '

The built-in WordPress maintenance mode page is automatically shown to everybody (visitors and admins) for a few moments when WordPress is doing updates to themes, plugins, or core. It\'s a built-in feature and its behaviour can\'t be changed. This page can\'t contain any interactive elements such as a contact forms because when updates are performed the database and some files might not be accessible.
By default the page is quite ugly and the content can\'t be easily changed (you can read about it in this article). This option enables you do have a nicer maintenance page with your custom text on it. It\'s still automatically enabled and disabled by WordPress.

'; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; wp_editor(stripslashes($options['custom_wp_maintenance_content']), 'custom_wp_maintenance_content', $settings = array( 'textarea_rows' => 10, 'media_buttons' => 1, 'teeny' => false, 'editor_class' => 'skip_save', )); echo '
'; $this->tab_footer(); } // tab_advanced /** * Reset Settings * * @return null */ public function mtnc_reset_settings() { check_admin_referer('mtnc_admin_action'); if (!current_user_can('manage_options')) { wp_send_json_error(__('You are not allowed to run this action.', 'maintenance')); } $options = $this->get_options(); $default_theme_id = md5(time() . 'default'); $reset = sanitize_text_field(wp_unslash($_GET['reset'] ?? '')) == 'settings' ? 'settings':'theme'; if($reset == 'theme'){ $new_options = $options; } else { $new_options = array( 'status' => '0', 'mode' => 'layout', 'mtnc_page' => 0, 'header_text' => 'Our site is under maintenance!', //SEO 'title' => get_bloginfo('name') . ' is under maintenance', 'description' => 'We are doing some work on our site. Please come back later. We\'ll be up and running in no time.', 'target_keyword' => 'maintenance', 'excludese' => '0', 'blockse' => '0', 'favicon' => '', 'social_preview' => '', 'analytics' => '', 'tracking_pixel' => '', 'twitter_site' => '', 'facebook_site' => '', //Access 'show_logged_in' => '1', 'ip_whitelist' => '', 'per_url_settings' => '', 'per_url_enable_disable' => '', 'direct_access_link' => '', 'custom_login_url' => '', 'login_button' => '1', 'wplogin_button_tooltip' => 'Access WordPress admin', 'maintenance_password' => '', 'site_password' => '', 'password_button' => '0', 'login_button_text' => 'Access the Site', 'login_message' => 'Please enter the password to access the site', 'login_wrong_password_text' => 'Wrong password', 'login_button_tooltip' => 'Direct Access login', //Advanced 'no_cache_headers' => '1', 'disable_toolbar_menu' => '', 'force_ssl' => '', 'enable_rest' => '', 'custom_wp_maintenance' => '', 'custom_wp_maintenance_title' => '', 'custom_wp_maintenance_content' => '', 'upgraded' => $options['upgraded'] ); } $new_options['theme_global'] = $default_theme_id; $new_options['themes'] = array($default_theme_id => json_decode( '{ "modules": { "header-dbd02cd1": { "name": "Header", "type": "header", "groups": { "header": { "name": "Header", "active": true, "fields": { "text": { "type": "text", "name": "text", "label": "Text", "value": "Site is undergoing maintenance", "class": "full-width", "desc": "" }, "text_align": { "type": "radio", "name": "text_align", "label": "Text Align", "class": "", "values": { "left": "Left", "center": "Center", "right": "Right" }, "value": "center" }, "font_size": { "type": "range", "name": "font_size", "label": "Font Size", "value": "47", "min": 6, "max": 120, "class": "", "units": { "px": "px", "pt": "pt", "em": "em" }, "unit_value": "px" }, "color": { "type": "color", "name": "text_color", "label": "Color", "value": "rgba(255,255,255,1)", "desc": "" }, "font": { "type": "font", "name": "font", "label": "Font", "value": "Open Sans", "class": "full-width", "desc": "" }, "line_height": { "type": "number", "name": "line_height", "label": "Line Height", "value": "2", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "em", "class": "number_small", "desc": "" } } }, "layout": { "name": "Layout", "fields": { "padding_label": { "type": "label", "name": "padding_label", "label": "Padding" }, "padding_top": { "type": "number", "name": "padding_top", "label": "Top", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_top.png", "value": "10", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_bottom": { "type": "number", "name": "padding_bottom", "label": "Bottom", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_bottom.png", "value": "10", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_left": { "type": "number", "name": "padding_left", "label": "Left", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_left.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_right": { "type": "number", "name": "padding_right", "label": "Right", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_right.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_label": { "type": "label", "name": "margin_label", "label": "Margin" }, "margin_top": { "type": "number", "name": "margin_top", "label": "Top", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_top.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_bottom": { "type": "number", "name": "margin_bottom", "label": "Bottom", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_bottom.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_left": { "type": "number", "name": "margin_left", "label": "Left", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_left.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_right": { "type": "number", "name": "margin_right", "label": "Right", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_right.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "background_label": { "type": "label", "name": "background_label", "label": "Background" }, "background_color": { "type": "color", "name": "background_color", "nolabel": true, "value": "rgba(255,255,255,0)", "desc": "" }, "background": { "type": "image", "name": "background", "nolabel": true, "value": "", "class": "", "desc": "" } } } } }, "content-471365b7": { "name": "Content", "type": "content", "groups": { "col1": { "name": "Footer", "active": true, "fields": { "text": { "type": "textarea", "name": "text", "label": "Text", "value": "Maintenance mode is on", "class": "full-width", "desc": "" }, "font_size": { "type": "number", "name": "font_size", "label": "Font Size", "value": "36", "class": "number_small", "units": { "px": "px", "pt": "pt", "em": "em" }, "unit_value": "px" }, "color": { "type": "color", "name": "text_color", "label": "Color", "value": "rgba(255,255,255,1)", "desc": "" }, "font": { "type": "font", "name": "font", "label": "Font", "value": "Open Sans", "class": "full-width", "desc": "" }, "line_height": { "type": "number", "name": "line_height", "label": "Line Height", "value": "1", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "em", "class": "number_small", "desc": "" } } }, "layout": { "name": "Layout", "fields": { "padding_label": { "type": "label", "name": "padding_label", "label": "Padding" }, "padding_top": { "type": "number", "name": "padding_top", "label": "Top", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_top.png", "value": "100", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_bottom": { "type": "number", "name": "padding_bottom", "label": "Bottom", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_bottom.png", "value": "10", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_left": { "type": "number", "name": "padding_left", "label": "Left", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_left.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_right": { "type": "number", "name": "padding_right", "label": "Right", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_right.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_label": { "type": "label", "name": "margin_label", "label": "Margin" }, "margin_top": { "type": "number", "name": "margin_top", "label": "Top", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_top.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_bottom": { "type": "number", "name": "margin_bottom", "label": "Bottom", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_bottom.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_left": { "type": "number", "name": "margin_left", "label": "Left", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_left.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_right": { "type": "number", "name": "margin_right", "label": "Right", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_right.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "background_label": { "type": "label", "name": "background_label", "label": "Background" }, "background_color": { "type": "color", "name": "background_color", "nolabel": true, "value": "rgba(255,255,255,0)", "desc": "" }, "background": { "type": "image", "name": "background", "nolabel": true, "value": "", "class": "", "desc": "" } } } } }, "content-9742e2f8": { "name": "Content", "type": "content", "groups": { "col1": { "name": "Footer", "active": true, "fields": { "text": { "type": "textarea", "name": "text", "label": "Text", "value": "Site will be available soon. Thank you for your patience!", "class": "full-width", "desc": "" }, "font_size": { "type": "number", "name": "font_size", "label": "Font Size", "value": "20", "class": "number_small", "units": { "px": "px", "pt": "pt", "em": "em" }, "unit_value": "px" }, "color": { "type": "color", "name": "text_color", "label": "Color", "value": "rgba(255,255,255,1)", "desc": "" }, "font": { "type": "font", "name": "font", "label": "Font", "value": "Open Sans", "class": "full-width", "desc": "" }, "line_height": { "type": "number", "name": "line_height", "label": "Line Height", "value": "1", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "em", "class": "number_small", "desc": "" } } }, "layout": { "name": "Layout", "fields": { "padding_label": { "type": "label", "name": "padding_label", "label": "Padding" }, "padding_top": { "type": "number", "name": "padding_top", "label": "Top", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_top.png", "value": "10", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_bottom": { "type": "number", "name": "padding_bottom", "label": "Bottom", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_bottom.png", "value": "10", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_left": { "type": "number", "name": "padding_left", "label": "Left", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_left.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_right": { "type": "number", "name": "padding_right", "label": "Right", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_right.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_label": { "type": "label", "name": "margin_label", "label": "Margin" }, "margin_top": { "type": "number", "name": "margin_top", "label": "Top", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_top.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_bottom": { "type": "number", "name": "margin_bottom", "label": "Bottom", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_bottom.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_left": { "type": "number", "name": "margin_left", "label": "Left", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_left.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_right": { "type": "number", "name": "margin_right", "label": "Right", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_right.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "background_label": { "type": "label", "name": "background_label", "label": "Background" }, "background_color": { "type": "color", "name": "background_color", "nolabel": true, "value": "rgba(255,255,255,0)", "desc": "" }, "background": { "type": "image", "name": "background", "nolabel": true, "value": "", "class": "", "desc": "" } } } } }, "footer-a29820d6": { "name": "Footer", "type": "footer", "groups": { "col1": { "name": "Footer", "active": true, "fields": { "text": { "type": "textarea", "name": "text", "label": "Text", "value": "© Maintenance 2026", "class": "full-width", "desc": "" }, "font_size": { "type": "number", "name": "font_size", "label": "Font Size", "value": "24", "class": "number_small", "units": { "px": "px", "pt": "pt", "em": "em" }, "unit_value": "px" }, "color": { "type": "color", "name": "text_color", "label": "Color", "value": "rgba(255,255,255,1)", "desc": "" }, "font": { "type": "font", "name": "font", "label": "Font", "value": "Open Sans", "class": "full-width", "desc": "" }, "line_height": { "type": "number", "name": "line_height", "label": "Line Height", "value": "1", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "em", "class": "number_small", "desc": "" } } }, "layout": { "name": "Layout", "fields": { "padding_label": { "type": "label", "name": "padding_label", "label": "Padding" }, "padding_top": { "type": "number", "name": "padding_top", "label": "Top", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_top.png", "value": "10", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_bottom": { "type": "number", "name": "padding_bottom", "label": "Bottom", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_bottom.png", "value": "10", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_left": { "type": "number", "name": "padding_left", "label": "Left", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_left.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "padding_right": { "type": "number", "name": "padding_right", "label": "Right", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/padding_right.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_label": { "type": "label", "name": "margin_label", "label": "Margin" }, "margin_top": { "type": "number", "name": "margin_top", "label": "Top", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_top.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_bottom": { "type": "number", "name": "margin_bottom", "label": "Bottom", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_bottom.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_left": { "type": "number", "name": "margin_left", "label": "Left", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_left.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "margin_right": { "type": "number", "name": "margin_right", "label": "Right", "image_label": "' . trailingslashit(MTNC_URL) . 'img/icons/margin_right.png", "value": "0", "class": "number_small", "units": { "px": "px", "percent": "%", "em": "em" }, "unit_value": "px", "wrapper_class": "col-4" }, "background_label": { "type": "label", "name": "background_label", "label": "Background" }, "background_color": { "type": "color", "name": "background_color", "nolabel": true, "value": "rgba(255,255,255,0)", "desc": "" }, "background": { "type": "image", "name": "background", "nolabel": true, "value": "", "class": "", "desc": "" } } } } } }, "modules_order": { "header-dbd02cd1": "header-dbd02cd1", "content-471365b7": "content-471365b7", "content-9742e2f8": "content-9742e2f8", "footer-a29820d6": "footer-a29820d6" }, "name": "Default", "theme_thumbnail": "", "theme_status": "", "body_font_size": "16", "body_font_color": "#FFFFFF", "body_font": "Open Sans", "body_link_color": "#0096FF", "body_link_hover_color": "#57BAFF", "background_type": "image", "background_video": "", "background_video_fallback": "", "background_video_filter": "", "background_size_opt": "cover", "background_position": "center center", "background_image_filter": "", "background_blur": 0, "background_image": "' . trailingslashit(MTNC_URL) . 'img/mt-sample-background.jpg", "preloader_background_image": "", "background_color": "rgba(0,0,0,1)", "login_background_color": "rgba(0,0,0,1)", "content_overlay": "", "content_width": 916, "content_overlay_color": "rgba(0,0,0,0.2)", "content_overlay_shadow_color": "rgba(0,0,0,0.2)", "content_position": "middle", "modules_spacing": 20, "custom_css": ".mtnc_module,\r\n.mtnc_module h2{\r\n\tfont-weight:300;\r\n}" }' ) ); $this->update_options('options', $new_options); if (!empty($_GET['redirect'])) { if($reset == 'theme'){ wp_safe_redirect(admin_url('admin.php?page=maintenance&theme-reset=true')); } else { wp_safe_redirect(admin_url('admin.php?page=maintenance&settings-reset=true')); } } die(); } /** * Create select options * * @param array $options Options * @param string $selected current value * @param bool $output current value * * @return string html if $output is false */ public function create_select_options($options, $selected = null, $output = true) { $out = "\n"; foreach ($options as $option) { $disabled = ''; if (isset($option['disabled'])) { $disabled .= ' disabled="disabled" '; } $out .= ''; } // foreach if ($output) { self::wp_kses_wf($out); } else { return $out; } } // create_select_options /** * Generate CSS Style for a module for front-end display * * @param object $module object * * @return string CSS styles */ public function get_module_style($module) { $styles = 'padding:0px; margin:' . round($this->theme->modules_spacing / 2) . 'px auto; text-align:center;'; //Padding if (!empty($module->groups->layout->fields->padding_top->value)) { $styles .= 'padding-top:' . $module->groups->layout->fields->padding_top->value . str_replace('percent', '%', $module->groups->layout->fields->padding_top->unit_value) . ';'; } if (!empty($module->groups->layout->fields->padding_right->value)) { $styles .= 'padding-right:' . $module->groups->layout->fields->padding_right->value . str_replace('percent', '%', $module->groups->layout->fields->padding_right->unit_value) . ';'; } if (!empty($module->groups->layout->fields->padding_bottom->value)) { $styles .= 'padding-bottom:' . $module->groups->layout->fields->padding_bottom->value . str_replace('percent', '%', $module->groups->layout->fields->padding_bottom->unit_value) . ';'; } if (!empty($module->groups->layout->fields->padding_left->value)) { $styles .= 'padding-left:' . $module->groups->layout->fields->padding_left->value . str_replace('percent', '%', $module->groups->layout->fields->padding_left->unit_value) . ';'; } //Margin if (!empty($module->groups->layout->fields->margin_top->value)) { $styles .= 'margin-top:' . $module->groups->layout->fields->margin_top->value . str_replace('percent', '%', $module->groups->layout->fields->margin_top->unit_value) . ';'; } if (!empty($module->groups->layout->fields->margin_right->value)) { $styles .= 'margin-right:' . $module->groups->layout->fields->margin_right->value . str_replace('percent', '%', $module->groups->layout->fields->margin_right->unit_value) . ';'; } if (!empty($module->groups->layout->fields->margin_bottom->value)) { $styles .= 'margin-bottom:' . $module->groups->layout->fields->margin_bottom->value . str_replace('percent', '%', $module->groups->layout->fields->margin_bottom->unit_value) . ';'; } if (!empty($module->groups->layout->fields->margin_left->value)) { $styles .= 'margin-left:' . $module->groups->layout->fields->margin_left->value . str_replace('percent', '%', $module->groups->layout->fields->margin_left->unit_value) . ';'; } //Background if (!empty($module->groups->layout->fields->background_color->value)) { $styles .= 'background-color:' . $module->groups->layout->fields->background_color->value . ';'; } if (!empty($module->groups->layout->fields->background->value)) { $styles .= 'background:url(' . $module->groups->layout->fields->background->value . ');'; } if ($module->type == 'footer') { $styles .= 'position:absolute; bottom:0px; left: 0px;'; } return $styles; } /** * Convert GA Code * * @param string GA Code * * @return string GA Code */ public function convert_ga($code) { if (empty($code) || strpos($code, 'load_maintenance_page($original_template); return $original_template; } public function check_maintenance_unlocked() { $mtnc_options = $this->get_options(true); if (isset($_COOKIE['maintenance_unlocked']) && $_COOKIE['maintenance_unlocked'] == md5($mtnc_options['maintenance_password'])) { return true; } else { return false; } } public function check_site_unlocked() { $mtnc_options = $this->get_options(true); if (isset($_COOKIE['site_unlocked']) && $_COOKIE['site_unlocked'] == md5($mtnc_options['site_password'])) { return true; } else { return false; } } public function check_maintenance_locked() { $mtnc_options = $this->get_options(true); if (isset($mtnc_options['maintenance_password']) && strlen($mtnc_options['maintenance_password']) > 0 && !$this->check_maintenance_unlocked()) { return true; } return false; } public function check_site_locked() { $mtnc_options = $this->get_options(true); if (isset($mtnc_options['site_password']) && strlen($mtnc_options['site_password']) > 0 && !$this->check_site_unlocked()) { return true; } return false; } public function load_maintenance_page($original_template) { $mtnc_options = $this->get_options(true); // just to be on the safe side if (defined('DOING_CRON') && DOING_CRON) { return false; } if (defined('DOING_AJAX') && DOING_AJAX) { return false; } if (defined('WP_CLI') && WP_CLI) { return false; } // init custom enter no main url $custom_url_link = $mtnc_options['direct_access_link']; if (!empty($custom_url_link)) { if (isset($_GET[$custom_url_link])) { //phpcs:ignore setcookie("skip_maintenance_mode", true, time() + 24 * 60 * 60, '/'); $_COOKIE['skip_maintenance_mode'] = true; } } // Getting custom login URL for the admin $login_url = wp_login_url(); // This is the server address of the current page $request_uri = sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'] ?? '')); $request_uri = $this->slashit(strtolower(wp_parse_url($request_uri, PHP_URL_PATH))); $server_url = get_home_url() . $request_uri; // Checking for the custom_login_url value if (empty($mtnc_options['custom_login_url'])) { $mtnc_options['custom_login_url'] = ''; } else { $mtnc_options['custom_login_url'] = get_home_url() . $this->slashit($mtnc_options['custom_login_url']); } if (!is_admin() || isset($_GET['maintenance-preview'])) { //phpcs:ignore if ('1' == $mtnc_options['status'] || apply_filters('mtnc_force_display', false) || isset($_GET['maintenance-preview'])) { //phpcs:ignore if ( false === strpos($server_url, '/wp-login.php') && false === strpos($server_url, '/wp-admin/') && false === strpos($server_url, '/async-upload.php') && false === strpos($server_url, '/upgrade.php') && false === strpos($server_url, '/xmlrpc.php') && false === strpos($server_url, $login_url) && !isset($_GET['mainwpsignature']) //phpcs:ignore ) { $show_maintenance_page = 1; if (!empty($mtnc_options['custom_login_url']) && false !== strpos($server_url, $mtnc_options['custom_login_url'])) { $show_maintenance_page = 0; } // search engines if ($mtnc_options['excludese'] == '1' && $this->check_referrer()) { $show_maintenance_page = 0; } // if logged in if ($mtnc_options['show_logged_in'] == '1' && is_user_logged_in()) { $show_maintenance_page = 0; } // IP whitelist $all_ips = explode("\n", $mtnc_options['ip_whitelist']); $all_ips = array_map('trim', $all_ips); $current_ip = sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'] ?? '')); if (@in_array($current_ip, $all_ips)) { $show_maintenance_page = 0; } // urls list $all_urls = explode("\n", trim($mtnc_options['per_url_enable_disable'])); $all_urls = array_map('trim', $all_urls); // whitelisted / blacklisted URLs if ($mtnc_options['per_url_settings'] == 'whitelist' && !empty($all_urls)) { if (in_array($request_uri, $all_urls)) { $show_maintenance_page = 0; } } elseif ($mtnc_options['per_url_settings'] == 'blacklist' && !empty($all_urls)) { if (!in_array($request_uri, $all_urls)) { $show_maintenance_page = 0; } } if (!empty($_COOKIE['skip_maintenance_mode'])) { $show_maintenance_page = 0; } if (isset($_COOKIE['site_unlocked']) && $_COOKIE['site_unlocked'] == md5($mtnc_options['site_password'])) { $show_maintenance_page = 0; } $show_maintenance_page = apply_filters('mtnc_force_display', $show_maintenance_page); if ($show_maintenance_page == 1 || isset($_GET['maintenance-preview'])) { //phpcs:ignore if (file_exists(MTNC_LOAD . 'index.php')) { add_filter('script_loader_tag', 'mtnc_defer_scripts', 10, 2); return MTNC_LOAD . 'index.php'; } else { return $original_template; } } } } } return $original_template; } public function slashit($url) { if (strpos($url, '?') === false && substr($url, -4, 1) != '.') { $url = trailingslashit($url); } if ($url != '/') { $url = '/' . ltrim($url, '/'); } return $url; } // slashit public function get_headers_503() { $mtnc_options = $this->get_options(true); nocache_headers(); if (!empty($mtnc_options['blockse'])) { $protocol = 'HTTP/1.0'; if (isset($_SERVER['SERVER_PROTOCOL']) && 'HTTP/1.1' === $_SERVER['SERVER_PROTOCOL']) { $protocol = 'HTTP/1.1'; } header("$protocol 503 Service Unavailable", true, 503); $v_curr_date_end = ''; $vdate_end = date_i18n('Y-m-d', strtotime(current_time('mysql', 0))); $vtime_end = date_i18n('h:i a', strtotime('12:00 pm')); if (!empty($mtnc_options['expiry_date_end'])) { $vdate_end = $mtnc_options['expiry_date_end']; } if (!empty($mtnc_options['expiry_time_end'])) { $vtime_end = $mtnc_options['expiry_time_end']; } if ($mtnc_options['state'] && !empty($mtnc_options['expiry_date_end']) && !empty($mtnc_options['expiry_time_end'])) { $date_concat = $vdate_end . ' ' . $vtime_end; $v_curr_date = strtotime($date_concat); if (strtotime(current_time('mysql', 0)) < $v_curr_date) { header('Retry-After: ' . gmdate('D, d M Y H:i:s', $v_curr_date)); } else { header('Retry-After: 3600'); } } else { header('Retry-After: 3600'); } } } public function add_bunny_fonts($theme) { $fonts = array(); foreach ($theme->modules as $module) { foreach ($module->groups as $group) { foreach ($group->fields as $field) { if ($field->type == 'font') { $font_link = $this->get_bunny_font(esc_attr($field->value)); if (!empty($font_link)) { $fonts[] = $font_link; } } } } } return $fonts; } //add_bunny_fonts /** * Get Google link * * @return string link */ public function get_bunny_font($font = null) { $font_params = $full_link = $gg_fonts = ''; $gg_fonts = json_decode($this->get_bunny_fonts()); if (property_exists($gg_fonts, $font)) { $curr_font = $gg_fonts->{$font}; if (!empty($curr_font)) { foreach ($curr_font->variants as $values) { if (!empty($values->id)) { $font_params .= $values->id . ','; } elseif (!empty($values)) { $font_params .= $values . ','; } } $font_params = trim($font_params, ','); $full_link = $font . ':' . $font_params; } } return $full_link; } //get_bunny_font /** * Get Google fonts from json * * @return string Google fonts */ public function get_bunny_fonts() { $gg_fonts = file_get_contents(MTNC_PATH . 'css/font/bunnyfonts.json'); return $gg_fonts; } //get_bunny_fonts public function get_custom_login_code() { global $wp_query, $error; $mtnc_options = $this->get_options(); $user_connect = false; if (!is_array($wp_query->query_vars)) { $wp_query->query_vars = array(); } $error_message = $user_login = $user_pass = $error = ''; $is_role_check = true; $class_login = 'user-icon'; $class_password = 'pass-icon'; $using_cookie = false; if (isset($_POST['is_custom_login'])) { $user_login = ''; if (isset($_POST['log']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['mtnc_login_check'] ?? '')), 'mtnc_login')) { $user_login = sanitize_text_field(wp_unslash($_POST['log'])); } $user_login = sanitize_user($user_login); $user_pass = ''; if (isset($_POST['pwd']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['mtnc_login_check'] ?? '')), 'mtnc_login')) { $user_pass = sanitize_text_field(wp_unslash($_POST['pwd'])); } $access = array(); $access['user_login'] = esc_attr($user_login); $access['user_password'] = $user_pass; $access['remember'] = true; $user = null; $user = new WP_User(0, $user_login); $current_role = current($user->roles); if (!empty($mtnc_options['roles_array'])) { foreach (array_keys($mtnc_options['roles_array']) as $key) { if ($key === $current_role) { $is_role_check = false; } } } else { $is_role_check = true; } if (!$is_role_check) { $error_message = esc_html__('Permission access denied!', 'maintenance'); $class_login = 'error'; $class_password = 'error'; } else { if (is_ssl()) { $ssl = true; } else { $ssl = false; } $user_connect = wp_signon($access, $ssl); if (is_wp_error($user_connect)) { if ($user_connect->get_error_code() === 'invalid_username') { $error_message = esc_html__('Login is incorrect!', 'maintenance'); $class_login = 'error'; $class_password = 'error'; } elseif ($user_connect->get_error_code() === 'incorrect_password') { $error_message = esc_html__('Password is incorrect!', 'maintenance'); $class_password = 'error'; } else { $error_message = esc_html__('Login and password are incorrect!', 'maintenance'); $class_login = 'error'; $class_password = 'error'; } } else { wp_safe_redirect(home_url('/')); exit; } } } if (!$user_connect) { $this->get_headers_503(); } return array($error_message, $class_login, $class_password, $user_login); } /** * Check referrer if it's a SERP crawler * * @return bool true if crawler */ public function check_referrer() { // List of crawlers to check for $crawlers = array( 'Abacho' => 'AbachoBOT', 'Accoona' => 'Acoon', 'AcoiRobot' => 'AcoiRobot', 'Adidxbot' => 'adidxbot', 'AltaVista robot' => 'Altavista', 'Altavista robot' => 'Scooter', 'ASPSeek' => 'ASPSeek', 'Atomz' => 'Atomz', 'Bing' => 'bingbot', 'BingPreview' => 'BingPreview', 'CrocCrawler' => 'CrocCrawler', 'Dumbot' => 'Dumbot', 'eStyle Bot' => 'eStyle', 'FAST-WebCrawler' => 'FAST-WebCrawler', 'GeonaBot' => 'GeonaBot', 'Gigabot' => 'Gigabot', 'Google' => 'Googlebot', 'ID-Search Bot' => 'IDBot', 'Lycos spider' => 'Lycos', 'MSN' => 'msnbot', 'MSRBOT' => 'MSRBOT', 'Rambler' => 'Rambler', 'Scrubby robot' => 'Scrubby', 'Yahoo' => 'Yahoo', ); // Checking for the crawler over here if ($this->string_to_array(sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'] ?? '')), $crawlers)) { return true; } return false; } //check_referrer /** * Function to match the user agent with the crawlers array * * @param string string to find * @param array array to look in * * @return bool true if match found */ public function string_to_array($str, $array) { $regexp = '~(' . implode('|', array_values($array)) . ')~i'; return (bool) preg_match($regexp, $str); } //string_to_array static function wp_kses_wf($html) { add_filter('safe_style_css', function ($styles) { $styles_wf = array( 'text-align', 'margin', 'color', 'float', 'border', 'background', 'background-color', 'border-bottom', 'border-bottom-color', 'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-left', 'border-left-color', 'border-left-style', 'border-left-width', 'border-right', 'border-right-color', 'border-right-style', 'border-right-width', 'border-spacing', 'border-style', 'border-top', 'border-top-color', 'border-top-style', 'border-top-width', 'border-width', 'caption-side', 'clear', 'cursor', 'direction', 'font', 'font-family', 'font-size', 'font-style', 'font-variant', 'font-weight', 'height', 'letter-spacing', 'line-height', 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'overflow', 'padding', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align', 'width', 'display', ); foreach ($styles_wf as $style_wf) { $styles[] = $style_wf; } return $styles; }); $allowed_tags = wp_kses_allowed_html('post'); $allowed_tags['input'] = array( 'type' => true, 'style' => true, 'class' => true, 'id' => true, 'checked' => true, 'disabled' => true, 'name' => true, 'size' => true, 'placeholder' => true, 'value' => true, 'data-*' => true, 'size' => true, 'disabled' => true ); $allowed_tags['textarea'] = array( 'type' => true, 'style' => true, 'class' => true, 'id' => true, 'checked' => true, 'disabled' => true, 'name' => true, 'size' => true, 'placeholder' => true, 'value' => true, 'data-*' => true, 'cols' => true, 'rows' => true, 'disabled' => true, 'autocomplete' => true ); $allowed_tags['select'] = array( 'type' => true, 'style' => true, 'class' => true, 'id' => true, 'checked' => true, 'disabled' => true, 'name' => true, 'size' => true, 'placeholder' => true, 'value' => true, 'data-*' => true, 'multiple' => true, 'disabled' => true ); $allowed_tags['option'] = array( 'type' => true, 'style' => true, 'class' => true, 'id' => true, 'checked' => true, 'disabled' => true, 'name' => true, 'size' => true, 'placeholder' => true, 'value' => true, 'selected' => true, 'data-*' => true ); $allowed_tags['optgroup'] = array( 'type' => true, 'style' => true, 'class' => true, 'id' => true, 'checked' => true, 'disabled' => true, 'name' => true, 'size' => true, 'placeholder' => true, 'value' => true, 'selected' => true, 'data-*' => true, 'label' => true ); $allowed_tags['a'] = array( 'href' => true, 'data-*' => true, 'class' => true, 'style' => true, 'id' => true, 'target' => true, 'data-*' => true, 'role' => true, 'aria-controls' => true, 'aria-selected' => true, 'disabled' => true ); $allowed_tags['div'] = array( 'style' => true, 'class' => true, 'id' => true, 'data-*' => true, 'role' => true, 'aria-labelledby' => true, 'value' => true, 'aria-modal' => true, 'tabindex' => true ); $allowed_tags['h2'] = array( 'style' => true, 'class' => true, 'id' => true, 'data-*' => true, 'role' => true, 'aria-labelledby' => true, 'value' => true, 'aria-modal' => true, 'tabindex' => true, 'font-family' => true, ); $allowed_tags['li'] = array( 'style' => true, 'class' => true, 'id' => true, 'data-*' => true, 'role' => true, 'aria-labelledby' => true, 'value' => true, 'aria-modal' => true, 'tabindex' => true ); $allowed_tags['span'] = array( 'style' => true, 'class' => true, 'id' => true, 'data-*' => true, 'aria-hidden' => true ); $allowed_tags['style'] = array( 'class' => true, 'id' => true, 'type' => true, 'font-family' => true, ); $allowed_tags['fieldset'] = array( 'class' => true, 'id' => true, 'type' => true ); $allowed_tags['link'] = array( 'class' => true, 'id' => true, 'type' => true, 'rel' => true, 'href' => true, 'media' => true ); $allowed_tags['form'] = array( 'style' => true, 'class' => true, 'id' => true, 'method' => true, 'action' => true, 'data-*' => true ); echo wp_kses($html, $allowed_tags); add_filter('safe_style_css', function ($styles) { $styles_wf = array( 'text-align', 'margin', 'color', 'float', 'border', 'background', 'background-color', 'border-bottom', 'border-bottom-color', 'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-left', 'border-left-color', 'border-left-style', 'border-left-width', 'border-right', 'border-right-color', 'border-right-style', 'border-right-width', 'border-spacing', 'border-style', 'border-top', 'border-top-color', 'border-top-style', 'border-top-width', 'border-width', 'caption-side', 'clear', 'cursor', 'direction', 'font', 'font-family', 'font-size', 'font-style', 'font-variant', 'font-weight', 'height', 'letter-spacing', 'line-height', 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'overflow', 'padding', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align', 'width' ); foreach ($styles_wf as $style_wf) { if (($key = array_search($style_wf, $styles)) !== false) { unset($styles[$key]); } } return $styles; }); } function is_plugin_installed($slug) { if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all_plugins = get_plugins(); if (!empty($all_plugins[$slug])) { return true; } else { return false; } } // is_plugin_installed // auto download / install / activate WP Force SSL plugin function install_wpfssl() { check_ajax_referer('install_wpfssl'); if (false === current_user_can('administrator')) { wp_die('Sorry, you have to be an admin to run this action.'); } $plugin_slug = 'wp-force-ssl/wp-force-ssl.php'; $plugin_zip = 'https://downloads.wordpress.org/plugin/wp-force-ssl.latest-stable.zip'; @include_once ABSPATH . 'wp-admin/includes/plugin.php'; @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; @include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; @include_once ABSPATH . 'wp-admin/includes/file.php'; @include_once ABSPATH . 'wp-admin/includes/misc.php'; echo ''; echo '
'; echo 'If things are not done in a minute install the plugin manually via Plugins page

'; echo 'Starting ...

'; wp_cache_flush(); $upgrader = new Plugin_Upgrader(); echo 'Check if WP Force SSL is already installed ...
'; if ($this->is_plugin_installed($plugin_slug)) { echo 'WP Force SSL is already installed!

Making sure it\'s the latest version.
'; $upgrader->upgrade($plugin_slug); $installed = true; } else { echo 'Installing WP Force SSL.
'; $installed = $upgrader->install($plugin_zip); } wp_cache_flush(); if (!is_wp_error($installed) && $installed) { echo 'Activating WP Force SSL.
'; $activate = activate_plugin($plugin_slug); if (is_null($activate)) { echo 'WP Force SSL Activated.
'; echo ''; echo '
If you are not redirected in a few seconds - click here.'; } } else { echo 'Could not install WP Force SSL. You\'ll have to download and install manually.'; } echo '
'; } // install_wpfssl // auto download / install / activate Advanced Google reCAPTCHA plugin function install_wpcaptcha() { check_ajax_referer('install_wpcaptcha'); if (false === current_user_can('administrator')) { wp_die('Sorry, you have to be an admin to run this action.'); } $plugin_slug = 'advanced-google-recaptcha/advanced-google-recaptcha.php'; $plugin_zip = 'https://downloads.wordpress.org/plugin/advanced-google-recaptcha.latest-stable.zip'; @include_once ABSPATH . 'wp-admin/includes/plugin.php'; @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; @include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; @include_once ABSPATH . 'wp-admin/includes/file.php'; @include_once ABSPATH . 'wp-admin/includes/misc.php'; echo ''; echo '
'; echo 'If things are not done in a minute install the plugin manually via Plugins page

'; echo 'Starting ...

'; wp_cache_flush(); $upgrader = new Plugin_Upgrader(); echo 'Check if Advanced Google reCAPTCHA is already installed ...
'; if ($this->is_plugin_installed($plugin_slug)) { echo 'Advanced Google reCAPTCHA is already installed!

Making sure it\'s the latest version.
'; $upgrader->upgrade($plugin_slug); $installed = true; } else { echo 'Installing Advanced Google reCAPTCHA.
'; $installed = $upgrader->install($plugin_zip); } wp_cache_flush(); if (!is_wp_error($installed) && $installed) { echo 'Activating Advanced Google reCAPTCHA.
'; $activate = activate_plugin($plugin_slug); if (is_null($activate)) { echo 'Advanced Google reCAPTCHA Activated.
'; echo ''; echo '
If you are not redirected in a few seconds - click here.'; } } else { echo 'Could not install Advanced Google reCAPTCHA. You\'ll have to download and install manually.'; } echo '
'; } // install_wpcaptcha // auto download / install / activate Weglot plugin function install_weglot() { check_ajax_referer('install_weglot'); if (false === current_user_can('administrator')) { wp_die('Sorry, you have to be an admin to run this action.'); } $plugin_slug = 'weglot/weglot.php'; $plugin_zip = 'https://downloads.wordpress.org/plugin/weglot.latest-stable.zip'; @include_once ABSPATH . 'wp-admin/includes/plugin.php'; @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; @include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; @include_once ABSPATH . 'wp-admin/includes/file.php'; @include_once ABSPATH . 'wp-admin/includes/misc.php'; echo ''; echo '
'; echo 'If things are not done in a minute install the plugin manually via Plugins page

'; echo 'Starting ...

'; wp_cache_flush(); $upgrader = new Plugin_Upgrader(); echo 'Check if Weglot is already installed ...
'; if ($this->is_plugin_installed($plugin_slug)) { echo 'Weglot is already installed!

Making sure it\'s the latest version.
'; $upgrader->upgrade($plugin_slug); $installed = true; } else { echo 'Installing Weglot.
'; $installed = $upgrader->install($plugin_zip); } wp_cache_flush(); if (!is_wp_error($installed) && $installed) { echo 'Activating Weglot.
'; $activate = activate_plugin($plugin_slug); if (is_null($activate)) { echo 'Weglot Activated.
'; echo ''; echo '
If you are not redirected in a few seconds - click here.'; } } else { echo 'Could not install Weglot. You\'ll have to download and install manually.'; } echo '
'; } // install_weglot /** * Disabled; we use singleton pattern so magic functions need to be disabled * * @return null */ public function __clone() {} /** * Disabled; we use singleton pattern so magic functions need to be disabled * * @return null */ public function __sleep() {} /** * Disabled; we use singleton pattern so magic functions need to be disabled * * @return null */ public function __wakeup() {} } // MTNC class // Create plugin instance and hook things up global $wf_mtnc; //phpcs:ignore $wf_mtnc = MTNC::getInstance(); //phpcs:ignore