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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52017 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Timothy Jacobs
2021-11-05 02:29:32 +00:00
parent 827dd20997
commit ca7450dfdd
4 changed files with 45 additions and 4 deletions
@@ -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(