удалить стили gutenberg blocks for woocommerce

PHOTO EMBED

Mon Mar 20 2023 16:26:55 GMT+0000 (Coordinated Universal Time)

Saved by @mastaklance

// ************************************************************ //
// Disable WooCommerce Blocks Manually
// https://rudrastyh.com/woocommerce/remove-woocommerce-blocks.html
// ************************************************************ //

add_filter( 'allowed_block_types_all', 'misha_allowed_blocks' );
function misha_allowed_blocks( $allowed_blocks ) {
	$registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
 	// specify all the blocks you would like to disable here
	unset( $registered_blocks[ 'woocommerce/all-products' ] );
	// etc ...
	// now $registered_blocks contains only blocks registered by plugins, but we need keys only
	$registered_blocks = array_keys( $registered_blocks );
	// merge the whitelist with plugins blocks
	$allowed_blocks = array_merge( 
		array(
			'core/heading',
		),
		$registered_blocks 
	);
	return $allowed_blocks;
}


/**
 * Disable WooCommerce block styles (front-end).
 */
function themesharbor_disable_woocommerce_block_styles() {
  wp_dequeue_style( 'wc-blocks-style' );
}
add_action( 'wp_enqueue_scripts', 'themesharbor_disable_woocommerce_block_styles' );


// Remove each style one by one
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_dequeue_styles( $enqueue_styles ) {
	unset( $enqueue_styles['woocommerce-general'] );	// Remove the gloss
	unset( $enqueue_styles['woocommerce-layout'] );		// Remove the layout
	unset( $enqueue_styles['woocommerce-smallscreen'] );	// Remove the smallscreen optimisation
	return $enqueue_styles;
}
content_copyCOPY