Skip to content

Instantly share code, notes, and snippets.

@leobaiano
Created June 27, 2017 19:49
Show Gist options
  • Save leobaiano/38dcc1460d63a7a4ff84cf131b344f10 to your computer and use it in GitHub Desktop.
Save leobaiano/38dcc1460d63a7a4ff84cf131b344f10 to your computer and use it in GitHub Desktop.
Plugin WordPress para forçar o acesso via https
<?php
/*
Plugin Name: LB Force HTTPS
Plugin URI:
Description: Redirect all visits to https
Author: leobaiano
Author URI:
Version: 0.0.1
*/
/**
* Redirect to https if http
*/
function redirect_for_https() {
if ( !is_ssl() ) {
wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit();
}
}
add_action ( 'template_redirect', 'redirect_for_https', 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment