WordPress.org

Make WordPress Core

Ticket #18017: 18017.2.diff

File 18017.2.diff, 1.4 KB (added by ryan, 6 years ago)

Refresh, add relative support

  • wp-includes/link-template.php

     
    21982198}
    21992199
    22002200/**
     2201 * Set the scheme for a URL
     2202 *
     2203 * @since 3.4.0
     2204 *
     2205 * @param string $url Absolute url that includes a scheme
     2206 * @param string $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
     2207 * @return string $url URL with chosen scheme.
     2208 */
     2209function set_url_scheme( $url, $scheme = null ) {
     2210        $orig_scheme = $scheme;
     2211        if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
     2212                if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
     2213                        $scheme = 'https';
     2214                elseif ( ( 'login' == $scheme ) && force_ssl_admin() )
     2215                        $scheme = 'https';
     2216                elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )
     2217                        $scheme = 'https';
     2218                else
     2219                        $scheme = ( is_ssl() ? 'https' : 'http' );
     2220        }
     2221
     2222        if ( 'relative' == $scheme )
     2223                $url = preg_replace( '#^.+://[^/]*#', '', $url );
     2224        else
     2225                $url = preg_replace( '#^.+://#', $scheme . '://', $url );
     2226
     2227        return apply_filters('set_url_scheme', $url, $scheme);
     2228}
     2229
     2230/**
    22012231 * Get the URL to the user's dashboard.
    22022232 *
    22032233 * If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site,