Automattic\WooCommerce\Internal\Admin
Loader::add_admin_body_classes()
Adds body classes to the main wp-admin wrapper, allowing us to better target elements in specific scenarios.
Method of the class: Loader{}
Hooks from the method
Return
null
. Nothing.
Usage
$result = Loader::add_admin_body_classes( $admin_body_class );
- $admin_body_class(string)
- Body class to add.
Default: ''
Loader::add_admin_body_classes() Loader::add admin body classes code WC 7.7.0
public static function add_admin_body_classes( $admin_body_class = '' ) { if ( ! PageController::is_admin_or_embed_page() ) { return $admin_body_class; } $classes = explode( ' ', trim( $admin_body_class ) ); $classes[] = 'woocommerce-page'; if ( PageController::is_embed_page() ) { $classes[] = 'woocommerce-embed-page'; } /** * Some routes or features like onboarding hide the wp-admin navigation and masterbar. * Setting `woocommerce_admin_is_loading` to true allows us to premeptively hide these * elements while the JS app loads. * This class needs to be removed by those feature components (like <ProfileWizard />). * * @param bool $is_loading If WooCommerce Admin is loading a fullscreen view. */ $is_loading = apply_filters( 'woocommerce_admin_is_loading', false ); if ( PageController::is_admin_page() && $is_loading ) { $classes[] = 'woocommerce-admin-is-loading'; } $admin_body_class = implode( ' ', array_unique( $classes ) ); return " $admin_body_class "; }