original_string: private function create_taxonomy_replace_tag( $post_id, $permalink ) {
  		$search  = array();
  		$replace = array();
  
  		$taxonomies = CPTP_Util::get_taxonomies( true );
  
  		// %taxnomomy% -> parent/child
  		foreach ( $taxonomies as $taxonomy => $objects ) {
  
  			if ( false !== strpos( $permalink, '%' . $taxonomy . '%' ) ) {
  				$terms = get_the_terms( $post_id, $taxonomy );
  
  				if ( $terms && ! is_wp_error( $terms ) ) {
  					$parents  = array_map( array( __CLASS__, 'get_term_parent' ), $terms );
  					$newTerms = array();
  					foreach ( $terms as $key => $term ) {
  						if ( ! in_array( $term->term_id, $parents , true ) ) {
  							$newTerms[] = $term;
  						}
  					}
  
  					$term_obj  = reset( $newTerms );
  					$term_slug = $term_obj->slug;
  
  					if ( isset( $term_obj->parent ) && $term_obj->parent ) {
  						$term_slug = CPTP_Util::get_taxonomy_parents_slug( $term_obj->parent, $taxonomy, '/', true ) . $term_slug;
  					}
  				}
  
  				if ( isset( $term_slug ) ) {
  					$search[]  = '%' . $taxonomy . '%';
  					$replace[] = $term_slug;
  				}
  			}
  		}
  
  		return array(
  			'search' => $search,
  			'replace' => $replace,
  		);
  	}
code: private function create_taxonomy_replace_tag( $post_id, $permalink ) {
  		$search  = array();
  		$replace = array();
  
  		$taxonomies = CPTP_Util::get_taxonomies( true );
  
  		// %taxnomomy% -> parent/child
  		foreach ( $taxonomies as $taxonomy => $objects ) {
  
  			if ( false !== strpos( $permalink, '%' . $taxonomy . '%' ) ) {
  				$terms = get_the_terms( $post_id, $taxonomy );
  
  				if ( $terms && ! is_wp_error( $terms ) ) {
  					$parents  = array_map( array( __CLASS__, 'get_term_parent' ), $terms );
  					$newTerms = array();
  					foreach ( $terms as $key => $term ) {
  						if ( ! in_array( $term->term_id, $parents , true ) ) {
  							$newTerms[] = $term;
  						}
  					}
  
  					$term_obj  = reset( $newTerms );
  					$term_slug = $term_obj->slug;
  
  					if ( isset( $term_obj->parent ) && $term_obj->parent ) {
  						$term_slug = CPTP_Util::get_taxonomy_parents_slug( $term_obj->parent, $taxonomy, '/', true ) . $term_slug;
  					}
  				}
  
  				if ( isset( $term_slug ) ) {
  					$search[]  = '%' . $taxonomy . '%';
  					$replace[] = $term_slug;
  				}
  			}
  		}
  
  		return array(
  			'search' => $search,
  			'replace' => $replace,
  		);
  	}
code_tokens: private function create_taxonomy_replace_tag ( $ post_id , $ permalink ) { $ search = array ( ) ; $ replace = array ( ) ; $ taxonomies = CPTP_Util :: get_taxonomies ( true ) ; // %taxnomomy% -> parent/child foreach ( $ taxonomies as $ taxonomy => $ objects ) { if ( false !== strpos ( $ permalink , '%' . $ taxonomy . '%' ) ) { $ terms = get_the_terms ( $ post_id , $ taxonomy ) ; if ( $ terms && ! is_wp_error ( $ terms ) ) { $ parents = array_map ( array ( __CLASS__ , 'get_term_parent' ) , $ terms ) ; $ newTerms = array ( ) ; foreach ( $ terms as $ key => $ term ) { if ( ! in_array ( $ term -> term_id , $ parents , true ) ) { $ newTerms [ ] = $ term ; } } $ term_obj = reset ( $ newTerms ) ; $ term_slug = $ term_obj -> slug ; if ( isset ( $ term_obj -> parent ) && $ term_obj -> parent ) { $ term_slug = CPTP_Util :: get_taxonomy_parents_slug ( $ term_obj -> parent , $ taxonomy , '/' , true ) . $ term_slug ; } } if ( isset ( $ term_slug ) ) { $ search [ ] = '%' . $ taxonomy . '%' ; $ replace [ ] = $ term_slug ; } } } return array ( 'search' => $ search , 'replace' => $ replace , ) ; }
docstring: Create %tax% -> term
  
  @param int    $post_id  post id.
  @param string $permalink permalink uri.
  
  @return array
docstring_tokens: Create %tax% - > term