Make WordPress Core


Ignore:
Timestamp:
06/22/2020 10:24:42 AM (4 years ago)
Author:
gziolo
Message:

Blocks: Add context fields to WP_Block_Type

New block context related fields were added as part of https://github.com/WordPress/gutenberg/pull/22686. This changest backports them to WP_Block_Type class.

Props aduth, spacedmonkey, mcsf, epiqueras.
Fixes #47656.

File:
1 edited

Legend:

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

    r47875 r48117  
    22352235    $block_registry = WP_Block_Type_Registry::get_instance();
    22362236    $blocks         = array();
    2237     $keys_to_pick   = array( 'title', 'description', 'icon', 'category', 'keywords', 'parent', 'supports', 'attributes', 'styles', 'textdomain', 'example' );
     2237    $fields_to_pick   = array(
     2238        'title'            => 'title',
     2239        'description'      => 'description',
     2240        'icon'             => 'icon',
     2241        'category'         => 'category',
     2242        'keywords'         => 'keywords',
     2243        'parent'           => 'parent',
     2244        'supports'         => 'supports',
     2245        'attributes'       => 'attributes',
     2246        'provides_context' => 'providesContext',
     2247        'uses_context'     => 'usesContext',
     2248        'styles'           => 'styles',
     2249        'textdomain'       => 'textdomain',
     2250        'example'          => 'example',
     2251    );
    22382252
    22392253    foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
    2240         foreach ( $keys_to_pick as $key ) {
    2241             if ( ! isset( $block_type->{ $key } ) ) {
     2254        foreach ( $fields_to_pick as $field => $key ) {
     2255            if ( ! isset( $block_type->{ $field } ) ) {
    22422256                continue;
    22432257            }
     
    22472261            }
    22482262
    2249             $blocks[ $block_name ][ $key ] = $block_type->{ $key };
     2263            $blocks[ $block_name ][ $key ] = $block_type->{ $field };
    22502264        }
    22512265    }
Note: See TracChangeset for help on using the changeset viewer.