Beispiel #1
0
 /**
  * s2Member's Security Gate (protects WordPress content).
  *
  * @package s2Member\Security
  * @since 3.5
  *
  * @attaches-to ``add_action("wp");``
  *
  * @return null May redirect a browser *(exiting script execution)*, when/if content is NOT available to the current User/Member.
  */
 public static function security_gate()
 {
     do_action("ws_plugin__s2member_before_security_gate", get_defined_vars());
     if (is_category()) {
         // Categories & other inclusives.
         c_ws_plugin__s2member_catgs::check_catg_level_access();
     } else {
         if (is_tag()) {
             // Post/Page Tags & other inclusives.
             c_ws_plugin__s2member_ptags::check_ptag_level_access();
         } else {
             if (is_single()) {
                 // All Posts & other inclusives.
                 c_ws_plugin__s2member_posts::check_post_level_access();
             } else {
                 if (is_page()) {
                     // All Pages & other inclusives.
                     c_ws_plugin__s2member_pages::check_page_level_access();
                 } else {
                     // Else, we simply look at URIs & other inclusives.
                     c_ws_plugin__s2member_ruris::check_ruri_level_access();
                 }
             }
         }
     }
     do_action("ws_plugin__s2member_after_security_gate", get_defined_vars());
     return;
 }
 /**
  * Handles Category Level Access *( for current page )*.
  *
  * @package s2Member\Categories
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_catg_level_access()
 {
     global $post;
     /* ``get_the_ID()`` is NOT available outside The Loop. */
     /**/
     do_action("ws_plugin__s2member_before_check_catg_level_access", get_defined_vars());
     /**/
     $excluded = apply_filters("ws_plugin__s2member_check_catg_level_access_excluded", false, get_defined_vars());
     /**/
     if (!$excluded && is_category() && ($cat_id = get_query_var("cat")) && ($cat_id = (int) $cat_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             /* Current User's object. */
             /**/
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level0"))) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("catg", $cat_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit;
             } else {
                 if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit;
                         } else {
                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array($cat_id, $catgs = preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"])) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit;
                             } else {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) {
                                     /* Check Category ancestry. */
                                     foreach (preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg) {
                                         if ($catg && cat_is_ancestor_of($catg, $cat_id) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     /**/
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                             /* URIs configured at this Level? */
                             /**/
                             foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                 if ($str && preg_match("/" . preg_quote($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("catg", $cat_id, "level", $n, $_SERVER["REQUEST_URI"], "ruri") . exit;
                                 }
                             }
                         }
                     }
                 }
             }
             /**/
             do_action("ws_plugin__s2member_during_check_catg_level_access", get_defined_vars());
         }
     }
     /**/
     do_action("ws_plugin__s2member_after_check_catg_level_access", get_defined_vars());
     /**/
     return;
     /* For uniformity. */
 }
Beispiel #3
0
 /**
  * Handles URI Level Access permissions *(for current URI)*.
  *
  * @package s2Member\URIs
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_ruri_level_access()
 {
     do_action('ws_plugin__s2member_before_check_ruri_level_access', get_defined_vars());
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     $excluded = apply_filters('ws_plugin__s2member_check_ruri_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/' . $ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0'))) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ruri', $_SERVER['REQUEST_URI'], 'level', 0, $_SERVER['REQUEST_URI'], 'sys') . exit;
             } else {
                 if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                             // URIs configured at this Level?
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                 if ($str && preg_match('/' . preg_quote($str, '/') . '/' . $ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ruri', $_SERVER['REQUEST_URI'], 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                                 }
                             }
                         }
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_ruri_level_access', get_defined_vars());
         }
     }
     do_action('ws_plugin__s2member_after_check_ruri_level_access', get_defined_vars());
 }
Beispiel #4
0
 /**
  * Handles URI Level Access *(for specific URIs)*.
  *
  * @package s2Member\URIs
  * @since 3.5
  *
  * @param string $uri A URI, or a full URL is also fine.
  * @param bool   $check_user Test permissions against the current User? Defaults to true.
  *
  * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
  */
 public static function check_specific_ruri_level_access($uri = '', $check_user = TRUE)
 {
     do_action('ws_plugin__s2member_before_check_specific_ruri_level_access', get_defined_vars());
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     $uri = $uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri)) ? $uri : FALSE;
     $excluded = apply_filters('ws_plugin__s2member_check_specific_ruri_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && !empty($uri) && is_string($uri) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(NULL, $uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/' . $ci, $uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0'))) {
                 return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', array('s2member_level_req' => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(NULL, $uri)) {
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                             // URIs configured at this Level?
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                 if ($str && preg_match('/' . preg_quote($str, '/') . '/' . $ci, $uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_specific_ruri_level_access', get_defined_vars());
         }
     }
     return apply_filters('ws_plugin__s2member_check_specific_ruri_level_access', NULL, get_defined_vars());
 }
 /**
  * Handles URI Level Access *(for specific URIs)*.
  *
  * @package s2Member\URIs
  * @since 3.5
  *
  * @param string $uri A URI, or a full URL is also fine.
  * @param bool $check_user Test permissions against the current User? Defaults to true.
  * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
  */
 public static function check_specific_ruri_level_access($uri = FALSE, $check_user = TRUE)
 {
     do_action("ws_plugin__s2member_before_check_specific_ruri_level_access", get_defined_vars());
     $uri = $uri && is_string($uri) && ($uri = c_ws_plugin__s2member_utils_urls::parse_uri($uri)) ? $uri : false;
     $excluded = apply_filters("ws_plugin__s2member_check_specific_ruri_level_access_excluded", false, get_defined_vars());
     if (!$excluded && !empty($uri) && is_string($uri) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(null, $uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             // Current User's object.
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level0"))) {
                 return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", array("s2member_level_req" => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(null, $uri)) {
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                             // URIs configured at this Level?
                             foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                 if ($str && preg_match("/" . preg_quote($str, "/") . "/", $uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                 }
             }
             do_action("ws_plugin__s2member_during_check_specific_ruri_level_access", get_defined_vars());
         }
     }
     return apply_filters("ws_plugin__s2member_check_specific_ruri_level_access", null, get_defined_vars());
 }
