Make WordPress Core

Ticket #59879: 12345.diff

File 12345.diff, 834 bytes (added by nightnei, 13 months ago)

Default core styles should always be the first, to have opportunity to override them via theme.json

  • src/wp-includes/blocks.php

    diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php
    index 1dc1e66230..84d36c626d 100644
    a b function register_block_type_from_metadata( $file_or_folder, $args = array() ) { 
    531531                                        $processed_styles[] = $result;
    532532                                }
    533533                        }
     534
     535                        // we should put "wp-block-{$block_name}-theme" before styles from theme.json and any other styles,
     536                        // since these styles are default, so we should have opportunity to override it
     537                        if ( in_array( "wp-block-{$block_name}-theme", $processed_styles ) ) {
     538                                $processed_styles = array_diff( $processed_styles, array( "wp-block-{$block_name}-theme" ) );
     539                                array_unshift( $processed_styles, "wp-block-{$block_name}-theme" );
     540                        }
    534541                        $settings[ $settings_field_name ] = $processed_styles;
    535542                }
    536543        }