Files
apache
wp-content
mu-plugins
plugins
themes
upgrade-temp-backup
plugins
w3-total-cache
extension-example
inc
ini
languages
lib
pub
vendor
wp-content
Base_Page_Settings.php
BrowserCache_ConfigLabels.php
BrowserCache_Core.php
BrowserCache_Environment.php
BrowserCache_Environment_Apache.php
BrowserCache_Environment_LiteSpeed.php
BrowserCache_Environment_Nginx.php
BrowserCache_Page.php
BrowserCache_Page_View_QuickReference.php
BrowserCache_Page_View_SectionSecurity.php
BrowserCache_Plugin.php
BrowserCache_Plugin_Admin.php
Cache.php
CacheFlush.php
CacheFlush_Locally.php
CacheGroups_Plugin_Admin.php
CacheGroups_Plugin_Admin_View.js
CacheGroups_Plugin_Admin_View.php
Cache_Apc.php
Cache_Apcu.php
Cache_Base.php
Cache_Eaccelerator.php
Cache_File.php
Cache_File_Cleaner.php
Cache_File_Cleaner_Generic.php
Cache_File_Cleaner_Generic_HardDelete.php
Cache_File_Generic.php
Cache_Memcache.php
Cache_Memcached.php
Cache_Memcached_Stats.php
Cache_Nginx_Memcached.php
Cache_Redis.php
Cache_Wincache.php
Cache_Xcache.php
CdnEngine.php
CdnEngine_Azure.php
CdnEngine_Base.php
CdnEngine_CloudFront.php
CdnEngine_Ftp.php
CdnEngine_GoogleDrive.php
CdnEngine_Mirror.php
CdnEngine_Mirror_Akamai.php
CdnEngine_Mirror_Att.php
CdnEngine_Mirror_BunnyCdn.php
CdnEngine_Mirror_CloudFront.php
CdnEngine_Mirror_Cotendo.php
CdnEngine_Mirror_Edgecast.php
CdnEngine_Mirror_Highwinds.php
CdnEngine_Mirror_LimeLight.php
CdnEngine_Mirror_RackSpaceCdn.php
CdnEngine_Mirror_StackPath.php
CdnEngine_Mirror_StackPath2.php
CdnEngine_RackSpaceCloudFiles.php
CdnEngine_S3.php
CdnEngine_S3_Compatible.php
Cdn_AdminActions.php
Cdn_AdminNotes.php
Cdn_BunnyCdn_Api.php
Cdn_BunnyCdn_Page.php
Cdn_BunnyCdn_Page_View.js
Cdn_BunnyCdn_Page_View.php
Cdn_BunnyCdn_Page_View_Purge_Urls.php
Cdn_BunnyCdn_Popup.php
Cdn_BunnyCdn_Popup_View_Configured.php
Cdn_BunnyCdn_Popup_View_Deauthorize.php
Cdn_BunnyCdn_Popup_View_Deauthorized.php
Cdn_BunnyCdn_Popup_View_Intro.php
Cdn_BunnyCdn_Popup_View_Pull_Zones.php
Cdn_BunnyCdn_Widget.php
Cdn_BunnyCdn_Widget_View.css
Cdn_BunnyCdn_Widget_View_Authorized.php
Cdn_BunnyCdn_Widget_View_Unauthorized.php
Cdn_CacheFlush.php
Cdn_ConfigLabels.php
Cdn_Core.php
Cdn_Core_Admin.php
Cdn_Environment.php
Cdn_Environment_LiteSpeed.php
Cdn_Environment_Nginx.php
Cdn_GeneralPage_View.php
Cdn_GoogleDrive_AdminActions.php
Cdn_GoogleDrive_Page.php
Cdn_GoogleDrive_Page_View.js
Cdn_GoogleDrive_Page_View.php
Cdn_GoogleDrive_Popup_AuthReturn.php
Cdn_GoogleDrive_Popup_AuthReturn_View.php
Cdn_Highwinds_Api.php
Cdn_Highwinds_Page.php
Cdn_Highwinds_Page_View.js
Cdn_Highwinds_Page_View.php
Cdn_Highwinds_Popup.php
Cdn_Highwinds_Popup_View_ConfigureCnamesForm.php
Cdn_Highwinds_Popup_View_Intro.php
Cdn_Highwinds_Popup_View_SelectHost.php
Cdn_LimeLight_Page.php
Cdn_LimeLight_Page_View.js
Cdn_LimeLight_Page_View.php
Cdn_LimeLight_Popup.php
Cdn_LimeLight_Popup_View_Intro.php
Cdn_LimeLight_Popup_View_Success.php
Cdn_Page.php
Cdn_Page_View_Fsd_HeaderActions.php
Cdn_Plugin.php
Cdn_Plugin_Admin.php
Cdn_RackSpaceCdn_AdminActions.php
Cdn_RackSpaceCdn_Page.php
Cdn_RackSpaceCdn_Page_View.js
Cdn_RackSpaceCdn_Page_View.php
Cdn_RackSpaceCdn_Popup.php
Cdn_RackSpaceCdn_Popup_View_ConfigureDomains.php
Cdn_RackSpaceCdn_Popup_View_Intro.php
Cdn_RackSpaceCdn_Popup_View_Regions.php
Cdn_RackSpaceCdn_Popup_View_Service_Actualize.php
Cdn_RackSpaceCdn_Popup_View_Service_Create.php
Cdn_RackSpaceCdn_Popup_View_Service_Created.php
Cdn_RackSpaceCdn_Popup_View_Services.php
Cdn_RackSpaceCloudFiles_Page.php
Cdn_RackSpaceCloudFiles_Page_View.js
Cdn_RackSpaceCloudFiles_Page_View.php
Cdn_RackSpaceCloudFiles_Popup.php
Cdn_RackSpaceCloudFiles_Popup_View_Containers.php
Cdn_RackSpaceCloudFiles_Popup_View_Intro.php
Cdn_RackSpaceCloudFiles_Popup_View_Regions.php
Cdn_RackSpace_Api_CaCert-example.pem
Cdn_RackSpace_Api_Cdn.php
Cdn_RackSpace_Api_CloudFiles.php
Cdn_RackSpace_Api_CloudFilesCdn.php
Cdn_RackSpace_Api_Tokens.php
Cdn_StackPath2_Api.php
Cdn_StackPath2_Page.php
Cdn_StackPath2_Page_View.js
Cdn_StackPath2_Page_View.php
Cdn_StackPath2_Popup.php
Cdn_StackPath2_Popup_View_Intro.php
Cdn_StackPath2_Popup_View_Sites.php
Cdn_StackPath2_Popup_View_Stacks.php
Cdn_StackPath2_Popup_View_Success.php
Cdn_StackPath_Api.php
Cdn_StackPath_Page.php
Cdn_StackPath_Page_View.js
Cdn_StackPath_Page_View.php
Cdn_StackPath_Popup.php
Cdn_StackPath_Popup_View_Intro.php
Cdn_StackPath_Popup_View_Success.php
Cdn_StackPath_Popup_View_Zone.php
Cdn_StackPath_Popup_View_Zones.php
Cdn_Util.php
Cdnfsd_BunnyCdn_Engine.php
Cdnfsd_BunnyCdn_Page.php
Cdnfsd_BunnyCdn_Page_View.js
Cdnfsd_BunnyCdn_Page_View.php
Cdnfsd_BunnyCdn_Popup.php
Cdnfsd_BunnyCdn_Popup_View_Configured.php
Cdnfsd_BunnyCdn_Popup_View_Deauthorize.php
Cdnfsd_BunnyCdn_Popup_View_Deauthorized.php
Cdnfsd_BunnyCdn_Popup_View_Intro.php
Cdnfsd_BunnyCdn_Popup_View_Pull_Zones.php
Cdnfsd_CacheFlush.php
Cdnfsd_CloudFront_Engine.php
Cdnfsd_CloudFront_Page.php
Cdnfsd_CloudFront_Page_View.js
Cdnfsd_CloudFront_Page_View.php
Cdnfsd_CloudFront_Popup.php
Cdnfsd_CloudFront_Popup_View_Distribution.php
Cdnfsd_CloudFront_Popup_View_Distributions.php
Cdnfsd_CloudFront_Popup_View_Intro.php
Cdnfsd_CloudFront_Popup_View_Success.php
Cdnfsd_Core.php
Cdnfsd_GeneralPage_View.php
Cdnfsd_LimeLight_Api.php
Cdnfsd_LimeLight_Engine.php
Cdnfsd_LimeLight_Page.php
Cdnfsd_LimeLight_Page_View.js
Cdnfsd_LimeLight_Page_View.php
Cdnfsd_LimeLight_Popup.php
Cdnfsd_LimeLight_Popup_View_Intro.php
Cdnfsd_LimeLight_Popup_View_Success.php
Cdnfsd_Plugin.php
Cdnfsd_Plugin_Admin.php
Cdnfsd_StackPath2_Engine.php
Cdnfsd_StackPath2_Page.php
Cdnfsd_StackPath2_Page_View.js
Cdnfsd_StackPath2_Page_View.php
Cdnfsd_StackPath2_Popup.php
Cdnfsd_StackPath2_Popup_View_Intro.php
Cdnfsd_StackPath2_Popup_View_Sites.php
Cdnfsd_StackPath2_Popup_View_Stacks.php
Cdnfsd_StackPath2_Popup_View_Success.php
Cdnfsd_StackPath_Engine.php
Cdnfsd_StackPath_Page.php
Cdnfsd_StackPath_Page_View.js
Cdnfsd_StackPath_Page_View.php
Cdnfsd_StackPath_Popup.php
Cdnfsd_StackPath_Popup_View_Intro.php
Cdnfsd_StackPath_Popup_View_Success.php
Cdnfsd_StackPath_Popup_View_Zone.php
Cdnfsd_StackPath_Popup_View_Zones.php
Cdnfsd_TransparentCDN_Engine.php
Cdnfsd_TransparentCDN_Page.php
Cdnfsd_TransparentCDN_Page_View.js
Cdnfsd_TransparentCDN_Page_View.php
Cdnfsd_Util.php
Cli.php
Config.php
ConfigCache.php
ConfigCompiler.php
ConfigDbStorage.php
ConfigKeys.php
ConfigState.php
ConfigStateNote.php
ConfigUtil.php
DbCache_ConfigLabels.php
DbCache_Core.php
DbCache_Environment.php
DbCache_Page.php
DbCache_Plugin.php
DbCache_Plugin_Admin.php
DbCache_Wpdb.php
DbCache_WpdbBase.php
DbCache_WpdbInjection.php
DbCache_WpdbInjection_QueryCaching.php
DbCache_WpdbLegacy.php
DbCache_WpdbNew.php
Dispatcher.php
Enterprise_CacheFlush_MakeSnsEvent.php
Enterprise_Dbcache_WpdbInjection_Cluster.php
Enterprise_SnsBase.php
Enterprise_SnsServer.php
Extension_Amp_Page_View.php
Extension_Amp_Plugin.php
Extension_Amp_Plugin_Admin.php
Extension_CloudFlare_AdminActions.php
Extension_CloudFlare_Api.php
Extension_CloudFlare_Cdn_Page_View.php
Extension_CloudFlare_GeneralPage_View.php
Extension_CloudFlare_Page.php
Extension_CloudFlare_Page_View.js
Extension_CloudFlare_Page_View.php
Extension_CloudFlare_Plugin.php
Extension_CloudFlare_Plugin_Admin.php
Extension_CloudFlare_Popup.php
Extension_CloudFlare_Popup_View_Intro.php
Extension_CloudFlare_Popup_View_Zones.php
Extension_CloudFlare_SettingsForUi.php
Extension_CloudFlare_View_Dashboard.js
Extension_CloudFlare_Widget.php
Extension_CloudFlare_Widget_Logo.png
Extension_CloudFlare_Widget_View.css
Extension_CloudFlare_Widget_View.php
Extension_FragmentCache_Api.php
Extension_FragmentCache_Core.php
Extension_FragmentCache_Environment.php
Extension_FragmentCache_GeneralPage.php
Extension_FragmentCache_GeneralPage_View.php
Extension_FragmentCache_Page.php
Extension_FragmentCache_Page_View.php
Extension_FragmentCache_Plugin.php
Extension_FragmentCache_Plugin_Admin.php
Extension_FragmentCache_WpObjectCache.php
Extension_Genesis_Page.php
Extension_Genesis_Page_View.php
Extension_Genesis_Plugin.php
Extension_Genesis_Plugin_Admin.php
Extension_ImageService_Api.php
Extension_ImageService_Cron.php
Extension_ImageService_Environment.php
Extension_ImageService_Page_View.php
Extension_ImageService_Plugin.php
Extension_ImageService_Plugin_Admin.css
Extension_ImageService_Plugin_Admin.js
Extension_ImageService_Plugin_Admin.php
Extension_ImageService_Widget.js
Extension_ImageService_Widget.php
Extension_ImageService_Widget_View.php
Extension_NewRelic_AdminActions.php
Extension_NewRelic_AdminNotes.php
Extension_NewRelic_Api.php
Extension_NewRelic_Core.php
Extension_NewRelic_GeneralPage.php
Extension_NewRelic_GeneralPage_View.php
Extension_NewRelic_Page.php
Extension_NewRelic_Page_View_Apm.php
Extension_NewRelic_Plugin.php
Extension_NewRelic_Plugin_Admin.php
Extension_NewRelic_Popup.php
Extension_NewRelic_Popup_View.js
Extension_NewRelic_Popup_View_Intro.php
Extension_NewRelic_Popup_View_ListApplications.php
Extension_NewRelic_Service.php
Extension_NewRelic_Widget.php
Extension_NewRelic_Widget_View.css
Extension_NewRelic_Widget_View.js
Extension_NewRelic_Widget_View_Apm.php
Extension_NewRelic_Widget_View_Browser.php
Extension_NewRelic_Widget_View_NotConfigured.php
Extension_Swarmify_AdminActions.php
Extension_Swarmify_Core.php
Extension_Swarmify_Page.php
Extension_Swarmify_Page_View.php
Extension_Swarmify_Plugin.php
Extension_Swarmify_Plugin_Admin.php
Extension_WordPressSeo_Plugin.php
Extension_WordPressSeo_Plugin_Admin.php
Extension_Wpml_Plugin.php
Extension_Wpml_Plugin_Admin.php
Extensions_AdminActions.php
Extensions_Page.php
Extensions_Plugin_Admin.php
Extensions_Util.php
FeatureShowcase_Plugin_Admin.php
FeatureShowcase_Plugin_Admin_View.php
Generic_AdminActions_Config.php
Generic_AdminActions_Default.php
Generic_AdminActions_Flush.php
Generic_AdminActions_Test.php
Generic_AdminNotes.php
Generic_ConfigLabels.php
Generic_Environment.php
Generic_Faq.php
Generic_GeneralPage_View_ShowEdge.js
Generic_GeneralPage_View_ShowSupportUs.js
Generic_Page_About.php
Generic_Page_Dashboard.php
Generic_Page_Dashboard_View.css
Generic_Page_General.php
Generic_Page_Install.php
Generic_Page_PurgeLog.php
Generic_Page_PurgeLog_View.php
Generic_Plugin.php
Generic_Plugin_Admin.php
Generic_Plugin_AdminCompatibility.php
Generic_Plugin_AdminNotifications.php
Generic_Plugin_AdminRowActions.php
Generic_Plugin_Admin_View_Faq.php
Generic_WidgetAccount.php
Generic_WidgetAccount_View.php
Generic_WidgetBoldGrid.php
Generic_WidgetBoldGrid_AdminActions.php
Generic_WidgetBoldGrid_Logo.svg
Generic_WidgetBoldGrid_View.js
Generic_WidgetBoldGrid_View.php
Generic_WidgetPartners.php
Generic_WidgetPartners_View.php
Generic_WidgetServices.php
Generic_WidgetServices_View.php
Generic_WidgetSettings.php
Generic_WidgetSettings_View.php
Generic_WidgetSpreadTheWord.js
Generic_WidgetSpreadTheWord_Plugin.php
Generic_WidgetSpreadTheWord_View.php
Generic_WidgetStats.js
Generic_WidgetStats.php
LICENSE
Licensing_AdminActions.php
Licensing_Core.php
Licensing_Plugin_Admin.php
Minify_AutoCss.php
Minify_AutoJs.php
Minify_ConfigLabels.php
Minify_ContentMinifier.php
Minify_Core.php
Minify_Environment.php
Minify_Environment_LiteSpeed.php
Minify_Extract.php
Minify_GeneralPage_View_ShowHelp.js
Minify_GeneralPage_View_ShowHelpForce.js
Minify_HelpPopup_View.php
Minify_MinifiedFileRequestHandler.php
Minify_Page.php
Minify_Plugin.php
Minify_Plugin_Admin.php
Mobile_Base.php
Mobile_Redirect.php
Mobile_Referrer.php
Mobile_UserAgent.php
ModuleStatus.php
ObjectCache_ConfigLabels.php
ObjectCache_Environment.php
ObjectCache_Page.php
ObjectCache_Page_View_PurgeLog.php
ObjectCache_Plugin.php
ObjectCache_Plugin_Admin.php
ObjectCache_WpObjectCache.php
ObjectCache_WpObjectCache_Regular.php
PageSpeed_Api.php
PageSpeed_Data.php
PageSpeed_Instructions.php
PageSpeed_Page.php
PageSpeed_Page_View.css
PageSpeed_Page_View.js
PageSpeed_Page_View.php
PageSpeed_Page_View_FromAPI.php
PageSpeed_Widget.php
PageSpeed_Widget_View.css
PageSpeed_Widget_View.js
PageSpeed_Widget_View.php
PageSpeed_Widget_View_FromApi.php
PgCache_ConfigLabels.php
PgCache_ContentGrabber.php
PgCache_Environment.php
PgCache_Flush.php
PgCache_Page.php
PgCache_Page_View.js
PgCache_Plugin.php
PgCache_Plugin_Admin.php
PgCache_QsExempts.php
Root_AdminActions.php
Root_AdminActivation.php
Root_AdminMenu.php
Root_Environment.php
Root_Loader.php
SetupGuide_Plugin_Admin.php
Support_AdminActions.php
Support_Page.php
Support_Page_View_DoneContent.php
Support_Page_View_PageContent.php
SystemOpCache_AdminActions.php
SystemOpCache_Core.php
SystemOpCache_GeneralPage_View.php
SystemOpCache_Plugin_Admin.php
UsageStatistics_AdminActions.php
UsageStatistics_Core.php
UsageStatistics_GeneralPage.php
UsageStatistics_GeneralPage_View.php
UsageStatistics_Page.php
UsageStatistics_Page_DbRequests_View.php
UsageStatistics_Page_ObjectCacheLog_View.php
UsageStatistics_Page_PageCacheRequests_View.php
UsageStatistics_Page_View.css
UsageStatistics_Page_View.js
UsageStatistics_Page_View.php
UsageStatistics_Page_View_Ad.php
UsageStatistics_Page_View_Disabled.php
UsageStatistics_Page_View_Free.php
UsageStatistics_Page_View_NoDebugMode.php
UsageStatistics_Plugin.php
UsageStatistics_Plugin_Admin.php
UsageStatistics_Source_AccessLog.php
UsageStatistics_Source_DbQueriesLog.php
UsageStatistics_Source_ObjectCacheLog.php
UsageStatistics_Source_PageCacheLog.php
UsageStatistics_Source_Wpdb.php
UsageStatistics_Sources.php
UsageStatistics_Sources_Apc.php
UsageStatistics_Sources_Memcached.php
UsageStatistics_Sources_Redis.php
UsageStatistics_StorageReader.php
UsageStatistics_StorageWriter.php
UserExperience_DeferScripts_Extension.php
UserExperience_DeferScripts_Mutator.php
UserExperience_DeferScripts_Page_View.php
UserExperience_DeferScripts_Script.js
UserExperience_Emoji_Extension.php
UserExperience_GeneralPage.php
UserExperience_GeneralPage_View.php
UserExperience_LazyLoad_GoogleMaps_GoogleMapsEasy.php
UserExperience_LazyLoad_GoogleMaps_WPGoogleMapPlugin.php
UserExperience_LazyLoad_GoogleMaps_WPGoogleMaps.php
UserExperience_LazyLoad_Mutator.php
UserExperience_LazyLoad_Mutator_Picture.php
UserExperience_LazyLoad_Mutator_Unmutable.php
UserExperience_LazyLoad_Page_View.php
UserExperience_LazyLoad_Plugin.php
UserExperience_OEmbed_Extension.php
UserExperience_Page.php
UserExperience_Page_View.php
UserExperience_Plugin_Admin.php
UserExperience_Plugin_Jquery.php
UserExperience_Preload_Requests_Extension.php
UserExperience_Preload_Requests_Page_View.php
UserExperience_Remove_CssJs_Extension.php
UserExperience_Remove_CssJs_Mutator.php
UserExperience_Remove_CssJs_Page_View.js
UserExperience_Remove_CssJs_Page_View.php
Util_Activation.php
Util_Admin.php
Util_AttachToActions.php
Util_Bus.php
Util_ConfigLabel.php
Util_Content.php
Util_Debug.php
Util_DebugPurgeLog_Reader.php
Util_Environment.php
Util_Environment_Exception.php
Util_Environment_Exceptions.php
Util_File.php
Util_Http.php
Util_Installed.php
Util_Mime.php
Util_PageSpeed.php
Util_PageUrls.php
Util_Request.php
Util_Rule.php
Util_Theme.php
Util_Ui.php
Util_UsageStatistics.php
Util_Widget.php
Util_WpFile.php
Util_WpFile_FilesystemChmodException.php
Util_WpFile_FilesystemCopyException.php
Util_WpFile_FilesystemMkdirException.php
Util_WpFile_FilesystemModifyException.php
Util_WpFile_FilesystemOperationException.php
Util_WpFile_FilesystemRmException.php
Util_WpFile_FilesystemRmdirException.php
Util_WpFile_FilesystemWriteException.php
Util_WpmuBlogmap.php
Varnish_Flush.php
Varnish_Plugin.php
index.html
press.txt
readme.txt
w3-total-cache-api.php
w3-total-cache-old-php.php
w3-total-cache.php
w3tc-config
index.php
.gitignore
htaccess
php.ini
laipower/wp-content/upgrade-temp-backup/plugins/w3-total-cache/PgCache_Flush.php

