diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 3c908f1820..b1d85e6f94 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -35,7 +35,7 @@ function wp_get_themes( $args = array() ) { $theme_directories = search_theme_directories(); - if ( count( $wp_theme_directories ) > 1 ) { + if ( is_array( $wp_theme_directories ) && count( $wp_theme_directories ) > 1 ) { // Make sure the current theme wins out, in case search_theme_directories() picks the wrong // one in the case of a conflict. (Normally, last registered theme root wins.) $current_theme = get_stylesheet(); @@ -627,8 +627,9 @@ function get_theme_root_uri( $stylesheet_or_template = false, $theme_root = fals function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) { global $wp_theme_directories; - if ( count($wp_theme_directories) <= 1 ) + if ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) { return '/themes'; + } $theme_root = false; diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 31a51c2020..3c1210e088 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -423,7 +423,8 @@ class Tests_Post_Types extends WP_UnitTestCase { 'public' => true, ) ); - $this->assertSame( 1, count( $wp_filter['future_foo'] ) ); + $this->assertArrayHasKey( 'future_foo', $wp_filter ); + $this->assertSame( 1, count( $wp_filter['future_foo']->callbacks ) ); $this->assertTrue( unregister_post_type( 'foo' ) ); $this->assertArrayNotHasKey( 'future_foo', $wp_filter ); } @@ -439,7 +440,8 @@ class Tests_Post_Types extends WP_UnitTestCase { 'register_meta_box_cb' => '__return_empty_string', ) ); - $this->assertSame( 1, count( $wp_filter['add_meta_boxes_foo'] ) ); + $this->assertArrayHasKey( 'add_meta_boxes_foo', $wp_filter ); + $this->assertSame( 1, count( $wp_filter['add_meta_boxes_foo']->callbacks ) ); $this->assertTrue( unregister_post_type( 'foo' ) ); $this->assertArrayNotHasKey( 'add_meta_boxes_foo', $wp_filter ); } diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 252280eef4..b5fd536100 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -764,7 +764,8 @@ class Tests_Taxonomy extends WP_UnitTestCase { register_taxonomy( 'foo', 'post' ); - $this->assertSame( 1, count( $wp_filter['wp_ajax_add-foo'] ) ); + $this->assertArrayHasKey( 'wp_ajax_add-foo', $wp_filter ); + $this->assertSame( 1, count( $wp_filter['wp_ajax_add-foo']->callbacks ) ); $this->assertTrue( unregister_taxonomy( 'foo' ) ); $this->assertArrayNotHasKey( 'wp_ajax_add-foo', $wp_filter ); }