diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php index 064fc2dd39..0f4da6773a 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php @@ -224,6 +224,7 @@ class WP_REST_Themes_Controller extends WP_REST_Controller { * * @since 5.0.0 * @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named parameter support. + * @since 6.6.0 Added `stylesheet_uri` and `template_uri` fields. * * @param WP_Theme $item Theme object. * @param WP_REST_Request $request Request object. @@ -331,6 +332,22 @@ class WP_REST_Themes_Controller extends WP_REST_Controller { $data['is_block_theme'] = $theme->is_block_theme(); } + if ( rest_is_field_included( 'stylesheet_uri', $fields ) ) { + if ( $this->is_same_theme( $theme, $current_theme ) ) { + $data['stylesheet_uri'] = get_stylesheet_directory_uri(); + } else { + $data['stylesheet_uri'] = $theme->get_stylesheet_directory_uri(); + } + } + + if ( rest_is_field_included( 'template_uri', $fields ) ) { + if ( $this->is_same_theme( $theme, $current_theme ) ) { + $data['template_uri'] = get_template_directory_uri(); + } else { + $data['template_uri'] = $theme->get_template_directory_uri(); + } + } + $data = $this->add_additional_fields_to_object( $data, $request ); // Wrap the data in a response object. @@ -447,11 +464,23 @@ class WP_REST_Themes_Controller extends WP_REST_Controller { 'type' => 'string', 'readonly' => true, ), + 'stylesheet_uri' => array( + 'description' => __( 'The uri for the theme\'s stylesheet directory.' ), + 'type' => 'string', + 'format' => 'uri', + 'readonly' => true, + ), 'template' => array( 'description' => __( 'The theme\'s template. If this is a child theme, this refers to the parent theme, otherwise this is the same as the theme\'s stylesheet.' ), 'type' => 'string', 'readonly' => true, ), + 'template_uri' => array( + '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.' ), + 'type' => 'string', + 'format' => 'uri', + 'readonly' => true, + ), 'author' => array( 'description' => __( 'The theme author.' ), 'type' => 'object', diff --git a/wp-includes/version.php b/wp-includes/version.php index b7795d0726..b3b0bd66d0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-58281'; +$wp_version = '6.6-alpha-58282'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.