Automattic\WooCommerce\Internal\Admin

SettingsNavigationFeature::redirect_core_settings_pages()publicWC 1.0

Redirect the old settings page URLs to the new ones.

Method of the class: SettingsNavigationFeature{}

No Hooks.

Return

null. Nothing (null).

Usage

$SettingsNavigationFeature = new SettingsNavigationFeature();
$SettingsNavigationFeature->redirect_core_settings_pages();

SettingsNavigationFeature::redirect_core_settings_pages() code WC 9.3.3

public function redirect_core_settings_pages() {
	/* phpcs:disable WordPress.Security.NonceVerification */
	if ( ! isset( $_GET['page'] ) || 'wc-settings' !== $_GET['page'] ) {
		return;
	}

	if ( ! current_user_can( 'manage_woocommerce' ) ) {
		return;
	}

	$setting_pages   = \WC_Admin_Settings::get_settings_pages();
	$default_setting = isset( $setting_pages[0] ) ? $setting_pages[0]->get_id() : '';
	$setting         = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : $default_setting;
	/* phpcs:enable */

	wp_safe_redirect( wc_admin_url( "&path=/settings/$setting" ) );
	exit;
}