| | 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 | */ |
| | 3631 | function 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 | /** |