Beispiel #6
0
 /**
  * Handles URI Level Access permissions *(for current URI)*.
  *
  * @package s2Member\URIs
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_ruri_level_access()
 {
     do_action("ws_plugin__s2member_before_check_ruri_level_access", get_defined_vars());
     $excluded = apply_filters("ws_plugin__s2member_check_ruri_level_access_excluded", false, get_defined_vars());
     if (!$excluded && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             // Current User's object.
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level0"))) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("ruri", $_SERVER["REQUEST_URI"], "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit;
             } else {
                 if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                             // URIs configured at this Level?
                             foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                 if ($str && preg_match("/" . preg_quote($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("ruri", $_SERVER["REQUEST_URI"], "level", $n, $_SERVER["REQUEST_URI"]) . exit;
                                 }
                             }
                         }
                     }
                 }
             }
             do_action("ws_plugin__s2member_during_check_ruri_level_access", get_defined_vars());
         }
     }
     do_action("ws_plugin__s2member_after_check_ruri_level_access", get_defined_vars());
     return;
     // For uniformity.
 }
 /**
  * Handles Category Level Access *( for specific Categories )*.
  *
  * @package s2Member\Categories
  * @since 3.5
  *
  * @param int|str $cat_id Numeric Category ID.
  * @param bool $check_user Test permissions against the current User? Defaults to true.
  * @return null|array Non-empty array ( with details ) if access is denied, else null if access is allowed.
  */
 public static function check_specific_catg_level_access($cat_id = FALSE, $check_user = TRUE)
 {
     do_action("ws_plugin__s2member_before_check_specific_catg_level_access", get_defined_vars());
     /**/
     $excluded = apply_filters("ws_plugin__s2member_check_specific_catg_level_access_excluded", false, get_defined_vars());
     /**/
     if (!$excluded && is_numeric($cat_id) && ($cat_id = (int) $cat_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         $cat_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_category_link($cat_id));
         /* Get a full valid URI for this Category. */
         /**/
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(null, $cat_uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             /* Current User's object. */
             /**/
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $cat_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level0"))) {
                 return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(null, $cat_uri)) {
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] === "all" && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                             return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => $n), get_defined_vars());
                         } else {
                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"] && in_array($cat_id, $catgs = preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"])) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                 return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => $n), get_defined_vars());
                             } else {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) {
                                     /* Check Category ancestry. */
                                     foreach (preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_catgs"]) as $catg) {
                                         if ($catg && cat_is_ancestor_of($catg, $cat_id) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     /**/
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                             /* URIs configured at this Level? */
                             /**/
                             foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                 if ($str && preg_match("/" . preg_quote($str, "/") . "/", $cat_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                 }
             }
             /**/
             do_action("ws_plugin__s2member_during_check_specific_catg_level_access", get_defined_vars());
         }
     }
     /**/
     return apply_filters("ws_plugin__s2member_check_specific_catg_level_access", null, get_defined_vars());
 }
Beispiel #8
0
 /**
  * Handles Category Level Access *(for current page)*.
  *
  * @package s2Member\Categories
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_catg_level_access()
 {
     global $post;
     // ``get_the_ID()`` is NOT available outside The Loop.
     do_action('ws_plugin__s2member_before_check_catg_level_access', get_defined_vars());
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     $excluded = apply_filters('ws_plugin__s2member_check_catg_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && is_category() && ($cat_id = get_query_var('cat')) && ($cat_id = (int) $cat_id) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/' . $ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0'))) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys') . exit;
             } else {
                 if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                         } else {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'] && in_array($cat_id, $catgs = preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                             } else {
                                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs']) {
                                     foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs']) as $catg) {
                                         if ($catg && cat_is_ancestor_of($catg, $cat_id) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                 if ($str && preg_match('/' . preg_quote($str, '/') . '/' . $ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('catg', $cat_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri') . exit;
                                 }
                             }
                         }
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_catg_level_access', get_defined_vars());
         }
     }
     do_action('ws_plugin__s2member_after_check_catg_level_access', get_defined_vars());
 }
Beispiel #9
0
 /**
  * Handles Tag Level Access permissions *(for current page)*.
  *
  * @package s2Member\Tags
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_ptag_level_access()
 {
     /**
      * @var $post WP_Post Reference for IDEs.
      * @var $wp_query WP_Query Reference for IDEs.
      */
     global $wp_query, $post;
     // ``get_the_ID()`` NOT available outside The Loop.
     do_action('ws_plugin__s2member_before_check_ptag_level_access', get_defined_vars());
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     $excluded = apply_filters('ws_plugin__s2member_check_ptag_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && is_tag() && is_object($tag = $wp_query->get_queried_object()) && !empty($tag->term_id) && ($tag_id = (int) $tag->term_id) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/' . $ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0'))) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ptag', $tag_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys') . exit;
             } else {
                 if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ptag', $tag_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                         } else {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] && (is_tag($tags = preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'])) || in_array($tag_id, $tags)) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ptag', $tag_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                             }
                         }
                     }
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                             // URIs configured at this Level?
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                 if ($str && preg_match('/' . preg_quote($str, '/') . '/' . $ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('ptag', $tag_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri') . exit;
                                 }
                             }
                         }
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_ptag_level_access', get_defined_vars());
         }
     }
     do_action('ws_plugin__s2member_after_check_ptag_level_access', get_defined_vars());
 }
 /**
  * Handles Tag Level Access permissions *(for current page)*.
  *
  * @package s2Member\Tags
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_ptag_level_access()
 {
     global $wp_query, $post;
     // ``get_the_ID()`` is NOT available outside The Loop.
     do_action("ws_plugin__s2member_before_check_ptag_level_access", get_defined_vars());
     $excluded = apply_filters("ws_plugin__s2member_check_ptag_level_access_excluded", false, get_defined_vars());
     if (!$excluded && is_tag() && is_object($tag = $wp_query->get_queried_object()) && !empty($tag->term_id) && ($tag_id = (int) $tag->term_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             // Current User's object.
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap("access_s2member_level0"))) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("ptag", $tag_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit;
             } else {
                 if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("ptag", $tag_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit;
                         } else {
                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && (is_tag($tags = preg_split("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) || in_array($tag_id, $tags)) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("ptag", $tag_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit;
                             }
                         }
                     }
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                             // URIs configured at this Level?
                             foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                 if ($str && preg_match("/" . preg_quote($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("ptag", $tag_id, "level", $n, $_SERVER["REQUEST_URI"], "ruri") . exit;
                                 }
                             }
                         }
                     }
                 }
             }
             do_action("ws_plugin__s2member_during_check_ptag_level_access", get_defined_vars());
         }
     }
     do_action("ws_plugin__s2member_after_check_ptag_level_access", get_defined_vars());
     return;
     // For uniformity.
 }
 /**
  * Handles Tag Level Access *(for specific Tags)*.
  *
  * @package s2Member\Tags
  * @since 3.5
  *
  * @param int|string $_tag Numeric Tag ID, Tag Slug, or Tag Name.
  * @param bool $check_user Test permissions against the current User? Defaults to true.
  * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
  */
 public static function check_specific_ptag_level_access($_tag = FALSE, $check_user = TRUE)
 {
     do_action("ws_plugin__s2member_before_check_specific_ptag_level_access", get_defined_vars());
     if ($_tag && is_numeric($_tag) && is_object($term = get_term_by("id", $_tag, "post_tag"))) {
         $tag_id = (int) $_tag;
         // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
         $tag_slug = $term->slug;
         // Tag slug.
         $tag_name = $term->name;
         // Tag name.
     } else {
         if ($_tag && is_string($_tag) && is_object($term = get_term_by("name", $_tag, "post_tag"))) {
             $tag_name = $_tag;
             // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
             $tag_id = (int) $term->term_id;
             // Tag ID.
             $tag_slug = $term->slug;
             // Tag slug.
         } else {
             if ($_tag && is_string($_tag) && is_object($term = get_term_by("slug", $_tag, "post_tag"))) {
                 $tag_slug = $_tag;
                 // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
                 $tag_id = (int) $term->term_id;
                 // Tag ID.
                 $tag_name = $term->name;
                 // Tag name.
             }
         }
     }
     $excluded = apply_filters("ws_plugin__s2member_check_specific_ptag_level_access_excluded", false, get_defined_vars());
     if (!$excluded && !empty($tag_id) && !empty($tag_slug) && !empty($tag_name) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         $tag_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_tag_link($tag_id));
         // Get a full valid URI for this Tag.
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(null, $tag_uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             // Current User's object.
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $tag_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level0"))) {
                 return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", array("s2member_level_req" => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(null, $tag_uri)) {
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                             return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", array("s2member_level_req" => $n), get_defined_vars());
                         } else {
                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && (in_array($tag_name, $tags = preg_split("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) || in_array($tag_slug, $tags)) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                 return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", array("s2member_level_req" => $n), get_defined_vars());
                             }
                         }
                     }
                     for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                             // URIs configured at this Level?
                             foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                 if ($str && preg_match("/" . preg_quote($str, "/") . "/", $tag_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                 }
             }
             do_action("ws_plugin__s2member_during_check_specific_ptag_level_access", get_defined_vars());
         }
     }
     return apply_filters("ws_plugin__s2member_check_specific_ptag_level_access", null, get_defined_vars());
 }
