Add block editor block as a Query Loop variation#212
Open
jeherve wants to merge 12 commits into
Open
Conversation
Set up webpack build pipeline via @wordpress/scripts with pinned dependency versions. Add node_modules/ and build/ to gitignore, build artifacts to phpcs excludes, and dist excludes.
Add a public static method for building date queries, shared between the widget and the new block. Uses wp_timezone() for consistent timezone handling. Add WP_REST_Request stub to test bootstrap and build_date_query tests to QueryTest.
Test init hook registration, maybe_add_query_filter namespace matching and idempotency, filter_query_vars with exact/non-exact/empty context, and filter_rest_query with and without parameters.
Group all @wordpress/* dependencies so they get updated together in a single PR.
Register the Block class on plugin load. Add changelog entry for the new block editor integration.
d811775 to
093d984
Compare
The plugin is no longer just a widget — update the short description, long description, installation instructions, and tags to reference the new block editor support alongside the legacy widget.
Set isLink: true on the core/post-title inner block so titles in the "Posts On This Day" variation are clickable out of the box.
Mention the block alongside the legacy widget, update install instructions to include npm build step, and replace WorDBless reference with Brain Monkey.
The block should always query posts, so post type shouldn't be a user-configurable option in the block settings.
Register query_loop_block_query_vars directly in init() instead of conditionally via pre_render_block. Inner blocks render before the parent's pre_render_block fires, so the filter was being added too late for core/post-template to use it. Also apply the date filter to the re-query in maybe_inject_year_headings, since build_query_vars_from_query_block() only extracts core's known query properties and skips our custom yearsBack/exactMatch attributes.
The core/query block defaults inherit to true, which makes the post-template use the global WP_Query instead of building a custom one. On singular pages this means only the page's own post is returned. Use render_block_data to override inherit to false for our namespace so our date-based query always runs via query_loop_block_query_vars.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
query_loop_block_query_varsandrest_post_queryto inject date-based queries.core/post-templateoutput to group posts by year with configurable heading levels.build_date_query()static method from the Query class for shared use between widget and block.@wordpress/*npm dependencies to exact versions and adds Renovate grouping.Fixes #7.
Test plan
composer phpunitand verify all 16 tests pass.composer phpcs:lintand verify no violations.npm run buildand verify the JS builds without errors.