Plugin Directory

Changeset 2211545


Ignore:
Timestamp:
12/13/2019 11:58:47 AM (6 years ago)
Author:
wordpresssimpletools
Message:

Aggiornamento 13/12/19

Location:
wpsimpletools-maintenance-mode/trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • wpsimpletools-maintenance-mode/trunk/maintenance.php

    r2210036 r2211545  
    77body {
    88    text-align: center;
    9     padding: 5%;
     9    padding: 4%;
    1010    background-color: #eee;
    1111}
     
    1616
    1717body {
    18     font: 20px Helvetica, sans-serif;
     18    font: 28px Helvetica, sans-serif;
    1919    color: #333;
     20    line-height: 150%;
    2021}
    2122
     
    3132<body>
    3233    <article>
    33         <h1><?php _e('We\'ll be back soon!', 'wpsimpletools-maintenance-mode');?></h1>
     34        <h1><?php echo esc_attr(get_option('pageTitle'))  ?></h1>
    3435        <div>
    35             <p>
    36                 <?php _e('Sorry for the inconvenience but we\'re performing some maintenance at the moment.', 'wpsimpletools-maintenance-mode');?><br />
    37                 <?php _e('We\'ll be back online shortly!', 'wpsimpletools-maintenance-mode');?>
    38             </p>
    39             <p>&mdash; <?php bloginfo('name') ?></p>
     36            <p><?php echo esc_attr(get_option('pageText'))  ?></p>
     37            <p><?php bloginfo('name') ?></p>
    4038        </div>
    4139    </article>
  • wpsimpletools-maintenance-mode/trunk/readme.txt

    r2209421 r2211545  
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
    1111
    12 Simple yet complete maintenance mode plugin
     12Simple yet complete maintenance mode plugin.
    1313
    1414== Description ==
  • wpsimpletools-maintenance-mode/trunk/wpsimpletools-maintenance.php

    r2210150 r2211545  
    1414}
    1515
    16 //
    17 function wpst_m_init() {
     16include_once 'wpsimpletools-maintenance-admin.php';
    1817
    19     // load_plugin_textdomain('wpsimpletools-maintenance-mode', false, basename(dirname(__FILE__)) . '/languages/');
    20 }
    21 add_action('plugins_loaded', 'wpst_m_init');
     18// function wpst_m_init() {
    2219
    23 //
    24 function wpst_m_options_page_body() {
    25 
    26     $enabled = esc_attr(get_option('enabled'));
    27     $redirect_url = esc_attr(get_option('url'));
    28     $maintenancePage = esc_attr(get_option('maintenancePage'));
    29    
    30     ?>
    31 
    32 
    33 <script type="text/javascript">
    34 
    35 jQuery(function($) {
    36 
    37     $('select#enabled').on('change', function() {
    38         manageForm()
    39     });
    40 
    41     $('select#maintenancePage').on('change', function() {
    42         manageForm()
    43     });
    44    
    45     function manageForm(){
    46 
    47         var enabled = $('select#enabled').val();
    48         console.log('enabled: ' + enabled);
    49 
    50         var maintenancePage = $('select#maintenancePage').val();
    51         console.log('maintenancePage: ' + maintenancePage);
    52    
    53         if(enabled > 0){
    54             $('select#maintenancePage').prop('disabled', false);
    55             if(maintenancePage == 'CUSTOM')
    56                 $('input#url').prop('disabled', false);
    57             else
    58                 $('input#url').prop('disabled', true);
    59         }else{
    60             $('select#maintenancePage').prop('disabled', true);
    61             $('input#url').prop('disabled', true);
    62         }
    63    
    64     }
    65 
    66     // onload
    67     manageForm();
    68    
    69 });
    70 
    71 </script>
    72 
    73 <div class="wrap">
    74     <h2>WpSimpleTools Maintenance Mode</h2>
    75 
    76     <form method="post" action="options.php">
    77             <?php settings_fields( 'wpsimpletools-manteinance' ); ?>
    78             <?php do_settings_sections( 'wpsimpletools-manteinance' ); ?>
    79             <table class="form-table">
    80             <tr valign="top">
    81                 <th scope="row"><?php _e('Enabled', 'wpsimpletools-maintenance-mode');?></th>
    82                 <td><select name="enabled" id="enabled">
    83                         <option <?php if(!$enabled) { echo 'selected="selected" '; } ?> value="0">No</option>
    84                         <option <?php if($enabled) { echo 'selected="selected" '; } ?> value="1" style="color: red;">Yes</option>
    85                 </select></td>
    86             </tr>
    87             <tr valign="top">
    88                 <th scope="row"><?php _e('Maintenance mode page', 'wpsimpletools-maintenance-mode');?></th>
    89                 <td><select name="maintenancePage" id="maintenancePage">
    90                         <option <?php if($maintenancePage == 'DEFAULT') { echo 'selected="selected" '; } ?> value="DEFAULT">Default page</option>
    91                         <option <?php if($maintenancePage == 'CUSTOM') { echo 'selected="selected" '; } ?> value="CUSTOM">Custom URL</option>
    92                 </select></td>
    93             </tr>
    94             <tr valign="top">
    95                 <th scope="row"><?php _e('URL', 'wpsimpletools-maintenance-mode');?></th>
    96                 <td><input type="text" name="url" id="url" value="<?php echo $redirect_url ?>" size="40" /></td>
    97             </tr>
    98         </table>
    99             <?php submit_button(); ?>
    100         </form>
    101 </div>
    102 <?php
    103 }
    104 
    105 function wpst_m_options_page() {
    106 
    107     if (function_exists('add_options_page'))
    108         add_options_page(__('Maintenance mode', 'wpsimpletools-maintenance-mode'), __('Maintenance mode', 'wpsimpletools-maintenance-mode'), 'manage_options', 'opts.php', 'wpst_m_options_page_body');
    109 }
    110 
    111 function wpst_m_register_settings() {
    112 
    113     register_setting('wpsimpletools-manteinance', 'enabled');
    114     register_setting('wpsimpletools-manteinance', 'maintenancePage');
    115     register_setting('wpsimpletools-manteinance', 'url');
    116 }
     20// }
     21// add_action('plugins_loaded', 'wpst_m_init');
    11722
    11823function wpst_m_process_redirect() {
     
    12328   
    12429    $url_parts = explode('/', $_SERVER['REQUEST_URI']);
    125    
    126     echo $_SERVER['REQUEST_URI'];
    12730   
    12831    if ($enabled) {
     
    15053    }
    15154}
    152 
    153 function wpst_m_admin_notice() {
    154 
    155     $enabled = esc_attr(get_option('enabled'));
    156     if ($enabled) {
    157         $class = 'notice notice-error';
    158         $message = __('Maintenance mode is active!', 'wpsimpletools-maintenance-mode');
    159         printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), esc_html($message));
    160     }
    161 }
     55add_action('send_headers', 'wpst_m_process_redirect', 1);
    16256
    16357function wpst_m_activation() {
    16458
    165     // Initialize some stuff for my_plugin
    16659}
     60register_activation_hook(__FILE__, 'wpst_m_activation');
    16761
    16862function wpst_m_deactivation() {
     
    17266    delete_option('url');
    17367}
    174 
    175 add_action('admin_menu', 'wpst_m_options_page');
    176 add_action('admin_init', 'wpst_m_register_settings');
    177 add_action('send_headers', 'wpst_m_process_redirect', 1);
    178 add_action('admin_notices', 'wpst_m_admin_notice');
    179 
    180 register_activation_hook(__FILE__, 'wpst_m_activation');
    18168register_deactivation_hook(__FILE__, 'wpst_m_deactivation');
Note: See TracChangeset for help on using the changeset viewer.