Make WordPress Core


Ignore:
Timestamp:
06/27/2023 11:11:02 AM (20 months ago)
Author:
isabel_brison
Message:

Editor: allow filtering block patterns by source.

Extends the REST API endpoint for block patterns to provide a source attribute that can be used to filter patterns.

Props aaronrobertshaw, mukesh27, talldanwp, ramonopoly.
Fixes 58622.

File:
1 edited

Legend:

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

    r55173 r56063  
    156156     *
    157157     * @since 6.0.0
     158     * @since 6.3.0 Added `source` property.
    158159     *
    159160     * @param array           $item    Raw pattern as registered, before any changes.
     
    175176            'postTypes'     => 'post_types',
    176177            'templateTypes' => 'template_types',
     178            'source'        => 'source',
    177179        );
    178180        $data   = array();
     
    193195     *
    194196     * @since 6.0.0
     197     * @since 6.3.0 Added `source` property.
    195198     *
    196199     * @return array Item schema data.
     
    268271                    'context'     => array( 'view', 'edit', 'embed' ),
    269272                ),
     273                'source'         => array(
     274                    'description' => __( 'Where the pattern comes from e.g. core' ),
     275                    'type'        => 'string',
     276                    'readonly'    => true,
     277                    'context'     => array( 'view', 'edit', 'embed' ),
     278                    'enum'        => array(
     279                        'core',
     280                        'plugin',
     281                        'theme',
     282                        'pattern-directory/core',
     283                        'pattern-directory/theme',
     284                        'pattern-directory/featured',
     285                    ),
     286                ),
    270287            ),
    271288        );
Note: See TracChangeset for help on using the changeset viewer.