Skip to content

Instantly share code, notes, and snippets.

@webaware
Last active April 4, 2025 15:56

Revisions

  1. webaware revised this gist Jan 22, 2016. No changes.
  2. webaware revised this gist Jan 22, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions force-ssl-url-scheme.php
    Original file line number Diff line number Diff line change
    @@ -5,13 +5,13 @@
    Description: Force the protocol scheme to be HTTPS when is_ssl() doesn't work
    Version: 1.0.0
    Author: WebAware
    Author URI: http://www.webaware.com.au/
    Author URI: http://webaware.com.au/
    @ref: http://wordpress.org/support/topic/ssl-insecure-needs-35-compatibility
    */

    /*
    copyright (c) 2013 WebAware Pty Ltd (email : rmckay@webaware.com.au)
    copyright (c) 2013 WebAware Pty Ltd (email : support@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
  3. webaware revised this gist Mar 11, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions force-ssl-url-scheme.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,13 @@
    <?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
    Author: WebAware
    Author URI: http://www.webaware.com.au/
    @ref: http://wordpress.org/support/topic/ssl-insecure-needs-35-compatibility
    */

    /*
  4. webaware revised this gist Feb 1, 2013. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions force-ssl-url-scheme.php
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,17 @@
    // if site is set to run on SSL, then force-enable SSL detection!
    if (stripos(get_option('siteurl'), 'https://') === 0) {
    $_SERVER['HTTPS'] = 'on';

    // add JavaScript detection of page protocol, and pray!
    add_action('wp_print_scripts', 'force_ssl_url_scheme_script');
    }

    function force_ssl_url_scheme_script() {
    ?>
    <script>
    if (document.location.protocol != "https:") {
    document.location = document.URL.replace(/^http:/i, "https:");
    }
    </script>
    <?php
    }
  5. webaware created this gist Feb 1, 2013.
    30 changes: 30 additions & 0 deletions force-ssl-url-scheme.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <?php
    /*
    Plugin Name: Force SSL URL Scheme
    Description: Force the protocol scheme to be HTTPS when is_ssl() doesn't work
    Version: 1.0.0
    Author: WebAware
    Author URI: http://www.webaware.com.au/
    */

    /*
    copyright (c) 2013 WebAware Pty Ltd (email : [email protected])
    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';
    }