Beispiel #12
0
 /**
  * Handles Tag Level Access *(for specific Tags)*.
  *
  * @package s2Member\Tags
  * @since 3.5
  *
  * @param int|string $_tag Numeric Tag ID, Tag Slug, or Tag Name.
  * @param bool       $check_user Test permissions against the current User? Defaults to true.
  *
  * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
  */
 public static function check_specific_ptag_level_access($_tag = '', $check_user = TRUE)
 {
     do_action('ws_plugin__s2member_before_check_specific_ptag_level_access', get_defined_vars());
     if ($_tag && is_numeric($_tag) && is_object($term = get_term_by('id', $_tag, 'post_tag'))) {
         $tag_id = (int) $_tag;
         // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
         $tag_slug = $term->slug;
         // Tag slug.
         $tag_name = $term->name;
         // Tag name.
     } else {
         if ($_tag && is_string($_tag) && is_object($term = get_term_by('name', $_tag, 'post_tag'))) {
             $tag_name = $_tag;
             // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
             $tag_id = (int) $term->term_id;
             // Tag ID.
             $tag_slug = $term->slug;
             // Tag slug.
         } else {
             if ($_tag && is_string($_tag) && is_object($term = get_term_by('slug', $_tag, 'post_tag'))) {
                 $tag_slug = $_tag;
                 // Need ``$tag_id``, ``$tag_slug``, and also the ``$tag_name``.
                 $tag_id = (int) $term->term_id;
                 // Tag ID.
                 $tag_name = $term->name;
                 // Tag name.
             }
         }
     }
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     $excluded = apply_filters('ws_plugin__s2member_check_specific_ptag_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && !empty($tag_id) && !empty($tag_slug) && !empty($tag_name) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         $tag_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_tag_link($tag_id));
         // Get a full valid URI for this Tag.
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page(NULL, $tag_uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/' . $ci, $tag_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0'))) {
                 return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', array('s2member_level_req' => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page(NULL, $tag_uri)) {
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] === 'all' && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                             return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', array('s2member_level_req' => $n), get_defined_vars());
                         } else {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] && (in_array($tag_name, $tags = preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'])) || in_array($tag_slug, $tags)) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', array('s2member_level_req' => $n), get_defined_vars());
                             }
                         }
                     }
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                             // URIs configured at this Level?
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                 if ($str && preg_match('/' . preg_quote($str, '/') . '/' . $ci, $tag_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_specific_ptag_level_access', get_defined_vars());
         }
     }
     return apply_filters('ws_plugin__s2member_check_specific_ptag_level_access', NULL, get_defined_vars());
 }
 /**
  * Handles Post Level Access *(for specific Posts)*.
  *
  * @package s2Member\Posts
  * @since 3.5
  *
  * @param int|string $post_id Numeric Post ID.
  * @param bool       $check_user Test permissions against the current User? Defaults to true.
  *
  * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
  */
 public static function check_specific_post_level_access($post_id = 0, $check_user = TRUE)
 {
     do_action('ws_plugin__s2member_before_check_specific_post_level_access', get_defined_vars());
     $excluded = apply_filters('ws_plugin__s2member_check_specific_post_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && is_numeric($post_id) && ($post_id = (int) $post_id) && ($post = get_post($post_id)) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         $post_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_permalink($post->ID));
         // Get a full valid URI for this Post now.
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page($post->ID, $post_uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/', $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0'))) {
                 return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => 0), get_defined_vars());
             } else {
                 if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page($post->ID, $post_uri)) {
                     $bbpress_restrictions_enable = apply_filters('ws_plugin__s2member_bbpress_restrictions_enable', TRUE);
                     $bbpress_installed = c_ws_plugin__s2member_utils_conds::bbp_is_installed();
                     // bbPress is installed?
                     $bbpress_forum_post_type = $bbpress_installed ? bbp_get_forum_post_type() : '';
                     // Acquire the current post type for forums.
                     $bbpress_topic_post_type = $bbpress_installed ? bbp_get_topic_post_type() : '';
                     // Acquire the current post type for topics.
                     $bbpress_topic_forum_id = $bbpress_installed && $post->post_type === $bbpress_topic_post_type ? bbp_get_topic_forum_id($post->ID) : 0;
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'] === 'all' && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                             return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                         } else {
                             if (strpos($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'], 'all-') !== FALSE && $post->post_type && (in_array('all-' . $post->post_type, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) || in_array('all-' . $post->post_type . 's', preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts']))) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                             } else {
                                 if ($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && strpos($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'], 'all-') !== FALSE && (in_array('all-' . $bbpress_forum_post_type, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) || in_array('all-' . $bbpress_forum_post_type . 's', preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts']))) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                 } else {
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'] && in_array($post->ID, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                         return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                     }
                                 }
                             }
                         }
                     }
                     if ($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && $bbpress_topic_forum_id) {
                         for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'] && in_array($bbpress_topic_forum_id, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                             }
                         }
                     }
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'] === 'all' && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                             return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                         } else {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'] && (in_category($catgs = preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs']), $post->ID) || c_ws_plugin__s2member_utils_conds::in_descendant_category($catgs, $post->ID)) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                             }
                         }
                     }
                     if (has_tag('', $post->ID)) {
                         for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] === 'all' && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                             } else {
                                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] && has_tag(preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags']), $post->ID) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                             // URIs configured at this Level?
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                 if ($str && preg_match('/' . preg_quote($str, '/') . '/', $post_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                 }
                             }
                         }
                     }
                     if (is_array($ccaps_req = get_post_meta($post->ID, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req)) {
                         foreach ($ccaps_req as $ccap) {
                             // The $user MUST satisfy ALL Custom Capabilities. Serialized array.
                             if (strlen($ccap) && (!$check_user || !$user || !$user->has_cap('access_s2member_ccap_' . $ccap))) {
                                 return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_ccap_req' => $ccap), get_defined_vars());
                             }
                         }
                     }
                     if ($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && $bbpress_topic_forum_id) {
                         if (is_array($ccaps_req = get_post_meta($bbpress_topic_forum_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req)) {
                             foreach ($ccaps_req as $ccap) {
                                 // The $user MUST satisfy ALL Custom Capabilities. Serialized array.
                                 if (strlen($ccap) && (!$check_user || !$user || !$user->has_cap('access_s2member_ccap_' . $ccap))) {
                                     return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_ccap_req' => $ccap), get_defined_vars());
                                 }
                             }
                         }
                     }
                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'] && in_array($post->ID, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'])) && (!$check_user || !c_ws_plugin__s2member_sp_access::sp_access($post->ID, 'read-only'))) {
                         return apply_filters('ws_plugin__s2member_check_specific_post_level_access', array('s2member_sp_req' => $post->ID), get_defined_vars());
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_specific_post_level_access', get_defined_vars());
         }
     }
     return apply_filters('ws_plugin__s2member_check_specific_post_level_access', NULL, get_defined_vars());
 }
