Skip to content

Enhanced query filter blocks [rebased and updated]#39

Merged
kadamwhite merged 13 commits into
mainfrom
enhanced-query-filter-blocks-updated
Jun 23, 2026
Merged

Enhanced query filter blocks [rebased and updated]#39
kadamwhite merged 13 commits into
mainfrom
enhanced-query-filter-blocks-updated

Conversation

@goldenapples

@goldenapples goldenapples commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

See #25 - this is the same branch, just cleaned up with phpcbf to follow the formatting standards of this project.

Original PR description:

This pull request enhances the query filter blocks for post types and taxonomies by adding support for multiple display types (dropdown, radio, and checkbox) and layout directions (vertical and horizontal). It also includes styling updates and adjusts rendering logic to accommodate the new features.

Enhancements to query filter blocks:

Functional improvements

  • Added new attributes displayType and layoutDirection to allow customization of the display format (dropdown, radio, or checkbox) and layout orientation (vertical or horizontal) for both post type and taxonomy filters.

Styling updates

  • Enhanced CSS to support the new layout options, including horizontal and vertical orientations for radio and checkbox groups.

Editor improvements

  • Modified JavaScript files to integrate the new attributes into the block editor, allowing users to select display type and layout direction via the block settings panel.

@goldenapples goldenapples force-pushed the enhanced-query-filter-blocks-updated branch 3 times, most recently from 167000c to 2ee049c Compare March 4, 2026 21:14
Thomas Navarro and others added 3 commits March 4, 2026 16:16
… direction

- Updated package.json to include @wordpress/env as a dev dependency.
- Added new attributes `displayType` and `layoutDirection` to block.json for post-type and taxonomy blocks.
- Modified the Edit component for post-type and taxonomy blocks to include SelectControl for display type and ToggleGroupControl for layout direction.
- Implemented conditional rendering for select, radio, and checkbox inputs based on the selected display type.
- Updated render.php files for post-type and taxonomy blocks to handle new display type and layout direction attributes.
- Added styles for radio and checkbox groups in style-index.css to support vertical and horizontal layouts.
- refactor: Remove shared styles registration and update label classes in taxonomy render

Build changes to render files

@kadamwhite kadamwhite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch looks sensible and I didn't see any blocking issues while reviewing, :shipit: !

Only called out a few areas where we could conceivably clean up apparently-duplicated UI and options code, and asked about whether the boolean tax query logic should be more explicitly spelled out in a comment.

Note: have not tested locally.

Comment thread inc/namespace.php Outdated
Comment thread src/post-type/edit.js
Comment thread src/post-type/edit.js
Comment thread src/taxonomy/edit.js
Comment thread build/post-type/block.json Outdated
…ne post_type key sanitization

In advanced query loop, if you selected multiple post types you would get no results because we were searching for a literal post type named "post,page".
Within the sanitization logic, we were most of the way there but post types use sanitize_key on their name so this brings the input values closer in line with how a post type slug is stored in the DB
@kadamwhite

Copy link
Copy Markdown
Contributor

I've resolved merge conflicts with main after bringing in the latest base branch, and fixed a few small bugs I noticed while testing this:

  • After applying sanitization in Fix flagged PHPCS throughout codebase #43, non-ASCII (i.e. URL-encoded) term slugs would not properly trigger the checked() or selected() checks when rendering the current taxonomy filter options since they were inconsistently decoded versus the DB options. We now URL-decode both the source and target values in a consistent way to ensure we match the selected terms in all modes.
  • When multiple post types were selected in checkbox mode, we were trying to literally match for a post type named e.g. post,page rather than either post OR page. I've added a guard to split the post type value into an array before passing to WP_Query so that we get results in any selected post type, rather than seeing NO results as soon as you check a second post type.

@goldenapples goldenapples left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates look good, thank you for picking this up @kadamwhite !

@kadamwhite kadamwhite merged commit 7d8b401 into main Jun 23, 2026
1 check passed
@kadamwhite kadamwhite deleted the enhanced-query-filter-blocks-updated branch June 23, 2026 20:51
@kadamwhite kadamwhite mentioned this pull request Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants