Make WordPress Core

Ticket #28487: 28487.2.diff

File 28487.2.diff, 1.4 KB (added by johnbillion, 11 years ago)
  • src/wp-includes/functions.php

     
    33603360}
    33613361
    33623362/**
     3363 * Determine if the scheme of the given URL is https.
     3364 *
     3365 * @since 4.0.0
     3366 *
     3367 * @param  string  $url The URL
     3368 * @return boolean      True if the given URL uses https, false if not (or if the URL is not valid).
     3369 */
     3370function is_https_url( $url ) {
     3371        return ( 'https' === parse_url( $url, PHP_URL_SCHEME ) );
     3372}
     3373
     3374/**
    33633375 * Whether SSL login should be forced.
    33643376 *
    33653377 * @since 2.6.0
  • tests/phpunit/tests/functions/isHttpsUrl.php

     
     1<?php
     2
     3/**
     4 * Test is_https_url().
     5 *
     6 * @group functions.php
     7 * @ticket 28487
     8 */
     9class Tests_Functions_IsHttpsUrl extends WP_UnitTestCase {
     10
     11        function test_is_https_url() {
     12
     13                $this->assertTrue( is_https_url( 'https://example.com/' ) );
     14                $this->assertTrue( is_https_url( 'https://localhost/' ) );
     15
     16                $this->assertFalse( is_https_url( 'http://example.com' ) );
     17                $this->assertFalse( is_https_url( 'Hello World!' ) );
     18                $this->assertFalse( is_https_url( 'httpsinvalid' ) );
     19
     20        }
     21
     22}