Website Under Maintenance

Our Website is currently undergoing scheduled maintenance. Please check back soon.

', LJMM_PLUGIN_DOMAIN); break; case 'warning_wp_super_cache': $default = __("Important: Don't forget to flush your cache using WP Super Cache when enabling or disabling Maintenance Mode.", LJMM_PLUGIN_DOMAIN); break; case 'warning_w3_total_cache': $default = __("Important: Don't forget to flush your cache using W3 Total Cache when enabling or disabling Maintenance Mode.", LJMM_PLUGIN_DOMAIN); break; case 'warning_comet_cache': $default = __("Important: Don't forget to flush your cache using Comet Cache when enabling or disabling Maintenance Mode.", LJMM_PLUGIN_DOMAIN); break; case 'ljmm_enabled': $default = __('Maintenance Mode is currently active. To make sure that it works, open your web page in either private / incognito mode, different browser or simply log out. Logged in users are not affected by the Maintenance Mode.', LJMM_PLUGIN_DOMAIN); break; case 'ljmm_add_widget_areas': $default = __('You can add widgets in Appearance -> Widgets.', LJMM_PLUGIN_DOMAIN); break; default: $default = false; break; } return $default; } /** * Set the default content * Avoid duplicate function. * * @since 1.0 */ function ljmm_set_content() { // If content is not set, set the default content. $content = get_option('ljmm-content'); if (empty($content)) { $content = ljmm_get_defaults('maintenance_message'); update_option('ljmm-content', stripslashes($content)); } // If content is not set, set the default content. $mode = get_option('ljmm-mode'); if (empty($mode)) { update_option('ljmm-mode', 'default'); } } /** * Load plugin textdomain. * * @since 1.3.1 */ function ljmm_load_textdomain() { load_plugin_textdomain(LJMM_PLUGIN_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages/'); } add_action('plugins_loaded', 'ljmm_load_textdomain'); /** * Main class * * @since 1.0 */ class ljMaintenanceMode { /** * Constructor * * @since 1.0 */ public function __construct() { add_action('admin_menu', array($this, 'ui')); add_action('admin_head', array($this, 'style')); add_action('admin_init', array($this, 'settings')); add_action('admin_init', array($this, 'manage_capabilities')); // remove old settings. This has been deprecated in 1.2 delete_option('ljmm-content-default'); // maintenance mode add_action('get_header', array($this, 'maintenance')); add_action('admin_bar_menu', array($this, 'indicator'), 100); add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'action_links')); add_action('ljmm_before_mm', array($this, 'before_maintenance_mode')); // add shortcode support add_filter('ljmm_content', 'do_shortcode', 11); // add widget areas if enabled if (get_option('ljmm_add_widget_areas')) { $this->register_widget_sidebars(); } } /** * Settings page * * @since 1.0 */ public function ui() { add_submenu_page('options-general.php', __('Maintenance Mode', LJMM_PLUGIN_DOMAIN), __('Maintenance Mode', LJMM_PLUGIN_DOMAIN), $this->get_relevant_cap(), 'lj-maintenance-mode', array($this, 'settingsPage')); } /** * Inject styling for admin bar indicator * * @since 1.1 */ public function style() { echo ''; } /** * Settings * * @since 1.0 */ public function settings() { register_setting('ljmm', 'ljmm-enabled'); register_setting('ljmm', 'ljmm-content'); register_setting('ljmm', 'ljmm_add_widget_areas'); register_setting('ljmm', 'ljmm_analytify'); register_setting('ljmm', 'ljmm_code_snippet'); register_setting('ljmm', 'ljmm-site-title'); register_setting('ljmm', 'ljmm-roles'); register_setting('ljmm', 'ljmm-mode'); // set the content ljmm_set_content(); } /** * Settings page * * @since 1.0 */ public function settingsPage() { ?>

notify(); ?>
>


