wc_update_200_permalinks

The WooCommerce wc update 200 permalinks function.

Description

wc_update_200_permalinks(); 

Usage

  1. if ( !function_exists( 'wc_update_200_permalinks' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-update-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wc_update_200_permalinks(); 
  7.  

Defined (1)

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

/includes/wc-update-functions.php  
  1. function wc_update_200_permalinks() { 
  2. // Setup default permalinks if shop page is defined 
  3. $permalinks = get_option( 'woocommerce_permalinks' ); 
  4. $shop_page_id = wc_get_page_id( 'shop' ); 
  5.  
  6. if ( empty( $permalinks ) && $shop_page_id > 0 ) { 
  7.  
  8. $base_slug = $shop_page_id > 0 && get_post( $shop_page_id ) ? get_page_uri( $shop_page_id ) : 'shop'; 
  9.  
  10. $category_base = get_option( 'woocommerce_prepend_shop_page_to_urls' ) == "yes" ? trailingslashit( $base_slug ) : ''; 
  11. $category_slug = get_option( 'woocommerce_product_category_slug' ) ? get_option( 'woocommerce_product_category_slug' ) : _x( 'product-category', 'slug', woocommerce ); 
  12. $tag_slug = get_option( 'woocommerce_product_tag_slug' ) ? get_option( 'woocommerce_product_tag_slug' ) : _x( 'product-tag', 'slug', woocommerce ); 
  13.  
  14. if ( 'yes' == get_option( 'woocommerce_prepend_shop_page_to_products' ) ) { 
  15. $product_base = trailingslashit( $base_slug ); 
  16. } else { 
  17. if ( ( $product_slug = get_option( 'woocommerce_product_slug' ) ) !== false && ! empty( $product_slug ) ) { 
  18. $product_base = trailingslashit( $product_slug ); 
  19. } else { 
  20. $product_base = trailingslashit( _x( 'product', 'slug', woocommerce ) ); 
  21.  
  22. if ( get_option( 'woocommerce_prepend_category_to_products' ) == 'yes' ) 
  23. $product_base .= trailingslashit( '%product_cat%' ); 
  24.  
  25. $permalinks = array( 
  26. 'product_base' => untrailingslashit( $product_base ),  
  27. 'category_base' => untrailingslashit( $category_base . $category_slug ),  
  28. 'attribute_base' => untrailingslashit( $category_base ),  
  29. 'tag_base' => untrailingslashit( $category_base . $tag_slug ),  
  30. ); 
  31.  
  32. update_option( 'woocommerce_permalinks', $permalinks );