Skip to content

Instantly share code, notes, and snippets.

@paretje
Forked from webaware/force-ssl-url-scheme.php
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paretje/286bc11942391b2f1ea0 to your computer and use it in GitHub Desktop.
Save paretje/286bc11942391b2f1ea0 to your computer and use it in GitHub Desktop.
Force WordPress to use https
<?php
/*
Plugin Name: Force SSL URL Scheme
Plugin URI: https://gist.github.com/webaware/4688802
Description: Force the protocol scheme to be HTTPS when is_ssl() doesn't work
Version: 1.0.0-paretje3
Author: WebAware
Author URI: http://www.webaware.com.au/
Changed by: Paretje
Change: no need of javascript
@ref: http://wordpress.org/support/topic/ssl-insecure-needs-35-compatibility
*/
/*
copyright (c) 2013 WebAware Pty Ltd (email : rmckay@webaware.com.au)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// if site is set to run on SSL, then force-enable SSL detection!
if (stripos(get_option('siteurl'), 'https://') === 0) {
$_SERVER['HTTPS'] = 'on';
$_SERVER['HTTP_HOST'] = trim(substr(get_option('siteurl'), 8), '/');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment