Clear PDF Cache on save_post Action
-
I’ve added the following action hook to save_post to make sure that the PDF cache is refreshed when the post is saved via the Admin or API.
pdf_cache_refresh( $post_id ){ // Bail early if the constant isn't defined if ( !defined( 'WPPT0PDFENH_CACHE_DIR' ) ) return; // Get the post $post = get_post( $post_id ); // TODO: A check to make this only apply to posts where Post to PDF is enabled? // Check if the file exists in the cache $filepath = WPPT0PDFENH_CACHE_DIR . '/' . $post->post_name . '.pdf'; if ( file_exists( $filepath ) ){ // Delete cached PDF @unlink( $filepath ); } } add_action( 'save_post', 'pdf_cache_refresh' );
https://www.ads-software.com/plugins/wp-post-to-pdf-enhanced/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Clear PDF Cache on save_post Action’ is closed to new replies.