Make WordPress Core


Ignore:
Timestamp:
11/09/2016 07:12:01 AM (9 years ago)
Author:
rmccue
Message:

REST API: Include template in all post type schemas.

[38951] added templates to all post types, but didn't add them to the schema.

Props swissspidy.
Fixes #38698.

File:
1 edited

Legend:

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

    r39162 r39182  
    10951095
    10961096    /**
    1097      * Sets the template for a page.
     1097     * Sets the template for a post.
    10981098     *
    10991099     * @since 4.7.0
     
    19231923        }
    19241924
    1925         if ( 'page' === $this->post_type ) {
    1926             $schema['properties']['template'] = array(
    1927                 'description' => __( 'The theme file to use to display the object.' ),
    1928                 'type'        => 'string',
    1929                 'enum'        => array_keys( wp_get_theme()->get_page_templates() ),
    1930                 'context'     => array( 'view', 'edit' ),
    1931             );
    1932         }
     1925        $schema['properties']['template'] = array(
     1926            'description' => __( 'The theme file to use to display the object.' ),
     1927            'type'        => 'string',
     1928            'enum'        => array_keys( wp_get_theme()->get_page_templates( null, $this->post_type ) ),
     1929            'context'     => array( 'view', 'edit' ),
     1930        );
    19331931
    19341932        $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
Note: See TracChangeset for help on using the changeset viewer.