Yoast\WP\SEO\Builders
Indexable_Post_Builder::build() public Yoast 1.0
Formats the data.
{} Это метод класса: Indexable_Post_Builder{}
Хуков нет.
Возвращает
true/false/Indexable. The extended indexable. False when unable to build.
Использование
$Indexable_Post_Builder = new Indexable_Post_Builder(); $Indexable_Post_Builder->build( $post_id, $indexable );
- $post_id(число) (обязательный)
- The post ID to use.
- $indexable(Indexable) (обязательный)
- The indexable to format.
Код Indexable_Post_Builder::build() Indexable Post Builder::build Yoast 15.6.2
public function build( $post_id, $indexable ) {
$post = $this->post_helper->get_post( $post_id );
if ( $post === null ) {
throw new Post_Not_Found_Exception();
}
if ( $this->should_exclude_post( $post ) ) {
return false;
}
$indexable->object_id = $post_id;
$indexable->object_type = 'post';
$indexable->object_sub_type = $post->post_type;
$indexable->permalink = $this->get_permalink( $post->post_type, $post_id );
$indexable->primary_focus_keyword_score = $this->get_keyword_score(
$this->get_meta_value( $post_id, 'focuskw' ),
(int) $this->get_meta_value( $post_id, 'linkdex' )
);
$indexable->readability_score = (int) $this->get_meta_value( $post_id, 'content_score' );
$indexable->is_cornerstone = ( $this->get_meta_value( $post_id, 'is_cornerstone' ) === '1' );
$indexable->is_robots_noindex = $this->get_robots_noindex(
$this->get_meta_value( $post_id, 'meta-robots-noindex' )
);
// Set additional meta-robots values.
$indexable->is_robots_nofollow = ( $this->get_meta_value( $post_id, 'meta-robots-nofollow' ) === '1' );
$noindex_advanced = $this->get_meta_value( $post_id, 'meta-robots-adv' );
$meta_robots = \explode( ',', $noindex_advanced );
foreach ( $this->get_robots_options() as $meta_robots_option ) {
$indexable->{'is_robots_' . $meta_robots_option} = \in_array( $meta_robots_option, $meta_robots, true ) ? 1 : null;
}
$this->reset_social_images( $indexable );
foreach ( $this->get_indexable_lookup() as $meta_key => $indexable_key ) {
$indexable->{$indexable_key} = $this->get_meta_value( $post_id, $meta_key );
}
if ( empty( $indexable->breadcrumb_title ) ) {
$indexable->breadcrumb_title = \wp_strip_all_tags( \get_the_title( $post_id ), true );
}
$this->handle_social_images( $indexable );
$indexable->author_id = $post->post_author;
$indexable->post_parent = $post->post_parent;
$indexable->number_of_pages = $this->get_number_of_pages_for_post( $post );
$indexable->post_status = $post->post_status;
$indexable->is_protected = $post->post_password !== '';
$indexable->is_public = $this->is_public( $indexable );
$indexable->has_public_posts = $this->has_public_posts( $indexable );
$indexable->blog_id = \get_current_blog_id();
$indexable->schema_page_type = $this->get_meta_value( $post_id, 'schema_page_type' );
$indexable->schema_article_type = $this->get_meta_value( $post_id, 'schema_article_type' );
return $indexable;
}