WordPress.org

Make WordPress Core

Changeset 51102


Ignore:
Timestamp:
06/08/2021 05:35:06 PM (6 months ago)
Author:
youknowriad
Message:

Block Editor: Allow themes to add inline styles for all blocks when using lazy styles loading.

Props aristath.
Fixes #53358.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r51089 r51102  
    209209     */
    210210    $metadata = apply_filters( 'block_type_metadata', $metadata );
     211
     212    /**
     213     * Add `style` and `editor_style` for core blocks if missing.
     214     *
     215     * @since 5.8.0
     216     */
     217    if ( ! empty( $metadata['name'] ) && 0 === strpos( $metadata['name'], 'core/' ) ) {
     218        $block_name = str_replace( 'core/', '', $metadata['name'] );
     219
     220        if ( ! isset( $metadata['style'] ) ) {
     221            $metadata['style'] = "wp-block-$block_name";
     222        }
     223        if ( ! isset( $metadata['editor_style'] ) ) {
     224            $metadata['editor_style'] = "wp-block-$block_name-editor";
     225        }
     226    }
    211227
    212228    $settings          = array();
Note: See TracChangeset for help on using the changeset viewer.