Yoast\WP\SEO\Helpers
Author_Archive_Helper::author_has_a_public_post() protected Yoast 1.0
Returns whether the author has at least one public post.
{} Это метод класса: Author_Archive_Helper{}
Хуков нет.
Возвращает
true/false. Whether the author has at least one public post.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->author_has_a_public_post( $author_id );
- $author_id(число) (обязательный)
- The author ID.
Код Author_Archive_Helper::author_has_a_public_post() Author Archive Helper::author has a public post Yoast 15.6.2
protected function author_has_a_public_post( $author_id ) {
$cache_key = 'author_has_a_public_post_' . $author_id;
$indexable_exists = \wp_cache_get( $cache_key );
if ( $indexable_exists === false ) {
$indexable_exists = Model::of_type( 'Indexable' )
->select( 'id' )
->where( 'object_type', 'post' )
->where_in( 'object_sub_type', $this->get_author_archive_post_types() )
->where( 'author_id', $author_id )
->where( 'is_public', 1 )
->find_one();
if ( $indexable_exists === false ) {
// Cache no results to prevent full table scanning on authors with no public posts.
\wp_cache_set( $cache_key, 0, '', \wp_rand( ( 2 * \HOUR_IN_SECONDS ), ( 4 * \HOUR_IN_SECONDS ) ) );
}
}
return (bool) $indexable_exists;
}