wp_cache_post_edit()WPSCache 1.0

check if we want to clear out all cached files on post updates, otherwise call standard wp_cache_post_change()

Возвращает

null. Ничего (null).

Использование

wp_cache_post_edit( $post_id );
$post_id (обязательный)
-

Код wp_cache_post_edit() WPSCache 1.12.0

function wp_cache_post_edit( $post_id ) {
	global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
	static $last_post_edited = -1;

	if ( $post_id == $last_post_edited ) {
		$action = current_filter();
		wp_cache_debug( "wp_cache_post_edit({$action}): Already processed post $post_id.", 4 );
		return $post_id;
	}

	$post = get_post( $post_id );
	if ( ! is_object( $post ) || 'auto-draft' === $post->post_status ) {
		return $post_id;
	}

	// Allow plugins to reject cache clears for specific posts.
	if ( ! apply_filters( 'wp_super_cache_clear_post_cache', true, $post ) ) {
		return $post_id;
	}

	// Some users are inexplicibly seeing this error on scheduled posts.
	// define this constant to disable the post status check.
	if ( ! defined( 'WPSCFORCEUPDATE' ) && ! in_array( get_post_status( $post ), array( 'publish', 'private' ), true ) ) {
		wp_cache_debug( 'wp_cache_post_edit: draft post, not deleting any cache files. status: ' . $post->post_status, 4 );
		return $post_id;
	}

	// we want to process the post again just in case it becomes published before the second time this function is called.
	$last_post_edited = $post_id;
	if ( $wp_cache_clear_on_post_edit ) {
		wp_cache_debug( "wp_cache_post_edit: Clearing cache $blog_cache_dir and {$cache_path}supercache/ on post edit per config.", 2 );
		prune_super_cache( $blog_cache_dir, true );
		prune_super_cache( get_supercache_dir(), true );

		do_action( 'wp_cache_cleared' );
	} else {
		$action = current_filter();
		wp_cache_debug( "wp_cache_post_edit: Clearing cache for post $post_id on {$action}", 2 );
		wp_cache_post_change( $post_id );
		wpsc_delete_post_archives( $post_id ); // delete related archive pages.
	}
}