Skip to content

Commit b1dd7ff

Browse files
committed
Use global functions if the requested theme is the current theme
1 parent 784fb46 commit b1dd7ff

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,19 @@ public function prepare_item_for_response( $item, $request ) {
333333
}
334334

335335
if ( rest_is_field_included( 'stylesheet_uri', $fields ) ) {
336-
$data['stylesheet_uri'] = $theme->get_stylesheet_directory_uri();
336+
if ( $this->is_same_theme( $theme, $current_theme ) ) {
337+
$data['stylesheet_uri'] = get_stylesheet_directory_uri();
338+
} else {
339+
$data['stylesheet_uri'] = $theme->get_stylesheet_directory_uri();
340+
}
337341
}
338342

339343
if ( rest_is_field_included( 'template_uri', $fields ) ) {
340-
$data['template_uri'] = $theme->get_template_directory_uri();
344+
if ( $this->is_same_theme( $theme, $current_theme ) ) {
345+
$data['template_uri'] = get_template_directory_uri();
346+
} else {
347+
$data['template_uri'] = $theme->get_template_directory_uri();
348+
}
341349
}
342350

343351
$data = $this->add_additional_fields_to_object( $data, $request );
@@ -459,6 +467,7 @@ public function get_item_schema() {
459467
'stylesheet_uri' => array(
460468
'description' => __( 'The uri for the theme\'s stylesheet directory.' ),
461469
'type' => 'string',
470+
'format' => 'uri',
462471
'readonly' => true,
463472
),
464473
'template' => array(
@@ -469,6 +478,7 @@ public function get_item_schema() {
469478
'template_uri' => array(
470479
'description' => __( 'The uri for the theme\'s template directory. If this is a child theme, this refers to the parent theme, otherwise this is the same as the theme\'s stylesheet directory.' ),
471480
'type' => 'string',
481+
'format' => 'uri',
472482
'readonly' => true,
473483
),
474484
'author' => array(

0 commit comments

Comments
 (0)