__( 'Settings', 'woocommerce-admin' ), 'desc' => __( 'Adds the new WooCommerce settings UI.', 'woocommerce-admin' ), 'id' => 'woocommerce_settings_enabled', 'type' => 'checkbox', ); return $features; } /** * Registers settings pages. */ public function register_pages() { $controller = PageController::get_instance(); $setting_pages = \WC_Admin_Settings::get_settings_pages(); $settings = array(); foreach ( $setting_pages as $setting_page ) { $settings = $setting_page->add_settings_page( $settings ); } $order = 0; foreach ( $settings as $key => $setting ) { $order += 10; $settings_page = array( 'parent' => 'woocommerce-settings', 'title' => $setting, 'id' => 'settings-' . $key, 'path' => "/settings/$key", 'nav_args' => array( 'capability' => 'manage_woocommerce', 'order' => $order, 'parent' => 'woocommerce-settings', ), ); // Replace the old menu with the first settings item. if ( 10 === $order ) { $this->replace_settings_page( $settings_page ); } $controller->register_page( $settings_page ); } } /** * Replace the Settings page in the original WooCommerce menu. * * @param array $page Page used to replace the original. */ protected function replace_settings_page( $page ) { global $submenu; // Check if WooCommerce parent menu has been registered. if ( ! isset( $submenu['woocommerce'] ) ) { return; } foreach ( $submenu['woocommerce'] as &$item ) { // The "slug" (aka the path) is the third item in the array. if ( 0 === strpos( $item[2], 'wc-settings' ) ) { $item[2] = wc_admin_url( "&path={$page['path']}" ); } } } }