Yoast\WP\SEO\Helpers
Author_Archive_Helper::author_has_a_post_with_is_public_null()
Returns whether the author has at least one post with the is public null.
Метод класса: Author_Archive_Helper{}
Хуков нет.
Возвращает
true|false
. Whether the author has at least one post with the is public null.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->author_has_a_post_with_is_public_null( $author_id );
- $author_id(int) (обязательный)
- The author ID.
Код Author_Archive_Helper::author_has_a_post_with_is_public_null() Author Archive Helper::author has a post with is public null Yoast 24.4
protected function author_has_a_post_with_is_public_null( $author_id ) { $cache_key = 'author_has_a_post_with_is_public_null_' . $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_null( 'is_public' ) ->find_one(); if ( $indexable_exists === false ) { // Cache no results to prevent full table scanning on authors with no is public null posts. \wp_cache_set( $cache_key, 0, '', \wp_rand( ( 2 * \HOUR_IN_SECONDS ), ( 4 * \HOUR_IN_SECONDS ) ) ); } } return (bool) $indexable_exists; }