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


PHP c_ws_plugin__s2member_utils_conds::bbp_is_installed方法代码示例

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


在下文中一共展示了c_ws_plugin__s2member_utils_conds::bbp_is_installed方法的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());
     $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

示例2: get_unavailable_singular_ids_with_ccaps

 /**
  * Retrieves a unique array of unavailable Singular IDs that require Custom Capabilities.
  *
  * Only returns Singular IDs that require Custom Capabilities;
  *   and ONLY those which are NOT satisfied by ``$user``.
  *
  * @package s2Member\Utilities
  * @since 111101
  *
  * @param WP_User $user Optional. A `WP_User` object. If this is a valid `WP_User` object, test against this ``$user``, else all are unavailable.
  *
  * @return array Unique array of all Singular IDs *(as integers)* NOT available to ``$user``, due to Custom Capability Restrictions.
  */
 public static function get_unavailable_singular_ids_with_ccaps($user = NULL)
 {
     /** @var wpdb $wpdb WordPress DB object instance. */
     global $wpdb;
     // Global DB object reference.
     if (is_array($results = $wpdb->get_results("SELECT `" . $wpdb->postmeta . "`.`post_id`, `" . $wpdb->postmeta . "`.`meta_value`, `" . $wpdb->posts . "`.`post_type`" . " FROM `" . $wpdb->posts . "`, `" . $wpdb->postmeta . "` WHERE `" . $wpdb->posts . "`.`ID` = `" . $wpdb->postmeta . "`.`post_id`" . " AND `" . $wpdb->postmeta . "`.`meta_key` = 's2member_ccaps_req' AND `" . $wpdb->postmeta . "`.`meta_value` != ''"))) {
         $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.
         foreach ($results as $r) {
             if (!is_object($user) || empty($user->ID)) {
                 // No ``$user`` object? Maybe not logged-in?.
                 $singular_ids[] = (int) $r->post_id;
             } else {
                 if (is_array($ccaps = @unserialize($r->meta_value))) {
                     foreach ($ccaps as $ccap) {
                         // Test for Custom Capability Restrictions now.
                         if (strlen($ccap) && !$user->has_cap('access_s2member_ccap_' . $ccap)) {
                             $singular_ids[] = (int) $r->post_id;
                             // It's NOT available.
                             break;
                             // Break now, no need to continue in this loop.
                         }
                     }
                 }
             }
             if ($bbpress_restrictions_enable && $bbpress_installed && $r->post_type === $bbpress_forum_post_type) {
                 if (!empty($singular_ids) && in_array((int) $r->post_id, $singular_ids, TRUE)) {
                     if (is_array($child_results = $wpdb->get_results("SELECT `" . $wpdb->posts . "`.`ID` as `post_id` FROM `" . $wpdb->posts . "`" . " WHERE `" . $wpdb->posts . "`.`post_parent` = '" . esc_sql($r->post_id) . "'" . " AND `" . $wpdb->posts . "`.`post_type` = '" . esc_sql($bbpress_topic_post_type) . "'"))) {
                         foreach ($child_results as $child_r) {
                             $singular_ids[] = (int) $child_r->post_id;
                         }
                     }
                 }
             }
         }
     }
     return !empty($singular_ids) && is_array($singular_ids) ? array_unique($singular_ids) : array();
 }
开发者ID:adnandot,项目名称:intenseburn,代码行数:56,代码来源:utils-gets.inc.php

示例3: 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

