Yoast\WP\SEO\Builders
Primary_Term_Builder::save_primary_term() protected Yoast 1.0
Save the primary term for a specific taxonomy.
{} Это метод класса: Primary_Term_Builder{}
Хуков нет.
Возвращает
null.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->save_primary_term( $post_id, $taxonomy );
- $post_id(число) (обязательный)
- Post ID to save primary term for.
- $taxonomy(строка) (обязательный)
- Taxonomy to save primary term for.
Код Primary_Term_Builder::save_primary_term() Primary Term Builder::save primary term Yoast 15.6.2
protected function save_primary_term( $post_id, $taxonomy ) {
$term_id = $this->meta->get_value( 'primary_' . $taxonomy, $post_id );
$term_selected = ! empty( $term_id );
$primary_term = $this->repository->find_by_post_id_and_taxonomy( $post_id, $taxonomy, $term_selected );
// Removes the indexable when found.
if ( ! $term_selected ) {
if ( $primary_term ) {
$primary_term->delete();
}
return;
}
$primary_term->term_id = $term_id;
$primary_term->post_id = $post_id;
$primary_term->taxonomy = $taxonomy;
$primary_term->blog_id = \get_current_blog_id();
$primary_term->save();
}