WordPress.org

Make WordPress Core

Ticket #31620: 31620.patch

File 31620.patch, 911 bytes (added by McGuive7, 5 years ago)
  • wp-includes/theme.php

     
    626626function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
    627627        global $wp_theme_directories;
    628628
    629         if ( count($wp_theme_directories) <= 1 )
     629        $theme_dir_count = count( $wp_theme_directories );
     630
     631        if ( 0 === $theme_dir_count ) {
    630632                return '/themes';
     633        }
    631634
     635        if ( 1 === $theme_dir_count ) {
     636                $theme_path = reset( $wp_theme_directories );
     637                $theme_real_path = realpath( $theme_path );
     638                $content_path = realpath( WP_CONTENT_DIR );
     639                return strpos( $theme_real_path, $content_path ) === 0 ? substr( $theme_real_path, strlen( $content_path ) ) : $theme_path;
     640        }
     641
    632642        $theme_root = false;
    633643
    634644        // If requesting the root for the current theme, consult options to avoid calling get_theme_roots()