Created
July 26, 2017 15:30
-
-
Save GhostToast/eb278edf333b5de6f584d668cd346b0c to your computer and use it in GitHub Desktop.
pagely purge path not working
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Cache functions. | |
*/ | |
namespace SLC; | |
use PagelyCachePurge; | |
/** | |
* If we can, purge the path. | |
* | |
* @param string $path The path to purge. | |
*/ | |
function purge_path( $path ) { | |
if ( class_exists( 'PagelyCachePurge' ) ) { | |
$pagely_cache_purge_instance = PagelyCachePurge::$instance; | |
$pagely_cache_purge_instance->purgePath( $path ); | |
} | |
} | |
/** | |
* Invalidate cache on the Deals Archive page when a new Deal is saved. | |
*/ | |
function invalidate_deals_archive_cache() { | |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { | |
return; | |
} | |
purge_path( get_post_type_archive_link( 'deal' ) ); | |
} | |
add_action( 'save_post_deal', __NAMESPACE__ . '\\invalidate_deals_archive_cache' ); | |
add_action( 'update_option_deal_page', __NAMESPACE__ . '\\invalidate_deals_archive_cache' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment