Enhanced query filter blocks with new display types#25
Enhanced query filter blocks with new display types#25thomasnavarro wants to merge 2 commits intohumanmade:mainfrom
Conversation
… 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.
…in taxonomy render
|
Any chance of getting this merged? |
goldenapples
left a comment
There was a problem hiding this comment.
I've also been wanting to use this feature, so I gave it an initial review. The feature itself looks great to me and I'd like to see it merged.
I see a couple things to update first:
- The whitespace shouldn't be changing in all the PHP files. There's not currently a PHP coding standard in the project, but for consistency it should follow HM or WordPress coding standards
- There have been 3 point releases since this PR was opened, and it doesn't apply cleanly on
mainanymore. We'll have to freshen up the branch and resolve conflicts. - I don't think the wp-env environment should be in this same PR, though it it really cool to have. I'd like to merge that separately to better preserve a clean history
I'm happy to take on these updates and get the feature merged, unless anyone sees other issues with it.
| <label class="wp-block-query-filter-post-type__label wp-block-query-filter__label<?php echo $attributes['showLabel'] ? '' : ' screen-reader-text' ?>" for="<?php echo esc_attr( $id ); ?>"> | ||
| <?php echo esc_html( $attributes['label'] ?? $taxonomy->label ); ?> | ||
| <div <?php echo get_block_wrapper_attributes(['class' => 'wp-block-query-filter']); ?> data-wp-interactive="query-filter" data-wp-context="{}"> | ||
| <label class="wp-block-query-filter-post-type__label wp-block-query-filter__label<?php echo $attributes['showLabel'] ? '' : ' screen-reader-text' ?>" for="<?php echo esc_attr($id); ?>"> |
There was a problem hiding this comment.
This class name is updated (from 'post-type' to 'taxonomy') in the src but not here, we'll need to check in the built files.
| add_action( 'pre_get_posts', __NAMESPACE__ . '\\pre_get_posts_transpose_query_vars' ); | ||
| add_filter( 'block_type_metadata', __NAMESPACE__ . '\\filter_block_type_metadata', 10 ); | ||
| add_action( 'init', __NAMESPACE__ . '\\register_blocks' ); | ||
| add_action( 'enqueue_block_assets', __NAMESPACE__ . '\\action_wp_enqueue_scripts' ); |
There was a problem hiding this comment.
It doesn't look like this function should be getting removed here, but also this is dead code that's been removed from main so it shouldn't show up in the diff.
| $values = explode(',', $value); | ||
| $values = array_map('trim', $values); | ||
| $values = array_filter($values); |
There was a problem hiding this comment.
This would be simpler with wp_parse_list:
| $values = explode(',', $value); | |
| $values = array_map('trim', $values); | |
| $values = array_filter($values); | |
| $values = wp_parse_list($value); |
| ?> | ||
| <?php foreach ($terms as $term) : ?> | ||
| <?php | ||
| $is_checked = in_array($term->slug, $selected_terms); |
There was a problem hiding this comment.
May as well pass strict: true here to pass common lint standards.
| $is_checked = in_array($term->slug, $selected_terms); | |
| $is_checked = in_array($term->slug, $selected_terms, true); |
| @@ -0,0 +1,3 @@ | |||
| { | |||
| "plugins": [ "." ] | |||
| } | |||
There was a problem hiding this comment.
Not at all opposed to adding this, but it should really be a separate PR.
Originally part of #25, extracted while I'm reworking that PR.
|
I've rebased this onto the latest |
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:
displayTypeandlayoutDirectionto 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:
Editor improvements:
Miscellaneous updates:
.wp-env.jsonconfiguration file to simplify local development setup.