Yoast\WP\SEO\Builders
Indexable_Post_Builder::has_public_posts() protected Yoast 1.0
Determines the value of has_public_posts.
{} Это метод класса: Indexable_Post_Builder{}
Хуков нет.
Возвращает
true/false/null. Whether the attachment has a public parent, can be true, false and null. Null when it is not an attachment.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->has_public_posts( $indexable );
- $indexable(Indexable) (обязательный)
- The indexable.
Код Indexable_Post_Builder::has_public_posts() Indexable Post Builder::has public posts Yoast 15.6.2
protected function has_public_posts( $indexable ) {
// Only attachments (and authors) have this value.
if ( $indexable->object_sub_type !== 'attachment' ) {
return null;
}
// The attachment should have a post parent.
if ( empty( $indexable->post_parent ) ) {
return false;
}
// The attachment should inherit the post status.
if ( $indexable->post_status !== 'inherit' ) {
return false;
}
// The post parent should be public.
$post_parent_indexable = $this->indexable_repository->find_by_id_and_type( $indexable->post_parent, 'post' );
if ( $post_parent_indexable !== false ) {
return $post_parent_indexable->is_public;
}
return false;
}