Opciones → Modo Mantenimiento para empezar.
Version: 4.0
Author: acidc00l
Author URI: http://www.laliamos.com
*/
/*
----------------------------------------------------------------------------
____________________________________________________
| |
| AciD Maintenance Mode WP |
|____________________________________________________|
Copyright © acidc00l
'.__('Modo mantenimiento activo.',$this->g_info['ShortName']).'
' . __("Modo mantenimiento activo.",$this->g_info['ShortName']) . ' ' . $link_to_mamo_opt . '
|
COPTHTML('mamo_activate'), 0, 2)=='on'?'checked="checked"':'') . " />
|
g_info['ShortName']) . "' />
|
".__('Backtime',$this->g_info['ShortName']).":
,
,
".__('Por favor introduce el tiempo estimado que necesitará para el mantenimiento. Los marcadores de posición [date], [time], [days], [hours], y [minutes] se calculan sobre la base de estos campos.',$this->g_info['ShortName'])
. '
' . __('Ten en cuenta que el modo de mantenimiento no se desactivará automáticamente.',$this->g_info['ShortName']) . " |
|
".__('Utilice sólo HTML, PHP no permitido. Puede utilizar los marcadores de posición siguientes: [blogurl] (La URL de tu WEB), [blogtitle] (El Título de tu WEB)',$this->g_info['ShortName']).' '
. __('Además, los marcadores de posición siguientes se calculan en función del valor que ha introducido o modificado anteriormente en el campo «Backtime».',$this->g_info['ShortName'])
. '
|
".__('Select the theme for the maintenance mode splash page (check out the screenshots in the plugin directory for a preview).',$this->g_info['ShortName']).'
'.
__('If you select «Use 503.php from theme folder», the plugin will use the file \'503.php\' from the current theme directory for the splash page. If there is no \'503.php\', it will use the default theme.',$this->g_info['ShortName']).' '.
__('So this option will help using a customized splash page without the fear of losing this page when updating the plugin.',$this->g_info['ShortName']).'
'
. __('Has diseñado un tema hermoso para la página de bienvenida y lo quieres compartir? Por favor, sigue este enlace y contacta conmigo para añadirlo al plugin.',$this->g_info['ShortName'])
."
' . __('By default, only logged in administrators (more exactly: users with the',$this->g_info['ShortName']) .' ' . __('capability',$this->g_info['ShortName']) . ' ' . __('«manage_options») do have full access to the blog\'s front-end and will not see any splash page when the maintenance mode is activated. You can change this here:',$this->g_info['ShortName']) .'
'.__('Access to blog front-end with capability (role)',$this->g_info['ShortName']).": " . '' . __('By default, anyone who is logged in to the blog (more exactly: users with the',$this->g_info['ShortName']) .' ' . __('capability',$this->g_info['ShortName']) . ' ' . __('«read») does have access to the WordPress administration (back-end) when the maintenance mode is activated. You can restrict this here:',$this->g_info['ShortName']) .'
'.__('Access to administration/back-end with capability (role)',$this->g_info['ShortName']).": '); $this->AddContentMain(__('Paths to be still accessable',$this->g_info['ShortName']), "
".__('Enter paths that shall be excluded and still be accessable. Separate multiple paths with line breaks.
Example: If you want to exclude http://site.com/about/, then enter /about/.
Hint: If you want to exclude the home page, enter [HOME].',$this->g_info['ShortName'])."
COPTHTML('mamo_include_feeds')=='1'?'checked="checked"':'') . " />
COPTHTML('mamo_include_trackbacks')=='1'?'checked="checked"':'') . " />
COPTHTML('mamo_include_xmlrpc')=='1'?'checked="checked"':'') . " />
"); $this->AddContentMain(__('Miscellaneous',$this->g_info['ShortName']), "COPTHTML('mamo_503_splashpage')=='1'?'checked="checked"':'') . " />
"); // Sidebar, we can also add individual items... $this->PrepareStandardSidebar(); $this->GetGeneratedOptionsPage(); } /** * Apply HTTP header */ function http_header_unavailable() { header('HTTP/1.0 503 Service Unavailable'); $calctimes_arr = $this->calculate_times(); $backtime = intval($calctimes_arr['minutes_total']); if ( $backtime > 1 ) { # Apply return-after only if value > 0. Also, intval returns 0 on failure; empty arrays and objects return 0, non-empty arrays and objects return 1 header('Retry-After: ' . $backtime * 60 ); } } /** * Convert option prior to save ("COPTSave"). * !!!! This function is used by the framework class !!!! */ function COPTSave($optname) { switch ($optname) { case 'mamo_excludedpaths': return $this->LinebreakToWhitespace($_POST[$optname]); case ($optname=='mamo_backtime_days' || $optname=='mamo_backtime_hours' || $optname=='mamo_backtime_mins'): // *********************************** // Convert input days/hours/minutes to avoid values like: 10 days, 28 hours, 800 seconds // *********************************** # build array $times_post = array(); $times_post['mamo_backtime_days'] = $_POST['mamo_backtime_days']; $times_post['mamo_backtime_hours'] = $_POST['mamo_backtime_hours']; $times_post['mamo_backtime_mins'] = $_POST['mamo_backtime_mins']; # clean values foreach ($times_post as $loop_name => $loop_val) { $result = $loop_val; $result = preg_replace('/[^0-9]/','',$result); // Strip all chars except numbers if (($result == '') or (intval($result) === false)) $result = '0'; $times_post[$loop_name] = $result; } # calculate number of minutes $res_minutes = 0; $res_minutes = $res_minutes + $times_post['mamo_backtime_days'] * (24 * 60); $res_minutes = $res_minutes + $times_post['mamo_backtime_hours'] * 60; $res_minutes = $res_minutes + $times_post['mamo_backtime_mins']; # calculate real days/hours/minutes to avoid values like: 10 days, 28 hours, 800 seconds $duration_arr = $this->duration($res_minutes); $times_post['mamo_backtime_days'] = $duration_arr['days']; $times_post['mamo_backtime_hours'] = $duration_arr['hours']; $times_post['mamo_backtime_mins'] = $duration_arr['mins']; return $times_post[$optname]; default: if (isset($_POST[$optname])) { return $_POST[$optname]; } else { return; } } // switch } /** * Convert option before HTML output ("COPTHTML"). * *NOT* used by the framework class */ function COPTHTML($optname) { $optval = $this->g_opt[$optname]; switch ($optname) { case 'mamo_excludedpaths': return $this->WhitespaceToLinebreak($optval); case 'mamo_pagetitle': return htmlspecialchars(stripslashes($optval)); case 'mamo_pagemsg': return htmlspecialchars(stripslashes($optval)); default: return $optval; } // switch } /** * Calculates date, time and number of minutes until the maintenance mode is supposed to be finished */ function calculate_times() { $delay = 0; $delay = $delay + ( intval($this->g_opt['mamo_backtime_days']) * 24 * 60 ); $delay = $delay + ( intval($this->g_opt['mamo_backtime_hours']) * 60 ); $delay = $delay + ( intval($this->g_opt['mamo_backtime_mins']) ); $intTimeActivated = intval(substr($this->g_opt['mamo_activate'], 3, 99)); // get the activation timestamp from the plugin option $intTimeFinished = $intTimeActivated + ($delay*60); // calculate the time when maintenance is supposed to be finished. $intCurrentTime = current_time('timestamp'); // get the current time, it considers GMT WordPress option settings $strTryBackDate = date_i18n( get_option('date_format'), $intTimeFinished ); // convert date into string format according to option settings $strTryBackTime = date_i18n( get_option('time_format'), $intTimeFinished ); // convert date into string format according to option settings $intTimeDelta_Seconds = $intTimeFinished - $intCurrentTime; // number of seconds until maintenance is supposed to be finished. $intTimeDelta_Minutes = round(($intTimeDelta_Seconds/(60)), 0); // convert into minutes $intTimeDelta_Hours = round(($intTimeDelta_Seconds/(60*60)), 1); // convert into hours if ( $intTimeDelta_Minutes < 0 ) { // if time exceeded, we display "0". $intTimeDelta_Minutes = 0; $intTimeDelta_Hours = 0; } $arrDuration = $this->duration($intTimeDelta_Minutes); // Converts number of minutes to days, hours and minutes // Output in array return array( 'date'=> $strTryBackDate, 'time'=> $strTryBackTime, 'minutes_total' => $intTimeDelta_Minutes, 'hours_total' => $intTimeDelta_Hours, 'calc_days' => $arrDuration['days'], 'calc_hours' => $arrDuration['hours'], 'calc_mins' => $arrDuration['mins'], ); } /** * Converts number of minutes to days, hours and minutes. For example '35390' results in '24 days, 13 hours, 50 minutes' */ function duration($minutes) { $minutes = intval($minutes); $vals_arr = array( 'days' => (int) ($minutes / (24*60) ), 'hours' => $minutes / 60 % 24, 'mins' => $minutes % 60); $return_arr = array(); $is_added = false; foreach ($vals_arr as $unit => $amount) { $return_arr[$unit] = 0; if ( ($amount > 0) || $is_added ) { $is_added = true; $return_arr[$unit] = $amount; } } return $return_arr; } /** * Provides the the maintenance mode message for the theme incl. replacement of placeholders. */ add_action('wp_footer', 'seowatcher_supportlink00'); function mamo_template_tag_message() { $mamo_msg = stripslashes($this->g_opt['mamo_pagemsg']); $mamo_msg = str_replace('[blogurl]', get_option('home'), $mamo_msg); $mamo_msg = str_replace('[blogtitle]', get_bloginfo('name'), $mamo_msg); $calctimes_arr = $this->calculate_times(); if ($calctimes_arr['minutes_total'] == 0) { $mamo_msg = str_replace('[until]', $this->g_opt['mamo_placeholder_until_exc'], $mamo_msg); } else { $mamo_msg = str_replace('[until]', $this->g_opt['mamo_placeholder_until'], $mamo_msg); } $mamo_msg = str_replace('[date]', $calctimes_arr['date'], $mamo_msg); $mamo_msg = str_replace('[time]', $calctimes_arr['time'], $mamo_msg); $mamo_msg = str_replace('[days]', $calctimes_arr['calc_days'], $mamo_msg); $mamo_msg = str_replace('[hours]', $calctimes_arr['calc_hours'], $mamo_msg); $mamo_msg = str_replace('[minutes]', $calctimes_arr['calc_mins'], $mamo_msg); return $mamo_msg; } /** * Provides the the login/logout menu for the theme */ function mamo_template_tag_login_logout() { global $user_ID, $wp_version, $status; get_currentuserinfo(); $returnval = ''; // Get URLs for login/logout // wp_logout_url() does not work here for some unknown reason... $loginurl = site_url('wp-login.php', 'login'); $logouturl = wp_nonce_url( site_url('wp-login.php?action=logout', 'login'), 'log-out' ); $adminurl = admin_url(); if ($user_ID) { if ($status == 'noaccesstobackend' ) { $returnval .= __('(Access to administration denied by administrator)',$this->g_info['ShortName']); } else { $returnval .= '' . __('Administration',$this->g_info['ShortName']) . ''; } $returnval .= ' | ' . __('Log Out',$this->g_info['ShortName']) . ''; } else { $returnval .= '' . __('Log In',$this->g_info['ShortName']) . ''; } return $returnval; } } // class if( !isset($myMaMo) ) { // Create a new instance of your plugin that utilizes the WordpressPluginFramework and initialize the instance. $myMaMo = new MaintenanceMode(); $myMaMo->Initialize( // 1. We define the plugin information now and do not use get_plugin_data() due to performance. array( # Plugin name 'Name' => 'Modo Mantenimiento', # Author of the plugin 'Author' => 'acidc00l & Michael Wöhrer', # Authot URI 'AuthorURI' => 'http://www.laliamos.com/', # Plugin URI 'PluginURI' => 'http://www.laliamos.com/obl-blog/wordpress-modo-mantenimiento-v6-0-spanish-plugin-wordpress/', # Support URI: E.g. WP or plugin forum, wordpress.org tags, etc. 'SupportURI' => 'http://www.laliamos.com/contacto/', # Name of the options for the options database table 'OptionName' => 'plugin_maintenance-mode', # Old option names to delete from the options table; newest last please 'DeleteOldOpt' => array('plugin_maintenancemode', 'plugin_maintenancemode2','plugin_maintenance-mode_5'), # Plugin version 'Version' => '3.0', # First plugin version of which we do not reset the plugin options to default; # Normally we reset the plugin's options after an update; but if we for example # update the plugin from version 2.3 to 2.4 und did only do minor changes and # not any option modifications, we should enter '2.3' here. In this example # options are being reset to default only if the old plugin version was < 2.3. 'UseOldOpt' => '1.0', # Copyright year(s) 'CopyrightYear' => '2011', # Minimum WordPress version 'MinWP' => '3.1', # Do not change; full path and filename of the plugin 'PluginFile' => __FILE__, # Used for language file, nonce field security, etc. 'ShortName' => 'modo-mantenimiento', ), // 2. We define the plugin option names and the initial options array( 'mamo_activate' => 'off', 'mamo_excludedpaths' => '', 'mamo_include_feeds' => '', 'mamo_include_trackbacks' =>'', 'mamo_include_xmlrpc' => '', 'mamo_backtime_days' => '0', 'mamo_backtime_hours' => '1', 'mamo_backtime_mins' => '0', 'mamo_pagetitle' => 'Modo Mantenimiento', 'mamo_pagemsg' => '[blogtitle] se encuentra actualmente en mantenimiento programado.
' . "\n
\n" . 'Por favor, inténtelo de nuevo en [until].
Disculpa las molestias.
', 'mamo_placeholder_until' => 'Vuelve en [days] días, [hours] horas, y [minutes] minutos