Make WordPress Core

Ticket #48529: 48529.2.diff

File 48529.2.diff, 5.1 KB (added by spacedmonkey, 3 years ago)
  • src/wp-includes/class-wp-block-type.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    1515 * @see register_block_type()
    1616 */
    1717class WP_Block_Type {
     18
    1819        /**
    1920         * Block type key.
    2021         *
     
    2324         */
    2425        public $name;
    2526
     27        /**
     28         * @since 5.5.0
     29         * @var string
     30         */
     31        public $title = '';
     32
     33        /**
     34         * @since 5.5.0
     35         * @var string
     36         */
     37        public $category = '';
     38
     39        /**
     40         * @since 5.5.0
     41         * @var array|null
     42         */
     43        public $parent = null;
     44
     45        /**
     46         * @since 5.5.0
     47         * @var string
     48         */
     49        public $icon = '';
     50
     51        /**
     52         * @since 5.5.0
     53         * @var string
     54         */
     55        public $description = '';
     56
     57        /**
     58         * @since 5.5.0
     59         * @var array
     60         */
     61        public $keywords = array();
     62
     63        /**
     64         * @since 5.5.0
     65         * @var string
     66         */
     67        public $text_domain = '';
     68
     69        /**
     70         * @since 5.5.0
     71         * @var array
     72         */
     73        public $style_variations = array();
     74
     75        /**
     76         * @since 5.5.0
     77         * @var array
     78         */
     79        public $supports = array();
     80
     81        /**
     82         * @since 5.5.0
     83         * @var array
     84         */
     85        public $example = array();
     86
    2687        /**
    2788         * Block type render callback.
    2889         *
    2990         * @since 5.0.0
    3091         * @var callable
    3192         */
    32         public $render_callback;
     93        public $render_callback = null;
    3394
    3495        /**
    3596         * Block type attributes property schemas.
     
    3798         * @since 5.0.0
    3899         * @var array
    39100         */
    40         public $attributes;
     101        public $attributes = array();
    41102
    42103        /**
    43104         * Block type editor script handle.
     
    45106         * @since 5.0.0
    46107         * @var string
    47108         */
    48         public $editor_script;
     109        public $editor_script = '';
    49110
    50111        /**
    51112         * Block type front end script handle.
     
    53114         * @since 5.0.0
    54115         * @var string
    55116         */
    56         public $script;
     117        public $script = '';
    57118
    58119        /**
    59120         * Block type editor style handle.
     
    61122         * @since 5.0.0
    62123         * @var string
    63124         */
    64         public $editor_style;
     125        public $editor_style = '';
    65126
    66127        /**
    67128         * Block type front end style handle.
     
    69130         * @since 5.0.0
    70131         * @var string
    71132         */
    72         public $style;
     133        public $style = '';
    73134
    74135        /**
    75136         * Constructor.
    76137         *
    77138         * Will populate object properties from the provided arguments.
    78139         *
    79          * @since 5.0.0
    80          *
    81          * @see register_block_type()
    82          *
    83140         * @param string       $block_type Block type name including namespace.
    84141         * @param array|string $args       Optional. Array or string of arguments for registering a block type.
    85142         *                                 Default empty array.
     143         *
     144         * @since 5.0.0
     145         *
     146         * @see   register_block_type()
     147         *
    86148         */
    87149        public function __construct( $block_type, $args = array() ) {
    88150                $this->name = $block_type;
  • src/wp-admin/includes/post.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    22262226function get_block_editor_server_block_settings() {
    22272227        $block_registry = WP_Block_Type_Registry::get_instance();
    22282228        $blocks         = array();
    2229         $keys_to_pick   = array( 'title', 'description', 'icon', 'category', 'keywords', 'parent', 'supports', 'attributes', 'styles' );
     2229        $keys_to_pick   = array( 'title', 'description', 'icon', 'category', 'keywords', 'parent', 'supports', 'attributes', 'styles', 'style_variations', 'text_domain', 'example' );
    22302230
    22312231        foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
    22322232                foreach ( $keys_to_pick as $key ) {
  • tests/phpunit/tests/blocks/block-type.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    349349                return json_encode( $attributes );
    350350        }
    351351
     352        /**
     353         * @ticket 48529
     354         */
     355        public function test_register_block() {
     356                $block_type = new WP_Block_Type( 'core/fake', array(
     357                        'title'       => 'Test title',
     358                        'category'    => 'Test category',
     359                        'parent'      => [ 'core/third-party' ],
     360                        'icon'        => 'icon.png',
     361                        'description' => 'test description',
     362                        'keywords'    => [ 'test keyword' ],
     363                        'text_domain' => [ 'test_domain' ],
     364                        'supports'    => [ 'alignment' ],
     365                ) );
     366
     367                $this->assertSame( 'Test title', $block_type->title );
     368                $this->assertSame( 'Test category', $block_type->category );
     369                $this->assertEqualSets( [ 'core/third-party' ], $block_type->parent );
     370                $this->assertSame( 'icon.png', $block_type->icon );
     371                $this->assertSame( 'test description', $block_type->description );
     372                $this->assertEqualSets( [ 'test keyword' ], $block_type->keywords );
     373                $this->assertEqualSets( [ 'test_domain' ], $block_type->text_domain );
     374                $this->assertEqualSets( [ 'alignment' ], $block_type->supports );
     375        }
     376
    352377        /**
    353378         * Testing the block version.
    354379         *