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/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php

    r55457 r56063  
    7777                'categories'    => array( 'test' ),
    7878                'templateTypes' => array( 'page' ),
     79                'source'        => 'theme',
    7980            )
    8081        );
     
    8788                'categories'    => array( 'test' ),
    8889                'templateTypes' => array( 'single' ),
     90                'source'        => 'core',
    8991            )
    9092        );
     
    9698                'content'    => '<!-- wp:paragraph --><p>Three</p><!-- /wp:paragraph -->',
    9799                'categories' => array( 'test', 'buttons', 'query' ),
     100                'source'     => 'pattern-directory/featured',
    98101            )
    99102        );
     
    125128
    126129        $request            = new WP_REST_Request( 'GET', static::REQUEST_ROUTE );
    127         $request['_fields'] = 'name,content,template_types';
     130        $request['_fields'] = 'name,content,source,template_types';
    128131        $response           = rest_get_server()->dispatch( $request );
    129132        $data               = $response->get_data();
     
    136139                'content'        => '<!-- wp:heading {"level":1} --><h1>One</h1><!-- /wp:heading -->',
    137140                'template_types' => array( 'page' ),
     141                'source'         => 'theme',
    138142            ),
    139143            $data[0],
     
    145149                'content'        => '<!-- wp:paragraph --><p>Two</p><!-- /wp:paragraph -->',
    146150                'template_types' => array( 'single' ),
     151                'source'         => 'core',
    147152            ),
    148153            $data[1],
Note: See TracChangeset for help on using the changeset viewer.