Skip to content

Instantly share code, notes, and snippets.

@GhostToast
Created July 26, 2017 15:30
Show Gist options
  • Save GhostToast/eb278edf333b5de6f584d668cd346b0c to your computer and use it in GitHub Desktop.
Save GhostToast/eb278edf333b5de6f584d668cd346b0c to your computer and use it in GitHub Desktop.
pagely purge path not working
<?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