Created
June 27, 2017 19:49
-
-
Save leobaiano/38dcc1460d63a7a4ff84cf131b344f10 to your computer and use it in GitHub Desktop.
Plugin WordPress para forçar o acesso via https
This file contains 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: 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