Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Private Site
- Description: Site is only viewable by logged in users.
- Author: c.bavota
- Version: 1.0.0
- Author URI: http://www.bavotasan.com/
- */
- class Bavotasan_Private {
- public function __construct() {
- add_action( 'init', array( $this, 'init' ) );
- }
- public function init() {
- if ( ! is_user_logged_in() && ! $this->is_login() ) {
- wp_redirect( wp_login_url() );
- exit;
- }
- }
- public function is_login() {
- return in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) );
- }
- }
- $bavotasan_private = new Bavotasan_Private;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement