Make WordPress Core


Ignore:
Timestamp:
12/14/2021 06:22:07 PM (2 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/wpRestTemplatesController.php

    r52275 r52376  
    5454    }
    5555
     56    /**
     57     * @covers WP_REST_Templates_Controller::register_routes
     58     * @ticket 54596
     59     */
    5660    public function test_register_routes() {
    5761        $routes = rest_get_server()->get_routes();
    58         $this->assertArrayHasKey( '/wp/v2/templates', $routes );
    59         $this->assertArrayHasKey( '/wp/v2/templates/(?P<id>[\/\w-]+)', $routes );
     62        $this->assertArrayHasKey(
     63            '/wp/v2/templates',
     64            $routes,
     65            'Templates route does not exist'
     66        );
     67        $this->assertArrayHasKey(
     68            '/wp/v2/templates/(?P<id>[\/\s%\w\.\(\)\[\]\@_\-]+)',
     69            $routes,
     70            'Single template based on the given ID route does not exist'
     71        );
    6072    }
    6173
Note: See TracChangeset for help on using the changeset viewer.