Indexed_Query_Protector implements Registerable, Premium_Service
Applies DLA access control to DVE indexed queries.
DVE's indexed query path bypasses WP_Query, so the standard Document_Loop and Category_Loop protectors don't fire. This class hooks into document_library_pro_query_constraints to add equivalent restrictions to both indexed queries and the WP_Query fallback.
Tags
Interfaces, Classes and Traits
- Registerable
- Premium_Service
Table of Contents
- $global_inherited_category_ids : array<string|int, int>|false
- Cached category IDs which inherit protection directly from the global setting.
- $global_visibility : Global_Visibility|null
- Cached global visibility instance.
- $hidden_document_ids : array<string|int, int>|false
- Cached hidden document IDs.
- $protected_category_ids : array<string|int, int>|false
- Cached protected category IDs.
- $unlocked_document_ids : array<string|int, int>|false
- Cached unlocked document IDs.
- $unlocked_protected_category_ids : array<string|int, int>|false
- Cached category IDs whose protection has been unlocked by the current user.
- add_access_control_constraints() : array<string|int, Query_Constraint>
- Add access control constraints to DataViews queries.
- bypass_legacy_protectors_for_data_views() : mixed
- Prevent legacy loop protectors from filtering DataViews-owned WP_Query calls.
- register() : mixed
- {@inheritdoc}
- remove_legacy_protection_tax_query() : array<string|int, mixed>
- Remove the legacy category protection tax query from DataViews queries.
- build_category_protection_constraint() : Query_Constraint|null
- Build category and global protection constraints.
- category_inherits_global_visibility() : bool
- Determine whether a category and all its ancestors inherit global visibility.
- get_global_inherited_category_ids() : array<string|int, int>
- Get category IDs whose effective visibility comes from global protection.
- get_global_visibility() : Global_Visibility
- Get the global visibility instance.
- get_hidden_document_ids() : array<string|int, int>
- Get document IDs that are hidden due to document-level protection.
- get_protected_category_ids() : array<string|int, int>
- Get category IDs that are protected at the category hierarchy level.
- get_unlocked_document_ids() : array<string|int, int>
- Get document IDs that have been unlocked by the current user.
- get_unlocked_protected_category_ids() : array<string|int, int>
- Get assigned category IDs whose category-level protection is unlocked.
- is_document_protected_for_index() : bool
- Determine document protection for indexed filtering without editor management shortcuts.
Properties
$global_inherited_category_ids
Cached category IDs which inherit protection directly from the global setting.
private
array<string|int, int>|false
$global_inherited_category_ids
= false
Tags
$global_visibility
Cached global visibility instance.
private
Global_Visibility|null
$global_visibility
= null
Tags
$hidden_document_ids
Cached hidden document IDs.
private
array<string|int, int>|false
$hidden_document_ids
= false
Tags
$protected_category_ids
Cached protected category IDs.
private
array<string|int, int>|false
$protected_category_ids
= false
Tags
$unlocked_document_ids
Cached unlocked document IDs.
private
array<string|int, int>|false
$unlocked_document_ids
= false
Tags
$unlocked_protected_category_ids
Cached category IDs whose protection has been unlocked by the current user.
private
array<string|int, int>|false
$unlocked_protected_category_ids
= false
Unlike public categories, these categories may override another locked category assigned to the same document.
Tags
Methods
add_access_control_constraints()
Add access control constraints to DataViews queries.
public
add_access_control_constraints(array<string|int, Query_Constraint> $constraints, object $query) : array<string|int, Query_Constraint>
Parameters
- $constraints : array<string|int, Query_Constraint>
-
Current query constraints.
- $query : object
-
The View_Query object.
Tags
Return values
array<string|int, Query_Constraint> —Modified query constraints.
bypass_legacy_protectors_for_data_views()
Prevent legacy loop protectors from filtering DataViews-owned WP_Query calls.
public
bypass_legacy_protectors_for_data_views(WP_Query $query) : mixed
Semantic constraints already authorize the fallback query and the indexed REST request. Legacy protectors must not apply a second restriction while DataViews hydrates the authorized results.
Parameters
- $query : WP_Query
-
Query instance.
Tags
Return values
mixed —register()
{@inheritdoc}
public
register() : mixed
Tags
Return values
mixed —remove_legacy_protection_tax_query()
Remove the legacy category protection tax query from DataViews queries.
public
remove_legacy_protection_tax_query(array<string|int, mixed> $query_args, object $query) : array<string|int, mixed>
Category_Loop adds its protection to the shared legacy query-args hook. DataViews applies the equivalent rule through semantic constraints, where it can be combined with document-owner overrides. Leave non-DataViews queries untouched so the legacy table retains its existing behavior.
Parameters
- $query_args : array<string|int, mixed>
-
Query arguments.
- $query : object
-
Query object.
Tags
Return values
array<string|int, mixed> —Modified query arguments.
build_category_protection_constraint()
Build category and global protection constraints.
private
build_category_protection_constraint() : Query_Constraint|null
Constraint truth table:
- P = category-level locked IDs.
- U = unlocked protected category IDs.
- G = category IDs which inherit global protection.
| global_protected | P empty | condition |
|---|---|---|
| yes | yes | EXISTS(category NOT IN G) |
| yes | no | EXISTS(category NOT IN G) AND (NOT EXISTS(P) OR EXISTS(U)) |
| no | yes | no clause (early return) |
| no | no | NOT EXISTS(P) OR EXISTS(U) |
The caller combines this with unlocked document IDs using ANY, then applies hidden document IDs with POST_NOT_IN.
Tags
Return values
Query_Constraint|null —Query constraint, or null when unrestricted.
category_inherits_global_visibility()
Determine whether a category and all its ancestors inherit global visibility.
private
category_inherits_global_visibility(object $category) : bool
Parameters
- $category : object
-
Category visibility object.
Tags
Return values
bool —get_global_inherited_category_ids()
Get category IDs whose effective visibility comes from global protection.
private
get_global_inherited_category_ids() : array<string|int, int>
Tags
Return values
array<string|int, int> —get_global_visibility()
Get the global visibility instance.
private
get_global_visibility() : Global_Visibility
Tags
Return values
Global_Visibility —get_hidden_document_ids()
Get document IDs that are hidden due to document-level protection.
private
get_hidden_document_ids() : array<string|int, int>
Mirrors Document_Loop::hidden_document_ids() logic.
Tags
Return values
array<string|int, int> —get_protected_category_ids()
Get category IDs that are protected at the category hierarchy level.
private
get_protected_category_ids() : array<string|int, int>
Categories whose protection comes only from the global setting are handled separately so an explicit public category can override global protection.
Tags
Return values
array<string|int, int> —get_unlocked_document_ids()
Get document IDs that have been unlocked by the current user.
private
get_unlocked_document_ids() : array<string|int, int>
Mirrors Document_Loop::unlocked_document_ids() logic.
Tags
Return values
array<string|int, int> —get_unlocked_protected_category_ids()
Get assigned category IDs whose category-level protection is unlocked.
private
get_unlocked_protected_category_ids() : array<string|int, int>
Public categories are deliberately excluded. The access-control contract allows one successfully unlocked protected category to grant access to a document assigned to multiple protected categories, but a public category must not bypass another category which remains locked.
Tags
Return values
array<string|int, int> —is_document_protected_for_index()
Determine document protection for indexed filtering without editor management shortcuts.
private
is_document_protected_for_index(Document_Visibility $document_visibility) : bool
Parameters
- $document_visibility : Document_Visibility
-
The document visibility object.