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 and perform an action based on the result
if ( wp_is_home_url_using_https() ) {
    // Home URL is using HTTPS
    // Perform secure actions here
} else {
    // Home URL is not using HTTPS
    // Handle non-secure actions here
}
// Example 2: Redirect to a secure version of the home URL if it is currently using HTTP
if ( ! wp_is_home_url_using_https() ) {
    $secure_home_url = set_url_scheme( home_url(), 'https' );
    wp_redirect( $secure_home_url );
    exit;
}
// Example 3: Output a message based on whether the home URL is using HTTPS or not
if ( wp_is_home_url_using_https() ) {
    echo 'The home URL is using HTTPS.';
} else {
    echo 'The home URL is not using HTTPS.';
}