WordPress.org

Make WordPress Core

Ticket #35521: 35521.3.diff

File 35521.3.diff, 1.5 KB (added by chris_dev, 4 years ago)

I did it in a different way. I kept the search_theme_directories() function.

  • wp-admin/theme-install.php

     
    2828}
    2929
    3030$installed_themes = search_theme_directories();
    31 foreach ( $installed_themes as $k => $v ) {
    32         if ( false !== strpos( $k, '/' ) ) {
    33                 unset( $installed_themes[ $k ] );
     31if ( is_array($installed_themes) ) {
     32        foreach ( $installed_themes as $k => $v ) {
     33                if ( false !== strpos( $k, '/' ) ) {
     34                        unset( $installed_themes[ $k ] );
     35                }
    3436        }
    3537}
    3638
  • wp-includes/class-wp-theme.php

     
    281281                        $parent_dir = dirname( $this->stylesheet );
    282282                        if ( '.' != $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) {
    283283                                $this->template = $parent_dir . '/' . $this->template;
    284                         } elseif ( ( $directories = search_theme_directories() ) && isset( $directories[ $this->template ] ) ) {
     284                        } elseif ( ( $directories = search_theme_directories() ) && is_array($directories) && isset( $directories[ $this->template ] ) ) {
    285285                                // Look for the template in the search_theme_directories() results, in case it is in another theme root.
    286286                                // We don't look into directories of themes, just the theme root.
    287287                                $theme_root_template = $directories[ $this->template ]['theme_root'];