Inventory_Presser_Taxonomy_Overlapper::term_relationship_updated( int $object_id, int $tt_id, string $taxonomy )
term_relationship_updated
On This Page
Parameters Parameters
- $object_id
-
(int) (Required) Object ID.
- $tt_id
-
(int) (Required) A term taxonomy ID.
- $taxonomy
-
(string) (Required) Taxonomy slug.
Return Return
(void)
Source Source
File: includes/class-taxonomy-overlapper.php
function term_relationship_updated( $object_id, $tt_id, $taxonomy ) { // Does $object_id belong to a vehicle? if ( INVP::POST_TYPE != get_post_type( $object_id ) ) { // No return; } // Is the taxonomy one that overlaps a meta field? $keys_and_taxonomies = $this->overlapping_meta_keys(); $taxonomies_and_keys = array_flip( $keys_and_taxonomies ); if ( ! in_array( $taxonomy, array_values( $keys_and_taxonomies ) ) ) { // No return; } // An empty array of terms is passed often if ( empty( $tt_id ) ) { return; } $term = get_term_by( 'term_taxonomy_id', $tt_id, $taxonomy ); if ( ! is_object( $term ) || 'WP_Term' != get_class( $term ) ) { return; } // For most taxonomies, we can just save the term name in the post meta field if ( 'availability' != strtolower( $taxonomy ) ) { $this->hooks_remove_meta(); update_post_meta( $object_id, apply_filters( 'invp_prefix_meta_key', $taxonomies_and_keys[ $taxonomy ] ), $term->name ); $this->hooks_add_meta(); do_action( 'invp_taxonomy_overlapper_updated_meta', $object_id, $taxonomy, $term ); return; } // The availability taxonomy was the one updated switch ( strtolower( $term->slug ) ) { case 'for-sale': case 'sold': $this->hooks_remove_meta(); update_post_meta( $object_id, apply_filters( 'invp_prefix_meta_key', 'availability' ), $term->name ); $this->hooks_add_meta(); break; case 'wholesale': $this->hooks_remove_meta(); update_post_meta( $object_id, apply_filters( 'invp_prefix_meta_key', 'wholesale' ), true ); $this->hooks_add_meta(); break; default: return; // Makes sure the action hook below only runs after an update } do_action( 'invp_taxonomy_overlapper_updated_meta', $object_id, $taxonomy, $term ); }
Expand full source codeCollapse full source codeView on Github