daily pastebin goal
42%
SHARE
TWEET

Private Site Plugin

SergeyBiryukov May 8th, 2013 525 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. Plugin Name: Private Site
  4. Description: Site is only viewable by logged in users.
  5. Author: c.bavota
  6. Version: 1.0.0
  7. Author URI: http://www.bavotasan.com/
  8. */
  9. class Bavotasan_Private {
  10.         public function __construct() {
  11.                 add_action( 'init', array( $this, 'init' ) );
  12.         }
  13.  
  14.         public function init() {
  15.                 if ( ! is_user_logged_in() && ! $this->is_login() ) {
  16.                         wp_redirect( wp_login_url() );
  17.                         exit;
  18.                 }
  19.         }
  20.  
  21.         public function is_login() {
  22.                 return in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) );
  23.         }
  24. }
  25. $bavotasan_private = new Bavotasan_Private;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top