Introduce is_https_url()
for testing whether the scheme for a given URL is https
. See #28487.
git-svn-id: https://develop.svn.wordpress.org/trunk@28894 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3426416dac
commit
3c77cf1140
@ -3359,6 +3359,18 @@ function is_ssl() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the scheme of the given URL is https.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param string $url The URL
|
||||
* @return boolean True if the given URL uses https, false if not (or if the URL is not valid).
|
||||
*/
|
||||
function is_https_url( $url ) {
|
||||
return ( 'https' === parse_url( $url, PHP_URL_SCHEME ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether SSL login should be forced.
|
||||
*
|
||||
|
22
tests/phpunit/tests/functions/isHttpsUrl.php
Normal file
22
tests/phpunit/tests/functions/isHttpsUrl.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Test is_https_url().
|
||||
*
|
||||
* @group functions.php
|
||||
* @ticket 28487
|
||||
*/
|
||||
class Tests_Functions_IsHttpsUrl extends WP_UnitTestCase {
|
||||
|
||||
function test_is_https_url() {
|
||||
|
||||
$this->assertTrue( is_https_url( 'https://example.com/' ) );
|
||||
$this->assertTrue( is_https_url( 'https://localhost/' ) );
|
||||
|
||||
$this->assertFalse( is_https_url( 'http://example.com' ) );
|
||||
$this->assertFalse( is_https_url( 'Hello World!' ) );
|
||||
$this->assertFalse( is_https_url( 'httpsinvalid' ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user