Make WordPress Core

Changeset 48117

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.

Location:
trunk
Files:
3 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 ( $ $key ) {
     2255            if ( ! isset( $block_type->{ $ } ) ) {
    22422256                continue;
    22432257            }
     
    22472261            }
    22482262
    2249             $blocks[ $block_name ][ $key ] = $block_type->{ $key };
     2263            $blocks[ $block_name ][ $key ] = $block_type->{ $ };
    22502264        }
    22512265    }
  • trunk/src/wp-includes/class-wp-block-type.php

    r48110 r48117  
    7575    /**
    7676     * @since 5.5.0
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
    77107     * @var array
    78108     */
    79     public $supports = array();
    80 
    81     /**
    82      * @since 5.5.0
    83      * @var array|null
    84      */
    85     public $example = null;
    86 
    87     /**
    88      * Block type render callback.
    89      *
    90      * @since 5.0.0
    91      * @var callable
    92      */
    93     public $render_callback = null;
    94 
    95     /**
    96      * Block type attributes property schemas.
    97      *
    98      * @since 5.0.0
    99      * @var array|null
    100      */
    101     public $attributes = null;
     109    public $uses_context = array();
     110
     111    /**
     112     * Context provided by blocks of this type.
     113     *
     114     * @since 5.5.0
     115     * @var array|null
     116     */
     117    public $provides_context = null;
    102118
    103119    /**
  • trunk/tests/phpunit/tests/admin/includesPost.php

    r47876 r48117  
    845845                'icon'        => 'text',
    846846                'keywords'    => array(),
    847                 'supports'    => array(),
     847                ' => array(),
    848848                'styles'      => array(),
    849849            ),
Note: See TracChangeset for help on using the changeset viewer.