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/block-patterns.php

    r55098 r55168  
    303303 *   - Block Types      (comma-separated values)
    304304 *   - Post Types       (comma-separated values)
     305 *   - Template Types   (comma-separated values)
    305306 *   - Inserter         (yes/no)
    306307 *
     
    319320        'postTypes'     => 'Post Types',
    320321        'inserter'      => 'Inserter',
     322        'templateTypes' => 'Template Types',
    321323    );
    322324
     
    389391
    390392                    // For properties of type array, parse data as comma-separated.
    391                     foreach ( array( 'categories', 'keywords', 'blockTypes', 'postTypes' ) as $property ) {
     393                    foreach ( array( 'categories', 'keywords', 'blockTypes', 'postTypes', 'templateTypes' ) as $property ) {
    392394                        if ( ! empty( $pattern_data[ $property ] ) ) {
    393395                            $pattern_data[ $property ] = array_filter(
Note: See TracChangeset for help on using the changeset viewer.