* Enqueue styles on non-WC pages

* Only load extra styles when navigation is enabled
This commit is contained in:
Joshua T Flowers 2020-10-20 14:47:11 -04:00 committed by GitHub
parent 523eac0131
commit c0be4ecb56
3 changed files with 30 additions and 15 deletions

View File

@ -31,11 +31,6 @@
} }
} }
#adminmenu
li.toplevel_page_woocommerce.wp-has-submenu.wp-not-current-submenu.opensub:hover::after {
display: none;
}
#woocommerce-embedded-navigation { #woocommerce-embedded-navigation {
position: fixed; position: fixed;
top: 0; top: 0;
@ -46,14 +41,4 @@
// @todo This should be updated to G2.darkGray.primary when possible. // @todo This should be updated to G2.darkGray.primary when possible.
background-color: #1e1e1e; background-color: #1e1e1e;
} }
body.is-folded #woocommerce-embedded-navigation {
height: 60px;
width: 60px;
overflow: hidden;
}
.toplevel_page_woocommerce ul.wp-submenu {
display: none;
}
} }

View File

@ -0,0 +1,11 @@
// Hide elements on non-WooCommerce pages.
body.js:not(.has-woocommerce-navigation) {
#adminmenu
li.toplevel_page_woocommerce.wp-has-submenu.wp-not-current-submenu.opensub:hover::after {
display: none;
}
.toplevel_page_woocommerce ul.wp-submenu {
display: none;
}
}

View File

@ -25,6 +25,7 @@ class Navigation {
if ( Loader::is_feature_enabled( 'navigation' ) ) { if ( Loader::is_feature_enabled( 'navigation' ) ) {
add_action( 'in_admin_header', array( __CLASS__, 'embed_navigation' ) ); add_action( 'in_admin_header', array( __CLASS__, 'embed_navigation' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'maybe_enqueue_scripts' ) );
Menu::instance()->init(); Menu::instance()->init();
CoreMenu::instance()->init(); CoreMenu::instance()->init();
@ -69,4 +70,22 @@ class Navigation {
<div id="woocommerce-embedded-navigation"></div> <div id="woocommerce-embedded-navigation"></div>
<?php <?php
} }
/**
* Enqueue scripts on non-WooCommerce pages.
*/
public function maybe_enqueue_scripts() {
if ( Screen::is_woocommerce_page() ) {
return;
}
$rtl = is_rtl() ? '-rtl' : '';
wp_enqueue_style(
'wc-admin-navigation',
Loader::get_url( "navigation/style{$rtl}", 'css' ),
array(),
Loader::get_file_version( 'css' )
);
}
} }