Make WordPress Core

Ticket #47620: 47620-context-2.diff

File 47620-context-2.diff, 2.8 KB (added by gziolo, 5 years ago)

Block context - try 2

  • src/wp-admin/includes/post.php

     
    22342234function get_block_editor_server_block_settings() {
    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                        }
    22442258
     
    22462260                                $blocks[ $block_name ] = array();
    22472261                        }
    22482262
    2249                         $blocks[ $block_name ][ $key ] = $block_type->{ $key };
     2263                        $blocks[ $block_name ][ $key ] = $block_type->{ $field };
    22502264                }
    22512265        }
    22522266
  • src/wp-includes/class-wp-block-type.php

     
    7474
    7575        /**
    7676         * @since 5.5.0
    77          * @var array
     77         * @var array|null
    7878         */
    79         public $supports = array();
     79        public $supports = null;
    8080
    8181        /**
    8282         * @since 5.5.0
     
    101101        public $attributes = null;
    102102
    103103        /**
     104         * Context values inherited by blocks of this type.
     105         *
     106         * @since 5.5.0
     107         * @var array
     108         */
     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;
     118
     119        /**
    104120         * Block type editor script handle.
    105121         *
    106122         * @since 5.0.0
  • tests/phpunit/tests/admin/includesPost.php

     
    844844                                'category'    => 'common',
    845845                                'icon'        => 'text',
    846846                                'keywords'    => array(),
    847                                 'supports'    => array(),
     847                                'usesContext' => array(),
    848848                                'styles'      => array(),
    849849                        ),
    850850                        $blocks[ $name ]