Switch locale only after init

This commit is contained in:
Mike Jolley 2017-02-09 11:23:44 +00:00
parent 639b805a24
commit 8242e5496d
1 changed files with 2 additions and 3 deletions

View File

@ -1569,7 +1569,7 @@ function wc_list_pluck( $list, $callback_or_field, $index_key = null ) {
* @return array
*/
function wc_get_permalink_structure() {
if ( function_exists( 'switch_to_locale' ) ) {
if ( function_exists( 'switch_to_locale' ) && did_action( 'init' ) ) {
switch_to_locale( get_locale() );
}
@ -1587,9 +1587,8 @@ function wc_get_permalink_structure() {
$permalinks['tag_rewrite_slug'] = untrailingslashit( empty( $permalinks['tag_base'] ) ? _x( 'product-tag', 'slug', 'woocommerce' ) : $permalinks['tag_base'] );
$permalinks['attribute_rewrite_slug'] = untrailingslashit( empty( $permalinks['attribute_base'] ) ? '' : $permalinks['attribute_base'] );
if ( function_exists( 'restore_current_locale' ) ) {
if ( function_exists( 'restore_current_locale' ) && did_action( 'init' ) ) {
restore_current_locale();
}
return $permalinks;
}