Skip to content

Instantly share code, notes, and snippets.

@marcwiest
Last active April 13, 2020 06:11
Show Gist options
  • Select an option

  • Save marcwiest/5e812df4d0332fe204e3f6abee4759c5 to your computer and use it in GitHub Desktop.

Select an option

Save marcwiest/5e812df4d0332fe204e3f6abee4759c5 to your computer and use it in GitHub Desktop.
Extended WP `is_ssl()` function
<?php
if (! function_exists('is_ssl')) :
/**
* Check if SSL is enabled.
*/
function is_ssl()
{
if (is_ssl()) {
return true;
}
elseif (0 === stripos(get_option('siteurl'), 'https://')) {
return true;
}
elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO']) {
return true;
}
return false;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment