Last active
March 11, 2017 11:08
-
-
Save zacscott/8c132e6f84095563664178510b4a8284 to your computer and use it in GitHub Desktop.
Disable HTTPS in for WordPress
This file contains hidden or 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 | |
/** | |
* Plugin Name: Disable HTTPS | |
* Description: Disables HTTPS in WordPress | |
* Version: 1.0 | |
* Author: Zachary Scott | |
*/ | |
namespace zacscott; | |
/** | |
* | |
* @auhtor Zachary Scott <[email protected]> | |
*/ | |
class DisableHttps { | |
function __construct() { | |
add_action( 'init', array( $this, 'redirect_https' ) ); | |
} | |
function redirect_https() { | |
$is_https = ( | |
! empty( $_SERVER['HTTPS'] ) && | |
$_SERVER['HTTPS'] !== 'off' | |
) || | |
$_SERVER['SERVER_PORT'] == 443; | |
if ( $is_https ) { | |
$http_url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; | |
header( 'Status: 301 Moved Permanently' ); | |
header( 'Location: ' . $http_url ); | |
exit; | |
} | |
} | |
} | |
// Boot | |
new DisableHttps(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment