/wp-content/plugins/s2member/includes/functions/api-functions.inc.php
PHP | 1102 lines | 137 code | 24 blank | 941 comment | 71 complexity | 1ef5731d54452dbc4c9091ecca69ad7a MD5 | raw file
- <?php
- /**
- * Core API Functions *(for site owners)*.
- *
- * Copyright: © 2009-2011
- * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
- * (coded in the USA)
- *
- * Released under the terms of the GNU General Public License.
- * You should have received a copy of the GNU General Public License,
- * along with this software. In the main directory, see: /licensing/
- * If not, see: {@link http://www.gnu.org/licenses/}.
- *
- * @package s2Member\API_Functions
- * @since 3.5
- */
- if(realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"]))
- exit("Do not access this file directly.");
- /**
- * Conditional to determine if the current User is NOT logged in.
- *
- * Counterpart {@link http://codex.wordpress.org/Function_Reference/is_user_logged_in is_user_logged_in()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Both Functions ————
- * ```
- * <!php
- * if(is_user_logged_in())
- * echo 'You ARE logged in.';
- *
- * else if(is_user_not_logged_in())
- * echo 'You are NOT logged in.';
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If is_user_logged_in()]
- * You ARE logged in.
- * [/s2If]
- * [s2If is_user_not_logged_in()]
- * You are NOT logged in.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @return bool True if the current User is NOT logged in, else false.
- *
- * @see http://codex.wordpress.org/Function_Reference/is_user_logged_in is_user_logged_in()
- */
- if(!function_exists("is_user_not_logged_in"))
- {
- function is_user_not_logged_in()
- {
- return (!is_user_logged_in());
- }
- }
- /**
- * Conditional to determine if a specific User is/has a specific Role.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/user_can user_can()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Both Functions ————
- * ```
- * <!php
- * if(user_is(123, "subscriber"))
- * echo 'User ID# 123 is a Free Subscriber at Level #0.';
- *
- * else if(user_is(123, "s2member_level1"))
- * echo 'User ID# 123 is a Member at Level #1.';
- *
- * else if(user_can(123, "access_s2member_level2"))
- * echo 'User ID# 123 has access to content protected at Level #2.';
- * # But, (important) they could actually be a Level #3 or #4 Member;
- * # because Membership Levels provide incremental access.
- * !>
- * ```
- *
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If user_is(123, subscriber)]
- * User ID# 123 is a Free Subscriber at Level #0.
- * [/s2If]
- * [s2If user_is(123, s2member_level1)]
- * User ID# 123 is a Member at Level #1.
- * [/s2If]
- * [s2If user_can(123, access_s2member_level2)]
- * User ID# 123 has access to content protected at Level #2.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 110524RC
- *
- * @param int|str $id A numeric WordPress® User ID.
- * @param str $role A WordPress® Role ID *( i.e. `s2member_level[0-9]+`, `administrator`, `editor`, `author`, `contributor`, `subscriber` )*.
- * @return bool True if the specific User is/has the specified Role, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("user_is"))
- {
- function user_is($id = FALSE, $role = FALSE)
- {
- $role = ($role === "s2member_level0") ? "subscriber" : preg_replace("/^access_/i", "", $role);
- if(($role === "super_administrator" || $role === "administrator") && is_multisite() && is_super_admin($id))
- return /* Return true, Super Admins are always considered an Admnistrator, for all Blogs. */ true;
- else if /* Else return false for Super Admins here. */(is_multisite() && is_super_admin($id))
- return /* Super Admins can access all Capabilities, so the default handling would fail. */ false;
- return user_can($id, $role);
- }
- }
- /**
- * Conditional to determine if a specific User is/does NOT have a specific Role.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/user_can user_can()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Three Functions ————
- * ```
- * <!php
- * if(user_is(123, "subscriber"))
- * echo 'User ID# 123 is a Free Subscriber at Level #0.';
- *
- * else if(user_is(123, "s2member_level1"))
- * echo 'User ID# 123 is a Member at Level #1.';
- *
- * else if(user_can(123, "access_s2member_level2") && user_is_not(123, "s2member_level2"))
- * echo 'User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member.';
- * # So, (important) they could actually be a Level #3 or #4 Member;
- * # because Membership Levels provide incremental access.
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If user_is(123, subscriber)]
- * User ID# 123 is a Free Subscriber at Level #0.
- * [/s2If]
- * [s2If user_is(123, s2member_level1)]
- * User ID# 123 is a Member at Level #1.
- * [/s2If]
- * [s2If user_can(123, access_s2member_level2) AND user_is_not(123, s2member_level2)]
- * User ID# 123 has access to content protected at Level #2, but they are NOT a Level #2 Member.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 110524RC
- *
- * @param int|str $id A numeric WordPress® User ID.
- * @param str $role A WordPress® Role ID *( i.e. `s2member_level[0-9]+`, `administrator`, `editor`, `author`, `contributor`, `subscriber` )*.
- * @return bool True if the specific User is/does NOT have the specified Role, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("user_is_not"))
- {
- function user_is_not($id = FALSE, $role = FALSE)
- {
- return (!user_is($id, $role));
- }
- }
- /**
- * Conditional to determine if the current User is/has a specific Role.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Both Functions ————
- * ```
- * <!php
- * if(current_user_is("subscriber"))
- * echo 'You ARE a Free Subscriber at Level #0.';
- *
- * else if(current_user_is("s2member_level1"))
- * echo 'You ARE a Member at Level #1.';
- *
- * else if(current_user_can("access_s2member_level2"))
- * echo 'You DO have access to content protected at Level #2.';
- * # But, (important) they could actually be a Level #3 or #4 Member;
- * # because Membership Levels provide incremental access.
- * !>
- * ```
- *
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If current_user_is(subscriber)]
- * You ARE a Free Subscriber at Level #0.
- * [/s2If]
- * [s2If current_user_is(s2member_level1)]
- * You ARE a Member at Level #1.
- * [/s2If]
- * [s2If current_user_can(access_s2member_level2)]
- * You DO have access to content protected at Level #2.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param str $role A WordPress® Role ID *( i.e. `s2member_level[0-9]+`, `administrator`, `editor`, `author`, `contributor`, `subscriber` )*.
- * @return bool True if the current User is/has the specified Role, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("current_user_is"))
- {
- function current_user_is($role = FALSE)
- {
- $role = ($role === "s2member_level0") ? "subscriber" : preg_replace("/^access_/i", "", $role);
- if(($role === "super_administrator" || $role === "administrator") && is_multisite() && is_super_admin())
- return /* Return true, Super Admins are always considered an Admnistrator, for all Blogs. */ true;
- else if /* Else return false for Super Admins here. */(is_multisite() && is_super_admin())
- return /* Super Admins can access all Capabilities, so the default handling would fail. */ false;
- return current_user_can($role);
- }
- }
- /**
- * Conditional to determine if the current User is/does NOT have a specific Role.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Three Functions ————
- * ```
- * <!php
- * if(current_user_is("subscriber"))
- * echo 'You ARE a Free Subscriber at Level #0.';
- *
- * else if(current_user_is("s2member_level1"))
- * echo 'You ARE a Member at Level #1.';
- *
- * else if(current_user_can("access_s2member_level2") && current_user_is_not("s2member_level2"))
- * echo 'You DO have access to content protected at Level #2, but you are NOT a Level #2 Member.';
- * # So, (important) they could actually be a Level #3 or #4 Member;
- * # because Membership Levels provide incremental access.
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If current_user_is(subscriber)]
- * You ARE a Free Subscriber at Level #0.
- * [/s2If]
- * [s2If current_user_is(s2member_level1)]
- * You ARE a Member at Level #1.
- * [/s2If]
- * [s2If current_user_can(access_s2member_level2) AND current_user_is_not(s2member_level2)]
- * You DO have access to content protected at Level #2, but you are NOT a Level #2 Member.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param str $role A WordPress® Role ID *( i.e. `s2member_level[0-9]+`, `administrator`, `editor`, `author`, `contributor`, `subscriber` )*.
- * @return bool True if the current User is/does NOT have the specified Role, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("current_user_is_not"))
- {
- function current_user_is_not($role = FALSE)
- {
- return (!current_user_is($role));
- }
- }
- /**
- * Conditional to determine if the current User is/has a specific Role, on a specific Blog within a Multisite Network.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Three Functions ————
- * ```
- * <!php
- * if(current_user_is("subscriber"))
- * echo 'You ARE a Free Subscriber at Level #0 (on this Blog).';
- *
- * else if(current_user_is_for_blog(5, "subscriber"))
- * echo 'You ARE a Free Subscriber at Level #0 (on Blog ID 5).';
- *
- * else if(current_user_is_for_blog(5, "s2member_level1"))
- * echo 'You ARE a Member at Level #1 (on Blog ID 5).';
- *
- * else if(current_user_can_for_blog(5, "access_s2member_level2"))
- * echo 'You DO have access to content protected at Level #2 (on Blog ID 5).';
- * # But, (important) they could actually be a Level #3 or #4 Member (on Blog ID 5);
- * # because Membership Levels provide incremental access.
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If current_user_is(subscriber)]
- * You ARE a Free Subscriber at Level #0 (on this Blog).
- * [/s2If]
- * [s2If current_user_is_for_blog(5, subscriber)]
- * You ARE a Free Subscriber at Level #0 (on Blog ID 5).
- * [/s2If]
- * [s2If current_user_is_for_blog(5, s2member_level1)]
- * You ARE a Member at Level #1 (on Blog ID 5).
- * [/s2If]
- * [s2If current_user_can_for_blog(5, access_s2member_level2)]
- * You DO have access to content protected at Level #2 (on Blog ID 5).
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param int|str $blog_id A WordPress® Blog ID *(must be numeric)*.
- * @param str $role A WordPress® Role ID *( i.e. `s2member_level[0-9]+`, `administrator`, `editor`, `author`, `contributor`, `subscriber` )*.
- * @return bool True if the current User is/has the specified Role, on the specified Blog, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("current_user_is_for_blog"))
- {
- function current_user_is_for_blog($blog_id = FALSE, $role = FALSE)
- {
- $role = ($role === "s2member_level0") ? "subscriber" : preg_replace("/^access_/i", "", $role);
- if(($role === "super_administrator" || $role === "administrator") && is_multisite() && is_super_admin())
- return /* Return true, Super Admins are always considered an Admnistrator, for all Blogs. */ true;
- else if /* Else return false for Super Admins here. */(is_multisite() && is_super_admin())
- return /* Super Admins can access all Capabilities, so the default handling would fail. */ false;
- return current_user_can_for_blog($blog_id, $role);
- }
- }
- /**
- * Conditional to determine if the current User is/does NOT have a specific Role, on a specific Blog within a Multisite Network.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Three Functions ————
- * ```
- * <!php
- * if(current_user_is_for_blog(5, "subscriber"))
- * echo 'You ARE a Free Subscriber at Level #0 (on Blog ID 5).';
- *
- * else if(current_user_can_for_blog(5, "access_s2member_level1") && current_user_is_not_for_blog(5, "s2member_level1"))
- * echo 'You DO have access to content protected at Level #1 (on Blog ID 5), but you are NOT a Level #1 Member (on Blog ID 5).';
- * # So, (important) they could actually be a Level #2 or #3 or #4 Member (on Blog ID 5);
- * # because Membership Levels provide incremental access.
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If current_user_is_for_blog(5, subscriber)]
- * You ARE a Free Subscriber at Level #0 (on Blog ID 5).
- * [/s2If]
- * [s2If current_user_can_for_blog(5, access_s2member_level1) AND current_user_is_not_for_blog(5, s2member_level1)]
- * You DO have access to content protected at Level #1 (on Blog ID 5), but you are NOT a Level #1 Member (on Blog ID 5).
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param int|str $blog_id A WordPress® Blog ID *(must be numeric)*.
- * @param str $role A WordPress® Role ID *( i.e. `s2member_level[0-9]+`, `administrator`, `editor`, `author`, `contributor`, `subscriber` )*.
- * @return bool True if the current User is/does NOT have the specified Role, on the specified Blog, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("current_user_is_not_for_blog"))
- {
- function current_user_is_not_for_blog($blog_id = FALSE, $role = FALSE)
- {
- return (!current_user_is_for_blog($blog_id, $role));
- }
- }
- /**
- * Conditional to determine if a specific User does NOT have a specific Capability or Role.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/user_can user_can()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Both Functions ————
- * ```
- * <!php
- * if(user_can(123, "access_s2member_level0"))
- * echo 'User ID# 123 CAN access content protected at Level #0.';
- *
- * else if(user_cannot(123, "access_s2member_level0"))
- * echo 'User ID# 123 CANNOT access content at Level #0.';
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If user_can(123, access_s2member_level0)]
- * User ID# 123 CAN access content protected at Level #0.
- * [/s2If]
- * [s2If user_cannot(123, access_s2member_level0)]
- * User ID# 123 CANNOT access content at Level #0.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param int|str $id A numeric WordPress® User ID.
- * @param str $capability A WordPress® Capability ID *( i.e. `access_s2member_level[0-9]+`, `access_s2member_ccap_music` )*.
- * @return bool True if the specific User does NOT have the specified Capability or Role, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("user_cannot"))
- {
- function user_cannot($id = FALSE, $capability = FALSE)
- {
- return (!user_can($id, $capability));
- }
- }
- /**
- * Conditional to determine if the current User does NOT have a specific Capability or Role.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Both Functions ————
- * ```
- * <!php
- * if(current_user_can("access_s2member_level0"))
- * echo 'You CAN access content protected at Level #0.';
- *
- * else if(current_user_cannot("access_s2member_level0"))
- * echo 'You CANNOT access content protected at Level #0.';
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If current_user_can(access_s2member_level0)]
- * You CAN access content protected at Level #0.
- * [/s2If]
- * [s2If current_user_cannot(access_s2member_level0)]
- * You CANNOT access content protected at Level #0.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param str $capability A WordPress® Capability ID *( i.e. `access_s2member_level[0-9]+`, `access_s2member_ccap_music` )*.
- * Or a Role ID *( i.e. `s2member_level[0-9]+`, `administrator`, `editor`, `author`, `contributor`, `subscriber` )*.
- * @return bool True if the current User does NOT have the specified Capability or Role, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("current_user_cannot"))
- {
- function current_user_cannot($capability = FALSE)
- {
- return (!current_user_can($capability));
- }
- }
- /**
- * Conditional to determine if the current User does NOT have a specific Capability or Role, on a specific Blog within a Multisite Network.
- *
- * Another function {@link http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()} already exists in the WordPress® core.
- *
- * ———— Code Sample Using Both Functions ————
- * ```
- * <!php
- * if(current_user_can_for_blog(5, "access_s2member_level0"))
- * echo 'You CAN access content protected at Level #0 (on Blog ID 5).';
- *
- * else if(current_user_cannot_for_blog(5, "access_s2member_level0"))
- * echo 'You CANNOT access content protected at Level #0 (on Blog ID 5).';
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If current_user_can_for_blog(5, access_s2member_level0)]
- * You CAN access content protected at Level #0 (on Blog ID 5).
- * [/s2If]
- * [s2If current_user_cannot_for_blog(5, access_s2member_level0)]
- * You CANNOT access content protected at Level #0 (on Blog ID 5).
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * ———— Membership Levels Provide Incremental Access ————
- *
- * o A Member with Level 4 access, will also be able to access Levels 0, 1, 2, 3.
- * o A Member with Level 3 access, will also be able to access Levels 0, 1, 2.
- * o A Member with Level 2 access, will also be able to access Levels 0, 1
- * o A Member with Level 1 access, will also be able to access Level 0.
- * o A Subscriber with Level 0 access, can ONLY access Level 0.
- * o A public Visitor will have NO access to protected content.
- *
- * WordPress® Subscribers are at Membership Level 0. If you're allowing Open Registration, Subscribers will be at Level 0 *(a Free Subscriber)*.
- * WordPress® Administrators, Editors, Authors, and Contributors have Level 4 access, with respect to s2Member.
- * All of their other {@link http://codex.wordpress.org/Roles_and_Capabilities Roles/Capabilities} are left untouched.
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param int|str $blog_id A WordPress® Blog ID *(must be numeric)*.
- * @param str $capability A WordPress® Capability ID *( i.e. `access_s2member_level[0-9]+`, `access_s2member_ccap_music` )*.
- * Or a Role ID *( i.e. `s2member_level[0-9]+`, `administrator`, `editor`, `author`, `contributor`, `subscriber` )*.
- * @return bool True if the current User does NOT have the specified Capability or Role, else false.
- *
- * @see s2Member\API_Functions\user_is()
- * @see s2Member\API_Functions\user_is_not()
- *
- * @see s2Member\API_Functions\current_user_is()
- * @see s2Member\API_Functions\current_user_is_not()
- * @see s2Member\API_Functions\current_user_is_for_blog()
- * @see s2Member\API_Functions\current_user_is_not_for_blog()
- *
- * @see s2Member\API_Functions\user_cannot()
- * @see s2Member\API_Functions\current_user_cannot()
- * @see s2Member\API_Functions\current_user_cannot_for_blog()
- *
- * @see http://codex.wordpress.org/Function_Reference/user_can user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can current_user_can()
- * @see http://codex.wordpress.org/Function_Reference/current_user_can_for_blog current_user_can_for_blog()
- */
- if(!function_exists("current_user_cannot_for_blog"))
- {
- function current_user_cannot_for_blog($blog_id = FALSE, $capability = FALSE)
- {
- return (!current_user_can_for_blog($blog_id, $capability));
- }
- }
- /**
- * Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is protected by s2Member;
- * without considering the current User's Role/Capabilites.
- *
- * ———— Extra Detail On Function Parameters ————
- *
- * **Parameter $what (int|str Optional).**
- * Defaults to the current $post ID when called from within {@link http://codex.wordpress.org/The_Loop The Loop}.
- * If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine.
- *
- * o If you pass in an ID, s2Member will check everything, including your configured URI Restrictions against the ID.
- * In other words, s2Member is capable of determining a URI based on the ID that you pass in.
- * So using an ID results in an all-inclusive scan against your configured Restrictions,
- * including any URI Restrictions that you may have configured.
- *
- * o If you pass in a URL or URI, s2Member will ONLY check URI Restrictions, because it has no ID to work with.
- * This is useful though. Some protected content is not associated with an ID. In those cases, URI Restrictions are all the matter.
- *
- * o Note: when passing in a URL or URI, the $type parameter must be set to `URI` or `uri`. Case insensitive.
- *
- * **Parameter $type (str Optional).**
- * One of `category`, `tag`, `post`, `page`, `singular` or `uri`. Defaults to `singular` *(i.e. a Post or Page)*.
- *
- * **Parameter $check_user (bool Optional).**
- * Consider the current User? Defaults to false.
- *
- * o In other words, by default, this Conditional function is only checking to see if the content is protected, and that's it.
- * o So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will.
- * o When $check_user is true, this function behaves like {@link s2Member\API_Functions\is_permitted_by_s2member()}.
- *
- * ———— Code Sample Using Function Parameters ————
- * ```
- * <!php
- * if(is_protected_by_s2member(123))
- * echo 'Post or Page ID #123 is protected by s2Member.';
- *
- * else if(is_protected_by_s2member(332, "tag"))
- * echo 'Tag ID #332 is protected by s2Member.';
- *
- * else if(is_protected_by_s2member(554, "category"))
- * echo 'Category ID #554 is protected by s2Member.';
- *
- * else if(is_protected_by_s2member("http://example.com/members/", "uri"))
- * echo 'This URL is protected by URI Restrictions.';
- *
- * else if(is_protected_by_s2member("/members/", "uri"))
- * echo 'This URI is protected by URI Restrictions.';
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If is_protected_by_s2member(123)]
- * Post or Page ID #123 is protected by s2Member.
- * [/s2If]
- * [s2If is_protected_by_s2member(332, tag)]
- * Tag ID #332 is protected by s2Member.
- * [/s2If]
- * [s2If is_protected_by_s2member(554, category)]
- * Category ID #554 is protected by s2Member.
- * [/s2If]
- * [s2If is_protected_by_s2member(http://example.com/members/, uri)]
- * This URL is protected by URI Restrictions.
- * [/s2If]
- * [s2If is_protected_by_s2member(/members/, uri)]
- * This URI is protected by URI Restrictions.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param int|str $what Optional. Defaults to the current $post ID when called from within {@link http://codex.wordpress.org/The_Loop The Loop}.
- * If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine.
- * @param str $type Optional. One of `category`, `tag`, `post`, `page`, `singular` or `uri`. Defaults to `singular` *(i.e. a Post or Page)*.
- * @param bool $check_user Optional. Consider the current User? Defaults to false.
- * @return array|bool A non-empty array *(meaning true)*, or false if the content is not protected *(i.e. available publicly)*.
- * When/if content IS protected, the return array will include one of these keys ``["s2member_(level|sp|ccap)_req"]``
- * indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the content.
- * In other words, the reason why it's protected; based on your s2Member configuration.
- *
- * @see s2Member\API_Functions\is_protected_by_s2member()
- * @see s2Member\API_Functions\is_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_category_protected_by_s2member()
- * @see s2Member\API_Functions\is_category_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_tag_protected_by_s2member()
- * @see s2Member\API_Functions\is_tag_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_post_protected_by_s2member()
- * @see s2Member\API_Functions\is_post_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_page_protected_by_s2member()
- * @see s2Member\API_Functions\is_page_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_uri_protected_by_s2member()
- * @see s2Member\API_Functions\is_uri_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\attach_s2member_query_filters()
- * @see s2Member\API_Functions\detach_s2member_query_filters()
- */
- if(!function_exists("is_protected_by_s2member"))
- {
- function is_protected_by_s2member($what = FALSE, $type = FALSE, $check_user = FALSE)
- {
- global /* Global reference to $post in The Loop. */ $post;
- $what = ($what) ? $what : ((is_object($post) && $post->ID) ? $post->ID : false);
- $type = ($type) ? strtolower($type) : "singular";
- if($type === "category" && ($array = c_ws_plugin__s2member_catgs_sp::check_specific_catg_level_access($what, $check_user)))
- return /* A non-empty array with ["s2member_level_req"]. */ $array;
- else if($type === "tag" && ($array = c_ws_plugin__s2member_ptags_sp::check_specific_ptag_level_access($what, $check_user)))
- return /* A non-empty array with ["s2member_level_req"]. */ $array;
- else if(($type === "post" || $type === "singular") && ($array = c_ws_plugin__s2member_posts_sp::check_specific_post_level_access($what, $check_user)))
- return /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */ $array;
- else if(($type === "page" || $type === "singular") && ($array = c_ws_plugin__s2member_pages_sp::check_specific_page_level_access($what, $check_user)))
- return /* A non-empty array with ["s2member_(level|sp|ccap)_req"]. */$array;
- else if($type === "uri" && ($array = c_ws_plugin__s2member_ruris_sp::check_specific_ruri_level_access($what, $check_user)))
- return /* A non-empty array with ["s2member_level_req"]. */ $array;
- return false;
- }
- }
- /**
- * Conditional to determine if a specific Category, Tag, Post, Page, URL or URI is permitted by s2Member,
- * with consideration given to the current User's Role/Capabilites.
- *
- * This function is similar to {@link s2Member\API_Functions\is_protected_by_s2member()}, except this function considers the current User's Role/Capabilites.
- * Also, this function does NOT return the array like {@link s2Member\API_Functions\is_protected_by_s2member()} does; it only returns true|false.
- *
- * ———— Extra Detail On Function Parameters ————
- *
- * **Parameter $what (int|str Optional).**
- * Defaults to the current $post ID when called from within {@link http://codex.wordpress.org/The_Loop The Loop}.
- * If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine.
- *
- * o If you pass in an ID, s2Member will check everything, including your configured URI Restrictions against the ID.
- * In other words, s2Member is capable of determining a URI based on the ID that you pass in.
- * So using an ID results in an all-inclusive scan against your configured Restrictions,
- * including any URI Restrictions that you may have configured.
- *
- * o If you pass in a URL or URI, s2Member will ONLY check URI Restrictions, because it has no ID to work with.
- * This is useful though. Some protected content is not associated with an ID. In those cases, URI Restrictions are all the matter.
- *
- * o Note: when passing in a URL or URI, the $type parameter must be set to `URI` or `uri`. Case insensitive.
- *
- * **Parameter $type (str Optional).**
- * One of `category`, `tag`, `post`, `page`, `singular` or `uri`. Defaults to `singular` *(i.e. a Post or Page)*.
- *
- * ———— Code Sample Using Function Parameters ————
- * ```
- * <!php
- * if(is_permitted_by_s2member(123))
- * echo 'Post or Page ID #123 is permitted by s2Member.';
- *
- * else if(is_permitted_by_s2member(332, "tag"))
- * echo 'Tag ID #332 is permitted by s2Member.';
- *
- * else if(is_permitted_by_s2member(554, "category"))
- * echo 'Category ID #554 is permitted by s2Member.';
- *
- * else if(is_permitted_by_s2member("http://example.com/members/", "uri"))
- * echo 'This URL is permitted by s2Member.';
- *
- * else if(is_permitted_by_s2member("/members/", "uri"))
- * echo 'This URI is permitted by s2Member.';
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If is_permitted_by_s2member(123)]
- * Post or Page ID #123 is permitted by s2Member.
- * [/s2If]
- * [s2If is_permitted_by_s2member(332, tag)]
- * Tag ID #332 is permitted by s2Member.
- * [/s2If]
- * [s2If is_permitted_by_s2member(554, category)]
- * Category ID #554 is permitted by s2Member.
- * [/s2If]
- * [s2If is_permitted_by_s2member(http://example.com/members/, uri)]
- * This URL is permitted by s2Member.
- * [/s2If]
- * [s2If is_permitted_by_s2member(/members/, uri)]
- * This URI is permitted by s2Member.
- * [/s2If]
- * ```
- * *but please note, `else if()` logic is not possible with `[s2If /]`.*
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param int|str $what Optional. Defaults to the current $post ID when called from within {@link http://codex.wordpress.org/The_Loop The Loop}.
- * If passed in, this should be a WordPress® Category ID, Tag ID, Post ID, or Page ID. Or a full URL. A URI is also fine.
- * @param str $type Optional. One of `category`, `tag`, `post`, `page`, `singular` or `uri`. Defaults to `singular` *(i.e. a Post or Page)*.
- * @return bool True if the current User IS permitted, else false if the content is NOT available to the current User;
- * based on your configuration of s2Member, and based on the current User's Role/Capabilities.
- *
- * @see s2Member\API_Functions\is_protected_by_s2member()
- * @see s2Member\API_Functions\is_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_category_protected_by_s2member()
- * @see s2Member\API_Functions\is_category_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_tag_protected_by_s2member()
- * @see s2Member\API_Functions\is_tag_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_post_protected_by_s2member()
- * @see s2Member\API_Functions\is_post_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_page_protected_by_s2member()
- * @see s2Member\API_Functions\is_page_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_uri_protected_by_s2member()
- * @see s2Member\API_Functions\is_uri_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\attach_s2member_query_filters()
- * @see s2Member\API_Functions\detach_s2member_query_filters()
- */
- if(!function_exists("is_permitted_by_s2member"))
- {
- function is_permitted_by_s2member($what = FALSE, $type = FALSE)
- {
- global /* Global reference to $post in The Loop. */ $post;
- $what = ($what) ? $what : ((is_object($post) && $post->ID) ? $post->ID : false);
- $type = ($type) ? strtolower($type) : "singular";
- if($type === "category" && c_ws_plugin__s2member_catgs_sp::check_specific_catg_level_access($what, true))
- return false;
- else if($type === "tag" && c_ws_plugin__s2member_ptags_sp::check_specific_ptag_level_access($what, true))
- return false;
- else if(($type === "post" || $type === "singular") && c_ws_plugin__s2member_posts_sp::check_specific_post_level_access($what, true))
- return false;
- else if(($type === "page" || $type === "singular") && c_ws_plugin__s2member_pages_sp::check_specific_page_level_access($what, true))
- return false;
- else if($type === "uri" && c_ws_plugin__s2member_ruris_sp::check_specific_ruri_level_access($what, true))
- return false;
- return true;
- }
- }
- /**
- * Conditional to determine if a specific Category is protected by s2Member;
- * without considering the current User's Role/Capabilites.
- *
- * ———— Extra Detail On Function Parameters ————
- *
- * **Parameter $cat_id (int Required).** This should be a WordPress® Category ID.
- *
- * o s2Member will check everything, including your configured URI Restrictions against the ID.
- * In other words, s2Member is capable of determining a URI based on the ID that you pass in.
- * So using an ID results in an all-inclusive scan against your configured Restrictions,
- * including any URI Restrictions that you may have configured.
- *
- * **Parameter $check_user (bool Optional).**
- * Consider the current User? Defaults to false.
- *
- * o In other words, by default, this Conditional function is only checking to see if the Category is protected, and that's it.
- * o So this function does NOT consider the current User's Role or Capabilities. If you set $check_user to true, it will.
- * o When $check_user is true, this function behaves like {@link s2Member\API_Functions\is_category_permitted_by_s2member()}.
- *
- * ———— Code Sample Using Function Parameters ————
- * ```
- * <!php
- * if(is_category_protected_by_s2member(123))
- * echo 'Category ID #123 is protected by s2Member.';
- * !>
- * ```
- * ———— Shortcode Conditional Equivalent ————
- * ```
- * [s2If is_category_protected_by_s2member(123)]
- * Category ID #123 is protected by s2Member.
- * [/s2If]
- * ```
- *
- * @package s2Member\API_Functions
- * @since 3.5
- *
- * @param int $cat_id Required. This should be a WordPress® Category ID.
- * @param bool $check_user Optional. Consider the current User? Defaults to false.
- * @return array|bool A non-empty array *(meaning true)*, or false if the Category is not protected *(i.e. available publicly)*.
- * When/if the Category IS protected, the return array will include one of these keys ``["s2member_(level|sp|ccap)_req"]``
- * indicating the Level #, Specific Post/Page ID #, or Custom Capability required to access the Category.
- * In other words, the reason why it's protected; based on your s2Member configuration.
- *
- * @see s2Member\API_Functions\is_protected_by_s2member()
- * @see s2Member\API_Functions\is_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_category_protected_by_s2member()
- * @see s2Member\API_Functions\is_category_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_tag_protected_by_s2member()
- * @see s2Member\API_Functions\is_tag_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_post_protected_by_s2member()
- * @see s2Member\API_Functions\is_post_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_page_protected_by_s2member()
- * @see s2Member\API_Functions\is_page_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\is_uri_protected_by_s2member()
- * @see s2Member\API_Functions\is_uri_permitted_by_s2member()
- *
- * @see s2Member\API_Functions\attach_s2member_query_filters()
- * @see s2Member\API_Functions\detach_s2member_query_filters()
- */
- if(!function_exists("is_category_protected_by_s2member"))
- {
- function is_category_protected_by_s2member($cat_id = FALSE, $check_user = FALSE)
- {
- if($cat_id && ($array = c_ws_plugin__s2member_catgs_sp::check_specific_catg_level_access($cat_id, $check_user)))
- return /* A non-empty array with ["s2member_level_req"]. */ $array;
- return false;
- }
- }
- /**
- * Conditional to determine if a specific Category is permitted by s2Member,
- * with consideration given to the current User's Role/Capabilites.
- *
- * This function is similar to {@link s2Member\API_Functions\is_category_protected_by_s2member()}, except this function considers the current User's Role/Capabilites.
- * Also, this function does NOT return the array like {@link s2Member\API_Functions\is_category_protected_by_s2member()} does; it only returns true|false.
- *
- * ———— Extra Detail On Function Parameters ————
- *
- * **Parameter $cat_id (int Required).** This should be a WordPress® Category ID.
- *
- * o s2Member will check everything, including your configured URI Restrictions against the ID.
- * In other words, s2Member is capable of determining a URI based on the ID that you pass in.
- * So using an ID results in an all-inclusive scan against your configured Restrictions,
- * including any URI Restrictions that you may have configured.
- *
- * ———— Code Sample Using Function Parameters ————
- * ```
- * <!php
- * if(is_category_permitted_by_s2member(123))
- * echo 'Category ID #123 is permitted by s2Member.';
- * !>
- * ```
- *