Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ public function prepare_item_for_response( $template, $request ) { // phpcs:igno
'has_theme_file' => $template->has_theme_file,
);

if ( 'wp_template' === $template->type ) {
$result['is_custom'] = $template->is_custom;
}

if ( 'wp_template_part' === $template->type ) {
$result['area'] = $template->area;
}
Expand Down Expand Up @@ -582,6 +586,15 @@ public function get_item_schema() {
),
);

if ( 'wp_template' === $this->post_type ) {
$schema['properties']['is_custom'] = array(
'description' => __( 'Whether a template is a custom template.', 'gutenberg' ),
'type' => 'bool',
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
);
}

if ( 'wp_template_part' === $this->post_type ) {
$schema['properties']['area'] = array(
'description' => __( 'Where the template part is intended for use (header, footer, etc.)', 'gutenberg' ),
Expand Down
3 changes: 3 additions & 0 deletions phpunit/class-gutenberg-rest-template-controller-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function find_and_normalize_template_by_id( $templates, $id ) {
'type' => 'wp_template',
'wp_id' => null,
'has_theme_file' => true,
'is_custom' => false,
),
find_and_normalize_template_by_id( $data, 'tt1-blocks//index' )
);
Expand Down Expand Up @@ -129,6 +130,7 @@ public function test_get_item() {
'type' => 'wp_template',
'wp_id' => null,
'has_theme_file' => true,
'is_custom' => false,
),
$data
);
Expand Down Expand Up @@ -193,6 +195,7 @@ public function test_create_item() {
'raw' => 'Content',
),
'has_theme_file' => false,
'is_custom' => true,
),
$data
);
Expand Down