Make WordPress Core


Ignore:
Timestamp:
12/14/2021 06:22:07 PM (5 years ago)
Author:
hellofromTonya
Message:

REST API: Add block theme support for valid non-alphanumeric characters in theme's directory name.

Themes whose wp-content/themes/<dirname> include valid non-alphanumeric (cross-platform) characters work for non-block themes, but did not previously resolve for block themes. For example, a block theme in wp-content/themes/twentytwentytwo-0.4.0/ directory resulted a 404 "No route was found matching the URL and request method" response when attempting to customize it in the Site Editor.

This commit adds support for the following characters in a theme's root directory: _, ., @, [, ], (, and ). Subdirectory themes and - are already supported.

Follow-up to [51003], [52051], [52275].

Props mkaz, costdev, hellofromTonya, jffng, justinahinon, peterwilsoncc, spacedmonkey, TimothyBlynJacobs.
Fixes #54596.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r52272 r52376  
    7070        }
    7171
     72        /**
     73         * @ticket 54596
     74         */
    7275        public function test_expected_routes_in_schema() {
    7376                $routes = rest_get_server()->get_routes();
     
    133136                        '/wp/v2/comments',
    134137                        '/wp/v2/comments/(?P<id>[\\d]+)',
    135                         '/wp/v2/global-styles/(?P<id>[\/\w-]+)',
    136                         '/wp/v2/global-styles/themes/(?P<stylesheet>[^.\/]+(?:\/[^.\/]+)?)',
     138                        '/wp/v2/global-styles/(?P<id>[\/\s%\w\.\(\)\[\]\@_\-]+)',
     139                        '/wp/v2/global-styles/themes/(?P<stylesheet>[\/\s%\w\.\(\)\[\]\@_\-]+)',
    137140                        '/wp/v2/search',
    138141                        '/wp/v2/block-renderer/(?P<name>[a-z0-9-]+/[a-z0-9-]+)',
     
    142145                        '/wp/v2/settings',
    143146                        '/wp/v2/template-parts',
    144                         '/wp/v2/template-parts/(?P<id>[\/\w-]+)',
     147                        '/wp/v2/template-parts/(?P<id>[\/\s%\w\.\(\)\[\]\@_\-]+)',
    145148                        '/wp/v2/template-parts/(?P<id>[\d]+)/autosaves',
    146149                        '/wp/v2/template-parts/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)',
     
    148151                        '/wp/v2/template-parts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+)',
    149152                        '/wp/v2/templates',
    150                         '/wp/v2/templates/(?P<id>[\/\w-]+)',
     153                        '/wp/v2/templates/(?P<id>[\/\s%\w\.\(\)\[\]\@_\-]+)',
    151154                        '/wp/v2/templates/(?P<id>[\d]+)/autosaves',
    152155                        '/wp/v2/templates/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+)',
Note: See TracChangeset for help on using the changeset viewer.