Make WordPress Core


Ignore:
Timestamp:
04/12/2022 09:24:51 AM (4 years ago)
Author:
gziolo
Message:

REST API: Bring new endpoints for Block Patterns from Gutenberg plugin

Related Gutenberg issue: https://github.com/WordPress/gutenberg/issues/39889.

Backporting changes from the Gutenberg plugin:

  • new Block Patterns REST API endpoint
  • new Block Pattern Categories REST API endpoint
  • updates to Query Loop related patterns
  • support for custom taxonomies in Query Loop block

Props hellofromtonya, peterwilsoncc, ntsekouras, zieladam, ironprogrammer, spacedmonkey, timothyblynjacobs, antonvlasenko, jsnajdr.
See #55505.

File:
1 edited

Legend:

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

    r52236 r53152  
    8181         *
    8282         * @since 5.8.0
     83         * @since 6.0.0 Added 'slug' to request.
    8384         *
    8485         * @param WP_REST_Request $request Full details about the request.
     
    101102                $keyword_id  = $request['keyword'];
    102103                $search_term = $request['search'];
     104                $slug        = $request['slug'];
    103105
    104106                if ( $category_id ) {
     
    112114                if ( $search_term ) {
    113115                        $query_args['search'] = $search_term;
     116                }
     117
     118                if ( $slug ) {
     119                        $query_args['slug'] = $slug;
    114120                }
    115121
     
    160166                                        'pattern_api_failed',
    161167                                        sprintf(
    162                                         /* translators: %s: Support forums URL. */
     168                                                /* translators: %s: Support forums URL. */
    163169                                                __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
    164170                                                __( 'https://wordpress.org/support/forums/' )
     
    256262                                        'type'        => 'integer',
    257263                                        'minimum'     => 1,
    258                                         'context'     => array( 'view', 'embed' ),
     264                                        'context'     => array( 'view', 'edit', 'embed' ),
    259265                                ),
    260266
     
    263269                                        'type'        => 'string',
    264270                                        'minLength'   => 1,
    265                                         'context'     => array( 'view', 'embed' ),
     271                                        'context'     => array( 'view', 'edit', 'embed' ),
    266272                                ),
    267273
     
    270276                                        'type'        => 'string',
    271277                                        'minLength'   => 1,
    272                                         'context'     => array( 'view', 'embed' ),
     278                                        'context'     => array( 'view', 'edit', 'embed' ),
    273279                                ),
    274280
     
    278284                                        'uniqueItems' => true,
    279285                                        'items'       => array( 'type' => 'string' ),
    280                                         'context'     => array( 'view', 'embed' ),
     286                                        'context'     => array( 'view', 'edit', 'embed' ),
    281287                                ),
    282288
     
    286292                                        'uniqueItems' => true,
    287293                                        'items'       => array( 'type' => 'string' ),
    288                                         'context'     => array( 'view', 'embed' ),
     294                                        'context'     => array( 'view', 'edit', 'embed' ),
    289295                                ),
    290296
     
    293299                                        'type'        => 'string',
    294300                                        'minLength'   => 1,
    295                                         'context'     => array( 'view', 'embed' ),
     301                                        'context'     => array( 'view', 'edit', 'embed' ),
    296302                                ),
    297303
     
    299305                                        'description' => __( 'The preferred width of the viewport when previewing a pattern, in pixels.' ),
    300306                                        'type'        => 'integer',
    301                                         'context'     => array( 'view', 'embed' ),
     307                                        'context'     => array( 'view', 'edit', 'embed' ),
    302308                                ),
    303309                        ),
Note: See TracChangeset for help on using the changeset viewer.