Beispiel #14
0
 /**
  * Handles Page Level Access *(for specific Pages)*.
  *
  * @package s2Member\Pages
  * @since 3.5
  *
  * @param int|string $page_id Numeric Page ID.
  * @param bool       $check_user Test permissions against the current User? Defaults to true.
  *
  * @return null|array Non-empty array(with details) if access is denied, else null if access is allowed.
  */
 public static function check_specific_page_level_access($page_id = 0, $check_user = TRUE)
 {
     do_action('ws_plugin__s2member_before_check_specific_page_level_access', get_defined_vars());
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     $excluded = apply_filters('ws_plugin__s2member_check_specific_page_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && is_numeric($page_id) && ($page_id = (int) $page_id) && ($page = get_post($page_id)) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         $page_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_page_link($page->ID));
         // Get a full valid URI for this Page now.
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page($page->ID, $page_uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && $page->ID === (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
                 return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => 0), get_defined_vars());
             } else {
                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/' . $ci, $page_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
                     return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => 0), get_defined_vars());
                 } else {
                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && $page->ID === (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && (!$check_user || !$user || !$user->has_cap('access_s2member_level0')) && $page->ID !== (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
                         return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => 0), get_defined_vars());
                     } else {
                         if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page($page->ID, $page_uri)) {
                             for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_pages'] === 'all' && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                 } else {
                                     if (strpos($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'], 'all-') !== FALSE && (in_array('all-page', preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) || in_array('all-pages', preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts']))) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                         return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                     } else {
                                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_pages'] && in_array($page->ID, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_pages'])) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                             return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             if (has_tag('', $page->ID)) {
                                 for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] === 'all' && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                         return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                     } else {
                                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] && has_tag(preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags']), $page->ID) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                             return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                                     // URIs configured at this Level?
                                     foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                         if ($str && preg_match('/' . preg_quote($str, '/') . '/' . $ci, $page_uri) && (!$check_user || !$user || !$user->has_cap('access_s2member_level' . $n))) {
                                             return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_level_req' => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             if (is_array($ccaps_req = get_post_meta($page->ID, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req)) {
                                 foreach ($ccaps_req as $ccap) {
                                     // The ``$user`` MUST satisfy ALL Custom Capabilities.
                                     if (strlen($ccap) && (!$check_user || !$user || !$user->has_cap('access_s2member_ccap_' . $ccap))) {
                                         return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_ccap_req' => $ccap), get_defined_vars());
                                     }
                                 }
                             }
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'] && in_array($page->ID, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'])) && (!$check_user || !c_ws_plugin__s2member_sp_access::sp_access($page->ID, 'read-only'))) {
                                 return apply_filters('ws_plugin__s2member_check_specific_page_level_access', array('s2member_sp_req' => $page->ID), get_defined_vars());
                             }
                         }
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_specific_page_level_access', get_defined_vars());
         }
     }
     return apply_filters('ws_plugin__s2member_check_specific_page_level_access', NULL, get_defined_vars());
 }
 /**
  * Handles Page Level Access permissions *(for current Page)*.
  *
  * @package s2Member\Pages
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_page_level_access()
 {
     global $post;
     // ``get_the_ID()`` unavailable outside The Loop.
     do_action('ws_plugin__s2member_before_check_page_level_access', get_defined_vars());
     $excluded = apply_filters('ws_plugin__s2member_check_page_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && is_page() && is_object($post) && !empty($post->ID) && ($page_id = (int) $post->ID) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && $page_id === (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'] && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys') . exit;
             } else {
                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/', $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys') . exit;
                 } else {
                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && $page_id === (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'] && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0')) && $page_id !== (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys') . exit;
                     } else {
                         if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                             for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_pages'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                                 } else {
                                     if (strpos($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'], 'all-') && (in_array('all-page', preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) || in_array('all-pages', preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts']))) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', $n, $_SERVER['REQUEST_URI'], 'post') . exit;
                                     } else {
                                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_pages'] && in_array($page_id, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_pages'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                                         }
                                     }
                                 }
                             }
                             if (has_tag()) {
                                 for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ptag') . exit;
                                     } else {
                                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] && has_tag(preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ptag') . exit;
                                         }
                                     }
                                 }
                             }
                             for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                                     // URIs configured at this Level?
                                     foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                         if ($str && preg_match('/' . preg_quote($str, '/') . '/', $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri') . exit;
                                         }
                                     }
                                 }
                             }
                             if (is_array($ccaps_req = get_post_meta($page_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted')) {
                                 foreach ($ccaps_req as $ccap) {
                                     // The ``$user`` MUST satisfy ALL Custom Capability requirements. Stored as an array of Custom Capabilities.
                                     if (strlen($ccap) && (!$user || !$user->has_cap('access_s2member_ccap_' . $ccap))) {
                                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'ccap', $ccap, $_SERVER['REQUEST_URI'], 'ccap') . exit;
                                     }
                                 }
                             }
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'] && in_array($page_id, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && !c_ws_plugin__s2member_sp_access::sp_access($page_id)) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('page', $page_id, 'sp', $page_id, $_SERVER['REQUEST_URI'], 'sp') . exit;
                             }
                         }
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_page_level_access', get_defined_vars());
         }
     }
     do_action('ws_plugin__s2member_after_check_page_level_access', get_defined_vars());
 }
Beispiel #16
0
 /**
  * Handles Page Level Access permissions *(for current Page)*.
  *
  * @package s2Member\Pages
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_page_level_access()
 {
     global $post;
     // ``get_the_ID()`` unavailable outside The Loop.
     do_action("ws_plugin__s2member_before_check_page_level_access", get_defined_vars());
     $excluded = apply_filters("ws_plugin__s2member_check_page_level_access_excluded", false, get_defined_vars());
     if (!$excluded && is_page() && is_object($post) && !empty($post->ID) && ($page_id = (int) $post->ID) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             // Current User's object.
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id === (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit;
             } else {
                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit;
                 } else {
                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id === (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", 0, $_SERVER["REQUEST_URI"], "sys") . exit;
                     } else {
                         if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                             for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit;
                                 } else {
                                     if (strpos($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"], "all-") && (in_array("all-page", preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) || in_array("all-pages", preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"]))) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "post") . exit;
                                     } else {
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array($page_id, preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"]) . exit;
                                         }
                                     }
                                 }
                             }
                             if (has_tag()) {
                                 for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ptag") . exit;
                                     } else {
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag(preg_split("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"])) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ptag") . exit;
                                         }
                                     }
                                 }
                             }
                             for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                                     // URIs configured at this Level?
                                     foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                         if ($str && preg_match("/" . preg_quote($str, "/") . "/", $_SERVER["REQUEST_URI"]) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && (!$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "level", $n, $_SERVER["REQUEST_URI"], "ruri") . exit;
                                         }
                                     }
                                 }
                             }
                             if (is_array($ccaps_req = get_post_meta($page_id, "s2member_ccaps_req", true)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants(true)) {
                                 foreach ($ccaps_req as $ccap) {
                                     // The ``$user`` MUST satisfy ALL Custom Capability requirements. Stored as an array of Custom Capabilities.
                                     if (strlen($ccap) && (!$user || !$user->has_cap("access_s2member_ccap_" . $ccap))) {
                                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "ccap", $ccap, $_SERVER["REQUEST_URI"], "ccap") . exit;
                                     }
                                 }
                             }
                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array($page_id, preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && c_ws_plugin__s2member_no_cache::no_cache_constants(true) && !c_ws_plugin__s2member_sp_access::sp_access($page_id)) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars("page", $page_id, "sp", $page_id, $_SERVER["REQUEST_URI"], "sp") . exit;
                             }
                         }
                     }
                 }
             }
             do_action("ws_plugin__s2member_during_check_page_level_access", get_defined_vars());
         }
     }
     do_action("ws_plugin__s2member_after_check_page_level_access", get_defined_vars());
     return;
     // For uniformity.
 }
Beispiel #17
0
 /**
  * Handles Page Level Access *(for specific Pages)*.
  *
  * @package s2Member\Pages
  * @since 3.5
  *
  * @param int|str $page_id Numeric Page ID.
  * @param bool $check_user Test permissions against the current User? Defaults to true.
  * @return null|array Non-empty array (with details) if access is denied, else null if access is allowed.
  *
  * @todo Provide more information in the return array (like MOP Vars).
  */
 public static function check_specific_page_level_access($page_id = FALSE, $check_user = TRUE)
 {
     do_action("ws_plugin__s2member_before_check_specific_page_level_access", get_defined_vars());
     $excluded = apply_filters("ws_plugin__s2member_check_specific_page_level_access_excluded", false, get_defined_vars());
     if (!$excluded && is_numeric($page_id) && ($page_id = (int) $page_id) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
         $page_uri = c_ws_plugin__s2member_utils_urls::parse_uri(get_page_link($page_id));
         // Get a full valid URI for this Page now.
         if (!c_ws_plugin__s2member_systematics_sp::is_wp_systematic_use_specific_page($page_id, $page_uri)) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : false;
             // Current User's object.
             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && $page_id === (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"] && (!$check_user || !$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                 return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => 0), get_defined_vars());
             } else {
                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, "root-returns-false")) && preg_match("/^" . preg_quote($login_redirection_uri, "/") . "\$/", $page_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                     return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => 0), get_defined_vars());
                 } else {
                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && $page_id === (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["file_download_limit_exceeded_page"] && (!$check_user || !$user || !$user->has_cap("access_s2member_level0")) && $page_id !== (int) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"]) {
                         return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => 0), get_defined_vars());
                     } else {
                         if (!c_ws_plugin__s2member_systematics_sp::is_systematic_use_specific_page($page_id, $page_uri)) {
                             for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] === "all" && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                     return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                 } else {
                                     if (strpos($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"], "all-") !== false && (in_array("all-page", preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) || in_array("all-pages", preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"]))) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                         return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                     } else {
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"] && in_array($page_id, preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_pages"])) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             if (has_tag("", $page_id)) {
                                 for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] === "all" && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                         return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                     } else {
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"] && has_tag(preg_split("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ptags"]), $page_id) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             for ($n = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n >= 0; $n--) {
                                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"]) {
                                     // URIs configured at this Level?
                                     foreach (preg_split("/[\r\n\t]+/", c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_ruris"], $user)) as $str) {
                                         if ($str && preg_match("/" . preg_quote($str, "/") . "/", $page_uri) && (!$check_user || !$user || !$user->has_cap("access_s2member_level" . $n))) {
                                             return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_level_req" => $n), get_defined_vars());
                                         }
                                     }
                                 }
                             }
                             if (is_array($ccaps_req = get_post_meta($page_id, "s2member_ccaps_req", true)) && !empty($ccaps_req)) {
                                 foreach ($ccaps_req as $ccap) {
                                     // The ``$user`` MUST satisfy ALL Custom Capabilities.
                                     if (strlen($ccap) && (!$check_user || !$user || !$user->has_cap("access_s2member_ccap_" . $ccap))) {
                                         return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_ccap_req" => $ccap), get_defined_vars());
                                     }
                                 }
                             }
                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"] && in_array($page_id, preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["specific_ids"])) && (!$check_user || !c_ws_plugin__s2member_sp_access::sp_access($page_id, "read-only"))) {
                                 return apply_filters("ws_plugin__s2member_check_specific_page_level_access", array("s2member_sp_req" => $page_id), get_defined_vars());
                             }
                         }
                     }
                 }
             }
             do_action("ws_plugin__s2member_during_check_specific_page_level_access", get_defined_vars());
         }
     }
     return apply_filters("ws_plugin__s2member_check_specific_page_level_access", null, get_defined_vars());
 }
