block_core_calendar_has_published_posts

函数
block_core_calendar_has_published_posts ( No parameters )

block_core_calendar_has_published_posts: 这个函数用来确定在一个给定的日期是否有任何已发表的文章。它接收一个日期字符串并返回一个布尔值。

返回是否有任何已发表的文章。

当没有发表的文章时,用于隐藏日历块。这弥补了一个已知的核心错误:https://core.trac.wordpress.org/ticket/12016

function block_core_calendar_has_published_posts() {
	// Multisite already has an option that stores the count of the published posts.
	// Let's use that for multisites.
	if ( is_multisite() ) {
		return 0 < (int) get_option( 'post_count' );
	}

	// On single sites we try our own cached option first.
	$has_published_posts = get_option( 'wp_calendar_block_has_published_posts', null );
	if ( null !== $has_published_posts ) {
		return (bool) $has_published_posts;
	}

	// No cache hit, let's update the cache and return the cached value.
	return block_core_calendar_update_has_published_posts();
}

常见问题

FAQs
查看更多 >