Merge branch 'update/split-extensions-pages' of github.com:woocommerce/woocommerce into update/split-extensions-pages

This commit is contained in:
Maria Górska-Piszek 2021-08-06 13:24:14 +02:00
commit 379960e8c1
10 changed files with 261 additions and 385 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

View File

@ -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 extensions', '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&section=helper', array( $this, 'addons_page' ) );
}
/**
@ -387,6 +389,20 @@ 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&section=helper'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
}
return $parent_file;
}
}
return new WC_Admin_Menus();

View File

@ -1,19 +1,46 @@
<?php defined( 'ABSPATH' ) or exit(); ?>
<?php
/**
* Helper main view
*
* @package WooCommerce\Helper
*/
?>
<?php defined( 'ABSPATH' ) || exit(); ?>
<div class="wrap woocommerce wc_addons_wrap wc-helper">
<?php require WC_Helper::get_view_filename( 'html-section-nav.php' ); ?>
<h1 class="screen-reader-text"><?php _e( 'WooCommerce Extensions', 'woocommerce' ); ?></h1>
<h1 class="screen-reader-text"><?php esc_html_e( 'My Subscriptions', 'woocommerce' ); ?></h1>
<?php require WC_Helper::get_view_filename( 'html-section-notices.php' ); ?>
<div class="subscriptions-header">
<h2><?php _e( 'Subscriptions', 'woocommerce' ); ?></h2>
<h2><?php esc_html_e( 'Subscriptions', 'woocommerce' ); ?></h2>
<?php require WC_Helper::get_view_filename( 'html-section-account.php' ); ?>
<p><?php printf( __( 'Below is a list of extensions available on your WooCommerce.com account. To receive extension updates please make sure the extension is installed, and its subscription activated and connected to your WooCommerce.com account. Extensions can be activated from the <a href="%s">Plugins</a> screen.', 'woocommerce' ), admin_url( 'plugins.php' ) ); ?></p>
<p>
<?php
printf(
wp_kses(
/* translators: Introduction to list of WooCommerce.com extensions the merchant has subscriptions for. */
__(
'Below is a list of extensions available on your WooCommerce.com account. To receive extension updates please make sure the extension is installed, and its subscription activated and connected to your WooCommerce.com account. Extensions can be activated from the <a href="%s">Plugins</a> screen.',
'woocommerce'
),
array(
'a' => array(
'href' => array(),
),
)
),
esc_url(
admin_url( 'plugins.php' )
)
);
?>
</p>
</div>
<ul class="subscription-filter">
<label><?php _e( 'Sort by:', 'woocommerce' ); ?> <span class="chevron dashicons dashicons-arrow-up-alt2"></span></label>
<label><?php esc_html_e( 'Sort by:', 'woocommerce' ); ?> <span class="chevron dashicons dashicons-arrow-up-alt2"></span></label>
<?php
$filters = array_keys( WC_Helper::get_filters() );
$last_filter = array_pop( $filters );
@ -32,7 +59,7 @@
$class_html = $current_filter === $key ? 'class="current"' : '';
?>
<li>
<a <?php echo $class_html; ?> href="<?php echo esc_url( $url ); ?>">
<a <?php echo esc_attr( $class_html ); ?> href="<?php echo esc_url( $url ); ?>">
<?php echo esc_html( $label ); ?>
<span class="count">(<?php echo absint( $counts[ $key ] ); ?>)</span>
</a>
@ -55,27 +82,27 @@
<div class="wp-list-table__ext-description">
<?php if ( $subscription['lifetime'] ) : ?>
<span class="renews">
<?php _e( 'Lifetime Subscription', 'woocommerce' ); ?>
<?php esc_html_e( 'Lifetime Subscription', 'woocommerce' ); ?>
</span>
<?php elseif ( $subscription['expired'] ) : ?>
<span class="renews">
<strong><?php _e( 'Expired :(', 'woocommerce' ); ?></strong>
<?php echo date_i18n( 'F jS, Y', $subscription['expires'] ); ?>
<strong><?php esc_html_e( 'Expired :(', 'woocommerce' ); ?></strong>
<?php echo esc_html( date_i18n( 'F jS, Y', $subscription['expires'] ) ); ?>
</span>
<?php elseif ( $subscription['autorenew'] ) : ?>
<span class="renews">
<?php _e( 'Auto renews on:', 'woocommerce' ); ?>
<?php echo date_i18n( 'F jS, Y', $subscription['expires'] ); ?>
<?php esc_html_e( 'Auto renews on:', 'woocommerce' ); ?>
<?php echo esc_html( date_i18n( 'F jS, Y', $subscription['expires'] ) ); ?>
</span>
<?php elseif ( $subscription['expiring'] ) : ?>
<span class="renews">
<strong><?php _e( 'Expiring soon!', 'woocommerce' ); ?></strong>
<?php echo date_i18n( 'F jS, Y', $subscription['expires'] ); ?>
<strong><?php esc_html_e( 'Expiring soon!', 'woocommerce' ); ?></strong>
<?php echo esc_html( date_i18n( 'F jS, Y', $subscription['expires'] ) ); ?>
</span>
<?php else : ?>
<span class="renews">
<?php _e( 'Expires on:', 'woocommerce' ); ?>
<?php echo date_i18n( 'F jS, Y', $subscription['expires'] ); ?>
<?php esc_html_e( 'Expires on:', 'woocommerce' ); ?>
<?php echo esc_html( date_i18n( 'F jS, Y', $subscription['expires'] ) ); ?>
</span>
<?php endif; ?>
@ -84,19 +111,21 @@
<?php
if ( ! $subscription['active'] && $subscription['maxed'] ) {
/* translators: %1$d: sites active, %2$d max sites active */
printf( __( 'Subscription: Not available - %1$d of %2$d already in use', 'woocommerce' ), absint( $subscription['sites_active'] ), absint( $subscription['sites_max'] ) );
printf( esc_html__( 'Subscription: Not available - %1$d of %2$d already in use', 'woocommerce' ), absint( $subscription['sites_active'] ), absint( $subscription['sites_max'] ) );
} elseif ( $subscription['sites_max'] > 0 ) {
/* translators: %1$d: sites active, %2$d max sites active */
printf( __( 'Subscription: Using %1$d of %2$d sites available', 'woocommerce' ), absint( $subscription['sites_active'] ), absint( $subscription['sites_max'] ) );
printf( esc_html__( 'Subscription: Using %1$d of %2$d sites available', 'woocommerce' ), absint( $subscription['sites_active'] ), absint( $subscription['sites_max'] ) );
} else {
_e( 'Subscription: Unlimited', 'woocommerce' );
esc_html_e( 'Subscription: Unlimited', 'woocommerce' );
}
// Check shared.
if ( ! empty( $subscription['is_shared'] ) && ! empty( $subscription['owner_email'] ) ) {
printf( '</br>' . __( 'Shared by %s', 'woocommerce' ), esc_html( $subscription['owner_email'] ) );
/* translators: Email address of person who shared the subscription. */
printf( '</br>' . esc_html__( 'Shared by %s', 'woocommerce' ), esc_html( $subscription['owner_email'] ) );
} elseif ( isset( $subscription['master_user_email'] ) ) {
printf( '</br>' . __( 'Shared by %s', 'woocommerce' ), esc_html( $subscription['master_user_email'] ) );
/* translators: Email address of person who shared the subscription. */
printf( '</br>' . esc_html__( 'Shared by %s', 'woocommerce' ), esc_html( $subscription['master_user_email'] ) );
}
?>
</span>
@ -104,35 +133,35 @@
</td>
<td class="wp-list-table__ext-actions">
<?php if ( ! $subscription['active'] && $subscription['maxed'] ) : ?>
<a class="button" href="https://woocommerce.com/my-account/my-subscriptions/" target="_blank"><?php _e( 'Upgrade', 'woocommerce' ); ?></a>
<a class="button" href="https://woocommerce.com/my-account/my-subscriptions/" target="_blank"><?php esc_html_e( 'Upgrade', 'woocommerce' ); ?></a>
<?php elseif ( ! $subscription['local']['installed'] && ! $subscription['expired'] ) : ?>
<a class="button <?php echo empty( $subscription['download_primary'] ) ? 'button-secondary' : ''; ?>" href="<?php echo esc_url( $subscription['download_url'] ); ?>" target="_blank"><?php _e( 'Download', 'woocommerce' ); ?></a>
<a class="button <?php echo empty( $subscription['download_primary'] ) ? 'button-secondary' : ''; ?>" href="<?php echo esc_url( $subscription['download_url'] ); ?>" target="_blank"><?php esc_html_e( 'Download', 'woocommerce' ); ?></a>
<?php elseif ( $subscription['active'] ) : ?>
<span class="form-toggle__wrapper">
<a href="<?php echo esc_url( $subscription['deactivate_url'] ); ?>" class="form-toggle active is-compact" role="link" aria-checked="true"><?php _e( 'Active', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( $subscription['deactivate_url'] ); ?>" class="form-toggle active is-compact" role="link" aria-checked="true"><?php esc_html_e( 'Active', 'woocommerce' ); ?></a>
<label class="form-toggle__label" for="activate-extension">
<span class="form-toggle__label-content">
<label for="activate-extension"><?php _e( 'Active', 'woocommerce' ); ?></label>
<label for="activate-extension"><?php esc_html_e( 'Active', 'woocommerce' ); ?></label>
</span>
<span class="form-toggle__switch"></span>
</label>
</span>
<?php elseif ( ! $subscription['expired'] ) : ?>
<span class="form-toggle__wrapper">
<a href="<?php echo esc_url( $subscription['activate_url'] ); ?>" class="form-toggle is-compact" role="link" aria-checked="false"><?php _e( 'Inactive', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( $subscription['activate_url'] ); ?>" class="form-toggle is-compact" role="link" aria-checked="false"><?php esc_html_e( 'Inactive', 'woocommerce' ); ?></a>
<label class="form-toggle__label" for="activate-extension">
<span class="form-toggle__label-content">
<label for="activate-extension"><?php _e( 'Inactive', 'woocommerce' ); ?></label>
<label for="activate-extension"><?php esc_html_e( 'Inactive', 'woocommerce' ); ?></label>
</span>
<span class="form-toggle__switch"></span>
</label>
</span>
<?php else : ?>
<span class="form-toggle__wrapper">
<span class="form-toggle disabled is-compact"><?php _e( 'Inactive', 'woocommerce' ); ?></span>
<span class="form-toggle disabled is-compact"><?php esc_html_e( 'Inactive', 'woocommerce' ); ?></span>
<label class="form-toggle__label" for="activate-extension">
<span class="form-toggle__label-content">
<label for="activate-extension"><?php _e( 'Inactive', 'woocommerce' ); ?></label>
<label for="activate-extension"><?php esc_html_e( 'Inactive', 'woocommerce' ); ?></label>
</span>
</label>
</span>
@ -140,16 +169,16 @@
</td>
</tr>
<?php foreach ( $subscription['actions'] as $action ) : ?>
<?php foreach ( $subscription['actions'] as $subscription_action ) : ?>
<tr class="wp-list-table__row wp-list-table__ext-updates">
<td class="wp-list-table__ext-status <?php echo sanitize_html_class( $action['status'] ); ?>">
<p><span class="dashicons <?php echo sanitize_html_class( $action['icon'] ); ?>"></span>
<?php echo $action['message']; ?>
<td class="wp-list-table__ext-status <?php echo sanitize_html_class( $subscription_action['status'] ); ?>">
<p><span class="dashicons <?php echo sanitize_html_class( $subscription_action['icon'] ); ?>"></span>
<?php echo esc_html( $subscription_action['message'] ); ?>
</p>
</td>
<td class="wp-list-table__ext-actions">
<?php if ( ! empty( $action['button_label'] ) && ! empty( $action['button_url'] ) ) : ?>
<a class="button <?php echo empty( $action['primary'] ) ? 'button-secondary' : ''; ?>" href="<?php echo esc_url( $action['button_url'] ); ?>"><?php echo esc_html( $action['button_label'] ); ?></a>
<?php if ( ! empty( $subscription_action['button_label'] ) && ! empty( $subscription_action['button_url'] ) ) : ?>
<a class="button <?php echo empty( $subscription_action['primary'] ) ? 'button-secondary' : ''; ?>" href="<?php echo esc_url( $subscription_action['button_url'] ); ?>"><?php echo esc_html( $subscription_action['button_label'] ); ?></a>
<?php endif; ?>
</td>
</tr>
@ -159,14 +188,14 @@
<?php endforeach; ?>
<?php else : ?>
<tr>
<td colspan="3"><em><?php _e( 'Could not find any subscriptions on your WooCommerce.com account', 'woocommerce' ); ?></td>
<td colspan="3"><em><?php esc_html_e( 'Could not find any subscriptions on your WooCommerce.com account', 'woocommerce' ); ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php if ( ! empty( $no_subscriptions ) ) : ?>
<h2><?php _e( 'Installed Extensions without a Subscription', 'woocommerce' ); ?></h2>
<h2><?php esc_html_e( 'Installed Extensions without a Subscription', 'woocommerce' ); ?></h2>
<p>Below is a list of WooCommerce.com products available on your site - but are either out-dated or do not have a valid subscription.</p>
<table class="wp-list-table widefat fixed striped">
@ -183,25 +212,25 @@
</td>
<td class="wp-list-table__ext-actions">
<span class="form-toggle__wrapper">
<span class="form-toggle disabled is-compact" ><?php _e( 'Inactive', 'woocommerce' ); ?></span>
<span class="form-toggle disabled is-compact" ><?php esc_html_e( 'Inactive', 'woocommerce' ); ?></span>
<label class="form-toggle__label" for="activate-extension">
<span class="form-toggle__label-content">
<label for="activate-extension"><?php _e( 'Inactive', 'woocommerce' ); ?></label>
<label for="activate-extension"><?php esc_html_e( 'Inactive', 'woocommerce' ); ?></label>
</span>
</label>
</span>
</td>
</tr>
<?php foreach ( $data['_actions'] as $action ) : ?>
<?php foreach ( $data['_actions'] as $subscription_action ) : ?>
<tr class="wp-list-table__row wp-list-table__ext-updates">
<td class="wp-list-table__ext-status <?php echo sanitize_html_class( $action['status'] ); ?>">
<p><span class="dashicons <?php echo sanitize_html_class( $action['icon'] ); ?>"></span>
<?php echo $action['message']; ?>
<td class="wp-list-table__ext-status <?php echo sanitize_html_class( $subscription_action['status'] ); ?>">
<p><span class="dashicons <?php echo sanitize_html_class( $subscription_action['icon'] ); ?>"></span>
<?php echo esc_html( $subscription_action['message'] ); ?>
</p>
</td>
<td class="wp-list-table__ext-actions">
<a class="button" href="<?php echo esc_url( $action['button_url'] ); ?>" target="_blank"><?php echo esc_html( $action['button_label'] ); ?></a>
<a class="button" href="<?php echo esc_url( $subscription_action['button_url'] ); ?>" target="_blank"><?php echo esc_html( $subscription_action['button_label'] ); ?></a>
</td>
</tr>
<?php endforeach; ?>

View File

@ -10,7 +10,6 @@ defined( 'ABSPATH' ) || exit();
?>
<div class="wrap woocommerce wc_addons_wrap wc-helper">
<?php require WC_Helper::get_view_filename( 'html-section-nav.php' ); ?>
<h1 class="screen-reader-text"><?php esc_html_e( 'WooCommerce Extensions', 'woocommerce' ); ?></h1>
<?php require WC_Helper::get_view_filename( 'html-section-notices.php' ); ?>

View File

@ -1,19 +0,0 @@
<?php
/**
* Helper admin navigation.
*
* @package WooCommerce\Helper
*/
defined( 'ABSPATH' ) || exit(); ?>
<nav class="nav-tab-wrapper woo-nav-tab-wrapper">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-addons' ) ); ?>" class="nav-tab"><?php esc_html_e( 'Browse Extensions', 'woocommerce' ); ?></a>
<?php
$count_html = WC_Helper_Updater::get_updates_count_html();
/* translators: %s: WooCommerce.com Subscriptions tab count HTML. */
$menu_title = sprintf( __( 'WooCommerce.com Subscriptions %s', 'woocommerce' ), $count_html );
?>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-addons&section=helper' ) ); ?>" class="nav-tab nav-tab-active"><?php echo wp_kses_post( $menu_title ); ?></a>
</nav>

View File

@ -13,31 +13,26 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div class="wrap woocommerce wc_addons_wrap">
<nav class="nav-tab-wrapper woo-nav-tab-wrapper">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-addons' ) ); ?>" class="nav-tab nav-tab-active"><?php esc_html_e( 'Browse Extensions', 'woocommerce' ); ?></a>
<?php
$count_html = WC_Helper_Updater::get_updates_count_html();
// translators: Count of updates for WooCommerce.com subscriptions.
$menu_title = sprintf( __( 'WooCommerce.com Subscriptions %s', 'woocommerce' ), $count_html );
?>
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-addons&section=helper' ) ); ?>" class="nav-tab"><?php echo wp_kses_post( $menu_title ); ?></a>
</nav>
<h1 class="screen-reader-text"><?php esc_html_e( 'WooCommerce Extensions', 'woocommerce' ); ?></h1>
<h1 class="screen-reader-text"><?php esc_html_e( 'Marketplace', 'woocommerce' ); ?></h1>
<?php if ( $sections ) : ?>
<ul class="subsubsub">
<?php foreach ( $sections as $section ) : ?>
<li>
<a
class="<?php echo $current_section === $section->slug ? 'current' : ''; ?>"
href="<?php echo esc_url( admin_url( 'admin.php?page=wc-addons&section=' . esc_attr( $section->slug ) ) ); ?>">
<?php echo esc_html( $section->label ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<div class="marketplace-header">
<h1 class="marketplace-header__title"><?php esc_html_e( 'WooCommerce Marketplace', 'woocommerce' ); ?></h1>
<p class="marketplace-header__description"><?php esc_html_e( 'Grow your business with hundreds of free and paid WooCommerce extensions.', 'woocommerce' ); ?></p>
<form class="marketplace-header__search-form" method="GET">
<input
type="text"
name="search"
value="<?php echo esc_attr( isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>"
placeholder="<?php esc_attr_e( 'Search for extensions', 'woocommerce' ); ?>"
/>
<button type="submit">
<span class="dashicons dashicons-search"></span>
</button>
<input type="hidden" name="page" value="wc-addons">
<input type="hidden" name="section" value="_all">
</form>
</div>
<?php if ( isset( $_GET['search'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>
<h1 class="search-form-title" >
@ -46,18 +41,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</h1>
<?php endif; ?>
<form class="search-form" method="GET">
<button type="submit">
<span class="dashicons dashicons-search"></span>
</button>
<input
type="text"
name="search"
value="<?php echo esc_attr( isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>"
placeholder="<?php esc_attr_e( 'Enter a search term and press enter', 'woocommerce' ); ?>">
<input type="hidden" name="page" value="wc-addons">
<input type="hidden" name="section" value="_all">
</form>
<?php if ( '_featured' === $current_section ) : ?>
<div class="addons-featured">
<?php

View File

@ -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([

View File

@ -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&section=helper';
/**
* Shop pages.

View File

@ -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, {