#10: implement support for protecting posts with category-based recursive restriction#12
Conversation
michaeltech
commented
Apr 21, 2026
- extend protection logic to support posts
- implement recursive restriction via categories and subcategories
- keep feature optional via filter (no UI changes)
- align behavior with existing page protection
…rsive restriction - extend protection logic to support posts - implement recursive restriction via categories and subcategories - keep feature optional via filter (no UI changes) - align behavior with existing page protection
…rsive restriction
| if ( $term instanceof WP_Term && ! is_wp_error( $term ) ) { | ||
| $all[] = (int) $term->term_id; | ||
| } | ||
| $children = get_term_children( $root_id, 'category' ); |
There was a problem hiding this comment.
@michaeltech - rather than looping over children one by one, would it possible to fetch them in single query to prevent N+1 queries?
There was a problem hiding this comment.
@michaeltech - after further research, this isn't actually N+1 query problem because of WP's own caching mechanism. These changes could be reverted, sorry for trouble.
27ce995 to
49a2c3a
Compare
|
Thank you for your feedback. |
| if ( ! is_array( $not_in ) ) { | ||
| $not_in = array(); | ||
| } | ||
| $existing_not_in = array_map( 'intval', $not_in ); |
There was a problem hiding this comment.
@michaeltech - there could separate function for this piece of code, since there's another almost identical logic in floauth_get_extranet_restricted_category_term_ids function.
There was a problem hiding this comment.
@michaeltech - floauth_get_extranet_restricted_category_root_ids could use newly implemented floauth_extranet_normalize_positive_ids function as well.
There was a problem hiding this comment.
@jrajamaki - I updated floauth_get_extranet_restricted_category_root_ids() through floauth_extranet_normalize_positive_ids() so filtered root IDs use the same sanitization as elsewhere (positive ints, uniqueness) and duplicate logic is removed.