Make WordPress Core


Ignore:
Timestamp:
02/06/2023 07:38:08 PM (16 months ago)
Author:
flixos90
Message:

Editor: Support the block_types and viewport_width props for remote patterns fetched from Pattern Directory.

Props ntsekouras, ironprogrammer, hellofromtonya, flixos90.
Fixes #57611.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php

    r55132 r55234  
    104104            'slug'     => true,
    105105        );
    106         $query_args = array_intersect_key( $request->get_params(), $valid_query_args );
     106        $query_args       = array_intersect_key( $request->get_params(), $valid_query_args );
    107107
    108108        $query_args['locale']             = get_user_locale();
     
    203203            'description'    => sanitize_text_field( $raw_pattern->meta->wpop_description ),
    204204            'viewport_width' => absint( $raw_pattern->meta->wpop_viewport_width ),
     205            'block_types'    => array_map( 'sanitize_text_field', $raw_pattern->meta->wpop_block_types ),
    205206        );
    206207
     
    225226     *
    226227     * @since 5.8.0
     228     * @since 6.2.0 Added `'block_types'` to schema.
    227229     *
    228230     * @return array Item schema data.
     
    286288                    'type'        => 'integer',
    287289                    'context'     => array( 'view', 'edit', 'embed' ),
     290                ),
     291
     292                'block_types'    => array(
     293                    'description' => __( 'The block types which can use this pattern.' ),
     294                    'type'        => 'array',
     295                    'uniqueItems' => true,
     296                    'items'       => array( 'type' => 'string' ),
     297                    'context'     => array( 'view', 'embed' ),
    288298                ),
    289299            ),
Note: See TracChangeset for help on using the changeset viewer.