block_core_calendar_update_has_published_posts example

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

/** * Queries the database for any published post and saves * a flag whether any published post exists or not. * * @return bool Has any published posts or not. */
function block_core_calendar_update_has_published_posts() {
    global $wpdb;
    $has_published_posts = (bool) $wpdb->get_var( "SELECT 1 as test FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
    
Home | Imprint | This part of the site doesn't use cookies.