芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/wordpress-seo/src/builders/primary-term-builder.php
repository = $repository; $this->indexable_helper = $indexable_helper; $this->primary_term = $primary_term; $this->meta = $meta; } /** * Formats and saves the primary terms for the post with the given post id. * * @param int $post_id The post ID. * * @return void */ public function build( $post_id ) { foreach ( $this->primary_term->get_primary_term_taxonomies( $post_id ) as $taxonomy ) { $this->save_primary_term( $post_id, $taxonomy->name ); } } /** * Save the primary term for a specific taxonomy. * * @param int $post_id Post ID to save primary term for. * @param string $taxonomy Taxonomy to save primary term for. * * @return void */ 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_indexable = $this->repository->find_by_post_id_and_taxonomy( $post_id, $taxonomy, $term_selected ); // Removes the indexable when no term found. if ( ! $term_selected ) { if ( $primary_term_indexable ) { $primary_term_indexable->delete(); } return; } $primary_term_indexable->term_id = $term_id; $primary_term_indexable->post_id = $post_id; $primary_term_indexable->taxonomy = $taxonomy; $primary_term_indexable->blog_id = \get_current_blog_id(); $this->indexable_helper->save_indexable( $primary_term_indexable ); } }