Make WordPress Core

Ticket #18017: 18017b.diff

File 18017b.diff, 1.1 KB (added by jkudish, 14 years ago)
  • wp-includes/functions.php

     
    36223622}
    36233623
    36243624/**
     3625 * Filter a url to have the correct protocol
     3626 *
     3627 * @since 3.3
     3628 * @param string $url, url to filter
     3629 * @return string $url, filtered url
     3630 */
     3631function set_url_scheme($url, $scheme = null) {
     3632        $orig_scheme = $scheme;
     3633        if ( !in_array( $scheme, array( 'http', 'https' ) ) ) {
     3634                if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
     3635                        $scheme = 'https';
     3636                elseif ( ( 'login' == $scheme ) && force_ssl_admin() )
     3637                        $scheme = 'https';
     3638                elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )
     3639                        $scheme = 'https';
     3640                else
     3641                        $scheme = ( is_ssl() ? 'https' : 'http' );
     3642        }
     3643        if ($scheme == 'https') {
     3644                $url = str_replace( 'http://', 'https://', $url );
     3645        } else {
     3646                $url = str_replace( 'https://', 'http://', $url );
     3647  }
     3648        return apply_filters('set_url_scheme', $url, $scheme);
     3649}
     3650
     3651/**
    36253652 * Whether SSL login should be forced.
    36263653 *
    36273654 * @since 2.6.0