Properties

$term_id

$term_id : 

Type

$visibility

$visibility : 

Type

$passwords

$passwords : 

Type

$roles

$roles : 

Type

$users

$users : 

Type

$ancestors

$ancestors : 

Type

Methods

__construct()

__construct(  $term_id) 

Parameters

$term_id

ancestors()

ancestors() : array

Get the ancestors for this category as an array of WC_PPC_Category_Visibility objects.

Returns

array —

The array of ancestors.

check_password()

check_password(string  $password, boolean  $check_ancestors = true) : boolean|integer

Checks if the supplied password is valid for this category. If the password is valid, it returns the term_id (an integer) for the category the password is valid for.

Parameters

string $password

The password to check

boolean $check_ancestors

Whether to check passwords against ancestor categories as well.

Returns

boolean|integer —

The term ID the password is valid for, or false if not valid.

has_protection()

has_protection() : boolean

Does this category have password, role or user protection?

Returns

boolean —

true if protected

has_password_protection()

has_password_protection() : boolean

Does this category have password protection?

Returns

boolean —

true if password protected

has_role_protection()

has_role_protection() : boolean

Does this category have role protection?

Returns

boolean —

true if role protected

has_user_protection()

has_user_protection() : boolean

Does this category have user protection?

Returns

boolean —

true if user protected

has_private_protection()

has_private_protection() : boolean

Does this category have private protection?

Returns

boolean —

true if private protection set

is_unlocked()

is_unlocked() : boolean

Is this category unlocked by password, role, user, or for private access?

Returns

boolean —

true if unlocked.

is_unlocked_by_password()

is_unlocked_by_password() : boolean

Is this category unlocked by password?

Returns

boolean —

true if password protected and the correct password has been entered.

is_unlocked_by_role()

is_unlocked_by_role() : boolean

Is this category unlocked by role?

Returns

boolean —

true if role protected and the current user has one of the required roles.

is_unlocked_by_user()

is_unlocked_by_user() : boolean

Is this category unlocked by the current user?

Returns

boolean —

true if user protected and the current user is allowed access.

is_unlocked_for_private_access()

is_unlocked_for_private_access() : boolean

Is this category private and unlocked by the current user?

Returns

boolean —

true if unlocked for private access.

is_public()

is_public(boolean  $check_ancestors = false) : boolean

Is this category public?

If $check_ancestors is true, and this category is public, all ancestor categories will also be checked. If any are not public, then this function returns false.

Parameters

boolean $check_ancestors

Whether the check the ancestors as well.

Returns

boolean —

true if public.

is_protected()

is_protected(boolean  $check_ancestors = false) : boolean

Is this category protected? 'Protected' can mean a password is required, or the category is locked to specific roles or users.

This function will return false for private categories, and there is a separate function (is_private) to check for private level access.

If $check_ancestors is true, and this category is not protected, its ancestor categories will also be checked. The function halts once the first protected ancestor is found. *

Parameters

boolean $check_ancestors

Whether to check the ancestor categories as well (if any).

Returns

boolean —

true if this category is protected.

is_password_protected()

is_password_protected(boolean  $check_ancestors = false) : boolean

Is this category password protected?

If $check_ancestors is true, and this category is not password protected, the ancestors will also be checked. The function halts once the first password protected ancestor is found.

Parameters

boolean $check_ancestors

Whether to check the ancestor categories as well (if any).

Returns

boolean —

true if this category is password protected.

is_role_protected()

is_role_protected(boolean  $check_ancestors = false) : boolean

Is this category protected by user role?

Parameters

boolean $check_ancestors

Whether to check the ancestor categories as well (if any).

Returns

boolean —

true if this category is role protected.

is_user_protected()

is_user_protected(boolean  $check_ancestors = false) : boolean

Is this category protected by user (i.e. only specific users have access)?

Parameters

boolean $check_ancestors

Whether to check the ancestor categories as well (if any).

Returns

boolean —

true if this category is user protected.

is_private()

is_private(boolean  $check_ancestors = false) : boolean

Is this category private? A private category is one that can only be viewed by users with the 'read_private_products' capability.

If $check_ancestors is true, and this category is not private, its ancestor categories will also be checked. The function halts once the first private ancestor is found.

Parameters

boolean $check_ancestors

Whether to check the ancestors as well.

Returns

boolean —

true if private.

correct_password_entered()

correct_password_entered() : boolean

Returns true if this category has had the correct password entered by the current user. The category password cookie is checked, and if it matches any one of the passwords for this category, then it returns true, otherwise returns false.

Returns

boolean —

true if the correct password has been entered.

current_user_allowed_by_role()

current_user_allowed_by_role() 

current_user_allowed_by_id()

current_user_allowed_by_id() 

current_user_allowed_private_access()

current_user_allowed_private_access()