wpseo_split_shared_term

Makes sure the taxonomy meta is updated when a taxonomy term is split.

Description

wpseo_split_shared_term( (string) $old_term_id, (string) $new_term_id, (string) $term_taxonomy_id, (string) $taxonomy ); 

Parameters (4)

0. $old_term_id (string)
Old term id of the taxonomy term that was splitted.
1. $new_term_id (string)
New term id of the taxonomy term that was splitted.
2. $term_taxonomy_id (string)
Term taxonomy id for the taxonomy that was affected.
3. $taxonomy (string)
The taxonomy that the taxonomy term was splitted for.

Usage

  1. if ( !function_exists( 'wpseo_split_shared_term' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/inc/wpseo-functions.php'; 
  3.  
  4. // Old term id of the taxonomy term that was splitted. 
  5. $old_term_id = ''; 
  6.  
  7. // New term id of the taxonomy term that was splitted. 
  8. $new_term_id = ''; 
  9.  
  10. // Term taxonomy id for the taxonomy that was affected. 
  11. $term_taxonomy_id = ''; 
  12.  
  13. // The taxonomy that the taxonomy term was splitted for. 
  14. $taxonomy = ''; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wpseo_split_shared_term($old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy); 
  18.  

Defined (1)

The function is defined in the following location(s).

/inc/wpseo-functions.php  
  1. function wpseo_split_shared_term( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { 
  2. $tax_meta = get_option( wpseo_taxonomy_meta, array() ); 
  3.  
  4. if ( ! empty( $tax_meta[ $taxonomy ][ $old_term_id ] ) ) { 
  5. $tax_meta[ $taxonomy ][ $new_term_id ] = $tax_meta[ $taxonomy ][ $old_term_id ]; 
  6. unset( $tax_meta[ $taxonomy ][ $old_term_id ] ); 
  7. update_option( wpseo_taxonomy_meta, $tax_meta );