Add filter for root back URL (https://github.com/woocommerce/woocommerce-admin/pull/5878)
* Add filter for root back URL * Add filter for root back button label
This commit is contained in:
parent
8f606ea159
commit
6e2bf974c7
|
@ -10,7 +10,6 @@ import {
|
|||
__experimentalNavigationMenu as NavigationMenu,
|
||||
__experimentalNavigationGroup as NavigationGroup,
|
||||
} from '@wordpress/components';
|
||||
import { getAdminLink } from '@woocommerce/wc-admin-settings';
|
||||
import { NAVIGATION_STORE_NAME } from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import { withSelect } from '@wordpress/data';
|
||||
|
@ -29,7 +28,7 @@ const Container = ( { menuItems } ) => {
|
|||
adminMenu.classList.add( 'folded' );
|
||||
}, [] );
|
||||
|
||||
const dashboardUrl = getAdminLink( '' );
|
||||
const { rootBackLabel, rootBackUrl } = window.wcNavigation;
|
||||
|
||||
const parentCategory = {
|
||||
capability: 'manage_woocommerce',
|
||||
|
@ -130,14 +129,11 @@ const Container = ( { menuItems } ) => {
|
|||
setActiveLevel( ...args );
|
||||
} }
|
||||
>
|
||||
{ activeLevel === 'woocommerce' && dashboardUrl && (
|
||||
{ activeLevel === 'woocommerce' && rootBackUrl && (
|
||||
<NavigationBackButton
|
||||
className="woocommerce-navigation__back-to-dashboard"
|
||||
href={ dashboardUrl }
|
||||
backButtonLabel={ __(
|
||||
'WordPress Dashboard',
|
||||
'woocommerce-navigation'
|
||||
) }
|
||||
href={ rootBackUrl }
|
||||
backButtonLabel={ rootBackLabel }
|
||||
onClick={ () => trackBackClick( 'woocommerce' ) }
|
||||
></NavigationBackButton>
|
||||
) }
|
||||
|
|
|
@ -651,14 +651,12 @@ class Menu {
|
|||
* @return array
|
||||
*/
|
||||
public function enqueue_data( $menu ) {
|
||||
global $submenu, $parent_file, $typenow, $self;
|
||||
|
||||
$data = array(
|
||||
'menuItems' => self::get_prepared_menu_item_data(),
|
||||
'menuItems' => self::get_prepared_menu_item_data(),
|
||||
'rootBackUrl' => apply_filters( 'woocommerce_navigation_root_back_url', get_dashboard_url() ),
|
||||
'rootBackLabel' => apply_filters( 'woocommerce_navigation_root_back_label', __( 'WordPress Dashboard', 'woocommerce-admin' ) ),
|
||||
);
|
||||
|
||||
$paul = wp_add_inline_script( WC_ADMIN_APP, 'window.wcNavigation = ' . wp_json_encode( $data ), 'before' );
|
||||
|
||||
return $menu;
|
||||
wp_add_inline_script( WC_ADMIN_APP, 'window.wcNavigation = ' . wp_json_encode( $data ), 'before' );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue