diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 02bf0299bf..9780519856 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -948,6 +948,10 @@ function wp_get_active_and_valid_themes() { return $themes; } + if ( ! wp_using_themes() ) { + return $themes; + } + if ( TEMPLATEPATH !== STYLESHEETPATH ) { $themes[] = STYLESHEETPATH; } diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index 1113a87eea..7e183c995d 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -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' ) ) { diff --git a/tests/phpunit/tests/load/wpGetActiveAndValidThemes.php b/tests/phpunit/tests/load/wpGetActiveAndValidThemes.php new file mode 100644 index 0000000000..f6519486f8 --- /dev/null +++ b/tests/phpunit/tests/load/wpGetActiveAndValidThemes.php @@ -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() + ); + } +}