Version Description
- Bug for roles and capacities fixed
=
Download this release
Release Info
Developer | Florent73 |
Plugin | WP Maintenance |
Version | 4.0.4 |
Comparing to | |
See all releases |
Code changes from version 4.0.3 to 4.0.4
- classes/wp-maintenance.php +53 -40
- readme.txt +5 -2
- wp-maintenance.php +4 -4
classes/wp-maintenance.php
CHANGED
@@ -2,15 +2,17 @@
|
|
2 |
|
3 |
class WP_maintenance {
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
is_null( self::$instance ) AND self::$instance = new self;
|
9 |
-
return self::$instance;
|
10 |
-
}
|
11 |
|
12 |
-
|
|
|
13 |
|
|
|
|
|
|
|
|
|
14 |
/* Version du plugin */
|
15 |
$option['wp_maintenance_version'] = WPM_VERSION;
|
16 |
if( !get_option('wp_maintenance_version') ) {
|
@@ -18,24 +20,25 @@ class WP_maintenance {
|
|
18 |
} else if ( get_option('wp_maintenance_version') != WPM_VERSION ) {
|
19 |
update_option('wp_maintenance_version', WPM_VERSION);
|
20 |
}
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
}
|
34 |
|
35 |
function wpm_theme_add_editor_styles() {
|
36 |
add_editor_style( plugins_url('../css/custom-editor-style.css', __FILE__ ) );
|
37 |
}
|
38 |
-
public static function
|
39 |
|
40 |
$nameServer = '';
|
41 |
if( isset($_SERVER['SERVER_NAME']) ) {
|
@@ -544,25 +547,15 @@ a.wpmadashicons:hover { text-decoration:none;color: '.$colors[2].'!important; }
|
|
544 |
|
545 |
}
|
546 |
|
547 |
-
/* Mode Maintenance */
|
548 |
-
function
|
549 |
-
|
550 |
-
global $current_user;
|
551 |
|
552 |
if(get_option('wp_maintenance_settings')) { extract(get_option('wp_maintenance_settings')); }
|
553 |
$paramMMode = get_option('wp_maintenance_settings');
|
554 |
|
555 |
-
if(get_option('wp_maintenance_slider')) { extract(get_option('wp_maintenance_slider')); }
|
556 |
-
$paramSlider = get_option('wp_maintenance_slider');
|
557 |
-
|
558 |
-
if(get_option('wp_maintenance_slider_options')) { extract(get_option('wp_maintenance_slider_options')); }
|
559 |
-
$paramSliderOptions = get_option('wp_maintenance_slider_options');
|
560 |
-
|
561 |
/* Récupère le status */
|
562 |
$statusActive = get_option('wp_maintenance_active');
|
563 |
|
564 |
-
$paramSocialOption = get_option('wp_maintenance_social_options');
|
565 |
-
|
566 |
// Récupère les ip autorisee
|
567 |
$paramIpAddress = get_option('wp_maintenance_ipaddresses');
|
568 |
/* Désactive le mode maintenance pour les IP définies */
|
@@ -582,18 +575,23 @@ a.wpmadashicons:hover { text-decoration:none;color: '.$colors[2].'!important; }
|
|
582 |
|
583 |
if( isset($paramLimit) && count($paramLimit)>1 ) {
|
584 |
foreach($paramLimit as $limitrole) {
|
585 |
-
if(
|
586 |
-
$
|
|
|
|
|
|
|
|
|
|
|
587 |
}
|
588 |
}
|
589 |
}
|
590 |
-
|
591 |
/* Désactive le mode maintenance pour les PAGE ID définies */
|
592 |
-
if( isset($paramMMode['id_pages']) ) {
|
593 |
$listPageId = explode(',', $paramMMode['id_pages']);
|
594 |
foreach($listPageId as $keyPageId => $valPageId) {
|
595 |
if( $valPageId == get_the_ID() ) {
|
596 |
-
$statusActive =
|
597 |
}
|
598 |
}
|
599 |
}
|
@@ -602,6 +600,23 @@ a.wpmadashicons:hover { text-decoration:none;color: '.$colors[2].'!important; }
|
|
602 |
if( current_user_can('administrator') == true ) {
|
603 |
$statusActive = 0;
|
604 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
|
606 |
/* on doit retourner 12/31/2020 5:00 AM */
|
607 |
$dateNow = strtotime(date("Y-m-d H:i:s")) + 3600 * get_option('gmt_offset');
|
@@ -619,12 +634,10 @@ a.wpmadashicons:hover { text-decoration:none;color: '.$colors[2].'!important; }
|
|
619 |
|
620 |
if( $dateNow > $dateFinCpt ) {
|
621 |
$ChangeStatus = wpm_change_active();
|
622 |
-
$statusActive = 0;
|
623 |
}
|
624 |
-
|
625 |
}
|
626 |
|
627 |
-
|
628 |
|
629 |
if ( file_exists( get_stylesheet_directory() ) ) {
|
630 |
$urlTpl = get_stylesheet_directory();
|
@@ -940,7 +953,7 @@ $wpmStyle .= '
|
|
940 |
$template_page = str_replace(array_keys($tplRemplacements), array_values($tplRemplacements), $template_page );
|
941 |
|
942 |
$content = $template_page;
|
943 |
-
|
944 |
if( isset($paramMMode['error_503']) && $paramMMode['error_503']=='Yes' ) {
|
945 |
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
946 |
header('Status: 503 Service Temporarily Unavailable');
|
2 |
|
3 |
class WP_maintenance {
|
4 |
|
5 |
+
protected static $instance;
|
6 |
|
7 |
+
public function __construct() {
|
|
|
|
|
|
|
8 |
|
9 |
+
/* Récupère le status */
|
10 |
+
$statusActive = $this->wpm_check_active();
|
11 |
|
12 |
+
if ( isset($statusActive) && $statusActive == 1) {
|
13 |
+
add_action( 'template_redirect', array( &$this, 'wpm_maintenance_mode'), 2 );
|
14 |
+
}
|
15 |
+
|
16 |
/* Version du plugin */
|
17 |
$option['wp_maintenance_version'] = WPM_VERSION;
|
18 |
if( !get_option('wp_maintenance_version') ) {
|
20 |
} else if ( get_option('wp_maintenance_version') != WPM_VERSION ) {
|
21 |
update_option('wp_maintenance_version', WPM_VERSION);
|
22 |
}
|
23 |
+
add_action( 'init', array( &$this, 'wpm_dashboard_install') );
|
24 |
+
|
25 |
+
if( is_admin() ) {
|
26 |
+
add_action( 'admin_menu', array( &$this, 'wpm_add_admin') );
|
27 |
+
add_filter( 'plugin_action_links', array( &$this, 'wpm_plugin_actions'), 10, 2 );
|
28 |
+
add_action( 'admin_head', array( &$this, 'wpm_admin_head') );
|
29 |
+
add_action( 'init', array( &$this, 'wpm_date_picker') );
|
30 |
+
add_action( 'admin_bar_menu', array( &$this, 'wpm_add_menu_admin_bar'), 999 );
|
31 |
+
add_action( 'admin_footer', array( &$this, 'wpm_print_footer_scripts') );
|
32 |
+
add_action( 'admin_init', array( &$this, 'wpm_process_settings_import') );
|
33 |
+
add_action( 'admin_init', array( &$this, 'wpm_process_settings_export') );
|
34 |
+
add_action( 'after_setup_theme', array( &$this, 'wpm_theme_add_editor_styles') );
|
35 |
+
}
|
36 |
}
|
37 |
|
38 |
function wpm_theme_add_editor_styles() {
|
39 |
add_editor_style( plugins_url('../css/custom-editor-style.css', __FILE__ ) );
|
40 |
}
|
41 |
+
public static function wpm_dashboard_install() {
|
42 |
|
43 |
$nameServer = '';
|
44 |
if( isset($_SERVER['SERVER_NAME']) ) {
|
547 |
|
548 |
}
|
549 |
|
550 |
+
/* Check le Mode Maintenance si on doit l'activer ou non */
|
551 |
+
function wpm_check_active() {
|
|
|
|
|
552 |
|
553 |
if(get_option('wp_maintenance_settings')) { extract(get_option('wp_maintenance_settings')); }
|
554 |
$paramMMode = get_option('wp_maintenance_settings');
|
555 |
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
/* Récupère le status */
|
557 |
$statusActive = get_option('wp_maintenance_active');
|
558 |
|
|
|
|
|
559 |
// Récupère les ip autorisee
|
560 |
$paramIpAddress = get_option('wp_maintenance_ipaddresses');
|
561 |
/* Désactive le mode maintenance pour les IP définies */
|
575 |
|
576 |
if( isset($paramLimit) && count($paramLimit)>1 ) {
|
577 |
foreach($paramLimit as $limitrole) {
|
578 |
+
if( is_user_logged_in() ) {
|
579 |
+
$user_id = get_current_user_id();
|
580 |
+
$user_info = get_userdata($user_id);
|
581 |
+
$user_role = implode(', ', $user_info->roles);
|
582 |
+
if( $limitrole == $user_role ) {
|
583 |
+
$statusActive = 0;
|
584 |
+
}
|
585 |
}
|
586 |
}
|
587 |
}
|
588 |
+
|
589 |
/* Désactive le mode maintenance pour les PAGE ID définies */
|
590 |
+
if( isset($paramMMode['id_pages']) && !empty($paramMMode['id_pages']) ) {
|
591 |
$listPageId = explode(',', $paramMMode['id_pages']);
|
592 |
foreach($listPageId as $keyPageId => $valPageId) {
|
593 |
if( $valPageId == get_the_ID() ) {
|
594 |
+
$statusActive = 'page'.$valPageId;
|
595 |
}
|
596 |
}
|
597 |
}
|
600 |
if( current_user_can('administrator') == true ) {
|
601 |
$statusActive = 0;
|
602 |
}
|
603 |
+
|
604 |
+
return $statusActive;
|
605 |
+
}
|
606 |
+
|
607 |
+
/* Mode Maintenance */
|
608 |
+
function wpm_maintenance_mode() {
|
609 |
+
|
610 |
+
if(get_option('wp_maintenance_settings')) { extract(get_option('wp_maintenance_settings')); }
|
611 |
+
$paramMMode = get_option('wp_maintenance_settings');
|
612 |
+
|
613 |
+
if(get_option('wp_maintenance_slider')) { extract(get_option('wp_maintenance_slider')); }
|
614 |
+
$paramSlider = get_option('wp_maintenance_slider');
|
615 |
+
|
616 |
+
if(get_option('wp_maintenance_slider_options')) { extract(get_option('wp_maintenance_slider_options')); }
|
617 |
+
$paramSliderOptions = get_option('wp_maintenance_slider_options');
|
618 |
+
|
619 |
+
$paramSocialOption = get_option('wp_maintenance_social_options');
|
620 |
|
621 |
/* on doit retourner 12/31/2020 5:00 AM */
|
622 |
$dateNow = strtotime(date("Y-m-d H:i:s")) + 3600 * get_option('gmt_offset');
|
634 |
|
635 |
if( $dateNow > $dateFinCpt ) {
|
636 |
$ChangeStatus = wpm_change_active();
|
|
|
637 |
}
|
|
|
638 |
}
|
639 |
|
640 |
+
|
641 |
|
642 |
if ( file_exists( get_stylesheet_directory() ) ) {
|
643 |
$urlTpl = get_stylesheet_directory();
|
953 |
$template_page = str_replace(array_keys($tplRemplacements), array_values($tplRemplacements), $template_page );
|
954 |
|
955 |
$content = $template_page;
|
956 |
+
|
957 |
if( isset($paramMMode['error_503']) && $paramMMode['error_503']=='Yes' ) {
|
958 |
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
959 |
header('Status: 503 Service Temporarily Unavailable');
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpmaintenance.info/a-propos/
|
|
4 |
Tags: Maintenance, Construction, Launch, Coming soon
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 4.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -67,11 +67,14 @@ You can translate WP Maintenance on [__translate.wordpress.org__](https://transl
|
|
67 |
|
68 |
== Upgrade Notice ==
|
69 |
|
70 |
-
= 4.0.
|
71 |
* Bug for roles and capacities fixed
|
72 |
|
73 |
== Changelog ==
|
74 |
|
|
|
|
|
|
|
75 |
= 4.0.2 =
|
76 |
* Bug IP addresses fixed
|
77 |
* Clean code
|
4 |
Tags: Maintenance, Construction, Launch, Coming soon
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 4.0.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
67 |
|
68 |
== Upgrade Notice ==
|
69 |
|
70 |
+
= 4.0.4 =
|
71 |
* Bug for roles and capacities fixed
|
72 |
|
73 |
== Changelog ==
|
74 |
|
75 |
+
= 4.0.3 =
|
76 |
+
* Bug for roles and capacities fixed
|
77 |
+
|
78 |
= 4.0.2 =
|
79 |
* Bug IP addresses fixed
|
80 |
* Clean code
|
wp-maintenance.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: The WP Maintenance plugin allows you to put your website on the waiting time for you to do maintenance or launch your website. Personalize this page with picture, countdown...
|
6 |
* Author: Florent Maillefaud
|
7 |
* Author URI: https://wpmaintenance.info
|
8 |
-
* Version: 4.0.
|
9 |
* Text Domain: wp-maintenance
|
10 |
* Domain Path: /languages/
|
11 |
*/
|
@@ -36,7 +36,7 @@ define( 'WPM_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
|
36 |
define( 'WPM_PLUGIN_URL', plugins_url().'/'.strtolower('wp-maintenance').'/');
|
37 |
define( 'WPM_ICONS_URL', plugins_url().'/'.strtolower('wp-maintenance').'/socialicons/');
|
38 |
|
39 |
-
if( !defined( 'WPM_VERSION' )) { define( 'WPM_VERSION', '4.0.
|
40 |
|
41 |
require WPM_DIR . 'classes/wp-maintenance.php';
|
42 |
require WPM_DIR . 'classes/slider.php';
|
@@ -47,7 +47,7 @@ require WPM_DIR . 'includes/shortcodes.php';
|
|
47 |
add_action( 'plugins_loaded', '_wpm_load' );
|
48 |
function _wpm_load() {
|
49 |
$wp_maintenance = new WP_maintenance();
|
50 |
-
$wp_maintenance->
|
51 |
}
|
52 |
|
53 |
// Enable localization
|
@@ -60,4 +60,4 @@ register_activation_hook( __FILE__, array( 'WP_maintenance', 'wpm_dashboard_inst
|
|
60 |
register_deactivation_hook( __FILE__, array( 'WP_maintenance', 'wpm_dashboard_remove' ) );
|
61 |
register_uninstall_hook( __FILE__, array( 'WP_maintenance', 'wpm_dashboard_remove' ) );
|
62 |
|
63 |
-
add_action( 'plugins_loaded', array( 'WP_maintenance', 'init' ) );
|
5 |
* Description: The WP Maintenance plugin allows you to put your website on the waiting time for you to do maintenance or launch your website. Personalize this page with picture, countdown...
|
6 |
* Author: Florent Maillefaud
|
7 |
* Author URI: https://wpmaintenance.info
|
8 |
+
* Version: 4.0.4
|
9 |
* Text Domain: wp-maintenance
|
10 |
* Domain Path: /languages/
|
11 |
*/
|
36 |
define( 'WPM_PLUGIN_URL', plugins_url().'/'.strtolower('wp-maintenance').'/');
|
37 |
define( 'WPM_ICONS_URL', plugins_url().'/'.strtolower('wp-maintenance').'/socialicons/');
|
38 |
|
39 |
+
if( !defined( 'WPM_VERSION' )) { define( 'WPM_VERSION', '4.0.4' ); }
|
40 |
|
41 |
require WPM_DIR . 'classes/wp-maintenance.php';
|
42 |
require WPM_DIR . 'classes/slider.php';
|
47 |
add_action( 'plugins_loaded', '_wpm_load' );
|
48 |
function _wpm_load() {
|
49 |
$wp_maintenance = new WP_maintenance();
|
50 |
+
$wp_maintenance->__construct();
|
51 |
}
|
52 |
|
53 |
// Enable localization
|
60 |
register_deactivation_hook( __FILE__, array( 'WP_maintenance', 'wpm_dashboard_remove' ) );
|
61 |
register_uninstall_hook( __FILE__, array( 'WP_maintenance', 'wpm_dashboard_remove' ) );
|
62 |
|
63 |
+
//add_action( 'plugins_loaded', array( 'WP_maintenance', 'init' ) );
|