/** * Determine whether or not the current visibility for the given post is * set to 'private'. This method takes into account both the default * privacy setting for the type of post given, as well as any override * setting on the post itself. * * If there is not override setting on the given post, and no default has * been established for the post type, the post is considered 'public' and * false will be returned. This can happen if the post is a type that is not * managed by this plugin, either by design or following the introduction of * a new post type by WordPress. * * This method is meant to be called as a static method. * * @param integer $post_id * @return boolean */ function isPrivate($post_id) { $post = get_post($post_id); if (null === $post) { return false; } $plugin = MemberAccess::instance(); $visibility = $post->{'member_access_visibility'}; if ('default' === $visibility) { if ('post' == $post->post_type && $plugin->getOption('posts_private')) { $visibility = 'private'; } if ('page' == $post->post_type && $plugin->getOption('pages_private')) { $visibility = 'private'; } } return 'private' === $visibility; }
/** * This function unhooks the redirections added by MemberAccess. * * @return void * * @since PHPDOC */ public static function unhook_redirections() { /** @noinspection PhpUndefinedClassInspection */ $aux = MemberAccess::instance(); remove_filter('the_posts', array(&$aux, 'filterPosts')); }