deleteCache(); } } function slim_maintenance_mode_on_deactivation() { if ( !current_user_can( 'activate_plugins' ) ) return; $plugin = isset( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : ''; check_admin_referer( "deactivate-plugin_{$plugin}" ); // Clear Cachify Cache if ( has_action('cachify_flush_cache') ) { do_action('cachify_flush_cache'); } // Clear LiteSpeed Cache if ( has_action('litespeed_purge_all') ) { do_action( 'litespeed_purge_all' ); } // Clear Super Cache if ( function_exists( 'wp_cache_clear_cache' ) ) { ob_end_clean(); wp_cache_clear_cache(); } // Clear W3 Total Cache if ( function_exists( 'w3tc_pgcache_flush' ) ) { ob_end_clean(); w3tc_pgcache_flush(); } // Clear WP-Rocket Cache if ( function_exists( 'rocket_clean_domain' ) ) { rocket_clean_domain(); } // Clear WP Fastest Cache if ( isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache') ) { $GLOBALS['wp_fastest_cache']->deleteCache(); } } register_activation_hook( __FILE__, 'slim_maintenance_mode_on_activation' ); register_deactivation_hook( __FILE__, 'slim_maintenance_mode_on_deactivation' ); /** * Localization */ load_plugin_textdomain( 'slim-maintenance-mode', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); /** * Alert message when active */ function slim_maintenance_mode_admin_notices() { echo '

' . __( 'Maintenance mode is active!', 'slim-maintenance-mode' ) . ' ' . __( 'Deactivate it, when work is done.', 'slim-maintenance-mode' ) . '

'; } if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) add_action( 'network_admin_notices', 'slim_maintenance_mode_admin_notices' ); add_action( 'admin_notices', 'slim_maintenance_mode_admin_notices' ); add_filter( 'login_message', function() { return '
' . __( 'Maintenance mode is active!', 'slim-maintenance-mode' ) . '
'; } ); /** * Maintenance message when active */ function slim_maintenance_mode() { nocache_headers(); if ( !current_user_can('activate_plugins') || !is_user_logged_in() ) { wp_die( '

' . __( 'Maintenance', 'slim-maintenance-mode' ) . '

' . __( 'Please check back soon.', 'slim-maintenance-mode' ) . '

', __( 'Maintenance', 'slim-maintenance-mode' ), array('response' => '503')); } } add_action('parse_request', 'slim_maintenance_mode'); /** * Deactivate feeds when plugin is active */ function slim_maintenance_mode_disable_feed() { wp_die( __( 'Maintenance', 'slim-maintenance-mode' ) . '. ' .__( 'Please check back soon.', 'slim-maintenance-mode' ), __( 'Maintenance', 'slim-maintenance-mode' ), array('response' => '503') ); } add_action('do_feed', 'slim_maintenance_mode_disable_feed', 1); add_action('do_feed_rdf', 'slim_maintenance_mode_disable_feed', 1); add_action('do_feed_rss', 'slim_maintenance_mode_disable_feed', 1); add_action('do_feed_rss2', 'slim_maintenance_mode_disable_feed', 1); add_action('do_feed_atom', 'slim_maintenance_mode_disable_feed', 1); add_action('do_feed_rss2_comments', 'slim_maintenance_mode_disable_feed', 1); add_action('do_feed_atom_comments', 'slim_maintenance_mode_disable_feed', 1); ?>