^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 5年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云1核2g仅需102元/年,今日10点开抢

wordpress函数clean_post_cache()用法示例

clean_post_cache( int|WP_Post $post )

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().


参数

$post

(int|WP_Post)
(Required)
Post ID or post object to remove from the cache.


源代码

File: wp-includes/post.php

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' );
}

更新日志

Version 描述
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/cache.php:
    wp_cache_delete()
  • wp-includes/cache.php:
    wp_cache_set()
  • wp-includes/taxonomy.php:
    clean_object_term_cache()
  • wp-includes/plugin.php:
    do_action()
  • wp-includes/post.php:
    clean_post_cache
  • wp-includes/post.php:
    clean_page_cache
  • wp-includes/post.php:
    get_post()
  • Show 2 more uses
    Hide more uses


Used By

  • wp-includes/theme.php:
    _wp_keep_alive_customize_changeset_dependent_auto_drafts()
  • wp-includes/theme.php:
    _wp_customize_publish_changeset()
  • wp-includes/post.php:
    wp_add_trashed_suffix_to_post_name_for_post()
  • wp-admin/includes/user.php:
    wp_delete_user()
  • wp-admin/includes/class-wp-posts-list-table.php:
    WP_Posts_List_Table::_display_rows_hierarchical()
  • wp-includes/deprecated.php:
    clean_page_cache()
  • wp-includes/post.php:
    wp_delete_attachment()
  • wp-includes/post.php:
    wp_publish_post()
  • wp-includes/post.php:
    add_ping()
  • wp-includes/post.php:
    wp_insert_post()
  • wp-includes/post.php:
    wp_delete_post()
  • wp-includes/post.php:
    set_post_type()
  • wp-includes/comment.php:
    wp_update_comment_count_now()
  • Show 8 more used by
    Hide more used by


User Contributed Notes

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