Skip to content

Commit

Permalink
Update rule checks using explicit contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
danieliser committed Aug 13, 2024
1 parent 6e40f6e commit bd895b6
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 33 deletions.
17 changes: 16 additions & 1 deletion inc/functions/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,24 @@ function reset_query_context() {
* 3. Alternate query posts are checked in the_posts or pre_get_posts & ! $wp_query->is_main_query().
* 4. Blocks are checked in the content_control/should_hide_block filter.
*
* switch ( current_query_context() ) {
* // Catch all known contexts.
* case 'main':
* case 'main/blocks':
* case 'main/posts':
* case 'posts':
* case 'blocks':
* case 'restapi/posts':
* case 'restapi':
* case 'restapi/terms':
* case 'terms':
* case 'unknown':
* return false;
* }
*
* @param \WP_Query|null $query Query object.
*
* @return string 'main', 'main/posts', 'posts', 'main/blocks', 'blocks`.
* @return 'main'|'main/posts'|'posts'|'main/blocks'|'blocks'|'restapi'|'restapi/posts'|'restapi/terms'|'terms'|'unknown'
*/
function current_query_context( $query = null ) {
if ( ! global_is_empty( 'current_query_context' ) ) {
Expand Down
Loading

0 comments on commit bd895b6

Please sign in to comment.