| 1 |
<?php |
| 2 |
// @codingStandardsIgnoreFile |
| 3 |
/** |
| 4 |
* s2Member's Security Gate. |
| 5 |
* |
| 6 |
* Copyright: © 2009-2011 |
| 7 |
* {@link http://websharks-inc.com/ WebSharks, Inc.} |
| 8 |
* (coded in the USA) |
| 9 |
* |
| 10 |
* Released under the terms of the GNU General Public License. |
| 11 |
* You should have received a copy of the GNU General Public License, |
| 12 |
* along with this software. In the main directory, see: /licensing/ |
| 13 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 14 |
* |
| 15 |
* @package s2Member\Security |
| 16 |
* @since 3.5 |
| 17 |
*/ |
| 18 |
if(!defined('WPINC')) // MUST have WordPress. |
| 19 |
exit('Do not access this file directly.'); |
| 20 |
|
| 21 |
if(!class_exists('c_ws_plugin__s2member_security')) |
| 22 |
{ |
| 23 |
/** |
| 24 |
* s2Member's Security Gate. |
| 25 |
* |
| 26 |
* @package s2Member\Security |
| 27 |
* @since 3.5 |
| 28 |
*/ |
| 29 |
class c_ws_plugin__s2member_security |
| 30 |
{ |
| 31 |
/** |
| 32 |
* s2Member's Security Gate (protects WordPress content). |
| 33 |
* |
| 34 |
* @package s2Member\Security |
| 35 |
* @since 3.5 |
| 36 |
* |
| 37 |
* @attaches-to ``add_action('wp');`` |
| 38 |
* |
| 39 |
* @return null May redirect a browser *(exiting script execution)*, when/if content is NOT available to the current User/Member. |
| 40 |
*/ |
| 41 |
public static function security_gate() // s2Member's Security Gate. |
| 42 |
{ |
| 43 |
do_action('ws_plugin__s2member_before_security_gate', get_defined_vars()); |
| 44 |
|
| 45 |
if(is_category()) // Categories & other inclusives. |
| 46 |
c_ws_plugin__s2member_catgs::check_catg_level_access(); |
| 47 |
|
| 48 |
else if(is_tag()) // Post/Page Tags & other inclusives. |
| 49 |
c_ws_plugin__s2member_ptags::check_ptag_level_access(); |
| 50 |
|
| 51 |
else if(is_single()) // All Posts & other inclusives. |
| 52 |
c_ws_plugin__s2member_posts::check_post_level_access(); |
| 53 |
|
| 54 |
else if(is_page()) // All Pages & other inclusives. |
| 55 |
c_ws_plugin__s2member_pages::check_page_level_access(); |
| 56 |
|
| 57 |
else // Else, we simply look at URIs & other inclusives. |
| 58 |
c_ws_plugin__s2member_ruris::check_ruri_level_access(); |
| 59 |
|
| 60 |
do_action('ws_plugin__s2member_after_security_gate', get_defined_vars()); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* s2Member's Security Gate (protects WordPress queries). |
| 65 |
* |
| 66 |
* @package s2Member\Security |
| 67 |
* @since 3.5 |
| 68 |
* |
| 69 |
* @attaches-to ``add_action('pre_get_posts');`` |
| 70 |
* |
| 71 |
* @param WP_Query $wp_query Global ``$wp_query``, by reference. |
| 72 |
* |
| 73 |
* @return null May filter WordPress queries, by hiding protected content which is NOT available to the current User/Member. |
| 74 |
*/ |
| 75 |
public static function security_gate_query(&$wp_query = NULL) // s2Member's Security Gate. |
| 76 |
{ |
| 77 |
do_action('ws_plugin__s2member_before_security_gate_query', get_defined_vars()); |
| 78 |
|
| 79 |
c_ws_plugin__s2member_querys::query_level_access($wp_query); // By reference. |
| 80 |
|
| 81 |
do_action('ws_plugin__s2member_after_security_gate_query', get_defined_vars()); |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|