Make WooCommerce breadcrumbs use WooCommerce branding if it is installed (https://github.com/woocommerce/woocommerce-admin/pull/3798)
* Make WooCommerce breadcrumbs use WooCommerce branding if it is installed * Undo everything * Whoops, add missing reverted code * Push 'WooCommerce' out to breadcrumbs from the server except for where it is built up on the client * Pass translated 'WooCommerce' down from the server to the front end * Fix comment * Use `admin_url` to build up the URL Co-Authored-By: Ron Rennick <ron@ronandandrea.com> * Use admin_url() Co-Authored-By: Ron Rennick <ron@ronandandrea.com> * Show WooCommerce breadcrumb on analytics pages * Stop double appending the admin URL to the root WooCommerce breadcrumb url Co-authored-by: Rebecca Scott <me@becdetat.com> Co-authored-by: Ron Rennick <ron@ronandandrea.com>
This commit is contained in:
parent
1088a0ce8c
commit
dd279a5cc1
|
@ -109,24 +109,9 @@ class Header extends Component {
|
|||
'is-scrolled': isScrolled,
|
||||
} );
|
||||
|
||||
const firstBreadCrumbPath = 'admin.php?page=wc-admin';
|
||||
|
||||
return (
|
||||
<div className={ className } ref={ this.headerRef }>
|
||||
<h1 className="woocommerce-layout__header-breadcrumbs">
|
||||
<span>
|
||||
<Link
|
||||
href={
|
||||
isEmbedded
|
||||
? getAdminLink( firstBreadCrumbPath )
|
||||
: firstBreadCrumbPath
|
||||
}
|
||||
type={ isEmbedded ? 'wp-admin' : 'wc-admin' }
|
||||
onClick={ this.trackLinkClick }
|
||||
>
|
||||
{ __( 'WooCommerce', 'woocommerce-admin' ) }
|
||||
</Link>
|
||||
</span>
|
||||
{ _sections.map( ( section, i ) => {
|
||||
const sectionPiece = Array.isArray( section ) ? (
|
||||
<Link
|
||||
|
|
|
@ -30,6 +30,7 @@ export const PAGES_FILTER = 'woocommerce_admin_pages_list';
|
|||
|
||||
export const getPages = () => {
|
||||
const pages = [];
|
||||
const initialBreadcrumbs = [ [ '', wcSettings.woocommerceTranslation ] ];
|
||||
|
||||
if ( window.wcAdminFeatures.devdocs ) {
|
||||
pages.push( {
|
||||
|
@ -40,10 +41,14 @@ export const getPages = () => {
|
|||
const component = searchParams.get( 'component' );
|
||||
|
||||
if ( component ) {
|
||||
return [ [ '/devdocs', 'Documentation' ], component ];
|
||||
return [
|
||||
...initialBreadcrumbs,
|
||||
[ '/devdocs', 'Documentation' ],
|
||||
component,
|
||||
];
|
||||
}
|
||||
|
||||
return [ 'Documentation' ];
|
||||
return [ ...initialBreadcrumbs, 'Documentation' ];
|
||||
},
|
||||
wpOpenMenu: 'toplevel_page_woocommerce',
|
||||
} );
|
||||
|
@ -53,7 +58,10 @@ export const getPages = () => {
|
|||
pages.push( {
|
||||
container: Dashboard,
|
||||
path: '/',
|
||||
breadcrumbs: [ __( 'Dashboard', 'woocommerce-admin' ) ],
|
||||
breadcrumbs: [
|
||||
...initialBreadcrumbs,
|
||||
__( 'Dashboard', 'woocommerce-admin' ),
|
||||
],
|
||||
wpOpenMenu: 'toplevel_page_woocommerce',
|
||||
} );
|
||||
}
|
||||
|
@ -63,6 +71,7 @@ export const getPages = () => {
|
|||
container: AnalyticsSettings,
|
||||
path: '/analytics/settings',
|
||||
breadcrumbs: [
|
||||
...initialBreadcrumbs,
|
||||
[
|
||||
'/analytics/revenue',
|
||||
__( 'Analytics', 'woocommerce-admin' ),
|
||||
|
@ -74,7 +83,10 @@ export const getPages = () => {
|
|||
pages.push( {
|
||||
container: AnalyticsReport,
|
||||
path: '/customers',
|
||||
breadcrumbs: [ __( 'Customers', 'woocommerce-admin' ) ],
|
||||
breadcrumbs: [
|
||||
...initialBreadcrumbs,
|
||||
__( 'Customers', 'woocommerce-admin' ),
|
||||
],
|
||||
wpOpenMenu: 'toplevel_page_woocommerce',
|
||||
} );
|
||||
pages.push( {
|
||||
|
@ -88,6 +100,7 @@ export const getPages = () => {
|
|||
return [];
|
||||
}
|
||||
return [
|
||||
...initialBreadcrumbs,
|
||||
[
|
||||
'/analytics/revenue',
|
||||
__( 'Analytics', 'woocommerce-admin' ),
|
||||
|
|
|
@ -54,15 +54,23 @@ function wc_admin_get_core_pages_to_connect() {
|
|||
* @return array Filtered breadcrumb pieces.
|
||||
*/
|
||||
function wc_admin_filter_core_page_breadcrumbs( $breadcrumbs ) {
|
||||
$screen_id = PageController::get_instance()->get_current_screen_id();
|
||||
$pages_to_connect = wc_admin_get_core_pages_to_connect();
|
||||
$screen_id = PageController::get_instance()->get_current_screen_id();
|
||||
$pages_to_connect = wc_admin_get_core_pages_to_connect();
|
||||
$woocommerce_breadcrumb = array(
|
||||
'admin.php?page=wc-admin',
|
||||
__( 'WooCommerce', 'woocommerce-admin' ),
|
||||
);
|
||||
|
||||
foreach ( $pages_to_connect as $page_id => $page_data ) {
|
||||
if ( preg_match( "/^woocommerce_page_{$page_id}\-/", $screen_id ) ) {
|
||||
if ( empty( $page_data['tabs'] ) ) {
|
||||
$new_breadcrumbs = array( $page_data['title'] );
|
||||
$new_breadcrumbs = array(
|
||||
$woocommerce_breadcrumb,
|
||||
$page_data['title'],
|
||||
);
|
||||
} else {
|
||||
$new_breadcrumbs = array(
|
||||
$woocommerce_breadcrumb,
|
||||
array(
|
||||
add_query_arg( 'page', $page_id, 'admin.php' ),
|
||||
$page_data['title'],
|
||||
|
|
|
@ -497,9 +497,6 @@ class Loader {
|
|||
<div class="woocommerce-layout">
|
||||
<div class="woocommerce-layout__header is-embed-loading">
|
||||
<h1 class="woocommerce-layout__header-breadcrumbs">
|
||||
<span>
|
||||
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-admin' ) ); ?>"><?php esc_html_e( 'WooCommerce', 'woocommerce-admin' ); ?></a>
|
||||
</span>
|
||||
<?php foreach ( $sections as $section ) : ?>
|
||||
<?php self::output_breadcrumbs( $section ); ?>
|
||||
<?php endforeach; ?>
|
||||
|
@ -690,6 +687,10 @@ class Loader {
|
|||
$settings['siteUrl'] = site_url();
|
||||
$settings['onboardingEnabled'] = self::is_onboarding_enabled();
|
||||
$settings['dateFormat'] = get_option( 'date_format' );
|
||||
// Plugins that depend on changing the translation work on the server but not the client -
|
||||
// WooCommerce Branding is an example of this - so pass through the translation of
|
||||
// 'WooCommerce' to wcSettings.
|
||||
$settings['woocommerceTranslation'] = __( 'WooCommerce', 'woocommerce-admin' );
|
||||
|
||||
if ( ! empty( $preload_data_endpoints ) ) {
|
||||
$settings['dataEndpoints'] = isset( $settings['dataEndpoints'] )
|
||||
|
|
|
@ -176,6 +176,10 @@ class PageController {
|
|||
}
|
||||
}
|
||||
|
||||
$woocommerce_breadcrumb = array( 'admin.php?page=wc-admin', __( 'WooCommerce', 'woocommerce-admin' ) );
|
||||
|
||||
array_unshift( $breadcrumbs, $woocommerce_breadcrumb );
|
||||
|
||||
/**
|
||||
* The navigation breadcrumbs for the current page.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue