Skip to content

Instantly share code, notes, and snippets.

@zacscott
Last active March 11, 2017 11:08
Show Gist options
  • Save zacscott/8c132e6f84095563664178510b4a8284 to your computer and use it in GitHub Desktop.
Save zacscott/8c132e6f84095563664178510b4a8284 to your computer and use it in GitHub Desktop.
Disable HTTPS in for WordPress
<?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