Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
git-svn-id: https://plugins.svn.wordpress.org/w3tc-auto-pilot/trunk@1177219 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information
Cybr authored and Cybr committed Jun 9, 2015
1 parent b988b47 commit 9958034
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=== W3TC Auto Pilot ===
Contributors: cybr
Tags: cache, control, w3, total
Tags: cache, control, w3, total, automatic, flush, update, multisite, mapping, hide
Requires at least: 3.6.0
Tested up to: 4.2.2
Stable tag: 4.2.2
Expand Down Expand Up @@ -50,8 +50,11 @@ It's absolutely great on MultiSite installations, especially when you allow untr

== Changelog ==

= 1.0.3 =
* Fine tuned the purging of page cache to only when a domain is actually mapped.

= 1.0.2 =
* Added forced page cache purging on each post save when Domain Mapping (by WPMUdev) is active
* Added forced page cache purging on each post save when Domain Mapping (by WPMUdev) is active. This will fix a bug with Domain Mapping.

= 1.0.1 =
* Removed admin notices and errors for non-super-admins (MultiSite) / non-admins (single)
Expand Down
31 changes: 28 additions & 3 deletions w3tc-auto-pilot.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: W3TC Auto Pilot
* Plugin URI: https://wordpress.org/plugins/w3tc-auto-pilot/
* Description: Put W3 Total Cache on auto pilot. This plugin allows you to control W3 Total Cache in such a manner that no one knows you're using it, not even your admins. Either network activate it or activate it per site.
* Version: 1.0.2
* Version: 1.0.3
* Author: Sybre Waaijer
* Author URI: https://cyberwire.nl/
* License: GPLv2 or later
Expand Down Expand Up @@ -61,8 +61,21 @@ function wap_w3tc_init() {

function wap_mapped_clear() {
//* Check for domain-mapping plugin
if ( is_plugin_active( 'domain-mapping/domain-mapping.php' ))
add_action( 'save_post', 'wap_w3tc_flush_page' );
if ( is_plugin_active( 'domain-mapping/domain-mapping.php' )) {
global $wpdb,$blog_id;

$ismapped = wp_cache_get('wap_mapped_clear_' . $blog_id, 'domain_mapping' );
if ( false === $ismapped ) {
$ismapped = $wpdb->get_var( $wpdb->prepare( "SELECT domain FROM {$wpdb->base_prefix}domain_mapping WHERE blog_id = %d", $blog_id ) ); //string
wp_cache_set('wap_mapped_clear_' . $blog_id, $ismapped, 'domain_mapping', 3600 ); // 1 hour
}

//* string $ismapped, if mapped != ''
if ( !empty($ismapped) ) {
// add_action( 'save_post', 'wap_w3tc_flush_single_post' ); // Doesn't work unfortunately with Domain Mapping... somehow 2 ID's are being created?
add_action( 'save_post', 'wap_w3tc_flush_page' ); // So we just flush it entirely. But only if the domain is mapped! :D
}
}
}

function wap_w3tc_flush_all() {
Expand Down Expand Up @@ -115,6 +128,18 @@ function wap_w3tc_flush_all_widget($instance, $new_instance, $old_instance, $thi
return $instance;
}

function wap_w3tc_flush_single_post() {

// Purge the single page cache
if ( function_exists( 'w3tc_pgcache_flush_post' ) ) {
global $post;
$post_id = $post->ID;

w3tc_pgcache_flush_post($post_id);
}

}

function wap_w3tc_flush_page() {

// Purge the entire page cache
Expand Down

0 comments on commit 9958034

Please sign in to comment.