Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

wp_is_home_url_using_https

Function Description:

Checks whether the current site URL is using HTTPS.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Check if the home URL is using HTTPS
if ( wp_is_home_url_using_https() ) {
    echo 'The home URL is using HTTPS';
} else {
    echo 'The home URL is not using HTTPS';
}
// Example 2: Redirect to HTTPS if the home URL is not using HTTPS
if ( ! wp_is_home_url_using_https() ) {
    wp_redirect( home_url(), 301 );
    exit;
}
// Example 3: Conditionally load assets based on the home URL protocol
if ( wp_is_home_url_using_https() ) {
    wp_enqueue_script( 'my-script', 'https://example.com/script.js', array(), null, true );
} else {
    wp_enqueue_script( 'my-script', 'http://example.com/script.js', array(), null, true );
}