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
This commit is contained in:
TimothyBlynJacobs 2021-11-05 02:30:57 +00:00
parent 04a853195b
commit fa473014dc
2 changed files with 4 additions and 2 deletions

View File

@ -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<stylesheet>[\w-]+)',
sprintf( '/%s/(?P<stylesheet>%s)', $this->rest_base, self::PATTERN ),
array(
'args' => array(
'stylesheet' => array(

View File

@ -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.