当前位置: 首页>>代码示例>>PHP>>正文


PHP c_ws_plugin__s2member_utils_conds::in_descendant_category方法代码示例

本文整理汇总了PHP中c_ws_plugin__s2member_utils_conds::in_descendant_category方法的典型用法代码示例。如果您正苦于以下问题:PHP c_ws_plugin__s2member_utils_conds::in_descendant_category方法的具体用法?PHP c_ws_plugin__s2member_utils_conds::in_descendant_category怎么用?PHP c_ws_plugin__s2member_utils_conds::in_descendant_category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在c_ws_plugin__s2member_utils_conds的用法示例。


在下文中一共展示了c_ws_plugin__s2member_utils_conds::in_descendant_category方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check_post_level_access

 /**
  * 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());
     /**/
     $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, "/") . "\$/", $_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("post", $post_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 . "_posts"] === "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("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 . "s", 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("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(true) && (!$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;
                                 }
                             }
                         }
                     }
                     /**/
                     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("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(true) && (!$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(true) && (!$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(true) && (!$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, "/") . "/", $_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("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(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("post", $post_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(true) && !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());
     /**/
     return;
     /* For uniformity. */
 }
开发者ID:vinvinh315,项目名称:maintainwebsolutions.com,代码行数:98,代码来源:posts.inc.php

示例2: check_post_level_access

 /**
  * 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;
                                 }
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member,代码行数:101,代码来源:posts.inc.php

示例3: check_specific_post_level_access

 /**
  * Handles Post Level Access *(for specific Posts)*.
  *
  * @package s2Member\Posts
  * @since 3.5
  *
  * @param int|str $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 = FALSE, $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) && $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)) {
                     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_type = get_post_type($post_id)) && (in_array("all-" . $post_type, preg_split("/[\r\n\t\\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_posts"])) || in_array("all-" . $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());
                                 }
                             }
                         }
                     }
                     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 ($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());
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:85,代码来源:posts-sp.inc.php

示例4: check_specific_post_level_access

 /**
  * 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))) {
//.........这里部分代码省略.........
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:101,代码来源:posts-sp.inc.php


注:本文中的c_ws_plugin__s2member_utils_conds::in_descendant_category方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。