Make WordPress Core


Ignore:
Timestamp:
12/14/2021 06:22:07 PM (3 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/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php

    r52345 r52376  
    6969        register_rest_route(
    7070            $this->namespace,
    71             '/' . $this->rest_base . '/(?P<id>[\/\w-]+)',
     71            '/' . $this->rest_base . '/(?P<id>[\/\s%\w\.\(\)\[\]\@_\-]+)',
    7272            array(
    7373                'args'   => array(
     
    150150     */
    151151    public function _sanitize_template_id( $id ) {
     152        // Decode empty space.
     153        $id = urldecode( $id );
     154
    152155        $last_slash_pos = strrpos( $id, '/' );
    153156        if ( false === $last_slash_pos ) {
Note: See TracChangeset for help on using the changeset viewer.