Created
December 30, 2011 05:20
-
-
Save evansolomon/1538036 to your computer and use it in GitHub Desktop.
A more private way to use WordPress without the hassle of passwords and such. Logged out users can only single posts, and only if they know the exact URL.
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: Privacy Please | |
Description: A more private way to use WordPress without the hassle of passwords and such. Logged out users can only access single posts, and only if they know the exact URL. | |
Author: Evan Solomon | |
*/ | |
/* Only allow singe page views */ | |
function only_singular_requests_for_you() { | |
if( ! is_user_logged_in() && ! is_singular() ) | |
wp_die( 'We can haz privacy' ); | |
} | |
add_action( 'pre_get_posts', 'only_singular_requests_for_you' ); | |
/* Don't let anyone guess URL's */ | |
function no_redirects_for_you( $redirect_url) { | |
if( is_user_logged_in() ) | |
return $redirect_url; | |
wp_die( 'We can haz privacy' ); | |
} | |
add_filter( 'redirect_canonical', 'no_redirects_for_you' ); | |
/* Don't give away other URL's with adjacent post links */ | |
function no_adjacent_posts_for_you( $format ) { | |
if( is_user_logged_in() ) | |
return $format; | |
return false; | |
} | |
add_filter( 'previous_post_link', 'no_adjacent_posts_for_you' ); | |
add_filter( 'next_post_link', 'no_adjacent_posts_for_you' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment