Make WordPress Core

Changeset 55426


Ignore:
Timestamp:
02/27/2023 03:32:22 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Themes: Account for a numeric theme directory in WP_Theme::__construct().

This ensures that if a theme with a numeric directory name is active, it is correctly identified as such, and that theme support features work as expected.

Follow-up to [20029], [49925].

Props lopo, alvastar, winterpsv, hugodevos, ankit-k-gupta, jakariaistauk, mukesh27, spacedmonkey, SergeyBiryukov.
Fixes #54645.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme.php

    r55332 r55426  
    242242            }
    243243        }
     244
     245        // Handle a numeric theme directory as a string.
     246        $theme_dir = (string) $theme_dir;
    244247
    245248        $this->theme_root = $theme_root;
  • trunk/tests/phpunit/tests/theme/wpTheme.php

    r55393 r55426  
    111111        $this->assertSame( 'subdir/theme2', $theme->get_stylesheet() );
    112112        $this->assertSame( 'subdir/theme2', $theme->get_template() );
     113    }
     114
     115    /**
     116     * Tests that WP_Theme::__construct() handles a numeric theme directory as a string.
     117     *
     118     * @ticket 54645
     119     *
     120     * @covers WP_Theme::__construct
     121     */
     122    public function test_new_WP_Theme_numeric_theme_directory() {
     123        $theme = new WP_Theme( 1234, $this->theme_root );
     124
     125        $this->assertSame( '1234', $theme->get_stylesheet(), 'The stylesheet property should be a string.' );
     126        $this->assertSame( '1234', $theme->get_template(), 'The template property should be a string.' );
    113127    }
    114128
Note: See TracChangeset for help on using the changeset viewer.