editor_content(); ?>
get_relevant_cap())) { return false; } if (!$enabled) { return false; } $is_enabled = get_option('ljmm-enabled'); $status = _x('Disabled', 'Admin bar indicator', LJMM_PLUGIN_DOMAIN); if ($is_enabled) { $status = _x('Enabled', 'Admin bar indicator', LJMM_PLUGIN_DOMAIN); } $indicatorClasses = $is_enabled ? 'ljmm-indicator ljmm-indicator--enabled' : 'ljmm-indicator'; $indicator = [ 'id' => 'ljmm-indicator', 'title' => ' ' . $status, 'parent' => false, 'href' => get_admin_url(null, 'options-general.php?page=lj-maintenance-mode'), 'meta' => [ 'title' => _x('Maintenance Mode', 'Admin bar indicator', LJMM_PLUGIN_DOMAIN), 'class' => $indicatorClasses, ] ]; $wp_admin_bar->add_node($indicator); } /** * Plugin action links * * @since 1.1 * @return mixed */ public function action_links($links) { $links[] = '' . _x('Settings', 'Plugin Settings link', LJMM_PLUGIN_DOMAIN) . ''; $links[] = '' . _x('Support', 'Plugin Support link', LJMM_PLUGIN_DOMAIN) . ''; return $links; } /** * Default site title for maintenance mode * * @since 2.0 * @return string */ public function site_title() { return apply_filters('ljmm_site_title', get_bloginfo('name') . ' - ' . __('Website Under Maintenance', LJMM_PLUGIN_DOMAIN)); } /** * Manage capabilities * * @since 2.0 */ public function manage_capabilities() { $wp_roles = get_editable_roles(); $all_roles = get_option('ljmm-roles'); // extra checks if ($wp_roles && is_array($wp_roles)) { foreach ($wp_roles as $role => $role_details) { $get_role = get_role($role); if (is_array($all_roles) && array_key_exists($role, $all_roles)) { $get_role->add_cap(LJMM_VIEW_SITE_CAP); } else { $get_role->remove_cap(LJMM_VIEW_SITE_CAP); } } } // administrator by default $admin_role = get_role('administrator'); $admin_role->add_cap(LJMM_VIEW_SITE_CAP); $admin_role->add_cap(LJMM_PLUGIN_CAP); } /** * Get mode * * @since 2.2 * @return int */ public function get_mode() { $mode = get_option('ljmm-mode'); if ($mode == 'cs') { // coming soon page return 200; } // maintenance mode return 503; } /** * Get content * * @since 2.3 * @return mixed */ public function get_content() { $get_content = get_option('ljmm-content'); $content = (!empty($get_content)) ? $get_content : ljmm_get_defaults('maintenance_message'); $content = apply_filters('wptexturize', $content); $content = apply_filters('wpautop', $content); $content = apply_filters('shortcode_unautop', $content); $content = apply_filters('prepend_attachment', $content); $content = apply_filters('wp_make_content_images_responsive', $content); $content = apply_filters('convert_smilies', $content); $content = apply_filters('ljmm_content', $content); // analytify support $analytify = $this->analytify_support(); // custom code snippets $code = get_option('ljmm_code_snippet'); // add widgets $widget_before = $this->widget_before(); $widget_after = $this->widget_after(); // add custom stylesheet $stylesheet = $this->custom_stylesheet(); return $analytify . $code . $stylesheet . $widget_before . $content . $widget_after; } /** * Get title * * @since 2.3 * @return string */ public function get_title() { $site_title = get_option('ljmm-site-title'); return $site_title ? $site_title : $this->site_title(); } /** * Get CSS file name * * @since 2.4 * @return string */ public function get_css_filename() { return apply_filters('ljmm_css_filename', 'maintenance.min.css'); } /** * Custom stylsheet * * @since 2.4 * @return void */ public function custom_stylesheet() { $stylesheet = ''; $url = $this->get_custom_stylesheet_url(); if ($url) { $stylesheet = ''; } return $stylesheet; } /** * Check for custom stylesheet * * @since 2.4 * @return boolean */ public function get_custom_stylesheet_url() { $stylesheet_url = false; $url_filename = $this->get_css_filename(); if (!validate_file($url_filename)) { $url = apply_filters('ljmm_css_url', get_stylesheet_directory() . '/' . $url_filename); if (file_exists($url)) { $stylesheet_url = $url; } } return $stylesheet_url; } /** * Editor content * * @since 2.4 * @return void */ public function editor_content() { $content = get_option('ljmm-content'); $editor_id = 'ljmm-content'; wp_editor($content, $editor_id); } /** * Before maintenance mode */ public function before_maintenance_mode() { // remove jetpack sharing remove_filter('the_content', 'sharing_display', 19); } /** * Is maintenance enabled? * * @since 2.3 * @return boolean */ public function enabled() { // enabled if (get_option('ljmm-enabled') || isset($_GET['ljmm']) && $_GET['ljmm'] == 'preview') { return true; } // disabled return false; } /** * Maintenance Mode * * @since 1.0 */ public function maintenance() { if (!$this->enabled()) { return false; } do_action('ljmm_before_mm'); // TML Compatibility if (class_exists('Theme_My_Login')) { if (Theme_My_Login::is_tml_page()) { return; } } if (!(current_user_can(LJMM_VIEW_SITE_CAP) || current_user_can('super admin')) || (isset($_GET['ljmm']) && $_GET['ljmm'] == 'preview')) { wp_die($this->get_content(), $this->get_title(), ['response' => $this->get_mode()]); } } /** * Get releavant cap * * This has been implementend due to lack of compatiblity with user role * and capabilities plugins that caused some users problems viewing the settings * page. So if user is a super admin, plugin will use 'delete_plugins' cap, otherwise * plugins' cap 'ljmm_control' * * @return void * @since 2.4.2 */ public function get_relevant_cap() { return is_super_admin() ? 'delete_plugins' : LJMM_PLUGIN_CAP; } /** * Notify if cache plugin detected * * @since 1.2 */ public function notify() { $cache_plugin_enabled = $this->cache_plugin(); if (!empty($cache_plugin_enabled)) { $class = 'error'; $message = $this->cache_plugin(); if (isset($_GET['settings-updated'])) { echo '

' . $message . '

'; } } } /** * Register widget sidebars * * @return void */ public function register_widget_sidebars() { if (function_exists('register_sidebar')) { register_sidebar([ 'id' => 'ljmm-before', 'name' => __('Maintenance mode - before content', LJMM_PLUGIN_DOMAIN), 'description' => __('', LJMM_PLUGIN_DOMAIN), 'before_widget' => "\n" . '
', 'after_widget' => '
' . "\n", ]); register_sidebar([ 'id' => 'ljmm-after', 'name' => __('Maintenance mode - after content', LJMM_PLUGIN_DOMAIN), 'description' => __('', LJMM_PLUGIN_DOMAIN), 'before_widget' => "\n" . '
', 'after_widget' => '
' . "\n", ]); } } /** * Widget * * @param string $id * @return void */ public function widget($id) { $widget = ''; if (get_option('ljmm_add_widget_areas')) { ob_start(); dynamic_sidebar(sprintf('ljmm-%s', $id)); $widget = ob_get_clean(); } return $widget; } /** * Widget before * * @return void */ public function widget_before() { return $this->widget('before'); } /** * Widget after * * @return void */ public function widget_after() { return $this->widget('after'); } /** * Analytify plugin support * * @since 2.4 * @return void */ public function analytify_support() { // Do we have a UA code from Analytify plugin? $analytify = ''; if (get_option('ljmm_analytify') && $ua_code = get_option('analytify_ua_code')) { // Yes, so we can generate the code to inject $analytify = << (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', '{$ua_code}', 'auto'); ga('send', 'pageview'); EOD; } return $analytify; } /** * Detect cache plugins * * @since 1.2 * @return string */ public function cache_plugin() { $message = ''; // add wp super cache support if (in_array('wp-super-cache/wp-cache.php', apply_filters('active_plugins', get_option('active_plugins')))) { $message = ljmm_get_defaults('warning_wp_super_cache'); } // add w3 total cache support if (in_array('w3-total-cache/w3-total-cache.php', apply_filters('active_plugins', get_option('active_plugins')))) { $message = ljmm_get_defaults('warning_w3_total_cache'); } // add comet cache support if (in_array('comet-cache/comet-cache.php', apply_filters('active_plugins', get_option('active_plugins')))) { $message = ljmm_get_defaults('warning_comet_cache'); } return $message; } } // initialise plugin. $ljMaintenanceMode = new ljMaintenanceMode();