Category_Loop implements Registerable, Standard_Service
This class provides unified category protection or unlocking by combining global and category-level access control.
Handles both global protection (excluding uncategorized documents when global protection is active) and category-level protection (excluding documents in protected categories) in a single tax_query to avoid conflicts and improve performance.
Runs at priority 10 to establish baseline protection before other query modifications.
Tags
Interfaces, Classes and Traits
- Registerable
- Standard_Service
Table of Contents
- $global_visibility : mixed
- $hidden_category_ids : mixed
- $unlocked_categories : mixed
- __construct() : mixed
- Constructor.
- aioseo_exclude_protected_categories() : array<string|int, mixed>
- Exclude hidden categories from All in One SEO Pack sitemap.
- get_excluded_category_ids() : array<string|int, mixed>
- Get all excluded category IDs (both global inherited and category-level protected).
- get_terms_args() : array<string|int, mixed>
- Adjust get_terms_args to exclude protected categories.
- limit_folder_data_column_categories() : array<string|int, WP_Term>
- Limit the categories in the folder data column to those that are not hidden.
- limit_search_filter_categories() : array<string|int, mixed>
- Filter the get_terms_args for the DLP Search Filter widget.
- limit_submission_categories() : array<string|int, mixed>
- Limit frontend submission categories if limit categories setting is on
- on_category_meta_updated() : mixed
- Clear cache when category visibility metadata is updated.
- protect_documents_in_loop() : mixed
- Protect documents in the loop using unified global and category protection.
- protect_shortcode_query() : array<string|int, mixed>
- Protect documents in shortcodes.
- register() : mixed
- {@inheritdoc}
- update_category_counts() : array<string|int, mixed>
- Update the category counts to reflect hidden ones.
- wpseo_exclude_protected_terms() : string
- Exclude hidden categories from WPSEO sitemap.
- build_protection_tax_query() : array<string|int, mixed>
- Build the unified protection tax query combining global and category protection.
- build_tax_query() : array<string|int, mixed>
- Build the unified taxonomy query that handles both global and category protection.
- get_category_hidden_ids() : array<string|int, mixed>
- Get category IDs that are explicitly protected at the category level.
- get_global_hidden_category_ids() : array<string|int, mixed>
- Get category IDs that should be excluded due to global protection inheritance.
- is_document_query() : bool
- Determine if this is a document-related query.
- unlocked_categories() : array<string|int, mixed>
- Set and retrieve unlocked category ids.
Properties
$global_visibility
private
mixed
$global_visibility
Tags
$hidden_category_ids
private
mixed
$hidden_category_ids
= false
Tags
$unlocked_categories
private
mixed
$unlocked_categories
= false
Tags
Methods
__construct()
Constructor.
public
__construct() : mixed
Tags
Return values
mixed —aioseo_exclude_protected_categories()
Exclude hidden categories from All in One SEO Pack sitemap.
public
aioseo_exclude_protected_categories(array<string|int, mixed> $ids, string $type) : array<string|int, mixed>
Parameters
- $ids : array<string|int, mixed>
-
The IDs of the documents to exclude.
- $type : string
-
The type of the sitemap.
Tags
Return values
array<string|int, mixed> —The IDs of the documents to exclude.
get_excluded_category_ids()
Get all excluded category IDs (both global inherited and category-level protected).
public
get_excluded_category_ids() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_terms_args()
Adjust get_terms_args to exclude protected categories.
public
get_terms_args(array<string|int, mixed> $args, array<string|int, mixed> $taxonomies) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed>
- $taxonomies : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —limit_folder_data_column_categories()
Limit the categories in the folder data column to those that are not hidden.
public
limit_folder_data_column_categories(array<string|int, WP_Term> $terms) : array<string|int, WP_Term>
Parameters
- $terms : array<string|int, WP_Term>
Tags
Return values
array<string|int, WP_Term> —limit_search_filter_categories()
Filter the get_terms_args for the DLP Search Filter widget.
public
limit_search_filter_categories(array<string|int, mixed> $terms, string $taxonomy, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $terms : array<string|int, mixed>
- $taxonomy : string
- $args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —limit_submission_categories()
Limit frontend submission categories if limit categories setting is on
public
limit_submission_categories(array<string|int, WP_Term> $terms, string $taxonomy) : array<string|int, mixed>
Parameters
- $terms : array<string|int, WP_Term>
- $taxonomy : string
Tags
Return values
array<string|int, mixed> —on_category_meta_updated()
Clear cache when category visibility metadata is updated.
public
on_category_meta_updated(int $meta_id, int $object_id, string $meta_key, mixed $meta_value) : mixed
Parameters
- $meta_id : int
-
ID of updated metadata entry.
- $object_id : int
-
ID of the object metadata is for.
- $meta_key : string
-
Metadata key.
- $meta_value : mixed
-
Metadata value.
Tags
Return values
mixed —protect_documents_in_loop()
Protect documents in the loop using unified global and category protection.
public
protect_documents_in_loop(WP_Query $query) : mixed
Parameters
- $query : WP_Query
Tags
Return values
mixed —protect_shortcode_query()
Protect documents in shortcodes.
public
protect_shortcode_query(array<string|int, mixed> $query_args) : array<string|int, mixed>
Parameters
- $query_args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —register()
{@inheritdoc}
public
register() : mixed
Tags
Return values
mixed —update_category_counts()
Update the category counts to reflect hidden ones.
public
update_category_counts(array<string|int, mixed> $terms, array<string|int, mixed> $taxonomies, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $terms : array<string|int, mixed>
- $taxonomies : array<string|int, mixed>
- $args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —wpseo_exclude_protected_terms()
Exclude hidden categories from WPSEO sitemap.
public
wpseo_exclude_protected_terms(string $url, string $type, object $data_object) : string
Parameters
- $url : string
- $type : string
- $data_object : object
Tags
Return values
string —build_protection_tax_query()
Build the unified protection tax query combining global and category protection.
private
build_protection_tax_query() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —build_tax_query()
Build the unified taxonomy query that handles both global and category protection.
private
build_tax_query(array<string|int, mixed> $query_args) : array<string|int, mixed>
Parameters
- $query_args : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_category_hidden_ids()
Get category IDs that are explicitly protected at the category level.
private
get_category_hidden_ids() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —get_global_hidden_category_ids()
Get category IDs that should be excluded due to global protection inheritance.
private
get_global_hidden_category_ids() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —is_document_query()
Determine if this is a document-related query.
private
is_document_query(WP_Query $query) : bool
Parameters
- $query : WP_Query
-
The WordPress query object
Tags
Return values
bool —True if this is a document query
unlocked_categories()
Set and retrieve unlocked category ids.
private
unlocked_categories() : array<string|int, mixed>