Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2. public function shorten_links_of_category_goods() {
  3. $terms = get_terms( array(
  4. 'taxonomy' => 'product_cat', // название таксономии с WP 4.5
  5. 'orderby' => 'id',
  6. 'order' => 'ASC',
  7. 'hide_empty' => false,
  8. // 'include' => array(589)
  9. //'number' => 15,
  10. ) );
  11.  
  12. //print_r( $terms );
  13.  
  14.  
  15. foreach ( $terms as $term ) {
  16. $id = $term->term_id;
  17.  
  18. $this->termstoSort[$id] = array();
  19. $slug = $term->slug;
  20. $link = str_replace( get_home_url(), "", get_term_link( $id ) );
  21. $this->redirectArray[$id] = array( $link );
  22. $this->termstoSort[$id]['slug'] = $slug;
  23. $this->termstoSort[$id]['link'] = $link;
  24.  
  25. $this->updateTerm($id, $this->serch_similar_the_worlds($link, $slug,$id));
  26. //echo $this->termstoSort[$id]['link'] . " = <span style='color:red'>" . $this->serch_similar_the_worlds( $link, $slug, $id ) . "</span><br><br>";
  27. }
  28.  
  29.  
  30. $this->add_new_category_goods();
  31. $this->print_CSV_Redirection();
  32. //echo print_r($this->redirectArray, true);
  33. }
  34.  
  35.  
  36. protected function updateTerm( $term_id, $slug, $taxonomy = "product_cat" ) {
  37. wp_update_term( $term_id, $taxonomy, array(
  38. 'slug' => $slug
  39. ) );
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement