Utility functions for WooCommerce Protected Categories.
is_protected(array|\Barn2\Plugin\WC_Protected_Categories\Category_Visibility $categories): boolean|string
Determines whether the supplied category or categories are protected.
Checks the supplied categories including all ancestors of those categories (if any). Returns one of the following values:
The function will return false (i.e. not protected) if all categories including ancestors are public.
It also returns false if at least one protected category has been unlocked - e.g. the correct password has been entered, or the user has the required role (depending on the protection type). In this instance, the category is only considered 'unlocked' only if the there are no child categories of that category which are protected by another means.
The function will always return false (i.e. unlocked) if at least one category is unlocked, regardless of the other categories supplied, even if the other categories are protected.
If two or more protected categories are found, or if one protected category has multiple types of protection, the function will return the first type of protection found, in the following order of precedence: password, private, user, role. This can be controlled using the 'wc_ppc_category_protection_priority_order' filter.
The category or array of Category_Visibility objects to check.
false if not protected, otherwise 'password', 'private', 'user' or 'role' to denote the protection type.
sanitize_whitespace_for_autop(string $text): string
Removes any new line characters and long whitespace sequences (2 or more) from HTML output so that wpautop doesn't mess up the formatting.
The text to sanitize.
The sanitized text, which can be passed safely to wpautop.