Make WordPress Core


Ignore:
Timestamp:
09/20/2022 09:19:10 PM (15 months ago)
Author:
hellofromTonya
Message:

Editor: Adds template types, is_wp_suggestion, and fallback template content.

This commit improves site editor templates by:

  • Adds a post meta is_wp_suggestion to templates created from the site editor.

Why? To differentiate the templates created from the post editor in the Template panel in inspector controls and the templates suggested in site editor.

See Gutenberg PR 41387 for more details.

  • Expands the template types that can be added to the site editor to include single custom post type and specific posts templates.

See Gutenberg PR 41189 for more details.

  • Adds fallback template content on creation in site editor:
    • Introduces get_template_hierarchy() to get the template hierarchy for a given template slug to be created.
    • Adds a lookup route to WP_REST_Templates_Controller to get the fallback template content.

See Gutenberg PR 42520 for more details.

  • Fixes a typo in default category template's description within get_default_block_template_types().

See Gutenberg PR 42586 for more details.

  • Changes field checks from in_array() to rest_is_field_included() in WP_REST_Post_Types_Controller.
  • Adds an icon field to WP_REST_Post_Types_Controller

Follow-up to [53129], [52331], [52275], [52062], [51962], [43087].

Props ntsekouras, spacedmonkey, mamaduka, mburridge, jameskoster, bernhard-reiter, mcsf, hellofromTonya.
See #56467.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-post-types-controller.php

    r54090 r54269  
    157157    }
    158158
     159    /**
     160     * @ticket 56467
     161     *
     162     * @covers WP_REST_Post_Types_Controller::get_item_schema
     163     */
    159164    public function test_get_item_schema() {
    160165        $request    = new WP_REST_Request( 'OPTIONS', '/wp/v2/types' );
     
    162167        $data       = $response->get_data();
    163168        $properties = $data['schema']['properties'];
    164         $this->assertCount( 12, $properties );
    165         $this->assertArrayHasKey( 'capabilities', $properties );
    166         $this->assertArrayHasKey( 'description', $properties );
    167         $this->assertArrayHasKey( 'hierarchical', $properties );
    168         $this->assertArrayHasKey( 'viewable', $properties );
    169         $this->assertArrayHasKey( 'labels', $properties );
    170         $this->assertArrayHasKey( 'name', $properties );
    171         $this->assertArrayHasKey( 'slug', $properties );
    172         $this->assertArrayHasKey( 'supports', $properties );
    173         $this->assertArrayHasKey( 'taxonomies', $properties );
    174         $this->assertArrayHasKey( 'rest_base', $properties );
    175         $this->assertArrayHasKey( 'rest_namespace', $properties );
    176         $this->assertArrayHasKey( 'visibility', $properties );
     169
     170        $this->assertCount( 13, $properties, 'Schema should have 13 properties' );
     171        $this->assertArrayHasKey( 'capabilities', $properties, '`capabilities` should be included in the schema' );
     172        $this->assertArrayHasKey( 'description', $properties, '`description` should be included in the schema' );
     173        $this->assertArrayHasKey( 'hierarchical', $properties, '`hierarchical` should be included in the schema' );
     174        $this->assertArrayHasKey( 'viewable', $properties, '`viewable` should be included in the schema' );
     175        $this->assertArrayHasKey( 'labels', $properties, '`labels` should be included in the schema' );
     176        $this->assertArrayHasKey( 'name', $properties, '`name` should be included in the schema' );
     177        $this->assertArrayHasKey( 'slug', $properties, '`slug` should be included in the schema' );
     178        $this->assertArrayHasKey( 'supports', $properties, '`supports` should be included in the schema' );
     179        $this->assertArrayHasKey( 'taxonomies', $properties, '`taxonomies` should be included in the schema' );
     180        $this->assertArrayHasKey( 'rest_base', $properties, '`rest_base` should be included in the schema' );
     181        $this->assertArrayHasKey( 'rest_namespace', $properties, '`rest_namespace` should be included in the schema' );
     182        $this->assertArrayHasKey( 'visibility', $properties, '`visibility` should be included in the schema' );
     183        $this->assertArrayHasKey( 'icon', $properties, '`icon` should be included in the schema' );
    177184    }
    178185
Note: See TracChangeset for help on using the changeset viewer.