function generate_plugin_page() { global $maintenance_variable; $mt_option = mt_get_plugin_options(true); ?> <div id="maintenance-options" class="wrap"> <form method="post" action="" enctype="multipart/form-data" name="options-form"> <?php wp_nonce_field('maintenance_edit_post', 'maintenance_nonce'); ?> <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <div class="postbox-container header-container column-1 normal"> <h1><?php _e('Maintenance', 'maintenance'); ?> <input type="checkbox" id="state" name="lib_options[state]" <?php checked($mt_option['state'], 1); ?> /> <?php submit_button(__('Save changes', 'maintenance'), 'primary'); ?> </h1> </div> <div class="clear"></div> <div id="poststuff"> <div class="metabox-holder"> <div id="all-fileds" class="postbox-container column-1 normal"> <?php do_meta_boxes($maintenance_variable->options_page, 'normal', null); ?> <?php do_meta_boxes($maintenance_variable->options_page, 'advanced', null); ?> </div> <div id="promo" class="postbox-container column-2 normal"> <?php do_meta_boxes($maintenance_variable->options_page, 'side', null); ?> </div> </div> <?php submit_button(__('Save changes', 'maintenance'), 'primary'); ?> </div> </form> </div> <?php }
function maintenance_update() { $options = mt_get_plugin_options(); $settings = get_option('maintenance_options'); update_option('maintenance_db_version', MAINTENANCE_DB_VERSION); foreach ($options as $key => $value) { if (!isset($settings[$key])) { $settings[$key] = $value; } } update_option('maintenance_options', $options); }
function bwp_is_maintenance_on() { // this is from the Maintenance plugin, function `load_maintenance_page` in // `load/functions.php` if (function_exists('mt_get_plugin_options') && !is_user_logged_in()) { $mt_options = mt_get_plugin_options(true); if ($mt_options['state']) { if (!empty($mt_options['expiry_date_start']) && !empty($mt_options['expiry_date_end'])) { $current_time = strtotime(current_time('mysql', 1)); $start = strtotime($mt_options['expiry_date_start']); $end = strtotime($mt_options['expiry_date_end']); if ($current_time < $start || $current_time >= $end && !empty($mt_options['is_down'])) { return false; } } return true; } } }
function mt_admin_bar() { add_action('admin_bar_menu', 'maintenance_add_toolbar_items', 100); if (!is_super_admin()) { $mt_options = mt_get_plugin_options(true); if (isset($mt_options['admin_bar_enabled']) && is_user_logged_in()) { add_filter('show_admin_bar', '__return_true'); } else { add_filter('show_admin_bar', '__return_false'); } } }
function maintenance_add_toolbar_items() { global $wp_admin_bar, $wpdb; $mt_options = mt_get_plugin_options(true); $check = ''; if (!is_super_admin() || !is_admin_bar_showing()) { return; } $url_to = admin_url('admin.php?page=maintenance'); if ($mt_options['state']) { $check = 'On'; } else { $check = 'Off'; } $wp_admin_bar->add_menu(array('id' => 'maintenance_options', 'title' => __('Maintenance', 'maintenance') . ' is ' . $check, 'href' => $url_to, 'meta' => array('title' => __('Maintenance', 'maintenance') . ' is ' . $check))); }
<?php $mess_arr = array(); $ebody_class = null; $mess_arr = get_custom_login_code(); if (!empty($mess_arr[0])) { $ebody_class = 'error'; } $mt_options = mt_get_plugin_options(true); ?> <!DOCTYPE html> <!--[if IE 7]> <html class="ie ie7" <?php language_attributes(); ?> > <![endif]--> <!--[if IE 8]> <html class="ie ie8" <?php language_attributes(); ?> > <![endif]--> <!--[if !(IE 7) | !(IE 8) ]><!--> <html <?php language_attributes(); ?> > <!--<![endif]--> <head> <meta charset="<?php
function get_headers_503() { $mt_options = mt_get_plugin_options(true); nocache_headers(); if (isset($mt_options['503_enabled'])) { $protocol = "HTTP/1.0"; if ("HTTP/1.1" == $_SERVER["SERVER_PROTOCOL"]) { $protocol = "HTTP/1.1"; } header("{$protocol} 503 Service Unavailable", true, 503); $vCurrDate_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($mt_options['expiry_date_end'])) { $vdate_end = $mt_options['expiry_date_end']; } if (!empty($mt_options['expiry_time_end'])) { $vtime_end = $mt_options['expiry_time_end']; } if ($mt_options['state'] && (!empty($mt_options['expiry_date_end']) && !empty($mt_options['expiry_time_end']))) { $date_concat = $vdate_end . ' ' . $vtime_end; $vCurrDate = strtotime($date_concat); if (strtotime(current_time('mysql', 0)) < $vCurrDate) { header("Retry-After: " . gmdate("D, d M Y H:i:s", $vCurrDate)); } else { header("Retry-After: 3600"); } } else { header("Retry-After: 3600"); } } }