Make WordPress Core

Ticket #25767: remove_scheme.diff

File remove_scheme.diff, 1.5 KB (added by GregLone, 10 years ago)
  • wp-admin/includes/file.php

     
    7979 * @return string Full filesystem path to the root of the WordPress installation
    8080 */
    8181function get_home_path() {
    82         $home = get_option( 'home' );
    83         $siteurl = get_option( 'siteurl' );
     82        $home = remove_url_scheme( get_option( 'home' ) );
     83        $siteurl = remove_url_scheme( get_option( 'siteurl' ) );
    8484        if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
    8585                $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
    8686                $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
  • wp-includes/link-template.php

     
    23322332}
    23332333
    23342334/**
     2335 * Remove the scheme from a URL
     2336 *
     2337 * @since 3.9.0
     2338 *
     2339 * @param string $url Absolute url that includes a scheme
     2340 * @return string $url URL without its scheme.
     2341 */
     2342function remove_url_scheme( $url ) {
     2343        $url = trim( $url );
     2344        if ( substr( $url, 0, 2 ) === '//' )
     2345                $url = 'http:' . $url;
     2346
     2347        return preg_replace( '#^\w+://#', '', $url );
     2348}
     2349
     2350/**
    23352351 * Get the URL to the user's dashboard.
    23362352 *
    23372353 * If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site,