示例4: query_level_access

 /**
  * Filter all WordPress queries.
  *
  * s2Member respects the query var: `suppress_filters`.
  * If you need to make a query without it being Filtered, use  ``$wp_query->set ('suppress_filters', true);``.
  *
  * @package s2Member\Queries
  * @since 3.5
  *
  * @attaches-to ``add_action('pre_get_posts');``
  *
  * @param WP_Query $wp_query Expects ``$wp_query`` by reference, from the Filter.
  * @param bool     $force Optional. Defaults to false. If true, we bypass all standard conditions.
  *   However, s2Member will NEVER bypass `supress_filters`.
  *
  * @todo For improved reliability, modify other query vars associated with exclusions/inclusions. Like `tag_slug__in`?
  *   See: {@link http://codex.wordpress.org/Class_Reference/WP_Query#Parameters WP_Query#Parameters}
  *
  * @todo Make it possible to force filtering, even when used in combination with Query Conditionals and ``get_posts()``, which auto-supresses.
  *   Or, perhaps strengthen the existing ``$force`` parameter in this regard.
  */
 public static function query_level_access(&$wp_query = NULL, $force = FALSE)
 {
     global $wpdb;
     // Global DB object reference.
     static $initial_query = TRUE;
     // Tracks the initial query.
     c_ws_plugin__s2member_querys::$current_wp_query =& $wp_query;
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_query_level_access', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
     c_ws_plugin__s2member_querys::_query_level_access_sys($wp_query);
     // Systematics.
     remove_filter('comment_feed_where', 'c_ws_plugin__s2member_querys::_query_level_access_coms', 100, 2);
     remove_filter('wp_get_nav_menu_items', 'c_ws_plugin__s2member_querys::_query_level_access_navs', 100);
     if (is_object($wpdb) && is_object($wp_query) && (($o = $GLOBALS['WS_PLUGIN__']['s2member']['o']['filter_wp_query']) || $force)) {
         if (!is_admin() || c_ws_plugin__s2member_querys::_is_admin_ajax_search($wp_query)) {
             $suppressing_filters = $wp_query->get('suppress_filters');
             // Filter suppression on?
             if (!$suppressing_filters && $force || !$suppressing_filters && in_array('all', $o) && !($initial_query && $wp_query->is_singular()) || !$suppressing_filters && (in_array('all', $o) || in_array('searches', $o)) && $wp_query->is_search() || !$suppressing_filters && (in_array('all', $o) || in_array('feeds', $o)) && $wp_query->is_feed() && !$wp_query->is_comment_feed() || !$suppressing_filters && (in_array('all', $o) || in_array('comment-feeds', $o)) && $wp_query->is_feed() && $wp_query->is_comment_feed() || $suppressing_filters !== 'n/a' && (in_array('all', $o) || in_array('nav-menus', $o)) && in_array('wp_get_nav_menu_items', $callers = isset($callers) ? $callers : c_ws_plugin__s2member_utilities::callers())) {
                 if (!$suppressing_filters && (in_array('all', $o) || in_array('comment-feeds', $o)) && $wp_query->is_feed() && $wp_query->is_comment_feed()) {
                     add_filter('comment_feed_where', 'c_ws_plugin__s2member_querys::_query_level_access_coms', 100, 2);
                 }
                 if ($suppressing_filters !== 'n/a' && (in_array('all', $o) || in_array('nav-menus', $o))) {
                     // Suppression irrelevant here.
                     if (in_array('wp_get_nav_menu_items', $callers = isset($callers) ? $callers : c_ws_plugin__s2member_utilities::callers())) {
                         add_filter('wp_get_nav_menu_items', 'c_ws_plugin__s2member_querys::_query_level_access_navs', 100);
                     }
                 }
                 if ($suppressing_filters !== 'n/a' && (in_array('all', $o) || in_array('pages', $o))) {
                     add_filter('wp_list_pages_excludes', 'c_ws_plugin__s2member_querys::_query_level_access_list_pages', 100);
                 }
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && !empty($user->ID) && ($user_id = $user->ID) || !($user = FALSE)) {
                     $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.
                     if (!$user && ($_lwp = (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page'])) {
                         $wp_query->set('post__in', array_unique(array_diff(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__in')), array($_lwp))));
                         $wp_query->set('post__not_in', array_unique(array_merge(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__not_in')), array($_lwp))));
                     }
                     if (!$user && ($_dep = (int) $GLOBALS['WS_PLUGIN__']['s2member']['o']['file_download_limit_exceeded_page'])) {
                         $wp_query->set('post__in', array_unique(array_diff(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__in')), array($_dep))));
                         $wp_query->set('post__not_in', array_unique(array_merge(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__not_in')), array($_dep))));
                     }
                     if (is_array($_ccaps = c_ws_plugin__s2member_utils_gets::get_unavailable_singular_ids_with_ccaps($user)) && !empty($_ccaps)) {
                         $wp_query->set('post__in', array_unique(array_diff(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__in')), $_ccaps)));
                         $wp_query->set('post__not_in', array_unique(array_merge(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__not_in')), $_ccaps)));
                     }
                     if (is_array($_sps = c_ws_plugin__s2member_utils_gets::get_unavailable_singular_ids_with_sp()) && !empty($_sps)) {
                         $wp_query->set('post__in', array_unique(array_diff(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__in')), $_sps)));
                         $wp_query->set('post__not_in', array_unique(array_merge(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__not_in')), $_sps)));
                     }
                     unset($_lwp, $_dep, $_ccaps, $_sps);
                     // A little housekeeping here. Ditch these temporary variables.
                     for ($n = $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']; $n >= 0; $n--) {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'] === 'all' && (!$user || !current_user_can('access_s2member_level' . $n))) {
                             $wp_query->set('category__in', array());
                             // Include no other Categories.
                             $wp_query->set('category__not_in', $_catgs = c_ws_plugin__s2member_utils_gets::get_all_category_ids());
                             $wp_query->set('post__not_in', array_unique(array_merge(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__not_in')), $_singulars = c_ws_plugin__s2member_utils_gets::get_singular_ids_in_terms($_catgs))));
                             $wp_query->set('post__in', array_unique(array_diff(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__in')), $_singulars)));
                             break;
                             // All Categories will be locked down.
                         } else {
                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs'] && (!$user || !current_user_can('access_s2member_level' . $n))) {
                                 foreach ($_catgs = preg_split('/[' . "\r\n\t" . '\\s;,]+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['level' . $n . '_catgs']) as $_catg) {
                                     $_catgs = array_merge($_catgs, c_ws_plugin__s2member_utils_gets::get_all_child_category_ids($_catg));
                                 }
                                 $wp_query->set('category__in', array_unique(array_diff(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('category__in')), $_catgs)));
                                 $wp_query->set('category__not_in', array_unique(array_merge(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('category__not_in')), $_catgs)));
                                 $wp_query->set('post__not_in', array_unique(array_merge(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__not_in')), $_singulars = c_ws_plugin__s2member_utils_gets::get_singular_ids_in_terms($_catgs))));
                                 $wp_query->set('post__in', array_unique(array_diff(c_ws_plugin__s2member_utils_arrays::force_integers((array) $wp_query->get('post__in')), $_singulars)));
                             }
//.........这里部分代码省略.........
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:101,代码来源:querys.inc.php


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