Category_Visibility
This class represents a WooCommerce category with various functions to test its visibility.
Tags
Table of Contents
- $ancestors : mixed
- $hide_prices : mixed
- $roles : mixed
- $term_id : mixed
- $visibility : mixed
- __construct() : mixed
- Constructor.
- ancestors() : array<string|int, mixed>
- Get the ancestors for this category as an array of Category_Visibility objects.
- get_hide_prices() : string
- Get hide price until login option.
- get_roles() : array<string|int, mixed>
- Get roles.
- get_term_id() : int
- Get term ID.
- get_visibility() : string
- Get visibility.
- has_protection() : bool
- Does this category have protection?
- has_wholesale_exclusion() : bool
- Does this category have role protection?
- has_wholesale_protection() : bool
- Does this category have role protection?
- is_exclusion_unlocked() : bool
- Is this category unlocked by role?
- is_price_hidden() : bool
- Is the price of products belonging to this category hidden?
- is_protected() : bool
- Is this category protected?
- is_protection_unlocked() : bool
- Is this category unlocked by role?
- is_public() : bool
- Is this category public?
- is_role_protected() : bool
- Is this category protected by user role?
- is_unlocked() : bool
- Is this category unlocked by password, role, user, or for private access?
- current_user_allowed_by_role() : bool
- Determine if the current user is allowed by orle.
Properties
$ancestors
private
mixed
$ancestors
= null
Tags
$hide_prices
private
mixed
$hide_prices
= ''
Tags
$roles
private
mixed
$roles
= []
Tags
$term_id
private
mixed
$term_id
Tags
$visibility
private
mixed
$visibility
= 'public'
Tags
Methods
__construct()
Constructor.
public
__construct(string|int $term_id) : mixed
Parameters
- $term_id : string|int
Tags
Return values
mixed —ancestors()
Get the ancestors for this category as an array of Category_Visibility objects.
public
ancestors() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of Category_Visibility objects or an empty array if no ancestors.
get_hide_prices()
Get hide price until login option.
public
get_hide_prices() : string
Tags
Return values
string —get_roles()
Get roles.
public
get_roles() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_term_id()
Get term ID.
public
get_term_id() : int
Tags
Return values
int —get_visibility()
Get visibility.
public
get_visibility() : string
Tags
Return values
string —has_protection()
Does this category have protection?
public
has_protection() : bool
Tags
Return values
bool —true if protected
has_wholesale_exclusion()
Does this category have role protection?
public
has_wholesale_exclusion() : bool
Tags
Return values
bool —true if role protected
has_wholesale_protection()
Does this category have role protection?
public
has_wholesale_protection() : bool
Tags
Return values
bool —true if role protected
is_exclusion_unlocked()
Is this category unlocked by role?
public
is_exclusion_unlocked() : bool
Tags
Return values
bool —true if role protected and the current user has one of the required roles.
is_price_hidden()
Is the price of products belonging to this category hidden?
public
is_price_hidden([bool $check_ancestors = false ]) : bool
If $check_ancestors is true, and this category is set to global (i.e. empty string), all ancestor categories will also be checked. If any are set to 'hide', then this function returns true.
Parameters
- $check_ancestors : bool = false
-
Whether the check the ancestors as well.
Tags
Return values
bool —true if price is hidden.
is_protected()
Is this category protected?
public
is_protected([bool $check_ancestors = false ]) : bool
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
- $check_ancestors : bool = false
-
Whether to check the ancestor categories as well (if any).
Tags
Return values
bool —true if this category is protected.
is_protection_unlocked()
Is this category unlocked by role?
public
is_protection_unlocked() : bool
Tags
Return values
bool —true if role protected and the current user has one of the required roles.
is_public()
Is this category public?
public
is_public([bool $check_ancestors = false ]) : bool
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
- $check_ancestors : bool = false
-
Whether the check the ancestors as well.
Tags
Return values
bool —true if public.
is_role_protected()
Is this category protected by user role?
public
is_role_protected([bool $check_ancestors = false ]) : bool
Parameters
- $check_ancestors : bool = false
-
Whether to check the ancestor categories as well (if any).
Tags
Return values
bool —true if this category is role protected.
is_unlocked()
Is this category unlocked by password, role, user, or for private access?
public
is_unlocked() : bool
Tags
Return values
bool —true if unlocked.
current_user_allowed_by_role()
Determine if the current user is allowed by orle.
private
current_user_allowed_by_role() : bool