Dequeue conflicting styles within product editor (#39478)

* Dequeue conflicting styles within product editor

* Add changelog

* Fix lint errors

* Add check to only dequeue on admin/embed pages
This commit is contained in:
louwie17 2023-08-01 09:19:37 -04:00 committed by GitHub
parent e9042633eb
commit 1ac824de2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Dequeue blocktheme styles on WooCommerce Admin pages when product block editor is enabled.

View File

@ -43,6 +43,7 @@ class Init {
if ( \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ) { if ( \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled( 'product_block_editor' ) ) {
if ( ! Features::is_enabled( 'new-product-management-experience' ) ) { if ( ! Features::is_enabled( 'new-product-management-experience' ) ) {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'dequeue_conflicting_styles' ), 100 );
add_action( 'get_edit_post_link', array( $this, 'update_edit_product_link' ), 10, 2 ); add_action( 'get_edit_post_link', array( $this, 'update_edit_product_link' ), 10, 2 );
} }
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@ -111,6 +112,17 @@ class Init {
do_action( 'enqueue_block_editor_assets' ); do_action( 'enqueue_block_editor_assets' );
} }
/**
* Dequeue conflicting styles.
*/
public function dequeue_conflicting_styles() {
if ( ! PageController::is_admin_or_embed_page() ) {
return;
}
// Dequeing this to avoid conflicts, until we remove the 'woocommerce-page' class.
wp_dequeue_style( 'woocommerce-blocktheme' );
}
/** /**
* Update the edit product links when the new experience is enabled. * Update the edit product links when the new experience is enabled.
* *