Add global variable to prevent error

This commit is contained in:
Shojib khan 2023-04-20 11:35:42 +06:00
parent fd9b709de4
commit ea85b1843c
1 changed files with 6 additions and 2 deletions

View File

@ -2211,7 +2211,9 @@ function wc_get_permalink_structure() {
* @since 3.1.0 * @since 3.1.0
*/ */
function wc_switch_to_site_locale() { function wc_switch_to_site_locale() {
if ( function_exists( 'switch_to_locale' ) ) { global $wp_locale_switcher;
if ( function_exists( 'switch_to_locale' ) && isset( $wp_locale_switcher ) ) {
switch_to_locale( get_locale() ); switch_to_locale( get_locale() );
// Filter on plugin_locale so load_plugin_textdomain loads the correct locale. // Filter on plugin_locale so load_plugin_textdomain loads the correct locale.
@ -2228,7 +2230,9 @@ function wc_switch_to_site_locale() {
* @since 3.1.0 * @since 3.1.0
*/ */
function wc_restore_locale() { function wc_restore_locale() {
if ( function_exists( 'restore_previous_locale' ) ) { global $wp_locale_switcher;
if ( function_exists( 'restore_previous_locale' ) && isset( $wp_locale_switcher ) ) {
restore_previous_locale(); restore_previous_locale();
// Remove filter. // Remove filter.