'; $html .= ''; echo $html; } function plugin_maint_section_text() { echo '

Set Maintenance Mode

'; } function plugin_maint_options_validate($input) { $options = get_option('plugin_options'); return $options; } add_action('wp_loaded', 'maintenance_mode'); function maintenance_mode(){ $options = get_option( 'plugin_options' ); $checked = ( isset($options['maint_checkbox']) && $options['maint_checkbox'] == 1) ? 1 : 0; global $pagenow; if( $checked == 1 ){ define('IN_MAINTENANCE', true); } else { define('IN_MAINTENANCE', false); } if( defined( 'IN_MAINTENANCE' ) && IN_MAINTENANCE && $pagenow !== 'wp-login.php' && ! is_user_logged_in() ) { if ( file_exists( plugin_dir_path( __FILE__ ) . '/maintenance.php' ) ) { require_once( plugin_dir_path( __FILE__ ) . '/maintenance.php' ); } die(); } };