wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



block_core_calendar_has_published_posts › WordPress Function

Seit5.9.0
Veraltetn/v
block_core_calendar_has_published_posts ( Keine Parameter )
Gibt zurück:
  • (bool) Has any published posts or not.
Definiert in:
Codex:

Returns whether or not there are any published posts.

Used to hide the calendar block when there are no published posts. This compensates for a known Core bug: https://core.trac.wordpress.org/ticket/12016


Quellcode

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