get_indexable( $term_id, $taxonomy, false ); $indexable->delete_meta(); $indexable->delete(); } catch ( No_Indexable_Found $exception ) { return; } } /** * Update the taxonomy meta data on save. * * Note: This method is missing functionality to update internal links and incoming links. * As this functionality is currently not available for terms, it has not been added in this * class yet. * * @param int $term_id ID of the term to save data for. * @param int $taxonomy_term_id The taxonomy_term_id for the term. * @param string $taxonomy The taxonomy the term belongs to. * * @return void */ public function save_meta( $term_id, $taxonomy_term_id, $taxonomy ) { try { $indexable = $this->get_indexable( $term_id, $taxonomy ); } catch ( No_Indexable_Found $exception ) { return; } $formatter = $this->get_formatter( $term_id, $taxonomy ); $indexable = $formatter->format( $indexable ); $indexable->save(); } /** * Retrieves an indexable for a term. * * @codeCoverageIgnore * * @param int $term_id The term the indexable is based upon. * @param string $taxonomy The taxonomy the indexable belongs to. * @param bool $auto_create Optional. Creates an indexable if it does not exist yet. * * @return Indexable The indexable found for the supplied term. * * @throws No_Indexable_Found Exception when no indexable could be found for the supplied term. */ protected function get_indexable( $term_id, $taxonomy, $auto_create = true ) { $indexable = Indexable::find_by_id_and_type( $term_id, 'term', $auto_create ); if ( ! $indexable ) { throw No_Indexable_Found::from_term_id( $term_id, $taxonomy ); } return $indexable; } /** * Returns formatter for given taxonomy. * * @codeCoverageIgnore * * @param int $term_id ID of the term to save data for. * @param string $taxonomy The taxonomy the term belongs to. * * @return Indexable_Term_Formatter Instance. */ protected function get_formatter( $term_id, $taxonomy ) { return new Indexable_Term_Formatter( $term_id, $taxonomy ); } }