Changeset 1409605
- Timestamp:
- 05/03/2016 12:56:01 PM (10 years ago)
- Location:
- maintenance-switch
- Files:
-
- 47 added
- 13 edited
-
tags/1.3.2 (added)
-
tags/1.3.2/LICENSE.txt (added)
-
tags/1.3.2/admin (added)
-
tags/1.3.2/admin/class-maintenance-switch-admin.php (added)
-
tags/1.3.2/admin/css (added)
-
tags/1.3.2/admin/css/maintenance-switch-admin.css (added)
-
tags/1.3.2/admin/css/maintenance-switch-admin.scss (added)
-
tags/1.3.2/admin/index.php (added)
-
tags/1.3.2/admin/js (added)
-
tags/1.3.2/admin/js/maintenance-switch-admin.js (added)
-
tags/1.3.2/admin/views (added)
-
tags/1.3.2/admin/views/maintenance-switch-admin-display.php (added)
-
tags/1.3.2/assets (added)
-
tags/1.3.2/assets/css (added)
-
tags/1.3.2/assets/css/maintenance-switch-button.css (added)
-
tags/1.3.2/assets/css/maintenance-switch-button.scss (added)
-
tags/1.3.2/assets/js (added)
-
tags/1.3.2/assets/js/maintenance-switch-button.js (added)
-
tags/1.3.2/includes (added)
-
tags/1.3.2/includes/class-maintenance-switch-activator.php (added)
-
tags/1.3.2/includes/class-maintenance-switch-deactivator.php (added)
-
tags/1.3.2/includes/class-maintenance-switch-i18n.php (added)
-
tags/1.3.2/includes/class-maintenance-switch-loader.php (added)
-
tags/1.3.2/includes/class-maintenance-switch.php (added)
-
tags/1.3.2/includes/config.php (added)
-
tags/1.3.2/includes/index.php (added)
-
tags/1.3.2/index.php (added)
-
tags/1.3.2/languages (added)
-
tags/1.3.2/languages/maintenance-switch-fr_FR.mo (added)
-
tags/1.3.2/languages/maintenance-switch-fr_FR.po (added)
-
tags/1.3.2/languages/maintenance-switch.pot (added)
-
tags/1.3.2/maintenance-switch.php (added)
-
tags/1.3.2/preview.php (added)
-
tags/1.3.2/public (added)
-
tags/1.3.2/public/class-maintenance-switch-public.php (added)
-
tags/1.3.2/public/css (added)
-
tags/1.3.2/public/css/maintenance-switch-public.css (added)
-
tags/1.3.2/public/index.php (added)
-
tags/1.3.2/public/js (added)
-
tags/1.3.2/public/js/maintenance-switch-public.js (added)
-
tags/1.3.2/public/views (added)
-
tags/1.3.2/public/views/maintenance-switch-public-display.php (added)
-
tags/1.3.2/readme.txt (added)
-
tags/1.3.2/templates (added)
-
tags/1.3.2/templates/.maintenance (added)
-
tags/1.3.2/templates/maintenance.php (added)
-
tags/1.3.2/uninstall.php (added)
-
trunk/admin/class-maintenance-switch-admin.php (modified) (3 diffs)
-
trunk/admin/css/maintenance-switch-admin.css (modified) (1 diff)
-
trunk/admin/css/maintenance-switch-admin.scss (modified) (1 diff)
-
trunk/admin/js/maintenance-switch-admin.js (modified) (2 diffs)
-
trunk/admin/views/maintenance-switch-admin-display.php (modified) (7 diffs)
-
trunk/includes/class-maintenance-switch-activator.php (modified) (1 diff)
-
trunk/includes/class-maintenance-switch.php (modified) (39 diffs)
-
trunk/languages/maintenance-switch-fr_FR.mo (modified) (previous)
-
trunk/languages/maintenance-switch-fr_FR.po (modified) (7 diffs)
-
trunk/languages/maintenance-switch.pot (modified) (5 diffs)
-
trunk/maintenance-switch.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates/maintenance.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
maintenance-switch/trunk/admin/class-maintenance-switch-admin.php
r1404482 r1409605 24 24 25 25 /** 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 /** 26 35 * The ID of this plugin. 27 36 * … … 48 57 * @param string $version The version of this plugin. 49 58 */ 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(); 54 63 } 55 64 … … 103 112 public function add_plugin_admin_menu() { 104 113 105 // Get main controller106 $plugin = new Maintenance_Switch();107 108 114 // Get the view 109 115 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 ); 111 117 112 118 // Adds option page in admin settings -
maintenance-switch/trunk/admin/css/maintenance-switch-admin.css
r1404661 r1409605 1 input.readonly, input[readonly], 2 textarea.readonly, textarea[readonly] { 3 color: #999; } 4 1 5 textarea { 2 6 width: 95%; } -
maintenance-switch/trunk/admin/css/maintenance-switch-admin.scss
r1404661 r1409605 1 1 // Settings form 2 3 input.readonly, input[readonly], 4 textarea.readonly, textarea[readonly] { 5 color:#999; 6 } 2 7 3 8 textarea { -
maintenance-switch/trunk/admin/js/maintenance-switch-admin.js
r1404482 r1409605 21 21 $('#ms_use_theme').on('change', function(e){ 22 22 var checked = this.checked; 23 $('#ms_page_html').prop(' disabled', checked);23 $('#ms_page_html').prop('readonly', checked); 24 24 }); 25 25 … … 37 37 } 38 38 }); 39 40 $('input[data-msg]').on('click', function(e) { 41 var message = $(this).data('msg'); 42 if ( !confirm( message ) ) 43 e.preventDefault(); 44 }); 39 45 }); 40 46 -
maintenance-switch/trunk/admin/views/maintenance-switch-admin-display.php
r1404661 r1409605 43 43 * @since 1.3.0 44 44 */ 45 public function __construct( $plugin ) {45 public function __construct( &$plugin ) { 46 46 47 47 $this->plugin = $plugin; 48 49 $this->plugin->admin_action_request(); 50 48 51 $this->maintenance_switch_settings = $plugin->get_the_settings(); 49 52 50 $this->request();51 52 53 add_action( 'admin_init', array( $this, 'maintenance_switch_page_init' ) ); 53 54 } 54 55 55 56 /** 56 * Function to execute according to the submit action57 *58 * @since 1.3.059 */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 /**82 57 * Display the admin settings view. 83 58 * WP Settings API … … 86 61 */ 87 62 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 ); 89 64 ?> 90 65 … … 93 68 <h2><?php echo esc_html( get_admin_page_title() ); ?></h2> 94 69 95 <form method="POST" action="options.php">70 <form id="settings-form" method="POST" action="options.php"> 96 71 <?php 97 72 settings_fields( 'maintenance_switch' ); … … 107 82 108 83 <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 ) ) ); ?> 111 86 </form> 112 87 113 88 <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 ) ) ); ?> 116 91 </form> 117 92 118 93 <?php if ( ! $this->plugin->theme_file_exists() ) : ?> 119 94 <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 ) ) ); ?> 122 97 </form> 123 98 <?php else : ?> 124 99 <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 ) ) ); ?> 127 102 </form> 128 103 <?php endif; ?> … … 229 204 230 205 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']; 232 207 } 233 208 … … 312 287 */ 313 288 public function ms_page_html_display() { 289 $theme_file_exists = $this->plugin->theme_file_exists(); 314 290 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' : '', 316 293 isset( $this->maintenance_switch_settings['ms_page_html'] ) ? $this->maintenance_switch_settings['ms_page_html'] : '' 317 294 ); … … 331 308 printf( 332 309 '<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' : '', 334 311 $theme_file_exists ? '' : 'disabled' 335 312 ); -
maintenance-switch/trunk/includes/class-maintenance-switch-activator.php
r1404661 r1409605 35 35 $plugin = new Maintenance_Switch(); 36 36 37 $plugin-> migrate_settings();37 $plugin->init_settings(); 38 38 $plugin->sync_status(); 39 39 -
maintenance-switch/trunk/includes/class-maintenance-switch.php
r1404756 r1409605 84 84 */ 85 85 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; 86 95 87 96 /** … … 97 106 98 107 $this->plugin_name = MS_SLUG; 99 $this->version = '1.3. 2';108 $this->version = '1.3.3'; 100 109 $this->default_settings = json_decode( MS_DEFAULT_SETTINGS, true ); 101 110 $this->current_theme = wp_get_theme(); … … 179 188 private function define_admin_hooks() { 180 189 181 $plugin_admin = new Maintenance_Switch_Admin( $this ->plugin_name, $this->version);190 $plugin_admin = new Maintenance_Switch_Admin( $this ); 182 191 183 192 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); … … 186 195 // Add the options page and menu item. 187 196 $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' ); 188 200 189 201 // Add an action link pointing to the options page. … … 197 209 $this->loader->add_action( 'wp_loaded', $this, 'admin_init' ); 198 210 199 // Add an action to process operations after updates200 $this->loader->add_filter( 'upgrader_process_complete', $this, 'after_upgrades', 10, 2 );201 202 211 // Add callback action for ajax request 203 212 $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' ); 204 216 205 217 } … … 214 226 private function define_public_hooks() { 215 227 216 $plugin_public = new Maintenance_Switch_Public( $this ->plugin_name, $this->version );228 $plugin_public = new Maintenance_Switch_Public( $this_name, $this->version ); 217 229 218 230 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); … … 223 235 224 236 /** 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 /** 225 298 * Callback after core or plugins install/updates 226 299 * 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 * 227 325 * @since 1.1.1 228 326 */ 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.1246 */247 327 public function admin_init() { 248 328 249 $this->init_options(); 250 $this->init_files(); 251 329 $this->init_settings(); 252 330 $this->sync_status(); 253 331 } … … 259 337 * @since 1.3.1 260 338 */ 261 public function migrate_settings() {339 public function init_settings() { 262 340 263 341 // Define if settings mode needs to be migrated from old to new system … … 265 343 266 344 // Get and delete previous settings values 267 if ( $this->version_before( '1.3. 2' ) ) {345 if ( $this->version_before( '1.3.3' ) ) { 268 346 269 347 // Get previous settins in an array … … 275 353 'ms_use_theme' => get_option( 'ms_use_theme' ) 276 354 ); 277 $ms_status = get_option( 'ms_status' );355 $ms_status = (int) get_option( 'ms_status' ); 278 356 279 357 // Remove old invalid settings … … 289 367 if ( $ms_status !== false ) { $migrate = true; delete_option( 'ms_status' ); } 290 368 369 if ( !$migrate ) return false; 291 370 } 292 371 … … 296 375 // Create the plugin core maintenance files 297 376 $this->init_files(); 377 378 return true; 298 379 } 299 380 … … 310 391 $defaults = $this->default_settings; 311 392 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 312 400 // Merging options param with defaults options 313 401 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 ); 321 403 322 404 // Save settings 323 $settings =update_option( 'maintenance_switch_settings', $settings );405 update_option( 'maintenance_switch_settings', $settings ); 324 406 325 407 // Set the status param … … 340 422 * @var integer $status the status to set, or just sync with file if null 341 423 */ 342 public function sync_status( $status=null ) { 343 344 $sync = false; 424 public function sync_status( $status_wanted=null ) { 425 345 426 // get the status in the database if no status in param 346 if ( $status === null ) {427 if ( $status_wanted === null ) 347 428 $status = $this->get_the_status(); 348 $sync = true;349 }429 else 430 $status = $status_wanted; 350 431 351 432 // try to create the file according to the status value … … 355 436 356 437 if ( $this->create_dot_file() ) { 357 $ msg = array( 'success' => true, 'data' => __( 'Maintenance turned on.', $this->plugin_name ));438 $response = array( 'success' => true ); 358 439 // if status called, update in db 359 if ( ! $sync) $this->set_the_status( $status );440 if ( $status_wanted !== null ) $this->set_the_status( $status ); 360 441 } else { 361 $ msg = array( 'success' => false, 'data' => __( 'Maintenance could not be turned on.', $this->plugin_name ));442 $response = array( 'success' => false ); 362 443 } 363 444 … … 367 448 368 449 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 ); 370 451 // if status called, update in db 371 if ( ! $sync) $this->set_the_status( $status );452 if ( $status_wanted !== null ) $this->set_the_status( $status ); 372 453 } else { 373 $ msg = array( 'success' => false, 'data' => __( 'Maintenance could not be turned off.', $this->plugin_name ));454 $response = array( 'success' => false ); 374 455 } 375 456 … … 378 459 } 379 460 380 $ msg['status'] = $status;381 382 return !empty($ msg) ? $msg: false;461 $response['status'] = $status; 462 463 return !empty($response) ? $response : false; 383 464 } 384 465 … … 389 470 * @return boolean true 390 471 */ 391 public function init_files( ) {472 public function init_files( $override=false ) { 392 473 393 474 // create the php file from template 394 if ( ! file_exists( MS_PHP_FILE_ACTIVE ) ) {475 if ( $override || ! file_exists( MS_PHP_FILE_ACTIVE ) ) { 395 476 $this->create_php_file(); 396 477 } 397 478 398 if ( $this-> status== 1 )479 if ( $this->get_the_status() == 1 ) 399 480 $this->create_dot_file(); 400 481 … … 424 505 */ 425 506 public function numeric_version( $version ) { 507 426 508 $version = str_replace( '.', '', $version ); 427 509 return (int) $version; … … 434 516 */ 435 517 public function get_current_theme() { 518 436 519 return $this->current_theme; 437 520 } … … 443 526 */ 444 527 public function get_the_status() { 528 445 529 $status = get_option( 'maintenance_switch_status' ); 446 530 if ( !$status ) { 447 531 $status = update_option( 'maintenance_switch_status', MS_DEFAULT_STATUS ); 532 return MS_DEFAULT_STATUS; 448 533 } 449 534 return $status; … … 458 543 */ 459 544 public function set_the_status( $status ) { 545 460 546 if ( isset( $status ) ) { 461 547 return update_option( 'maintenance_switch_status', $status ); … … 471 557 */ 472 558 public function get_the_version() { 559 473 560 return get_option( 'maintenance_switch_version', '1.0.0' ); 474 561 } … … 481 568 */ 482 569 public function get_the_settings() { 570 483 571 return get_option( 'maintenance_switch_settings' ); 484 572 } … … 490 578 */ 491 579 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 ); 494 583 } 495 584 … … 500 589 */ 501 590 public function restore_html_setting() { 591 502 592 $settings = $this->get_the_settings(); 503 593 $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 ); 505 595 } 506 596 … … 512 602 */ 513 603 public function get_theme_file_url() { 604 514 605 return $this->current_theme->get_stylesheet_directory_uri() . '/' . MS_THEME_FILENAME; 515 606 } … … 522 613 */ 523 614 public function get_theme_file_path() { 615 524 616 return $this->current_theme->get_stylesheet_directory() . '/' . MS_THEME_FILENAME; 525 617 } … … 532 624 */ 533 625 public function theme_file_exists() { 626 534 627 $theme_file = $this->get_theme_file_path(); 535 628 return file_exists( $theme_file ); … … 543 636 */ 544 637 public function create_theme_file() { 638 545 639 $theme_file = $this->get_theme_file_path(); 546 640 if ( ! $this->theme_file_exists() ) { … … 557 651 */ 558 652 public function delete_theme_file() { 653 559 654 $theme_file = $this->get_theme_file_path(); 560 655 if ( $this->theme_file_exists() ) { … … 576 671 $settings = $this->get_the_settings(); 577 672 578 if ( isset( $settings[ $setting_name ] ) ) 673 if ( isset( $settings[ $setting_name ] ) ) { 579 674 return $settings[ $setting_name ]; 675 } 580 676 581 677 return $default_value; … … 608 704 */ 609 705 public function run() { 706 610 707 $this->loader->run(); 611 708 } … … 619 716 */ 620 717 public function get_plugin_name() { 718 621 719 return $this->plugin_name; 622 720 } … … 629 727 */ 630 728 public function get_loader() { 729 631 730 return $this->loader; 632 731 } … … 639 738 */ 640 739 public function get_version() { 740 641 741 return $this->version; 642 742 } … … 649 749 */ 650 750 public function get_status() { 751 651 752 return $this->status; 652 753 } … … 659 760 */ 660 761 public function get_default_settings() { 762 661 763 return $this->default_settings; 662 764 } … … 829 931 830 932 // 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' ); 833 935 $theme = wp_get_theme(); 834 936 $theme_file = $theme->get_stylesheet_directory() . '/' . MS_THEME_FILENAME; -
maintenance-switch/trunk/languages/maintenance-switch-fr_FR.po
r1404661 r1409605 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Maintenance Switch 1.3. 1\n"5 "Project-Id-Version: Maintenance Switch 1.3.3\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/maintenance-" 7 7 "switch\n" 8 "POT-Creation-Date: 2016-0 4-26 11:53+0100\n"9 "PO-Revision-Date: 2016-0 4-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" 10 10 "Last-Translator: Vincent LALANNE <info@fugu.fr>\n" 11 11 "Language-Team: Fugu <support@fugu.fr>\n" … … 21 21 "X-Poedit-SearchPath-0: .\n" 22 22 23 #: admin/class-maintenance-switch-admin.php:1 1424 #: admin/class-maintenance-switch-admin.php:1 1523 #: admin/class-maintenance-switch-admin.php:120 24 #: admin/class-maintenance-switch-admin.php:121 25 25 msgid "Maintenance Switch" 26 26 msgstr "Maintenance Switch" 27 27 28 #: admin/class-maintenance-switch-admin.php:13 128 #: admin/class-maintenance-switch-admin.php:137 29 29 msgid "Settings" 30 30 msgstr "Réglages" 31 31 32 #: admin/views/maintenance-switch-admin-display.php: 10132 #: admin/views/maintenance-switch-admin-display.php:76 33 33 msgid "Save Settings" 34 34 msgstr "Enregistrer les réglages" 35 35 36 #: admin/views/maintenance-switch-admin-display.php: 10236 #: admin/views/maintenance-switch-admin-display.php:77 37 37 msgid "Preview page" 38 38 msgstr "Prévisualiser la page" 39 39 40 #: admin/views/maintenance-switch-admin-display.php: 10640 #: admin/views/maintenance-switch-admin-display.php:81 41 41 msgid "Default settings" 42 42 msgstr "Réglages par défauts" 43 43 44 #: admin/views/maintenance-switch-admin-display.php:110 44 #: admin/views/maintenance-switch-admin-display.php:85 45 msgid "Restore all settings" 46 msgstr "Restaurer tous les réglages" 47 48 #: admin/views/maintenance-switch-admin-display.php:85 49 msgid "Are you sure you want to retore all the default settings?" 50 msgstr "" 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 45 54 msgid "Restore page HTML" 46 55 msgstr "Restaurer la page HTML" 47 56 48 #: admin/views/maintenance-switch-admin-display.php: 11549 msgid " Restore all settings"50 msgstr " Restaurer tous les réglages"51 52 #: admin/views/maintenance-switch-admin-display.php: 12157 #: admin/views/maintenance-switch-admin-display.php:90 58 msgid "Are you sure you want to retore the default HTML code?" 59 msgstr "Êtes-vous certain(e) de vouloir restaurer le code HTML par défaut ?" 60 61 #: admin/views/maintenance-switch-admin-display.php:96 53 62 msgid "Create file in the theme" 54 63 msgstr "Créer le fichier dans le thème" 55 64 56 #: admin/views/maintenance-switch-admin-display.php:126 65 #: admin/views/maintenance-switch-admin-display.php:96 66 msgid "Are you sure you want to create the file in your theme?" 67 msgstr "Êtes-vous certain(e) de vouloir créer le fichier dans votre thème ?" 68 69 #: admin/views/maintenance-switch-admin-display.php:101 57 70 msgid "Delete file in the theme" 58 71 msgstr "Supprimer le fichier dans le thème" 59 72 60 #: admin/views/maintenance-switch-admin-display.php:151 73 #: admin/views/maintenance-switch-admin-display.php:101 74 msgid "Are you sure you want to delete the file in your theme?" 75 msgstr "Êtes-vous certain(e) de vouloir supprimer le fichier de votre thème ?" 76 77 #: admin/views/maintenance-switch-admin-display.php:126 61 78 msgid "Permissions" 62 79 msgstr "Permissions" 63 80 64 #: admin/views/maintenance-switch-admin-display.php:1 5881 #: admin/views/maintenance-switch-admin-display.php:133 65 82 msgid "Switch ability:" 66 83 msgstr "Capacité à switcher :" 67 84 68 #: admin/views/maintenance-switch-admin-display.php:1 6685 #: admin/views/maintenance-switch-admin-display.php:141 69 86 msgid "Bypass ability:" 70 87 msgstr "Capacité à outrepasser :" 71 88 72 #: admin/views/maintenance-switch-admin-display.php:1 8289 #: admin/views/maintenance-switch-admin-display.php:157 73 90 msgid "Display" 74 91 msgstr "Affichage" 75 92 76 #: admin/views/maintenance-switch-admin-display.php:1 8993 #: admin/views/maintenance-switch-admin-display.php:164 77 94 msgid "Maintenance page HTML:" 78 95 msgstr "Page de maintenance HTML :" 79 96 80 #: admin/views/maintenance-switch-admin-display.php:1 9797 #: admin/views/maintenance-switch-admin-display.php:172 81 98 msgid "Use theme file:" 82 99 msgstr "Utiliser le fichier du thème :" 83 100 84 #: admin/views/maintenance-switch-admin-display.php:2 44101 #: admin/views/maintenance-switch-admin-display.php:219 85 102 msgid "Ajust the behavior related to the access and capacities." 86 103 msgstr "" 87 104 "Ajustez le comportement lié aux accès et aux capacités des utilisateurs." 88 105 89 #: admin/views/maintenance-switch-admin-display.php:2 54106 #: admin/views/maintenance-switch-admin-display.php:229 90 107 msgid "Ajust the appearance of the maintenance page" 91 108 msgstr "Ajustez l'apparence de la page de maintenance" 92 109 93 #: admin/views/maintenance-switch-admin-display.php:2 71110 #: admin/views/maintenance-switch-admin-display.php:246 94 111 msgid "" 95 112 "The user roles can access the maintenance button in the adminbar and so " … … 99 116 "donc basculer le mode maintenance." 100 117 101 #: admin/views/maintenance-switch-admin-display.php:2 88118 #: admin/views/maintenance-switch-admin-display.php:263 102 119 msgid "" 103 120 "The user roles can bypass the maintenance mode and see the site like online." … … 106 123 "site comme si il était en ligne." 107 124 108 #: admin/views/maintenance-switch-admin-display.php: 302125 #: admin/views/maintenance-switch-admin-display.php:277 109 126 msgid "Add my IP" 110 127 msgstr "Ajouter mon IP" 111 128 112 #: admin/views/maintenance-switch-admin-display.php: 304129 #: admin/views/maintenance-switch-admin-display.php:279 113 130 msgid "" 114 131 "The IP list can bypass the maintenance mode and see the site like online, " … … 118 135 "comme si il était en ligne, séparées par des virgules." 119 136 120 #: admin/views/maintenance-switch-admin-display.php: 318137 #: admin/views/maintenance-switch-admin-display.php:295 121 138 msgid "The entire HTML code of the maintenance page." 122 139 msgstr "Le code HTML complet de la page de maintenance." 123 140 124 #: admin/views/maintenance-switch-admin-display.php:3 36141 #: admin/views/maintenance-switch-admin-display.php:313 125 142 msgid "" 126 143 "Use a file in your theme to display maintenance page instead of the HTML " … … 130 147 "maintenance au lieu du champs HTML ci-dessus." 131 148 132 #: admin/views/maintenance-switch-admin-display.php:3 43149 #: admin/views/maintenance-switch-admin-display.php:319 133 150 msgid "exists" 134 151 msgstr "existe" 135 152 136 #: admin/views/maintenance-switch-admin-display.php:3 43153 #: admin/views/maintenance-switch-admin-display.php:319 137 154 msgid "is missing" 138 155 msgstr "n'existe pas" 139 156 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 158 msgid "Default settings successfuly restored." 159 msgstr "Réglages par défaut restaurés." 160 161 #: includes/class-maintenance-switch.php:265 162 msgid "Default settings was not restored." 163 msgstr "Les réglages par défaut n'ont pas été restaurés." 164 165 #: includes/class-maintenance-switch.php:271 166 msgid "HTML code successfuly restored." 167 msgstr "Code HTML restauré." 168 169 #: includes/class-maintenance-switch.php:273 170 msgid "HTML code could was not restored." 171 msgstr "Le code HTML n'a pas été restauré." 172 173 #: includes/class-maintenance-switch.php:280 174 msgid "The theme file was created successfuly." 175 msgstr "Fichier créé dans le thème." 176 177 #: includes/class-maintenance-switch.php:282 178 msgid "The theme file was not created." 179 msgstr "Le fichier n'a pas pu être créé dans le thème." 180 181 #: includes/class-maintenance-switch.php:289 182 msgid "The theme file was deleted successfuly" 183 msgstr "Fichier supprimé du thème." 184 185 #: includes/class-maintenance-switch.php:291 186 msgid "The theme file was not deleted." 187 msgstr "Le fichier n'a pas pu être supprimé du thème." 188 189 #: includes/class-maintenance-switch.php:1042 157 190 msgid "Maintenance" 158 191 msgstr "Maintenance" … … 177 210 msgid "The maintenance team." 178 211 msgstr "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." 179 224 180 225 #~ msgid "Display settings" -
maintenance-switch/trunk/languages/maintenance-switch.pot
r1404661 r1409605 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Maintenance Switch 1.3. 1\n"5 "Project-Id-Version: Maintenance Switch 1.3.3\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/maintenance-" 7 7 "switch\n" 8 "POT-Creation-Date: 2016-0 4-26 16:06+0100\n"9 "PO-Revision-Date: 2016-0 4-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" 10 10 "Last-Translator: Vincent LALANNE <info@fugu.fr>\n" 11 11 "Language-Team: Fugu <support@fugu.fr>\n" … … 22 22 "X-Poedit-SearchPath-0: .\n" 23 23 24 #: admin/class-maintenance-switch-admin.php:1 1425 #: admin/class-maintenance-switch-admin.php:1 1524 #: admin/class-maintenance-switch-admin.php:120 25 #: admin/class-maintenance-switch-admin.php:121 26 26 msgid "Maintenance Switch" 27 27 msgstr "" 28 28 29 #: admin/class-maintenance-switch-admin.php:13 129 #: admin/class-maintenance-switch-admin.php:137 30 30 msgid "Settings" 31 31 msgstr "" 32 32 33 #: admin/views/maintenance-switch-admin-display.php:76 34 msgid "Save Settings" 35 msgstr "" 36 37 #: admin/views/maintenance-switch-admin-display.php:77 38 msgid "Preview page" 39 msgstr "" 40 41 #: admin/views/maintenance-switch-admin-display.php:81 42 msgid "Default settings" 43 msgstr "" 44 45 #: admin/views/maintenance-switch-admin-display.php:85 46 msgid "Restore all settings" 47 msgstr "" 48 49 #: admin/views/maintenance-switch-admin-display.php:85 50 msgid "Are you sure you want to retore all the default settings?" 51 msgstr "" 52 53 #: admin/views/maintenance-switch-admin-display.php:90 54 msgid "Restore page HTML" 55 msgstr "" 56 57 #: admin/views/maintenance-switch-admin-display.php:90 58 msgid "Are you sure you want to retore the default HTML code?" 59 msgstr "" 60 61 #: admin/views/maintenance-switch-admin-display.php:96 62 msgid "Create file in the theme" 63 msgstr "" 64 65 #: admin/views/maintenance-switch-admin-display.php:96 66 msgid "Are you sure you want to create the file in your theme?" 67 msgstr "" 68 33 69 #: 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" 70 msgid "Delete file in the theme" 71 msgstr "" 72 73 #: admin/views/maintenance-switch-admin-display.php:101 74 msgid "Are you sure you want to delete the file in your theme?" 55 75 msgstr "" 56 76 57 77 #: 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:15162 78 msgid "Permissions" 63 79 msgstr "" 64 80 65 #: admin/views/maintenance-switch-admin-display.php:1 5881 #: admin/views/maintenance-switch-admin-display.php:133 66 82 msgid "Switch ability:" 67 83 msgstr "" 68 84 69 #: admin/views/maintenance-switch-admin-display.php:1 6685 #: admin/views/maintenance-switch-admin-display.php:141 70 86 msgid "Bypass ability:" 71 87 msgstr "" 72 88 73 #: admin/views/maintenance-switch-admin-display.php:1 8289 #: admin/views/maintenance-switch-admin-display.php:157 74 90 msgid "Display" 75 91 msgstr "" 76 92 77 #: admin/views/maintenance-switch-admin-display.php:1 8993 #: admin/views/maintenance-switch-admin-display.php:164 78 94 msgid "Maintenance page HTML:" 79 95 msgstr "" 80 96 81 #: admin/views/maintenance-switch-admin-display.php:1 9797 #: admin/views/maintenance-switch-admin-display.php:172 82 98 msgid "Use theme file:" 83 99 msgstr "" 84 100 85 #: admin/views/maintenance-switch-admin-display.php:2 44101 #: admin/views/maintenance-switch-admin-display.php:219 86 102 msgid "Ajust the behavior related to the access and capacities." 87 103 msgstr "" 88 104 89 #: admin/views/maintenance-switch-admin-display.php:2 54105 #: admin/views/maintenance-switch-admin-display.php:229 90 106 msgid "Ajust the appearance of the maintenance page" 91 107 msgstr "" 92 108 93 #: admin/views/maintenance-switch-admin-display.php:2 71109 #: admin/views/maintenance-switch-admin-display.php:246 94 110 msgid "" 95 111 "The user roles can access the maintenance button in the adminbar and so " … … 97 113 msgstr "" 98 114 99 #: admin/views/maintenance-switch-admin-display.php:2 88115 #: admin/views/maintenance-switch-admin-display.php:263 100 116 msgid "" 101 117 "The user roles can bypass the maintenance mode and see the site like online." 102 118 msgstr "" 103 119 104 #: admin/views/maintenance-switch-admin-display.php: 302120 #: admin/views/maintenance-switch-admin-display.php:277 105 121 msgid "Add my IP" 106 122 msgstr "" 107 123 108 #: admin/views/maintenance-switch-admin-display.php: 304124 #: admin/views/maintenance-switch-admin-display.php:279 109 125 msgid "" 110 126 "The IP list can bypass the maintenance mode and see the site like online, " … … 112 128 msgstr "" 113 129 114 #: admin/views/maintenance-switch-admin-display.php: 318130 #: admin/views/maintenance-switch-admin-display.php:295 115 131 msgid "The entire HTML code of the maintenance page." 116 132 msgstr "" 117 133 118 #: admin/views/maintenance-switch-admin-display.php:3 36134 #: admin/views/maintenance-switch-admin-display.php:313 119 135 msgid "" 120 136 "Use a file in your theme to display maintenance page instead of the HTML " … … 122 138 msgstr "" 123 139 124 #: admin/views/maintenance-switch-admin-display.php:3 42140 #: admin/views/maintenance-switch-admin-display.php:319 125 141 msgid "exists" 126 142 msgstr "" 127 143 128 #: admin/views/maintenance-switch-admin-display.php:3 42144 #: admin/views/maintenance-switch-admin-display.php:319 129 145 msgid "is missing" 130 146 msgstr "" 131 147 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 149 msgid "Default settings successfuly restored." 150 msgstr "" 151 152 #: includes/class-maintenance-switch.php:265 153 msgid "Default settings was not restored." 154 msgstr "" 155 156 #: includes/class-maintenance-switch.php:271 157 msgid "HTML code successfuly restored." 158 msgstr "" 159 160 #: includes/class-maintenance-switch.php:273 161 msgid "HTML code could was not restored." 162 msgstr "" 163 164 #: includes/class-maintenance-switch.php:280 165 msgid "The theme file was created successfuly." 166 msgstr "" 167 168 #: includes/class-maintenance-switch.php:282 169 msgid "The theme file was not created." 170 msgstr "" 171 172 #: includes/class-maintenance-switch.php:289 173 msgid "The theme file was deleted successfuly" 174 msgstr "" 175 176 #: includes/class-maintenance-switch.php:291 177 msgid "The theme file was not deleted." 178 msgstr "" 179 180 #: includes/class-maintenance-switch.php:1042 149 181 msgid "Maintenance" 150 182 msgstr "" -
maintenance-switch/trunk/maintenance-switch.php
r1404756 r1409605 17 17 * Plugin URI: https://wordpress.org/plugins/maintenance-switch 18 18 * Description: Customize easily and switch in one-click to (native) maintenance mode from your backend or frontend. 19 * Version: 1.3. 219 * Version: 1.3.3 20 20 * Author: Fugu 21 21 * Author URI: http://www.fugu.fr -
maintenance-switch/trunk/readme.txt
r1404756 r1409605 5 5 Requires at least: 3.5 6 6 Tested up to: 4.5 7 Stable tag: 1.3. 27 Stable tag: 1.3.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 104 104 == Changelog == 105 105 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 106 112 = 1.3.2 = 107 113 * Fix a persistent bug with settings migration -
maintenance-switch/trunk/templates/maintenance.php
r1308219 r1409605 20 20 $use_theme = '{{MS_USE_THEME_FILE}}'; 21 21 22 if ( $use_theme == ' true' && file_exists( $theme_file ) ) {22 if ( $use_theme == '1' && file_exists( $theme_file ) ) { 23 23 require_once $theme_file; 24 24 die();
Note: See TracChangeset
for help on using the changeset viewer.