Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function shorten_links_of_category_goods() {
- $terms = get_terms( array(
- 'taxonomy' => 'product_cat', // название таксономии с WP 4.5
- 'orderby' => 'id',
- 'order' => 'ASC',
- 'hide_empty' => false,
- // 'include' => array(589)
- //'number' => 15,
- ) );
- //print_r( $terms );
- foreach ( $terms as $term ) {
- $id = $term->term_id;
- $this->termstoSort[$id] = array();
- $slug = $term->slug;
- $link = str_replace( get_home_url(), "", get_term_link( $id ) );
- $this->redirectArray[$id] = array( $link );
- $this->termstoSort[$id]['slug'] = $slug;
- $this->termstoSort[$id]['link'] = $link;
- $this->updateTerm($id, $this->serch_similar_the_worlds($link, $slug,$id));
- //echo $this->termstoSort[$id]['link'] . " = <span style='color:red'>" . $this->serch_similar_the_worlds( $link, $slug, $id ) . "</span><br><br>";
- }
- $this->add_new_category_goods();
- $this->print_CSV_Redirection();
- //echo print_r($this->redirectArray, true);
- }
- protected function updateTerm( $term_id, $slug, $taxonomy = "product_cat" ) {
- wp_update_term( $term_id, $taxonomy, array(
- 'slug' => $slug
- ) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement