Skip to content

Commit

Permalink
version 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
georgejipa committed Sep 2, 2014
1 parent 1273742 commit 45b6e6f
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 89 deletions.
58 changes: 43 additions & 15 deletions includes/classes/wp-maintenance-mode-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ private function __construct() {
// Add an action link pointing to the options page
$plugin_basename = plugin_basename(WPMM_PATH . $this->plugin_slug . '.php');
if (is_multisite() && is_plugin_active_for_network($plugin_basename)) {
add_filter('network_admin_plugin_action_links', array($this, 'add_settings_link'));
// settings link will point to admin_url of the main blog, not to network_admin_url
add_filter('network_admin_plugin_action_links_' . $plugin_basename, array($this, 'add_settings_link'));
} else {
add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_settings_link'));
}
Expand Down Expand Up @@ -201,29 +202,30 @@ public function save_plugin_settings() {
}
$_POST['options']['general']['notice'] = (int) $_POST['options']['general']['notice'];
$_POST['options']['general']['author_link'] = (int) $_POST['options']['general']['author_link'];

// delete cache everytime
$this->delete_cache();
break;
case 'design':
$custom_css = array();

// CONTENT
// CONTENT & CUSTOM CSS
$_POST['options']['design']['title'] = sanitize_text_field($_POST['options']['design']['title']);
$_POST['options']['design']['heading'] = sanitize_text_field($_POST['options']['design']['heading']);
if (!empty($_POST['options']['design']['heading_color'])) {
$_POST['options']['design']['heading_color'] = sanitize_text_field($_POST['options']['design']['heading_color']);
$custom_css['heading_color'] = '.wrap h1 { color: ' . $_POST['options']['design']['heading_color'] . '; }';
}
$_POST['options']['design']['text'] = wp_kses_post($_POST['options']['design']['text']);
if (!empty($_POST['options']['design']['text_color'])) {
$_POST['options']['design']['text_color'] = sanitize_text_field($_POST['options']['design']['text_color']);
$custom_css['text_color'] = '.wrap h2 { color: ' . $_POST['options']['design']['text_color'] . '; }';
}

// BACKGROUND & CUSTOM CSS
if (!empty($_POST['options']['design']['bg_type'])) {
$_POST['options']['design']['bg_type'] = sanitize_text_field($_POST['options']['design']['bg_type']);

if (!empty($_POST['options']['design']['heading_color'])) {
$_POST['options']['design']['heading_color'] = sanitize_text_field($_POST['options']['design']['heading_color']);
$custom_css['heading_color'] = '.wrap h1 { color: ' . $_POST['options']['design']['heading_color'] . '; }';
}

if (!empty($_POST['options']['design']['text_color'])) {
$_POST['options']['design']['text_color'] = sanitize_text_field($_POST['options']['design']['text_color']);
$custom_css['text_color'] = '.wrap h2 { color: ' . $_POST['options']['design']['text_color'] . '; }';
}

if ($_POST['options']['design']['bg_type'] == 'color' && !empty($_POST['options']['design']['bg_color'])) {
$_POST['options']['design']['bg_color'] = sanitize_text_field($_POST['options']['design']['bg_color']);
$custom_css['bg_color'] = 'body { background-color: ' . $_POST['options']['design']['bg_color'] . '; }';
Expand All @@ -241,14 +243,18 @@ public function save_plugin_settings() {
}

$_POST['options']['design']['custom_css'] = $custom_css;

// delete cache when is activated
if (!empty($this->plugin_settings['general']['status']) && $this->plugin_settings['general']['status'] == 1) {
$this->delete_cache();
}
break;
case 'modules':
$custom_css = array();

// COUNTDOWN & CUSTOM CSS
$_POST['options']['modules']['countdown_status'] = (int) $_POST['options']['modules']['countdown_status'];
$_POST['options']['modules']['countdown_start'] = sanitize_text_field($_POST['options']['modules']['countdown_start']);
$_POST['options']['modules']['countdown_start'] = sanitize_text_field($_POST['options']['modules']['countdown_start']);
$_POST['options']['modules']['countdown_details'] = array_map('trim', $_POST['options']['modules']['countdown_details']);
$_POST['options']['modules']['countdown_details']['days'] = !empty($_POST['options']['modules']['countdown_details']['days']) && is_numeric($_POST['options']['modules']['countdown_details']['days']) ? $_POST['options']['modules']['countdown_details']['days'] : 0;
$_POST['options']['modules']['countdown_details']['hours'] = !empty($_POST['options']['modules']['countdown_details']['hours']) && is_numeric($_POST['options']['modules']['countdown_details']['hours']) ? $_POST['options']['modules']['countdown_details']['hours'] : 1;
Expand Down Expand Up @@ -281,14 +287,36 @@ public function save_plugin_settings() {
$_POST['options']['modules']['contact_effects'] = sanitize_text_field($_POST['options']['modules']['contact_effects']);

$_POST['options']['modules']['custom_css'] = $custom_css;

// delete cache when is activated
if (!empty($this->plugin_settings['general']['status']) && $this->plugin_settings['general']['status'] == 1) {
$this->delete_cache();
}
break;
}

$this->plugin_settings[$tab] = array_map('stripslashes_deep', $_POST['options'][$tab]);
$this->plugin_settings[$tab] = $_POST['options'][$tab];
update_option('wpmm_settings', $this->plugin_settings);
}
}

/**
* Delete cache if any cache plugin (wp_cache or w3tc) is activated
*
* @since 2.0.1
*/
public function delete_cache() {
// Super Cache Plugin
if (function_exists('wp_cache_clear_cache')) {
wp_cache_clear_cache(get_current_blog_id());
}

// W3 Total Cache Plugin
if (function_exists('w3tc_pgcache_flush')) {
w3tc_pgcache_flush();
}
}

/**
* Add settings link
*
Expand All @@ -299,7 +327,7 @@ public function save_plugin_settings() {
public function add_settings_link($links) {
return array_merge(
array(
'settings' => '<a href="' . admin_url('options-general.php?page=' . $this->plugin_slug) . '">' . __('Settings', $this->plugin_slug) . '</a>'
'wpmm_settings' => '<a href="' . admin_url('options-general.php?page=' . $this->plugin_slug) . '">' . __('Settings', $this->plugin_slug) . '</a>'
), $links
);
}
Expand Down
30 changes: 10 additions & 20 deletions includes/classes/wp-maintenance-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class WP_Maintenance_Mode {

const VERSION = '2.0.0';
const VERSION = '2.0.1';

protected $plugin_slug = 'wp-maintenance-mode';
protected $plugin_settings;
Expand Down Expand Up @@ -391,19 +391,6 @@ public function load_plugin_textdomain() {
* Initialize when plugin is activated
*/
public function init() {
/**
* DELETE CACHE IF ACTIVATED
*/
// Super Cache Plugin
if (function_exists('wp_cache_clear_cache')) {
wp_cache_clear_cache(get_current_blog_id());
}

// W3 Total Cache Plugin
if (function_exists('w3tc_pgcache_flush')) {
w3tc_pgcache_flush();
}

/**
* CHECKS
*/
Expand All @@ -421,8 +408,8 @@ public function init() {
// HEADER STUFF
$protocol = !empty($_SERVER['SERVER_PROTOCOL']) && in_array($_SERVER['SERVER_PROTOCOL'], array('HTTP/1.1', 'HTTP/1.0')) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
$charset = get_bloginfo('charset') ? get_bloginfo('charset') : 'UTF-8';
$status_code = (int) apply_filters('wp_maintenance_mode_status_code', '503'); // this hook will be removed in the next versions
$status_code = (int) apply_filters('wpmm_status_code', '503');
$status_code = (int) apply_filters('wp_maintenance_mode_status_code', 503); // this hook will be removed in the next versions
$status_code = (int) apply_filters('wpmm_status_code', 503);
$backtime_seconds = $this->calculate_backtime();
$backtime = (int) apply_filters('wpmm_backtime', $backtime_seconds);

Expand All @@ -447,7 +434,9 @@ public function init() {

// CSS STUFF
$body_classes = !empty($this->plugin_settings['design']['bg_type']) && $this->plugin_settings['design']['bg_type'] != 'color' ? 'background' : '';
$custom_css = array_merge($this->plugin_settings['design']['custom_css'], $this->plugin_settings['modules']['custom_css']);
$custom_css_design = !empty($this->plugin_settings['design']['custom_css']) && is_array($this->plugin_settings['design']['custom_css']) ? $this->plugin_settings['design']['custom_css'] : array();
$custom_css_modules = !empty($this->plugin_settings['modules']['custom_css']) && is_array($this->plugin_settings['modules']['custom_css']) ? $this->plugin_settings['modules']['custom_css'] : array();
$custom_css = array_merge($custom_css_design, $custom_css_modules);

// CONTENT
$heading = !empty($this->plugin_settings['design']['heading']) ? $this->plugin_settings['design']['heading'] : '';
Expand Down Expand Up @@ -616,7 +605,8 @@ public function redirect() {
}

if (preg_match('#wp-admin/#', $_SERVER['REQUEST_URI'])) {
wp_redirect($this->plugin_settings['general']['redirection']);
$redirect_to = stripslashes($this->plugin_settings['general']['redirection']);
wp_redirect($redirect_to);
}
}

Expand All @@ -635,7 +625,7 @@ public function add_subscriber() {
if (empty($exists)) {
$wpdb->insert(
$wpdb->prefix . 'wpmm_subscribers', array(
'email' => $_REQUEST['email'],
'email' => sanitize_text_field($_REQUEST['email']),
'insert_date' => date('Y-m-d H:i:s')
), array('%s', '%s'));
}
Expand Down Expand Up @@ -673,7 +663,7 @@ public function send_contact() {
$email_content = ob_get_contents();
ob_clean();

$send_to = !empty($this->plugin_settings['modules']['contact_email']) ? $this->plugin_settings['modules']['contact_email'] : get_option('admin_email');
$send_to = !empty($this->plugin_settings['modules']['contact_email']) ? stripslashes($this->plugin_settings['modules']['contact_email']) : get_option('admin_email');
$subject = __('Message via contact', $this->plugin_slug);
add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ We embedded a new css style on maintenance page. Same mechanism can be used for

**Cache Plugin Support**

The plugin flush the cache on activate the maintenance mode form the plugins W3 Total Cache and WP Super Cache
WP Maintenance Mode can be unstable due the cache plugins, we recommend to deactivate any cache plugin when maintenance mode is active.

## Other Notes
### License
Expand Down
20 changes: 15 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Author URI: http://designmodo.com/
Tags: maintenance, mode, admin, administration, unavailable, coming soon, multisite, landing page, under construction, contact form, subscribe, countdown
Requires at least: 3.5
Tested up to: 3.9.2
Stable tag: 2.0.0
Stable tag: 2.0.1
License: GPL-2.0+

Adds a splash page to your site that lets visitors know your site is down for maintenance. It's perfect for a coming soon page.
Expand Down Expand Up @@ -60,19 +60,29 @@ Please give us feedback, contribute and file technical bugs on [GitHub Repo](htt
See [GitHub Repo] (https://github.com/Designmodocom/WP-Maintenance-Mode) FAQ.

= Cache Plugin Support =
The plugin flush the cache on activate the maintenance mode form the plugins W3 Total Cache and WP Super Cache
WP Maintenance Mode can be unstable due the cache plugins, we recommend to deactivate any cache plugin when maintenance mode is active.

== Changelog ==

= 2.0.0 (02/09/2014) =
= 2.0.1 (02/09/2014) =
* Reintroduced some deprecated actions from old version (but still available in next 4 releases, after that will be removed) and replaced with new ones:
- `wm_head` -> `wpmm_head`
- `wm_footer` -> `wpmm_footer`
* Multisite settings link fix
* WP_Maintenance_Mode: init (array checking for custom_css arrays, move delete cache part into a helper, etc.), add_subscriber, send_contact, redirect fixes & optimizations
* WP_Maintenance_Mode_Admin: save_plugin_settings fixes, delete_cache (new method)
* Settings & Maintenance views fixes
* Readme.txt changes

= 2.0.0 (01/09/2014) =
* Changed design and functionality, new features
* Changed multisite behaviour: now you can activate maintenance individually (each blog from the network has it's own maintenance settings)
* Removed actions: `wm_header`, `wm_footer`, `wm_content`
* Removed filters: `wm_header`
* Removed [loginform] shortcode
* Some filters are depreciated (but still available in next 4 releases, after that will be removed) and replaced with new ones:
* Some filters are deprecated (but still available in next 4 releases, after that will be removed) and replaced with new ones:
- `wm_heading` -> `wpmm_heading`,
- `wp_maintenance_mode_status_code` -> `wp_maintenance_mode_status_code`
- `wp_maintenance_mode_status_code` -> `wpmm_status_code`
- `wm_title` -> `wpmm_meta_title`
- `wm_meta_author` -> `wpmm_meta_author`
- `wm_meta_description` -> `wpmm_meta_description`
Expand Down
Loading

0 comments on commit 45b6e6f

Please sign in to comment.