wc_get_permalink_structure()

Get permalink settings for things like products and taxonomies.


Description Description

As of 3.3.0, the permalink settings are stored to the option instead of being blank and inheritting from the locale. This speeds up page loading times by negating the need to switch locales on each page load.

This is more inline with WP core behavior which does not localize slugs.


Return Return

(array)


Top ↑

Source Source

File: includes/wc-core-functions.php

2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
function wc_get_permalink_structure() {
    $saved_permalinks = (array) get_option( 'woocommerce_permalinks', array() );
    $permalinks       = wp_parse_args(
        array_filter( $saved_permalinks ),
        array(
            'product_base'           => _x( 'product', 'slug', 'woocommerce' ),
            'category_base'          => _x( 'product-category', 'slug', 'woocommerce' ),
            'tag_base'               => _x( 'product-tag', 'slug', 'woocommerce' ),
            'attribute_base'         => '',
            'use_verbose_page_rules' => false,
        )
    );
 
    if ( $saved_permalinks !== $permalinks ) {
        update_option( 'woocommerce_permalinks', $permalinks );
    }
 
    $permalinks['product_rewrite_slug']   = untrailingslashit( $permalinks['product_base'] );
    $permalinks['category_rewrite_slug']  = untrailingslashit( $permalinks['category_base'] );
    $permalinks['tag_rewrite_slug']       = untrailingslashit( $permalinks['tag_base'] );
    $permalinks['attribute_rewrite_slug'] = untrailingslashit( $permalinks['attribute_base'] );
 
    return $permalinks;
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.