diff --git a/includes/admin/class-wc-admin-menus.php b/includes/admin/class-wc-admin-menus.php index d926fcf548e..5b7c92dee6c 100644 --- a/includes/admin/class-wc-admin-menus.php +++ b/includes/admin/class-wc-admin-menus.php @@ -36,6 +36,7 @@ class WC_Admin_Menus { add_filter( 'menu_order', array( $this, 'menu_order' ) ); add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) ); add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 ); + add_filter( 'parent_file', array( $this, 'update_menu_highlight' ) ); // Add endpoints custom URLs in Appearance > Menus > Pages. add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); @@ -149,8 +150,9 @@ class WC_Admin_Menus { public function addons_menu() { $count_html = WC_Helper_Updater::get_updates_count_html(); /* translators: %s: extensions count */ - $menu_title = sprintf( __( 'Extensions %s', 'woocommerce' ), $count_html ); - add_submenu_page( 'woocommerce', __( 'WooCommerce extensions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) ); + $menu_title = sprintf( __( 'My Subscriptions %s', 'woocommerce' ), $count_html ); + add_submenu_page( 'woocommerce', __( 'WooCommerce Marketplace', 'woocommerce' ), __( 'Marketplace', 'woocommerce' ), 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) ); + add_submenu_page( 'woocommerce', __( 'My WooCommerce.com Subscriptions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons§ion=helper', array( $this, 'addons_page' ) ); } /** @@ -387,6 +389,38 @@ class WC_Admin_Menus { ) ); } + + /** + * Highlight the My Subscriptions menu item when on that page + * + * @param string $parent_file currently opened page. + * @return string + */ + public function update_menu_highlight( $parent_file ) { + global $submenu_file; + if ( 'woocommerce' === $parent_file && isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) { + $submenu_file = 'wc-addons§ion=helper'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + } + return $parent_file; + } + + /** + * Update the My Subscriptions document title when on that page. + * We want to maintain existing page URL but add it as a separate page, + * which requires updating it manually. + * + * @param string $admin_title existing page title. + * @return string + */ + public function update_my_subscriptions_title( $admin_title ) { + if ( + isset( $_GET['page'] ) && 'wc-addons' === $_GET['page'] && + isset( $_GET['section'] ) && 'helper' === $_GET['section'] + ) { + $admin_title = 'My WooCommerce.com Subscriptions'; + } + return $admin_title; + } } return new WC_Admin_Menus(); diff --git a/includes/admin/helper/views/html-main.php b/includes/admin/helper/views/html-main.php index ee6e02c63ff..ef39f92ef90 100644 --- a/includes/admin/helper/views/html-main.php +++ b/includes/admin/helper/views/html-main.php @@ -9,8 +9,7 @@
- -

+

@@ -174,7 +173,7 @@

- +

diff --git a/includes/admin/helper/views/html-oauth-start.php b/includes/admin/helper/views/html-oauth-start.php index 4b2e8cb0f13..76d60851924 100644 --- a/includes/admin/helper/views/html-oauth-start.php +++ b/includes/admin/helper/views/html-oauth-start.php @@ -10,7 +10,6 @@ defined( 'ABSPATH' ) || exit(); ?>
-

diff --git a/includes/admin/helper/views/html-section-nav.php b/includes/admin/helper/views/html-section-nav.php deleted file mode 100644 index 9af76fe32a0..00000000000 --- a/includes/admin/helper/views/html-section-nav.php +++ /dev/null @@ -1,19 +0,0 @@ - - - diff --git a/includes/admin/views/html-admin-page-addons.php b/includes/admin/views/html-admin-page-addons.php index ee022d91a76..06904328807 100644 --- a/includes/admin/views/html-admin-page-addons.php +++ b/includes/admin/views/html-admin-page-addons.php @@ -13,6 +13,8 @@ if ( ! defined( 'ABSPATH' ) ) { ?>
+

+

diff --git a/tests/e2e/core-tests/specs/merchant/wp-admin-extensions-connect-wccom.test.js b/tests/e2e/core-tests/specs/merchant/wp-admin-extensions-connect-wccom.test.js index c43022d2024..3cdc35a2924 100644 --- a/tests/e2e/core-tests/specs/merchant/wp-admin-extensions-connect-wccom.test.js +++ b/tests/e2e/core-tests/specs/merchant/wp-admin-extensions-connect-wccom.test.js @@ -22,13 +22,7 @@ const runInitiateWccomConnectionTest = () => { }); it('can initiate WCCOM connection', async () => { - await merchant.openExtensions(); - - // Click on a tab to choose WooCommerce Subscriptions extension - await Promise.all([ - expect(page).toClick('a.nav-tab', {text: "WooCommerce.com Subscriptions"}), - page.waitForNavigation({waitUntil: 'networkidle0'}), - ]); + await merchant.openHelper(); // Click on Connect button to initiate a WCCOM connection await Promise.all([ diff --git a/tests/e2e/utils/src/flows/constants.js b/tests/e2e/utils/src/flows/constants.js index 99de43aa0a7..118a207bdd6 100644 --- a/tests/e2e/utils/src/flows/constants.js +++ b/tests/e2e/utils/src/flows/constants.js @@ -41,6 +41,7 @@ export const WP_ADMIN_ANALYTICS_PAGES = WP_ADMIN_WC_HOME + '&path=%2Fanalytics%2 export const WP_ADMIN_WC_SETTINGS = WP_ADMIN_PLUGIN_PAGE + 'wc-settings&tab='; export const WP_ADMIN_NEW_SHIPPING_ZONE = WP_ADMIN_WC_SETTINGS + 'shipping&zone_id=new'; export const WP_ADMIN_WC_EXTENSIONS = WP_ADMIN_PLUGIN_PAGE + 'wc-addons'; +export const WP_ADMIN_WC_HELPER = WP_ADMIN_PLUGIN_PAGE + 'wc-addons§ion=helper'; /** * Shop pages. diff --git a/tests/e2e/utils/src/flows/merchant.js b/tests/e2e/utils/src/flows/merchant.js index c025d18ca29..2708d8b30f4 100644 --- a/tests/e2e/utils/src/flows/merchant.js +++ b/tests/e2e/utils/src/flows/merchant.js @@ -21,6 +21,7 @@ const { WP_ADMIN_WC_HOME, WP_ADMIN_WC_SETTINGS, WP_ADMIN_WC_EXTENSIONS, + WP_ADMIN_WC_HELPER, WP_ADMIN_NEW_SHIPPING_ZONE, WP_ADMIN_ANALYTICS_PAGES, WP_ADMIN_ALL_USERS_VIEW, @@ -134,6 +135,12 @@ const merchant = { } ); }, + openHelper: async () => { + await page.goto( WP_ADMIN_WC_HELPER, { + waitUntil: 'networkidle0', + } ); + }, + runSetupWizard: async () => { const setupWizard = IS_RETEST_MODE ? WP_ADMIN_SETUP_WIZARD : WP_ADMIN_WC_HOME; await page.goto( setupWizard, {