From fa473014dc5a34c69270e5a44817a1060254c828 Mon Sep 17 00:00:00 2001 From: TimothyBlynJacobs Date: Fri, 5 Nov 2021 02:30:57 +0000 Subject: [PATCH] REST API: Support subdirectory themes in the Themes controller. This allows for themes that are included inside of a subdirectory, for example `subdir/my-theme`, to be accessed via the single item route of the `/wp/v2/themes` controller. Fixes #54349. Built from https://develop.svn.wordpress.org/trunk@52017 git-svn-id: http://core.svn.wordpress.org/trunk@51609 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../rest-api/endpoints/class-wp-rest-themes-controller.php | 4 +++- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) 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 10b5c29a33..b34bc317e1 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 @@ -16,6 +16,8 @@ */ class WP_REST_Themes_Controller extends WP_REST_Controller { + const PATTERN = '[^.\/]+(?:\/[^.\/]+)?'; + /** * Constructor. * @@ -50,7 +52,7 @@ class WP_REST_Themes_Controller extends WP_REST_Controller { register_rest_route( $this->namespace, - '/' . $this->rest_base . '/(?P[\w-]+)', + sprintf( '/%s/(?P%s)', $this->rest_base, self::PATTERN ), array( 'args' => array( 'stylesheet' => array( diff --git a/wp-includes/version.php b/wp-includes/version.php index a9d1ddc3c5..47a4886c24 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52016'; +$wp_version = '5.9-alpha-52017'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.