Created
January 31, 2019 19:57
-
-
Save wpscholar/ecbc78f174c2ab74bae8f07f8901c1cd to your computer and use it in GitHub Desktop.
Sample plugin for redirecting a WordPress site to a specific URL.
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: | |
* Plugin URI: | |
* Description: | |
* Version: 1.0 | |
* Author: | |
* Author URI: | |
* License: GPL2 | |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
add_action( | |
'init', | |
function () { | |
global $pagenow; | |
// Allow requests to /wp-admin and wp-login so that admins can attempt to login | |
if ( 'wp-login.php' !== $pagenow && ! is_admin() ) { | |
wp_redirect( 'https://mynewsite.com', 301 ); | |
exit; | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment