Make WordPress Core


Ignore:
Timestamp:
01/31/2023 04:47:58 PM (3 years ago)
Author:
jorgefilipecosta
Message:

Add: Template types to the patterns API.

Backports https://github.com/WordPress/gutenberg/pull/45814 into the core.
This commit adds a new templateType property to the patterns registration API.
This property allows a pattern to specify which template it makes sense on, e.g.: 404, single-post, single-product, category.

Props youknowriad, ntsekouras,
spacedmonkey.

File:
1 edited

Legend:

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

    r55125 r55168  
    174174            'content'       => 'content',
    175175            'inserter'      => 'inserter',
     176            'templateTypes' => 'template_types',
    176177        );
    177178        $data   = array();
     
    249250                    'context'     => array( 'view', 'edit', 'embed' ),
    250251                ),
     252                'template_types' => array(
     253                    'description' => __( 'An array of template types where the pattern fits.' ),
     254                    'type'        => 'array',
     255                    'readonly'    => true,
     256                    'context'     => array( 'view', 'edit', 'embed' ),
     257                ),
    251258                'content'        => array(
    252259                    'description' => __( 'The pattern content.' ),
Note: See TracChangeset for help on using the changeset viewer.