Plugin Directory

Changeset 1409605


Ignore:
Timestamp:
05/03/2016 12:56:01 PM (10 years ago)
Author:
fugudesign
Message:
  • Fix bug with data saving
  • Fix bug with HTML encoding
  • Fix bug with files generation
  • Fix a very persistent bug with settings migration
Location:
maintenance-switch
Files:
47 added
13 edited

Legend:

Unmodified
Added
Removed
  • maintenance-switch/trunk/admin/class-maintenance-switch-admin.php

    r1404482 r1409605  
    2424
    2525    /**
     26     * The Instance of the main plugin class.
     27     *
     28     * @since    1.3.3
     29     * @access   protected
     30     * @var      object    $plugin    The instance of the main class
     31     */
     32    protected $plugin;
     33   
     34    /**
    2635     * The ID of this plugin.
    2736     *
     
    4857     * @param      string    $version    The version of this plugin.
    4958     */
    50     public function __construct( $plugin_name, $version ) {
    51 
    52         $this->plugin_name = $plugin_name;
    53         $this->version = $version;
     59    public function __construct( &$plugin ) {
     60        $this->plugin = $plugin;
     61        $this->plugin_name = $plugin->get_plugin_name();
     62        $this->version = $plugin->get_version();
    5463    }
    5564   
     
    103112    public function add_plugin_admin_menu() {
    104113       
    105         // Get main controller
    106         $plugin = new Maintenance_Switch();
    107        
    108114        // Get the view
    109115        include_once( 'views/maintenance-switch-admin-display.php' );
    110         $view = new Maintenance_Switch_Admin_Display( $plugin );
     116        $view = new Maintenance_Switch_Admin_Display( $this->plugin );
    111117       
    112118        // Adds option page in admin settings
  • maintenance-switch/trunk/admin/css/maintenance-switch-admin.css

    r1404661 r1409605  
     1input.readonly, input[readonly],
     2textarea.readonly, textarea[readonly] {
     3  color: #999; }
     4
    15textarea {
    26  width: 95%; }
  • maintenance-switch/trunk/admin/css/maintenance-switch-admin.scss

    r1404661 r1409605  
    11// Settings form
     2
     3input.readonly, input[readonly],
     4textarea.readonly, textarea[readonly] {
     5    color:#999;
     6}
    27
    38textarea {
  • maintenance-switch/trunk/admin/js/maintenance-switch-admin.js

    r1404482 r1409605  
    2121        $('#ms_use_theme').on('change', function(e){
    2222            var checked = this.checked;
    23             $('#ms_page_html').prop('disabled', checked);
     23            $('#ms_page_html').prop('readonly', checked);
    2424        });
    2525       
     
    3737            }
    3838        });
     39       
     40        $('input[data-msg]').on('click', function(e) {
     41            var message = $(this).data('msg');
     42            if ( !confirm( message ) )
     43                e.preventDefault();
     44        });
    3945    });
    4046
  • maintenance-switch/trunk/admin/views/maintenance-switch-admin-display.php

    r1404661 r1409605  
    4343     * @since    1.3.0
    4444     */
    45     public function __construct( $plugin ) {
     45    public function __construct( &$plugin ) {
    4646       
    4747        $this->plugin = $plugin;
     48       
     49        $this->plugin->admin_action_request();
     50       
    4851        $this->maintenance_switch_settings = $plugin->get_the_settings();
    4952       
    50         $this->request();
    51        
    5253        add_action( 'admin_init', array( $this, 'maintenance_switch_page_init' ) );
    5354    }
    5455   
    5556    /**
    56      * Function to execute according to the submit action
    57      *
    58      * @since    1.3.0
    59      */
    60     public function request() {
    61        
    62         if ( !empty( $_POST[ 'action' ] ) ) :
    63             switch( $_POST[ 'action' ] ) :
    64                
    65                 case 'restore-settings':    $this->plugin->restore_default_settings();
    66                     wp_redirect( admin_url( 'options-general.php?page=' . $this->plugin->get_plugin_name() ) ); break;
    67                    
    68                 case 'restore-html':        $this->plugin->restore_html_setting();
    69                     wp_redirect( admin_url( 'options-general.php?page=' . $this->plugin->get_plugin_name() ) );break;
    70                    
    71                 case 'create-theme-file':   $this->plugin->create_theme_file();
    72                     wp_redirect( admin_url( 'options-general.php?page=' . $this->plugin->get_plugin_name() ) );break;
    73                
    74                 case 'delete-theme-file':   $this->plugin->delete_theme_file();
    75                     wp_redirect( admin_url( 'options-general.php?page=' . $this->plugin->get_plugin_name() ) );break;
    76                
    77             endswitch;
    78         endif;
    79     }
    80    
    81     /**
    8257     * Display the admin settings view.
    8358     * WP Settings API
     
    8661     */
    8762    public function maintenance_switch_create_admin_page() {
    88         $plugin_settings_url = admin_url( 'options-general.php?page=' . $this->plugin->get_plugin_name() );
     63        $plugin_settings_url = admin_url( 'options-general.php?page=' . MS_SLUG );
    8964        ?>
    9065
     
    9368            <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
    9469
    95             <form method="POST" action="options.php">
     70            <form id="settings-form" method="POST" action="options.php">
    9671                <?php
    9772                    settings_fields( 'maintenance_switch' );
     
    10782           
    10883            <form id="restore-settings-form" action="<?php echo $plugin_settings_url; ?>" method="POST" class="inline-form">
    109                 <input type="hidden" name="action" value="restore-settings" />
    110                 <?php submit_button( __('Restore all settings', MS_SLUG), 'secondary', 'submit', false ); ?>
     84                <input type="hidden" name="action" value="restore_settings" />
     85                <?php submit_button( __('Restore all settings', MS_SLUG), 'secondary', 'submit', false, array( 'data-msg' => __( 'Are you sure you want to retore all the default settings?', MS_SLUG ) ) ); ?>
    11186            </form>
    11287           
    11388            <form id="restore-html-form" action="<?php echo $plugin_settings_url; ?>" method="POST" class="inline-form">
    114                 <input type="hidden" name="action" value="restore-html" />
    115                 <?php submit_button( __('Restore page HTML', MS_SLUG), 'secondary', 'submit', false ); ?>
     89                <input type="hidden" name="action" value="restore_html" />
     90                <?php submit_button( __('Restore page HTML', MS_SLUG), 'secondary', 'submit', false, array( 'data-msg' => __( 'Are you sure you want to retore the default HTML code?', MS_SLUG ) ) ); ?>
    11691            </form>
    11792           
    11893            <?php if ( ! $this->plugin->theme_file_exists() ) : ?>
    11994            <form id="create-theme-file" action="<?php echo $plugin_settings_url; ?>" method="POST" class="inline-form">
    120                 <input type="hidden" name="action" value="create-theme-file" />
    121                 <?php submit_button( __('Create file in the theme', MS_SLUG), 'secondary', 'submit', false ); ?>
     95                <input type="hidden" name="action" value="create_theme_file" />
     96                <?php submit_button( __('Create file in the theme', MS_SLUG), 'secondary', 'submit', false, array( 'data-msg' => __( 'Are you sure you want to create the file in your theme?', MS_SLUG ) ) ); ?>
    12297            </form>
    12398            <?php else : ?>
    12499            <form id="delete-theme-file" action="<?php echo $plugin_settings_url; ?>" method="POST" class="inline-form">
    125                 <input type="hidden" name="action" value="delete-theme-file" />
    126                 <?php submit_button( __('Delete file in the theme', MS_SLUG), 'secondary', 'submit', false ); ?>
     100                <input type="hidden" name="action" value="delete_theme_file" />
     101                <?php submit_button( __('Delete file in the theme', MS_SLUG), 'secondary', 'submit', false, array( 'data-msg' => __( 'Are you sure you want to delete the file in your theme?', MS_SLUG ) ) ); ?>
    127102            </form>
    128103            <?php endif; ?>
     
    229204       
    230205        if ( isset( $input['ms_use_theme'] ) ) {
    231             $sanitary_values['ms_use_theme'] = $input['ms_use_theme'];
     206            $sanitary_values['ms_use_theme'] = (int) $input['ms_use_theme'];
    232207        }
    233208
     
    312287     */
    313288    public function ms_page_html_display() {
     289        $theme_file_exists = $this->plugin->theme_file_exists();
    314290        printf(
    315             '<textarea id="ms_page_html" class="large-text" cols="70" rows="20" name="maintenance_switch_settings[ms_page_html]">%s</textarea>',
     291            '<textarea id="ms_page_html" class="large-text" cols="70" rows="20" name="maintenance_switch_settings[ms_page_html]" %s>%s</textarea>',
     292            ( isset( $this->maintenance_switch_settings['ms_use_theme'] ) && $this->maintenance_switch_settings['ms_use_theme'] == 1 && $theme_file_exists ) ? 'readonly' : '',
    316293            isset( $this->maintenance_switch_settings['ms_page_html'] ) ? $this->maintenance_switch_settings['ms_page_html'] : ''
    317294        );
     
    331308        printf(
    332309            '<p class="inline-checkbox"><input id="ms_use_theme" name="maintenance_switch_settings[ms_use_theme]" type="checkbox" value="1" %s %s></p>',
    333             ( isset( $this->maintenance_switch_settings['ms_use_theme'] ) && $this->maintenance_switch_settings['ms_use_theme'] === 1 ) ? 'checked' : '',
     310            ( isset( $this->maintenance_switch_settings['ms_use_theme'] ) && $this->maintenance_switch_settings['ms_use_theme'] == 1 && $theme_file_exists ) ? 'checked' : '',
    334311            $theme_file_exists ? '' : 'disabled'
    335312        );
  • maintenance-switch/trunk/includes/class-maintenance-switch-activator.php

    r1404661 r1409605  
    3535        $plugin = new Maintenance_Switch();
    3636       
    37         $plugin->migrate_settings();
     37        $plugin->init_settings();
    3838        $plugin->sync_status();
    3939       
  • maintenance-switch/trunk/includes/class-maintenance-switch.php

    r1404756 r1409605  
    8484     */
    8585    protected $current_theme;
     86   
     87    /**
     88     * The notices to display in admin panel
     89     *
     90     * @since    1.3.3
     91     * @access   protected
     92     * @var      array    $notices    The notice messages to display
     93     */
     94    protected $notices;
    8695
    8796    /**
     
    97106
    98107        $this->plugin_name = MS_SLUG;
    99         $this->version = '1.3.2';
     108        $this->version = '1.3.3';
    100109        $this->default_settings = json_decode( MS_DEFAULT_SETTINGS, true );
    101110        $this->current_theme = wp_get_theme();
     
    179188    private function define_admin_hooks() {
    180189
    181         $plugin_admin = new Maintenance_Switch_Admin( $this->plugin_name, $this->version );
     190        $plugin_admin = new Maintenance_Switch_Admin( $this );
    182191       
    183192        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
     
    186195        // Add the options page and menu item.
    187196        $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_admin_menu' );
     197       
     198        // Execute actions on settings option updated
     199        $this->loader->add_action( 'update_option_maintenance_switch_settings', $this, 'admin_action_update' );
    188200
    189201        // Add an action link pointing to the options page.
     
    197209        $this->loader->add_action( 'wp_loaded', $this, 'admin_init' );
    198210       
    199         // Add an action to process operations after updates
    200         $this->loader->add_filter( 'upgrader_process_complete', $this, 'after_upgrades', 10, 2 );
    201        
    202211        // Add callback action for ajax request
    203212        $this->loader->add_action( 'wp_ajax_toggle_status', $this, 'toggle_status_callback' );
     213       
     214        // Admin notices
     215        $this->loader->add_action( 'admin_notices', $this, 'display_admin_notices' );
    204216
    205217    }
     
    214226    private function define_public_hooks() {
    215227
    216         $plugin_public = new Maintenance_Switch_Public( $this->plugin_name, $this->version );
     228        $plugin_public = new Maintenance_Switch_Public( $this_name, $this->version );
    217229
    218230        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
     
    223235   
    224236    /**
     237     * Actions to execute according to the action field
     238     *
     239     * @since    1.3.3
     240     */
     241    public function admin_action_update() {
     242       
     243        $this->init_files( true );
     244    }
     245   
     246    /**
     247     * Actions to execute according to the action field
     248     *
     249     * @since    1.3.3
     250     */
     251    public function admin_action_request() {
     252       
     253        if ( !empty( $_REQUEST['action'] ) ) {
     254           
     255            switch( $_REQUEST['action'] ) {
     256               
     257                case 'restore_settings':
     258               
     259                    if ( $this->restore_default_settings() )
     260                        $this->notice( 'success', __( 'Default settings successfuly restored.', MS_SLUG ) );
     261                    else
     262                        $this->notice( 'error', __( 'Default settings was not restored.', MS_SLUG ) );
     263                    break;
     264               
     265                case 'restore_html':
     266               
     267                    if ( $this->restore_html_setting() ) {
     268                        $this->notice( 'success', __( 'HTML code successfuly restored.', MS_SLUG ) );
     269                    } else {
     270                        $this->notice( 'error', __( 'HTML code could was not restored.', MS_SLUG ) );
     271                    }
     272                    break;
     273               
     274                case 'create_theme_file':
     275               
     276                    if ( $this->create_theme_file() ) {
     277                        $this->notice( 'success', __( 'The theme file was created successfuly.', MS_SLUG ) );
     278                    } else {
     279                        $this->notice( 'error', __( 'The theme file was not created.', MS_SLUG ) );
     280                    }
     281                    break;
     282               
     283                case 'delete_theme_file':
     284               
     285                    if ( $this->delete_theme_file() ) {
     286                        $this->notice( 'success', __( 'The theme file was deleted successfuly', MS_SLUG ) );
     287                    } else {
     288                        $this->notice( 'error', __( 'The theme file was not deleted.', MS_SLUG ) );
     289                    }
     290                    break;
     291               
     292            }
     293           
     294        }
     295    }
     296   
     297    /**
    225298     * Callback after core or plugins install/updates
    226299     *
     300     * @since    1.3.3
     301     */
     302     public function notice( $type, $notice ) {
     303         
     304         if ( !empty( $type ) && !empty( $notice ) )
     305            $this->notices[] = sprintf( '<div class="notice notice-%s is-dismissible"><p>%s</p></div>', $type, $notice );
     306     }
     307     
     308     /**
     309     * Display admin notices stored in object
     310     *
     311     * @since    1.3.3
     312     */
     313    public function display_admin_notices() {
     314       
     315        if ( !empty( $this->notices ) ) {
     316            foreach( $this->notices as $key => $notice ) {
     317                echo $notice;
     318            }
     319        }
     320    }
     321   
     322    /**
     323     * Initialize the plugin in admin (after wp loaded)
     324     *
    227325     * @since    1.1.1
    228326     */
    229     public function after_upgrades( $upgrader_object, $options ) {
    230        
    231         if ($options['action'] == 'update' && $options['type'] == 'plugin' ){
    232             foreach( $options['packages'] as $plugin_package ){
    233                 if ( $plugin_package == $this->plugin_name ){
    234                    
    235                     $this->migrate_settings();
    236                     $this->sync_status();
    237                 }
    238             }
    239         }
    240     }
    241    
    242     /**
    243      * Initialize the plugin in admin (after wp loaded)
    244      *
    245      * @since    1.1.1
    246      */
    247327    public function admin_init() {
    248328       
    249         $this->init_options();
    250         $this->init_files();
    251        
     329        $this->init_settings();
    252330        $this->sync_status();
    253331    }
     
    259337     * @since    1.3.1
    260338     */
    261     public function migrate_settings() {
     339    public function init_settings() {
    262340       
    263341        // Define if settings mode needs to be migrated from old to new system
     
    265343
    266344        // Get and delete previous settings values
    267         if ( $this->version_before( '1.3.2' ) ) {
     345        if ( $this->version_before( '1.3.3' ) ) {
    268346           
    269347            // Get previous settins in an array
     
    275353                'ms_use_theme'      => get_option( 'ms_use_theme' )
    276354            );
    277             $ms_status = get_option( 'ms_status' );
     355            $ms_status = (int) get_option( 'ms_status' );
    278356           
    279357            // Remove old invalid settings
     
    289367            if ( $ms_status !== false ) { $migrate = true; delete_option( 'ms_status' ); }
    290368           
     369            if ( !$migrate ) return false;
    291370        }
    292371       
     
    296375        // Create the plugin core maintenance files
    297376        $this->init_files();
     377       
     378        return true;
    298379    }
    299380   
     
    310391        $defaults = $this->default_settings;
    311392       
     393        // Get settings
     394        $settings = $this->get_the_settings();
     395       
     396        // Merging database options with defaults options
     397        if ( empty($settings) )
     398            $settings = wp_parse_args( $settings, $defaults );
     399       
    312400        // Merging options param with defaults options
    313401        if ( !empty( $options ) )
    314             $defaults = wp_parse_args( $options, $defaults );
    315        
    316         // Get settings
    317         $settings = $this->get_the_settings();
    318        
    319         // Merging database options with defaults options
    320         $settings = wp_parse_args( $settings, $defaults );
     402            $settings = wp_parse_args( $settings, $options );
    321403       
    322404        // Save settings
    323         $settings = update_option( 'maintenance_switch_settings', $settings );
     405        update_option( 'maintenance_switch_settings', $settings );
    324406       
    325407        // Set the status param
     
    340422     * @var      integer    $status     the status to set, or just sync with file if null
    341423     */
    342     public function sync_status( $status=null ) {
    343 
    344         $sync = false;
     424    public function sync_status( $status_wanted=null ) {
     425
    345426        // get the status in the database if no status in param
    346         if ( $status === null ) {
     427        if ( $status_wanted === null )
    347428            $status = $this->get_the_status();
    348             $sync = true;
    349         }
     429        else
     430            $status = $status_wanted;
    350431       
    351432        // try to create the file according to the status value
     
    355436           
    356437                if ( $this->create_dot_file() ) {
    357                     $msg = array( 'success' => true, 'data' => __( 'Maintenance turned on.', $this->plugin_name ) );
     438                    $response = array( 'success' => true );
    358439                    // if status called, update in db
    359                     if ( ! $sync ) $this->set_the_status( $status );
     440                    if ( $status_wanted !== null ) $this->set_the_status( $status );
    360441                } else {
    361                     $msg = array( 'success' => false, 'data' => __( 'Maintenance could not be turned on.', $this->plugin_name ) );
     442                    $response = array( 'success' => false );
    362443                }
    363444               
     
    367448               
    368449                if ( $this->_delete_file( MS_DOT_FILE_ACTIVE, true ) ) {
    369                     $msg = array( 'success' => true, 'data' => __( 'Maintenance turned off.', $this->plugin_name ) );
     450                    $response = array( 'success' => true );
    370451                    // if status called, update in db
    371                     if ( ! $sync ) $this->set_the_status( $status );
     452                    if ( $status_wanted !== null ) $this->set_the_status( $status );
    372453                } else {
    373                     $msg = array( 'success' => false, 'data' => __( 'Maintenance could not be turned off.', $this->plugin_name ) );
     454                    $response = array( 'success' => false );
    374455                }
    375456               
     
    378459        }
    379460
    380         $msg['status'] = $status;
    381        
    382         return !empty($msg) ? $msg : false;
     461        $response['status'] = $status;
     462       
     463        return !empty($response) ? $response : false;
    383464    }
    384465   
     
    389470     * @return   boolean    true
    390471     */
    391     public function init_files() {
     472    public function init_files( $override=false ) {
    392473       
    393474        // create the php file from template
    394         if ( ! file_exists( MS_PHP_FILE_ACTIVE ) ) {
     475        if ( $override || ! file_exists( MS_PHP_FILE_ACTIVE ) ) {
    395476            $this->create_php_file();
    396477        }
    397478       
    398         if ( $this->status == 1 )
     479        if ( $this->get_the_status() == 1 )
    399480            $this->create_dot_file();
    400481               
     
    424505     */
    425506    public function numeric_version( $version ) {
     507       
    426508        $version = str_replace( '.', '', $version );
    427509        return (int) $version;
     
    434516     */
    435517    public function get_current_theme() {
     518       
    436519        return $this->current_theme;
    437520    }
     
    443526     */
    444527    public function get_the_status() {
     528       
    445529        $status = get_option( 'maintenance_switch_status' );
    446530        if ( !$status ) {
    447531            $status = update_option( 'maintenance_switch_status', MS_DEFAULT_STATUS );
     532            return MS_DEFAULT_STATUS;
    448533        }
    449534        return $status;
     
    458543     */
    459544    public function set_the_status( $status ) {
     545       
    460546        if ( isset( $status ) ) {
    461547            return update_option( 'maintenance_switch_status', $status );
     
    471557     */
    472558    public function get_the_version() {
     559       
    473560        return get_option( 'maintenance_switch_version', '1.0.0' );
    474561    }
     
    481568     */
    482569    public function get_the_settings() {
     570       
    483571        return get_option( 'maintenance_switch_settings' );
    484572    }
     
    490578     */
    491579    public function restore_default_settings() {
    492         $defaults = wp_parse_args( $this->default_settings );
    493         update_option( 'maintenance_switch_settings', $defaults );
     580       
     581        $settings = $this->default_settings;
     582        return update_option( 'maintenance_switch_settings', $settings );
    494583    }
    495584   
     
    500589     */
    501590    public function restore_html_setting() {
     591       
    502592        $settings = $this->get_the_settings();
    503593        $settings['ms_page_html'] = $this->default_settings['ms_page_html'];
    504         update_option( 'maintenance_switch_settings', $settings );
     594        return update_option( 'maintenance_switch_settings', $settings );
    505595    }
    506596   
     
    512602     */
    513603    public function get_theme_file_url() {
     604       
    514605        return $this->current_theme->get_stylesheet_directory_uri() . '/' . MS_THEME_FILENAME;
    515606    }
     
    522613     */
    523614    public function get_theme_file_path() {
     615       
    524616        return $this->current_theme->get_stylesheet_directory() . '/' . MS_THEME_FILENAME;
    525617    }
     
    532624     */
    533625    public function theme_file_exists() {
     626       
    534627        $theme_file = $this->get_theme_file_path();
    535628        return file_exists( $theme_file );
     
    543636     */
    544637    public function create_theme_file() {
     638       
    545639        $theme_file = $this->get_theme_file_path();
    546640        if ( ! $this->theme_file_exists() ) {
     
    557651     */
    558652    public function delete_theme_file() {
     653       
    559654        $theme_file = $this->get_theme_file_path();
    560655        if ( $this->theme_file_exists() ) {
     
    576671        $settings = $this->get_the_settings();
    577672       
    578         if ( isset( $settings[ $setting_name ] ) )
     673        if ( isset( $settings[ $setting_name ] ) ) {
    579674            return $settings[ $setting_name ];
     675        }
    580676       
    581677        return $default_value;
     
    608704     */
    609705    public function run() {
     706       
    610707        $this->loader->run();
    611708    }
     
    619716     */
    620717    public function get_plugin_name() {
     718       
    621719        return $this->plugin_name;
    622720    }
     
    629727     */
    630728    public function get_loader() {
     729       
    631730        return $this->loader;
    632731    }
     
    639738     */
    640739    public function get_version() {
     740       
    641741        return $this->version;
    642742    }
     
    649749     */
    650750    public function get_status() {
     751       
    651752        return $this->status;
    652753    }
     
    659760     */
    660761    public function get_default_settings() {
     762       
    661763        return $this->default_settings;
    662764    }
     
    829931       
    830932        // get flags values
    831         $page_html = $this->get_setting( 'ms_page_html' );
    832         $use_theme_file = $this->get_setting( 'ms_use_theme' ) ? 'true' : 'false';
     933        $page_html = wp_specialchars_decode( $this->get_setting( 'ms_page_html' ), ENT_QUOTES );
     934        $use_theme_file = $this->get_setting( 'ms_use_theme' );
    833935        $theme = wp_get_theme();
    834936        $theme_file = $theme->get_stylesheet_directory() . '/' . MS_THEME_FILENAME;
  • maintenance-switch/trunk/languages/maintenance-switch-fr_FR.po

    r1404661 r1409605  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Maintenance Switch 1.3.1\n"
     5"Project-Id-Version: Maintenance Switch 1.3.3\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/maintenance-"
    77"switch\n"
    8 "POT-Creation-Date: 2016-04-26 11:53+0100\n"
    9 "PO-Revision-Date: 2016-04-26 16:07+0100\n"
     8"POT-Creation-Date: 2016-05-03 02:33+0100\n"
     9"PO-Revision-Date: 2016-05-03 02:38+0100\n"
    1010"Last-Translator: Vincent LALANNE <info@fugu.fr>\n"
    1111"Language-Team: Fugu <support@fugu.fr>\n"
     
    2121"X-Poedit-SearchPath-0: .\n"
    2222
    23 #: admin/class-maintenance-switch-admin.php:114
    24 #: admin/class-maintenance-switch-admin.php:115
     23#: admin/class-maintenance-switch-admin.php:120
     24#: admin/class-maintenance-switch-admin.php:121
    2525msgid "Maintenance Switch"
    2626msgstr "Maintenance Switch"
    2727
    28 #: admin/class-maintenance-switch-admin.php:131
     28#: admin/class-maintenance-switch-admin.php:137
    2929msgid "Settings"
    3030msgstr "Réglages"
    3131
    32 #: admin/views/maintenance-switch-admin-display.php:101
     32#: admin/views/maintenance-switch-admin-display.php:76
    3333msgid "Save Settings"
    3434msgstr "Enregistrer les réglages"
    3535
    36 #: admin/views/maintenance-switch-admin-display.php:102
     36#: admin/views/maintenance-switch-admin-display.php:77
    3737msgid "Preview page"
    3838msgstr "Prévisualiser la page"
    3939
    40 #: admin/views/maintenance-switch-admin-display.php:106
     40#: admin/views/maintenance-switch-admin-display.php:81
    4141msgid "Default settings"
    4242msgstr "Réglages par défauts"
    4343
    44 #: admin/views/maintenance-switch-admin-display.php:110
     44#: admin/views/maintenance-switch-admin-display.php:85
     45msgid "Restore all settings"
     46msgstr "Restaurer tous les réglages"
     47
     48#: admin/views/maintenance-switch-admin-display.php:85
     49msgid "Are you sure you want to retore all the default settings?"
     50msgstr ""
     51"Êtes-vous certain(e) de vouloir restaurer tous les réglages par défaut ?"
     52
     53#: admin/views/maintenance-switch-admin-display.php:90
    4554msgid "Restore page HTML"
    4655msgstr "Restaurer la page HTML"
    4756
    48 #: admin/views/maintenance-switch-admin-display.php:115
    49 msgid "Restore all settings"
    50 msgstr "Restaurer tous les réglages"
    51 
    52 #: admin/views/maintenance-switch-admin-display.php:121
     57#: admin/views/maintenance-switch-admin-display.php:90
     58msgid "Are you sure you want to retore the default HTML code?"
     59msgstr "Êtes-vous certain(e) de vouloir restaurer le code HTML par défaut ?"
     60
     61#: admin/views/maintenance-switch-admin-display.php:96
    5362msgid "Create file in the theme"
    5463msgstr "Créer le fichier dans le thème"
    5564
    56 #: admin/views/maintenance-switch-admin-display.php:126
     65#: admin/views/maintenance-switch-admin-display.php:96
     66msgid "Are you sure you want to create the file in your theme?"
     67msgstr "Êtes-vous certain(e) de vouloir créer le fichier dans votre thème ?"
     68
     69#: admin/views/maintenance-switch-admin-display.php:101
    5770msgid "Delete file in the theme"
    5871msgstr "Supprimer le fichier dans le thème"
    5972
    60 #: admin/views/maintenance-switch-admin-display.php:151
     73#: admin/views/maintenance-switch-admin-display.php:101
     74msgid "Are you sure you want to delete the file in your theme?"
     75msgstr "Êtes-vous certain(e) de vouloir supprimer le fichier de votre thème ?"
     76
     77#: admin/views/maintenance-switch-admin-display.php:126
    6178msgid "Permissions"
    6279msgstr "Permissions"
    6380
    64 #: admin/views/maintenance-switch-admin-display.php:158
     81#: admin/views/maintenance-switch-admin-display.php:133
    6582msgid "Switch ability:"
    6683msgstr "Capacité à switcher :"
    6784
    68 #: admin/views/maintenance-switch-admin-display.php:166
     85#: admin/views/maintenance-switch-admin-display.php:141
    6986msgid "Bypass ability:"
    7087msgstr "Capacité à outrepasser :"
    7188
    72 #: admin/views/maintenance-switch-admin-display.php:182
     89#: admin/views/maintenance-switch-admin-display.php:157
    7390msgid "Display"
    7491msgstr "Affichage"
    7592
    76 #: admin/views/maintenance-switch-admin-display.php:189
     93#: admin/views/maintenance-switch-admin-display.php:164
    7794msgid "Maintenance page HTML:"
    7895msgstr "Page de maintenance HTML :"
    7996
    80 #: admin/views/maintenance-switch-admin-display.php:197
     97#: admin/views/maintenance-switch-admin-display.php:172
    8198msgid "Use theme file:"
    8299msgstr "Utiliser le fichier du thème :"
    83100
    84 #: admin/views/maintenance-switch-admin-display.php:244
     101#: admin/views/maintenance-switch-admin-display.php:219
    85102msgid "Ajust the behavior related to the access and capacities."
    86103msgstr ""
    87104"Ajustez le comportement lié aux accès et aux capacités des utilisateurs."
    88105
    89 #: admin/views/maintenance-switch-admin-display.php:254
     106#: admin/views/maintenance-switch-admin-display.php:229
    90107msgid "Ajust the appearance of the maintenance page"
    91108msgstr "Ajustez l'apparence de la page de maintenance"
    92109
    93 #: admin/views/maintenance-switch-admin-display.php:271
     110#: admin/views/maintenance-switch-admin-display.php:246
    94111msgid ""
    95112"The user roles can access the maintenance button in the adminbar and so "
     
    99116"donc basculer le mode maintenance."
    100117
    101 #: admin/views/maintenance-switch-admin-display.php:288
     118#: admin/views/maintenance-switch-admin-display.php:263
    102119msgid ""
    103120"The user roles can bypass the maintenance mode and see the site like online."
     
    106123"site comme si il était en ligne."
    107124
    108 #: admin/views/maintenance-switch-admin-display.php:302
     125#: admin/views/maintenance-switch-admin-display.php:277
    109126msgid "Add my IP"
    110127msgstr "Ajouter mon IP"
    111128
    112 #: admin/views/maintenance-switch-admin-display.php:304
     129#: admin/views/maintenance-switch-admin-display.php:279
    113130msgid ""
    114131"The IP list can bypass the maintenance mode and see the site like online, "
     
    118135"comme si il était en ligne, séparées par des virgules."
    119136
    120 #: admin/views/maintenance-switch-admin-display.php:318
     137#: admin/views/maintenance-switch-admin-display.php:295
    121138msgid "The entire HTML code of the maintenance page."
    122139msgstr "Le code HTML complet de la page de maintenance."
    123140
    124 #: admin/views/maintenance-switch-admin-display.php:336
     141#: admin/views/maintenance-switch-admin-display.php:313
    125142msgid ""
    126143"Use a file in your theme to display maintenance page instead of the HTML "
     
    130147"maintenance au lieu du champs HTML ci-dessus."
    131148
    132 #: admin/views/maintenance-switch-admin-display.php:343
     149#: admin/views/maintenance-switch-admin-display.php:319
    133150msgid "exists"
    134151msgstr "existe"
    135152
    136 #: admin/views/maintenance-switch-admin-display.php:343
     153#: admin/views/maintenance-switch-admin-display.php:319
    137154msgid "is missing"
    138155msgstr "n'existe pas"
    139156
    140 #: includes/class-maintenance-switch.php:769
    141 msgid "Maintenance turned on."
    142 msgstr "Maintenance activée."
    143 
    144 #: includes/class-maintenance-switch.php:773
    145 msgid "Maintenance could not be turned on."
    146 msgstr "La maintenance ne peut être activée."
    147 
    148 #: includes/class-maintenance-switch.php:781
    149 msgid "Maintenance turned off."
    150 msgstr "Maintenance désactivée."
    151 
    152 #: includes/class-maintenance-switch.php:785
    153 msgid "Maintenance could not be turned off."
    154 msgstr "La maintenance ne peut être désactivée."
    155 
    156 #: includes/class-maintenance-switch.php:828
     157#: includes/class-maintenance-switch.php:263
     158msgid "Default settings successfuly restored."
     159msgstr "Réglages par défaut restaurés."
     160
     161#: includes/class-maintenance-switch.php:265
     162msgid "Default settings was not restored."
     163msgstr "Les réglages par défaut n'ont pas été restaurés."
     164
     165#: includes/class-maintenance-switch.php:271
     166msgid "HTML code successfuly restored."
     167msgstr "Code HTML restauré."
     168
     169#: includes/class-maintenance-switch.php:273
     170msgid "HTML code could was not restored."
     171msgstr "Le code HTML n'a pas été restauré."
     172
     173#: includes/class-maintenance-switch.php:280
     174msgid "The theme file was created successfuly."
     175msgstr "Fichier créé dans le thème."
     176
     177#: includes/class-maintenance-switch.php:282
     178msgid "The theme file was not created."
     179msgstr "Le fichier n'a pas pu être créé dans le thème."
     180
     181#: includes/class-maintenance-switch.php:289
     182msgid "The theme file was deleted successfuly"
     183msgstr "Fichier supprimé du thème."
     184
     185#: includes/class-maintenance-switch.php:291
     186msgid "The theme file was not deleted."
     187msgstr "Le fichier n'a pas pu être supprimé du thème."
     188
     189#: includes/class-maintenance-switch.php:1042
    157190msgid "Maintenance"
    158191msgstr "Maintenance"
     
    177210msgid "The maintenance team."
    178211msgstr "L'équipe technique."
     212
     213#~ msgid "Maintenance turned on."
     214#~ msgstr "Maintenance activée."
     215
     216#~ msgid "Maintenance could not be turned on."
     217#~ msgstr "La maintenance ne peut être activée."
     218
     219#~ msgid "Maintenance turned off."
     220#~ msgstr "Maintenance désactivée."
     221
     222#~ msgid "Maintenance could not be turned off."
     223#~ msgstr "La maintenance ne peut être désactivée."
    179224
    180225#~ msgid "Display settings"
  • maintenance-switch/trunk/languages/maintenance-switch.pot

    r1404661 r1409605  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Maintenance Switch 1.3.1\n"
     5"Project-Id-Version: Maintenance Switch 1.3.3\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/maintenance-"
    77"switch\n"
    8 "POT-Creation-Date: 2016-04-26 16:06+0100\n"
    9 "PO-Revision-Date: 2016-04-26 16:06+0100\n"
     8"POT-Creation-Date: 2016-05-03 02:39+0100\n"
     9"PO-Revision-Date: 2016-05-03 02:39+0100\n"
    1010"Last-Translator: Vincent LALANNE <info@fugu.fr>\n"
    1111"Language-Team: Fugu <support@fugu.fr>\n"
     
    2222"X-Poedit-SearchPath-0: .\n"
    2323
    24 #: admin/class-maintenance-switch-admin.php:114
    25 #: admin/class-maintenance-switch-admin.php:115
     24#: admin/class-maintenance-switch-admin.php:120
     25#: admin/class-maintenance-switch-admin.php:121
    2626msgid "Maintenance Switch"
    2727msgstr ""
    2828
    29 #: admin/class-maintenance-switch-admin.php:131
     29#: admin/class-maintenance-switch-admin.php:137
    3030msgid "Settings"
    3131msgstr ""
    3232
     33#: admin/views/maintenance-switch-admin-display.php:76
     34msgid "Save Settings"
     35msgstr ""
     36
     37#: admin/views/maintenance-switch-admin-display.php:77
     38msgid "Preview page"
     39msgstr ""
     40
     41#: admin/views/maintenance-switch-admin-display.php:81
     42msgid "Default settings"
     43msgstr ""
     44
     45#: admin/views/maintenance-switch-admin-display.php:85
     46msgid "Restore all settings"
     47msgstr ""
     48
     49#: admin/views/maintenance-switch-admin-display.php:85
     50msgid "Are you sure you want to retore all the default settings?"
     51msgstr ""
     52
     53#: admin/views/maintenance-switch-admin-display.php:90
     54msgid "Restore page HTML"
     55msgstr ""
     56
     57#: admin/views/maintenance-switch-admin-display.php:90
     58msgid "Are you sure you want to retore the default HTML code?"
     59msgstr ""
     60
     61#: admin/views/maintenance-switch-admin-display.php:96
     62msgid "Create file in the theme"
     63msgstr ""
     64
     65#: admin/views/maintenance-switch-admin-display.php:96
     66msgid "Are you sure you want to create the file in your theme?"
     67msgstr ""
     68
    3369#: admin/views/maintenance-switch-admin-display.php:101
    34 msgid "Save Settings"
    35 msgstr ""
    36 
    37 #: admin/views/maintenance-switch-admin-display.php:102
    38 msgid "Preview page"
    39 msgstr ""
    40 
    41 #: admin/views/maintenance-switch-admin-display.php:106
    42 msgid "Default settings"
    43 msgstr ""
    44 
    45 #: admin/views/maintenance-switch-admin-display.php:110
    46 msgid "Restore all settings"
    47 msgstr ""
    48 
    49 #: admin/views/maintenance-switch-admin-display.php:115
    50 msgid "Restore page HTML"
    51 msgstr ""
    52 
    53 #: admin/views/maintenance-switch-admin-display.php:121
    54 msgid "Create file in the theme"
     70msgid "Delete file in the theme"
     71msgstr ""
     72
     73#: admin/views/maintenance-switch-admin-display.php:101
     74msgid "Are you sure you want to delete the file in your theme?"
    5575msgstr ""
    5676
    5777#: admin/views/maintenance-switch-admin-display.php:126
    58 msgid "Delete file in the theme"
    59 msgstr ""
    60 
    61 #: admin/views/maintenance-switch-admin-display.php:151
    6278msgid "Permissions"
    6379msgstr ""
    6480
    65 #: admin/views/maintenance-switch-admin-display.php:158
     81#: admin/views/maintenance-switch-admin-display.php:133
    6682msgid "Switch ability:"
    6783msgstr ""
    6884
    69 #: admin/views/maintenance-switch-admin-display.php:166
     85#: admin/views/maintenance-switch-admin-display.php:141
    7086msgid "Bypass ability:"
    7187msgstr ""
    7288
    73 #: admin/views/maintenance-switch-admin-display.php:182
     89#: admin/views/maintenance-switch-admin-display.php:157
    7490msgid "Display"
    7591msgstr ""
    7692
    77 #: admin/views/maintenance-switch-admin-display.php:189
     93#: admin/views/maintenance-switch-admin-display.php:164
    7894msgid "Maintenance page HTML:"
    7995msgstr ""
    8096
    81 #: admin/views/maintenance-switch-admin-display.php:197
     97#: admin/views/maintenance-switch-admin-display.php:172
    8298msgid "Use theme file:"
    8399msgstr ""
    84100
    85 #: admin/views/maintenance-switch-admin-display.php:244
     101#: admin/views/maintenance-switch-admin-display.php:219
    86102msgid "Ajust the behavior related to the access and capacities."
    87103msgstr ""
    88104
    89 #: admin/views/maintenance-switch-admin-display.php:254
     105#: admin/views/maintenance-switch-admin-display.php:229
    90106msgid "Ajust the appearance of the maintenance page"
    91107msgstr ""
    92108
    93 #: admin/views/maintenance-switch-admin-display.php:271
     109#: admin/views/maintenance-switch-admin-display.php:246
    94110msgid ""
    95111"The user roles can access the maintenance button in the adminbar and so "
     
    97113msgstr ""
    98114
    99 #: admin/views/maintenance-switch-admin-display.php:288
     115#: admin/views/maintenance-switch-admin-display.php:263
    100116msgid ""
    101117"The user roles can bypass the maintenance mode and see the site like online."
    102118msgstr ""
    103119
    104 #: admin/views/maintenance-switch-admin-display.php:302
     120#: admin/views/maintenance-switch-admin-display.php:277
    105121msgid "Add my IP"
    106122msgstr ""
    107123
    108 #: admin/views/maintenance-switch-admin-display.php:304
     124#: admin/views/maintenance-switch-admin-display.php:279
    109125msgid ""
    110126"The IP list can bypass the maintenance mode and see the site like online, "
     
    112128msgstr ""
    113129
    114 #: admin/views/maintenance-switch-admin-display.php:318
     130#: admin/views/maintenance-switch-admin-display.php:295
    115131msgid "The entire HTML code of the maintenance page."
    116132msgstr ""
    117133
    118 #: admin/views/maintenance-switch-admin-display.php:336
     134#: admin/views/maintenance-switch-admin-display.php:313
    119135msgid ""
    120136"Use a file in your theme to display maintenance page instead of the HTML "
     
    122138msgstr ""
    123139
    124 #: admin/views/maintenance-switch-admin-display.php:342
     140#: admin/views/maintenance-switch-admin-display.php:319
    125141msgid "exists"
    126142msgstr ""
    127143
    128 #: admin/views/maintenance-switch-admin-display.php:342
     144#: admin/views/maintenance-switch-admin-display.php:319
    129145msgid "is missing"
    130146msgstr ""
    131147
    132 #: includes/class-maintenance-switch.php:352
    133 msgid "Maintenance turned on."
    134 msgstr ""
    135 
    136 #: includes/class-maintenance-switch.php:356
    137 msgid "Maintenance could not be turned on."
    138 msgstr ""
    139 
    140 #: includes/class-maintenance-switch.php:364
    141 msgid "Maintenance turned off."
    142 msgstr ""
    143 
    144 #: includes/class-maintenance-switch.php:368
    145 msgid "Maintenance could not be turned off."
    146 msgstr ""
    147 
    148 #: includes/class-maintenance-switch.php:913
     148#: includes/class-maintenance-switch.php:263
     149msgid "Default settings successfuly restored."
     150msgstr ""
     151
     152#: includes/class-maintenance-switch.php:265
     153msgid "Default settings was not restored."
     154msgstr ""
     155
     156#: includes/class-maintenance-switch.php:271
     157msgid "HTML code successfuly restored."
     158msgstr ""
     159
     160#: includes/class-maintenance-switch.php:273
     161msgid "HTML code could was not restored."
     162msgstr ""
     163
     164#: includes/class-maintenance-switch.php:280
     165msgid "The theme file was created successfuly."
     166msgstr ""
     167
     168#: includes/class-maintenance-switch.php:282
     169msgid "The theme file was not created."
     170msgstr ""
     171
     172#: includes/class-maintenance-switch.php:289
     173msgid "The theme file was deleted successfuly"
     174msgstr ""
     175
     176#: includes/class-maintenance-switch.php:291
     177msgid "The theme file was not deleted."
     178msgstr ""
     179
     180#: includes/class-maintenance-switch.php:1042
    149181msgid "Maintenance"
    150182msgstr ""
  • maintenance-switch/trunk/maintenance-switch.php

    r1404756 r1409605  
    1717 * Plugin URI:        https://wordpress.org/plugins/maintenance-switch
    1818 * Description:       Customize easily and switch in one-click to (native) maintenance mode from your backend or frontend.
    19  * Version:           1.3.2
     19 * Version:           1.3.3
    2020 * Author:            Fugu
    2121 * Author URI:        http://www.fugu.fr
  • maintenance-switch/trunk/readme.txt

    r1404756 r1409605  
    55Requires at least: 3.5
    66Tested up to: 4.5
    7 Stable tag: 1.3.2
     7Stable tag: 1.3.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    104104== Changelog ==
    105105
     106= 1.3.3 =
     107* Fix bug with data saving
     108* Fix bug with HTML encoding
     109* Fix bug with files generation
     110* Fix a very persistent bug with settings migration
     111
    106112= 1.3.2 =
    107113* Fix a persistent bug with settings migration
  • maintenance-switch/trunk/templates/maintenance.php

    r1308219 r1409605  
    2020$use_theme = '{{MS_USE_THEME_FILE}}';
    2121
    22 if ( $use_theme == 'true' && file_exists( $theme_file ) ) {
     22if ( $use_theme == '1' && file_exists( $theme_file ) ) {
    2323    require_once $theme_file;
    2424    die();
Note: See TracChangeset for help on using the changeset viewer.