-
-
Save charmoney/a85719866488db6929b50c9a2c152c8b to your computer and use it in GitHub Desktop.
Support http and https concurrently in wp-config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Determine if the current request is SSL. Set $_SERVER['HTTPS'] for WordPress' build in is_ssl(). | |
* | |
* @return True if the site uses ssl directly or through a load balancer | |
*/ | |
function greenpeace_is_ssl() { | |
$is_ssl = (isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ) | |
|| (isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO']) | |
|| $_SERVER['SERVER_PORT'] == 443; | |
// https://codex.wordpress.org/Function_Reference/is_ssl | |
// Set the server HTTPS flag for WP's built in is_ssl() function | |
if ( $is_ssl ) { | |
$_SERVER['HTTPS'] = 'on'; | |
} | |
return $is_ssl; | |
} | |
$web_site = $_SERVER['HTTP_HOST']; | |
$schema = greenpeace_is_ssl() ? 'https://' : 'http://'; | |
$web_site_url = $schema . $web_site; | |
define( 'WP_HOME', $web_site_url ); | |
define( 'WP_SITEURL', $web_site_url ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment