Skip to content

Commit

Permalink
Block Styles: Remove core block style variations filters and action (W…
Browse files Browse the repository at this point in the history
…ordPress#62090)

Co-authored-by: aaronrobertshaw <[email protected]>
Co-authored-by: oandregal <[email protected]>
  • Loading branch information
3 people authored and patil-vipul committed Jun 17, 2024
1 parent c03b0ab commit b5c397c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/block-supports/block-style-variations.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,31 @@ function gutenberg_enqueue_block_style_variation_styles() {
// Register the block support.
WP_Block_Supports::get_instance()->register( 'block-style-variation', array() );

// Remove core filters and action.
if ( function_exists( 'wp_render_block_style_variation_support_styles' ) ) {
remove_filter( 'render_block_data', 'wp_render_block_style_variation_support_styles' );
}
if ( function_exists( 'wp_render_block_style_variation_class_name' ) ) {
remove_filter( 'render_block', 'wp_render_block_style_variation_class_name' );
}
if ( function_exists( 'wp_enqueue_block_style_variation_styles' ) ) {
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_block_style_variation_styles' );
}

if ( function_exists( 'wp_resolve_block_style_variations_from_primary_theme_json' ) ) {
remove_filter( 'wp_theme_json_data_theme', 'wp_resolve_block_style_variations_from_primary_theme_json' );
}
if ( function_exists( 'wp_resolve_block_style_variations_from_theme_json_partials' ) ) {
remove_filter( 'wp_theme_json_data_theme', 'wp_resolve_block_style_variations_from_theme_json_partials' );
}
if ( function_exists( 'wp_resolve_block_style_variations_from_styles_registry' ) ) {
remove_filter( 'wp_theme_json_data_theme', 'wp_resolve_block_style_variations_from_styles_registry' );
}
if ( function_exists( 'wp_resolve_block_style_variations_from_theme_style_variation' ) ) {
remove_filter( 'wp_theme_json_data_user', 'wp_resolve_block_style_variations_from_theme_style_variation' );
}

// Add Gutenberg filters and action.
add_filter( 'render_block_data', 'gutenberg_render_block_style_variation_support_styles', 10, 2 );
add_filter( 'render_block', 'gutenberg_render_block_style_variation_class_name', 10, 2 );
add_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_block_style_variation_styles', 1 );
Expand Down

0 comments on commit b5c397c

Please sign in to comment.