Make WordPress Core


Ignore:
Timestamp:
07/19/2014 11:06:54 PM (10 years ago)
Author:
wonderboymusic
Message:

Call untrailingslashit() when adding a theme directory in register_theme_directory(). This prevents double-slashing in generated URLs. Don't add a directory if it is already present.

Adds unit tests.
Props obenland, wonderboymusic.
Fixes #28662.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r29176 r29249  
    371371        $directory = WP_CONTENT_DIR . '/' . $directory;
    372372        // If this directory does not exist, return and do not register
    373         if ( ! file_exists( $directory ) )
     373        if ( ! file_exists( $directory ) ) {
    374374            return false;
    375     }
    376 
    377     $wp_theme_directories[] = $directory;
     375        }
     376    }
     377
     378    if ( ! is_array( $wp_theme_directories ) ) {
     379        $wp_theme_directories = array();
     380    }
     381
     382    $untrailed = untrailingslashit( $directory );
     383    if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) {
     384        $wp_theme_directories[] = $untrailed;
     385    }
    378386
    379387    return true;
Note: See TracChangeset for help on using the changeset viewer.