468 lines
13 KiB
PHP

<?php
namespace W3TC;
/**
* W3 PgCache flushing
*/
class PgCache_Flush extends PgCache_ContentGrabber {
/**
* Array of urls to flush
*/
private $queued_urls = array();
private $queued_groups = array();
private $queued_post_ids = array();
private $flush_all_operation_requested = false;
private $debug_purge = false;
public function __construct() {
parent::__construct();
$this->debug_purge = $this->_config->get_boolean( 'pgcache.debug_purge' );
}
/**
* Flushes all caches
*/
public function flush() {
if ( $this->debug_purge ) {
Util_Debug::log_purge( 'pagecache', 'flush_all' );
}
$this->flush_all_operation_requested = true;
return true;
}
public function flush_group( $group ) {
if ( $this->debug_purge ) {
Util_Debug::log_purge( 'pagecache', 'flush_group', $group );
}
$this->queued_groups[$group] = '*';
}
/**
* Flushes post cache
*
* @param integer $post_id Post ID.
* @param boolean $force Force flag (optional).
*/
public function flush_post( $post_id = null, $force = false ) {
if ( !$post_id ) {
$post_id = Util_Environment::detect_post_id();
}
if ( !$post_id ) {
return false;
}
global $wp_rewrite; // required by many Util_PageUrls methods
if ( empty( $wp_rewrite ) ) {
if ( $this->debug_purge ) {
Util_Debug::log_purge( 'pagecache', 'flush_post', array(
'post_id' => $post_id,
'error' => 'Post flush attempt before wp_rewrite initialization. Cant flush cache.'
) );
}
error_log('Post flush attempt before wp_rewrite initialization. Cant flush cache.');
return false;
}
// prevent multiple calculation of post urls
$queued_post_id_key = Util_Environment::blog_id() . '.' . $post_id;
if ( isset( $this->queued_post_ids[$queued_post_id_key] ) ) {
return true;
}
$this->queued_post_ids[$queued_post_id_key] = '*';
// calculate urls to purge
$full_urls = array();
$post = get_post( $post_id );
if ( empty( $post ) ) {
return true;
}
$is_cpt = Util_Environment::is_custom_post_type( $post );
$terms = array();
$feeds = $this->_config->get_array( 'pgcache.purge.feed.types' );
$limit_post_pages = $this->_config->get_integer( 'pgcache.purge.postpages_limit' );
if ( $this->_config->get_string( 'pgcache.rest' ) == 'cache' ) {
$this->flush_group( 'rest' );
}
if ( $this->_config->get_boolean( 'pgcache.purge.terms' ) ||
$this->_config->get_boolean( 'pgcache.purge.feed.terms' ) ) {
$taxonomies = get_post_taxonomies( $post_id );
$terms = wp_get_post_terms( $post_id, $taxonomies );
$terms = $this->_append_parent_terms( $terms, $terms );
}
$front_page = get_option( 'show_on_front' );
// Home (Frontpage) URL
if ( ( $this->_config->get_boolean( 'pgcache.purge.home' ) &&
$front_page == 'posts' ) ||
$this->_config->get_boolean( 'pgcache.purge.front_page' ) ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_frontpage_urls( $limit_post_pages ) );
}
// pgcache.purge.home becomes "Posts page" option in settings if home page and blog are set to page(s)
// Home (Post page) URL
if ( $this->_config->get_boolean( 'pgcache.purge.home' ) &&
$front_page != 'posts' &&
!$is_cpt ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_postpage_urls( $limit_post_pages ) );
}
// pgcache.purge.home becomes "Posts page" option in settings if home page and blog are set to page(s)
// Custom Post Type Archive URL
if ( $this->_config->get_boolean( 'pgcache.purge.home' ) &&
$is_cpt ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_cpt_archive_urls( $post_id, $limit_post_pages ) );
}
// Post URL
if ( $this->_config->get_boolean( 'pgcache.purge.post' ) || $force ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_post_urls( $post_id ) );
}
// Post comments URLs
if ( $this->_config->get_boolean( 'pgcache.purge.comments' ) &&
function_exists( 'get_comments_pagenum_link' ) ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_post_comments_urls( $post_id ) );
}
// Post author URLs
if ( $this->_config->get_boolean( 'pgcache.purge.author' ) && $post ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_post_author_urls( $post->post_author,
$limit_post_pages ) );
}
// Post terms URLs
if ( $this->_config->get_boolean( 'pgcache.purge.terms' ) ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_post_terms_urls( $terms, $limit_post_pages ) );
}
// Daily archive URLs
if ( $this->_config->get_boolean( 'pgcache.purge.archive.daily' ) && $post ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_daily_archive_urls( $post, $limit_post_pages ) );
}
// Monthly archive URLs
if ( $this->_config->get_boolean( 'pgcache.purge.archive.monthly' ) && $post ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_monthly_archive_urls( $post, $limit_post_pages ) );
}
// Yearly archive URLs
if ( $this->_config->get_boolean( 'pgcache.purge.archive.yearly' ) && $post ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_yearly_archive_urls( $post, $limit_post_pages ) );
}
// Feed URLs for posts
if ( $this->_config->get_boolean( 'pgcache.purge.feed.blog' ) &&
!$is_cpt ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_feed_urls( $feeds, null ) );
}
// Feed URLs for posts
if ( $this->_config->get_boolean( 'pgcache.purge.feed.blog' ) &&
$is_cpt ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_feed_urls( $feeds, $post->post_type ) );
}
if ( $this->_config->get_boolean( 'pgcache.purge.feed.comments' ) ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_feed_comments_urls( $post_id, $feeds ) );
}
if ( $this->_config->get_boolean( 'pgcache.purge.feed.author' ) ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_feed_author_urls( $post->post_author, $feeds ) );
}
if ( $this->_config->get_boolean( 'pgcache.purge.feed.terms' ) ) {
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_feed_terms_urls( $terms, $feeds ) );
}
// Purge selected pages
if ( $this->_config->get_array( 'pgcache.purge.pages' ) ) {
$pages = $this->_config->get_array( 'pgcache.purge.pages' );
$full_urls = array_merge( $full_urls,
Util_PageUrls::get_pages_urls( $pages ) );
}
// add mirror urls
$full_urls = Util_PageUrls::complement_with_mirror_urls( $full_urls );
$full_urls = apply_filters( 'pgcache_flush_post_queued_urls',
$full_urls );
if ( $this->debug_purge ) {
Util_Debug::log_purge( 'pagecache', 'flush_post', $post_id,
$full_urls );
}
// Queue flush
if ( count( $full_urls ) ) {
foreach ( $full_urls as $url )
$this->queued_urls[$url] = '*';
}
return true;
}
/**
* Flush a single url
*/
public function flush_url( $url ) {
$parts = parse_url( $url );
$uri = ( isset( $parts['path'] ) ? $parts['path'] : '' ) .
( isset( $parts['query'] ) ? '?' . $parts['query'] : '' );
$group = $this->get_cache_group_by_uri( $uri );
if ( $this->debug_purge ) {
Util_Debug::log_purge( 'pagecache', 'flush_url', array(
$url, $group ) );
}
$this->queued_urls[$url] = ( empty( $group ) ? '*' : $group );
}
/**
* Performs the actual flush at the end of request processing.
* Duplicate flushes avoided that way.
*/
public function flush_post_cleanup() {
if ( $this->flush_all_operation_requested ) {
if ( $this->_config->get_boolean( 'pgcache.debug' ) ) {
self::log( 'flush all' );
}
$groups_to_flush = array( '' );
if ( $this->_config->get_string( 'pgcache.rest' ) == 'cache' ) {
$groups_to_flush[] = 'rest';
}
$groups_to_flush = apply_filters(
'w3tc_pagecache_flush_all_groups', $groups_to_flush );
foreach ( $groups_to_flush as $group ) {
$cache = $this->_get_cache( $group );
$cache->flush( $group );
}
$count = 999;
$this->flush_all_operation_requested = false;
$this->queued_urls = array();
} else {
$count = 0;
if ( count( $this->queued_groups ) > 0 ) {
$count += count( $this->queued_urls );
foreach ( $this->queued_groups as $group => $flag ) {
if ( $this->_config->get_boolean( 'pgcache.debug' ) ) {
self::log( 'pgcache flush "' . $group . '" group' );
}
$cache = $this->_get_cache( $group );
$cache->flush( $group );
}
}
if ( count( $this->queued_urls ) > 0 ) {
if ( $this->_config->get_boolean( 'pgcache.debug' ) ) {
self::log( 'pgcache flush ' . $count . ' urls' );
}
$mobile_groups = $this->_get_mobile_groups();
$referrer_groups = $this->_get_referrer_groups();
$cookies = $this->_get_cookies();
$encryptions = $this->_get_encryptions();
$compressions = $this->_get_compressions();
$caches = array(
'*' => $this->_get_cache()
);
foreach ( $this->queued_urls as $url => $group ) {
if ( !isset( $caches[$group] ) ) {
$caches[$group] = $this->_get_cache( $group );
}
$this->_flush_url( $url, $caches[$group], $mobile_groups,
$referrer_groups, $cookies, $encryptions, $compressions,
$group == '*' ? '' : $group );
}
$count += count( $this->queued_urls );
// Purge sitemaps if a sitemap option has a regex
if ( $this->_config->get_string( 'pgcache.purge.sitemap_regex' ) ) {
$cache = $this->_get_cache( 'sitemaps' );
$cache->flush( 'sitemaps' );
$count++;
}
$this->queued_urls = array();
}
}
return $count;
}
/**
* Does the actual job - flushing of a single url cache entries
*/
private function _flush_url( $url, $cache, $mobile_groups, $referrer_groups,
$cookies, $encryptions, $compressions, $group ) {
if ( empty( $url ) ) {
return;
}
foreach ( $mobile_groups as $mobile_group ) {
foreach ( $referrer_groups as $referrer_group ) {
foreach ( $cookies as $cookie ) {
foreach ( $encryptions as $encryption ) {
foreach ( $compressions as $compression ) {
$page_keys = array();
$page_keys[] = $this->_get_page_key(
array(
'useragent' => $mobile_group,
'referrer' => $referrer_group,
'cookie' => $cookie,
'encryption' => $encryption,
'compression' => $compression,
'group' => $group
),
$url );
$page_keys = apply_filters(
'w3tc_pagecache_flush_url_keys', $page_keys );
foreach ( $page_keys as $page_key ) {
$cache->delete( $page_key, $group );
}
}
}
}
}
}
}
/**
* Returns array of mobile groups
*/
private function _get_mobile_groups() {
$mobile_groups = array( '' );
if ( $this->_mobile ) {
$mobile_groups = array_merge( $mobile_groups, array_keys(
$this->_mobile->get_groups() ) );
}
return $mobile_groups;
}
/**
* Returns array of referrer groups
*/
private function _get_referrer_groups() {
$referrer_groups = array( '' );
if ( $this->_referrer ) {
$referrer_groups = array_merge( $referrer_groups, array_keys(
$this->_referrer->get_groups() ) );
}
return $referrer_groups;
}
/**
* Returns array of cookies
*/
private function _get_cookies() {
$cookies = array( '' );
if ( $this->_config->get_boolean( 'pgcache.cookiegroups.enabled' ) ) {
$cookies = array_merge( $cookies,
array_keys( $this->_config->get_array( 'pgcache.cookiegroups.groups' ) ) );
}
return $cookies;
}
/**
* Returns array of encryptions
*/
private function _get_encryptions() {
$is_https = ( substr( get_home_url(), 0, 5 ) == 'https' );
$encryptions = array();
if ( ! $is_https || $this->_config->get_boolean( 'pgcache.cache.ssl' ) )
$encryptions[] = '';
if ( $is_https || $this->_config->get_boolean( 'pgcache.cache.ssl' ) )
$encryptions[] = 'ssl';
return $encryptions;
}
private function _append_parent_terms( $terms, $terms_to_check_parents ) {
$terms_to_check_parents = $terms;
$ids = null;
for ( ;; ) {
$parent_ids = array();
$taxonomies = array();
foreach ( $terms_to_check_parents as $term ) {
if ( $term->parent ) {
$parent_ids[$term->parent] = '*';
$taxonomies[$term->taxonomy] = '*';
}
}
if ( empty( $parent_ids ) )
return $terms;
if ( is_null( $ids ) ) {
// build a map of ids for faster check
$ids = array();
foreach ( $terms as $term )
$ids[$term->term_id] = '*';
} else {
// append last new items to ids map
foreach ( $terms_to_check_parents as $term )
$ids[$term->term_id] = '*';
}
// build list to extract
$include_ids = array();
foreach ( $parent_ids as $id => $v ) {
if ( !isset( $ids[$id] ) )
$include_ids[] = $id;
}
if ( empty( $include_ids ) )
return $terms;
$new_terms = get_terms( array_keys( $taxonomies ),
array( 'include' => $include_ids ) );
$terms = array_merge( $terms, $new_terms );
$terms_to_check_parents = $new_terms;
}
}
}