wc_get_permalink_structure

Get permalink settings for WooCommerce independent of the user locale.

Description

(array) wc_get_permalink_structure(); 

Returns (array)


Usage

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

Defined (1)

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

/includes/wc-core-functions.php  
  1. function wc_get_permalink_structure() { 
  2. if ( function_exists( 'switch_to_locale' ) && did_action( 'admin_init' ) ) { 
  3. switch_to_locale( get_locale() ); 
  4.  
  5. $permalinks = wp_parse_args( (array) get_option( 'woocommerce_permalinks', array() ), array( 
  6. 'product_base' => '',  
  7. 'category_base' => '',  
  8. 'tag_base' => '',  
  9. 'attribute_base' => '',  
  10. 'use_verbose_page_rules' => false,  
  11. ) ); 
  12.  
  13. // Ensure rewrite slugs are set. 
  14. $permalinks['product_rewrite_slug'] = untrailingslashit( empty( $permalinks['product_base'] ) ? _x( 'product', 'slug', woocommerce ) : $permalinks['product_base'] ); 
  15. $permalinks['category_rewrite_slug'] = untrailingslashit( empty( $permalinks['category_base'] ) ? _x( 'product-category', 'slug', woocommerce ) : $permalinks['category_base'] ); 
  16. $permalinks['tag_rewrite_slug'] = untrailingslashit( empty( $permalinks['tag_base'] ) ? _x( 'product-tag', 'slug', woocommerce ) : $permalinks['tag_base'] ); 
  17. $permalinks['attribute_rewrite_slug'] = untrailingslashit( empty( $permalinks['attribute_base'] ) ? '' : $permalinks['attribute_base'] ); 
  18.  
  19. if ( function_exists( 'restore_current_locale' ) && did_action( 'admin_init' ) ) { 
  20. restore_current_locale(); 
  21. return $permalinks;