clean_post_cache

The timeline below displays how wordpress function clean_post_cache has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (!$post) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete('post_parent:' . (string) $post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if ('page' === $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set_posts_last_changed();
}

WordPress Version: 6.3

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (!$post) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if ('page' === $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set_posts_last_changed();
}

WordPress Version: 5.6

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (!$post) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if ('page' === $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set('last_changed', microtime(), 'posts');
}

WordPress Version: 5.5

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (empty($post)) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if ('page' === $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set('last_changed', microtime(), 'posts');
}

WordPress Version: 4.4

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (empty($post)) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if ('page' == $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set('last_changed', microtime(), 'posts');
}

WordPress Version: 4.3

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation, $wpdb;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (empty($post)) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if ('page' == $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set('last_changed', microtime(), 'posts');
}

WordPress Version: 4.1

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation, $wpdb;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (empty($post)) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if ('page' == $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set('last_changed', microtime(), 'posts');
}

WordPress Version: 4.0

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database access abstraction object.
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation, $wpdb;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (empty($post)) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if ('page' == $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set('last_changed', microtime(), 'posts');
}

WordPress Version: 3.9

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @since 2.0.0
 *
 * @param int|WP_Post $post Post ID or post object to remove from the cache.
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation, $wpdb;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (empty($post)) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    /**
     * Fires immediately after the given post's cache is cleaned.
     *
     * @since 2.5.0
     *
     * @param int     $post_id Post ID.
     * @param WP_Post $post    Post object.
     */
    do_action('clean_post_cache', $post->ID, $post);
    if (is_post_type_hierarchical($post->post_type)) {
        wp_cache_delete('get_pages', 'posts');
    }
    if ('page' == $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        /**
         * Fires immediately after the given page's cache is cleaned.
         *
         * @since 2.5.0
         *
         * @param int $post_id Post ID.
         */
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set('last_changed', microtime(), 'posts');
}

WordPress Version: 3.7

/**
 * Will clean the post in the cache.
 *
 * Cleaning means delete from the cache of the post. Will call to clean the term
 * object cache associated with the post ID.
 *
 * This function not run if $_wp_suspend_cache_invalidation is not empty. See
 * wp_suspend_cache_invalidation().
 *
 * @package WordPress
 * @subpackage Cache
 * @since 2.0.0
 *
 * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any).
 *
 * @param int|object $post Post ID or object to remove from the cache
 */
function clean_post_cache($post)
{
    global $_wp_suspend_cache_invalidation, $wpdb;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $post = get_post($post);
    if (empty($post)) {
        return;
    }
    wp_cache_delete($post->ID, 'posts');
    wp_cache_delete($post->ID, 'post_meta');
    clean_object_term_cache($post->ID, $post->post_type);
    wp_cache_delete('wp_get_archives', 'general');
    do_action('clean_post_cache', $post->ID, $post);
    if (is_post_type_hierarchical($post->post_type)) {
        wp_cache_delete('get_pages', 'posts');
    }
    if ('page' == $post->post_type) {
        wp_cache_delete('all_page_ids', 'posts');
        do_action('clean_page_cache', $post->ID);
    }
    wp_cache_set('last_changed', microtime(), 'posts');
}