Beispiel #18
0
 /**
  * Handles Post Level Access permissions *(for current Post)*.
  *
  * @package s2Member\Posts
  * @since 3.5
  *
  * @return null Or exits script execution after redirection.
  */
 public static function check_post_level_access()
 {
     global $post;
     // ``get_the_ID()`` unavailable outside The Loop.
     do_action('ws_plugin__s2member_before_check_post_level_access', get_defined_vars());
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     $excluded = apply_filters('ws_plugin__s2member_check_post_level_access_excluded', FALSE, get_defined_vars());
     if (!$excluded && is_single() && is_object($post) && !empty($post->ID) && ($post_id = (int) $post->ID) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_options_page']) {
         if (!c_ws_plugin__s2member_systematics::is_wp_systematic_use_page()) {
             $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) ? $user : FALSE;
             // Current User's object.
             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_override'] && ($login_redirection_uri = c_ws_plugin__s2member_login_redirects::login_redirection_uri($user, 'root-returns-false')) && preg_match('/^' . preg_quote($login_redirection_uri, '/') . '$/' . $ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level0'))) {
                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', 0, $_SERVER['REQUEST_URI'], 'sys') . exit;
             } else {
                 if (!c_ws_plugin__s2member_systematics::is_systematic_use_page()) {
                     $bbpress_restrictions_enable = apply_filters('ws_plugin__s2member_bbpress_restrictions_enable', TRUE);
                     $bbpress_installed = c_ws_plugin__s2member_utils_conds::bbp_is_installed();
                     // bbPress is installed?
                     $bbpress_forum_post_type = $bbpress_installed ? bbp_get_forum_post_type() : '';
                     // Acquire the current post type for forums.
                     $bbpress_topic_post_type = $bbpress_installed ? bbp_get_topic_post_type() : '';
                     // Acquire the current post type for topics.
                     $bbpress_topic_forum_id = $bbpress_installed && $post->post_type === $bbpress_topic_post_type ? bbp_get_topic_forum_id($post->ID) : 0;
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                         } else {
                             if (strpos($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'], 'all-') !== FALSE && (in_array('all-' . $post->post_type, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) || in_array('all-' . $post->post_type . 's', preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts']))) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                             } else {
                                 if ($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && strpos($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'], 'all-') !== FALSE && (in_array('all-' . $bbpress_forum_post_type, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) || in_array('all-' . $bbpress_forum_post_type . 's', preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts']))) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                                 } else {
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'] && in_array($post_id, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                                     }
                                 }
                             }
                         }
                     }
                     if ($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && $bbpress_topic_forum_id) {
                         for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'] && in_array($bbpress_topic_forum_id, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_posts'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $bbpress_topic_forum_id, 'level', $n, $_SERVER['REQUEST_URI']) . exit;
                             }
                         }
                     }
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                             c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI'], 'catg') . exit;
                         } else {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'] && (in_category($catgs = preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs']), $post_id) || c_ws_plugin__s2member_utils_conds::in_descendant_category($catgs, $post_id)) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI'], 'catg') . exit;
                             }
                         }
                     }
                     if (has_tag()) {
                         for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] === 'all' && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ptag') . exit;
                             } else {
                                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'] && has_tag(preg_split('/[' . "\r\n\t" . ';,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ptags'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ptag') . exit;
                                 }
                             }
                         }
                     }
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris']) {
                             // URIs configured at this Level?
                             foreach (preg_split('/[' . "\r\n\t" . ']+/', c_ws_plugin__s2member_ruris::fill_ruri_level_access_rc_vars($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_ruris'], $user)) as $str) {
                                 if ($str && preg_match('/' . preg_quote($str, '/') . '/' . $ci, $_SERVER['REQUEST_URI']) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && (!$user || !$user->has_cap('access_s2member_level' . $n))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'level', $n, $_SERVER['REQUEST_URI'], 'ruri') . exit;
                                 }
                             }
                         }
                     }
                     if (is_array($ccaps_req = get_post_meta($post_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted')) {
                         foreach ($ccaps_req as $ccap) {
                             // The ``$user`` MUST satisfy ALL Custom Capability requirements. Stored as an array of Custom Capabilities.
                             if (strlen($ccap) && (!$user || !$user->has_cap('access_s2member_ccap_' . $ccap))) {
                                 c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'ccap', $ccap, $_SERVER['REQUEST_URI'], 'ccap') . exit;
                             }
                         }
                     }
                     if ($bbpress_restrictions_enable && $bbpress_installed && $post->post_type === $bbpress_topic_post_type && $bbpress_topic_forum_id) {
                         if (is_array($ccaps_req = get_post_meta($bbpress_topic_forum_id, 's2member_ccaps_req', TRUE)) && !empty($ccaps_req) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted')) {
                             foreach ($ccaps_req as $ccap) {
                                 // The ``$user`` MUST satisfy ALL Custom Capability requirements. Stored as an array of Custom Capabilities.
                                 if (strlen($ccap) && (!$user || !$user->has_cap('access_s2member_ccap_' . $ccap))) {
                                     c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $bbpress_topic_forum_id, 'ccap', $ccap, $_SERVER['REQUEST_URI'], 'ccap') . exit;
                                 }
                             }
                         }
                     }
                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'] && in_array($post_id, preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['specific_ids'])) && c_ws_plugin__s2member_no_cache::no_cache_constants('restricted') && !c_ws_plugin__s2member_sp_access::sp_access($post_id)) {
                         c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars('post', $post_id, 'sp', $post_id, $_SERVER['REQUEST_URI'], 'sp') . exit;
                     }
                 }
             }
             do_action('ws_plugin__s2member_during_check_post_level_access', get_defined_vars());
         }
     }
     do_action('ws_plugin__s2member_after_check_post_level_access', get_defined_vars());
 }