mirror of
git://develop.git.wordpress.org/
synced 2025-04-09 14:42:05 +02:00
Load: Avoid loading a theme's functions.php
when ! wp_using_themes()
.
Updates `wp_get_active_and_valid_themes()` to return early when `wp_using_themes()` returns `false`. This prevents a theme's `functions.php` from being loaded erroneously when the site isn't using themes. Also adds `define( 'WP_USE_THEMES', true );` to the test suite bootstrap. Some tests randomly break without it because they were dependent on the previous buggy behavior. Props bpayton, costdev, danielbachhuber, hellofromtonya, sergeybiryukov, spacedmonkey. Fixes #57928. git-svn-id: https://develop.svn.wordpress.org/trunk@55890 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
53b1e27f94
commit
8fe92ac137
@ -948,6 +948,10 @@ function wp_get_active_and_valid_themes() {
|
||||
return $themes;
|
||||
}
|
||||
|
||||
if ( ! wp_using_themes() ) {
|
||||
return $themes;
|
||||
}
|
||||
|
||||
if ( TEMPLATEPATH !== STYLESHEETPATH ) {
|
||||
$themes[] = STYLESHEETPATH;
|
||||
}
|
||||
|
@ -252,6 +252,7 @@ $phpmailer = new MockPHPMailer( true );
|
||||
if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
|
||||
define( 'WP_DEFAULT_THEME', 'default' );
|
||||
}
|
||||
define( 'WP_USE_THEMES', true );
|
||||
$wp_theme_directories = array();
|
||||
|
||||
if ( file_exists( DIR_TESTDATA . '/themedir1' ) ) {
|
||||
|
30
tests/phpunit/tests/load/wpGetActiveAndValidThemes.php
Normal file
30
tests/phpunit/tests/load/wpGetActiveAndValidThemes.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests for wp_get_active_and_valid_themes().
|
||||
*
|
||||
* @group load.php
|
||||
* @covers ::wp_get_active_and_valid_themes
|
||||
*/
|
||||
class Tests_Load_WpGetActiveAndValidThemes extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 57928
|
||||
*/
|
||||
public function test_wp_get_active_and_valid_themes() {
|
||||
// Defaults to TEMPLATEPATH (and potentially STYLESHEETPATH).
|
||||
$this->assertEquals(
|
||||
array(
|
||||
TEMPLATEPATH,
|
||||
),
|
||||
wp_get_active_and_valid_themes()
|
||||
);
|
||||
|
||||
// Disabling 'wp_using_themes' should return an empty array.
|
||||
add_filter( 'wp_using_themes', '__return_false' );
|
||||
$this->assertEquals(
|
||||
array(),
|
||||
wp_get_active_and_valid_themes()
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user