Preserve filters when searching on events page#1674
Open
dd32 wants to merge 3 commits into
Open
Conversation
6 tasks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cf6bf2b to
dabb3c8
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the wporg-events-2023 theme so that submitting the Search block on event listing pages keeps users on the events page and preserves any active event filters by modifying the rendered search form output.
Changes:
- Hook into
render_block_core/searchto rewrite the search form action URL and inject active filter values as hidden inputs. - Add a new PHPUnit test suite and theme-specific test bootstrap for the events theme.
- Add integration tests covering hidden input injection and basic action URL rewriting behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| public_html/wp-content/themes/wporg-events-2023/inc/events-query.php | Adds a render filter for the Search block and implements hidden filter injection + form action rewriting. |
| public_html/wp-content/themes/wporg-events-2023/tests/test-events-query.php | Adds tests for the new search-form modification behavior. |
| public_html/wp-content/themes/wporg-events-2023/tests/bootstrap.php | Adds a theme test bootstrap to load the required theme code for tests. |
| phpunit.xml.dist | Registers a new PHPUnit testsuite for the events theme tests. |
| phpunit-bootstrap.php | Loads the events theme test bootstrap in the global PHPUnit bootstrap sequence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…-search-preserves-filters
- Add build_search_form_action_url() helper that never resolves to home_url(), so a search submitted from the search results page itself still lands on the events listing (the existing build_form_action_url() returned home_url() when is_search() was true, dropping subsequent searches off the events network). - Tighten test_form_action_url_is_updated to assert the exact action URL rather than any URL-shaped string, and add a regression test covering the is_search() bug. - Drop the @coversDefaultClass annotation (it pointed at a namespace) and qualify @Covers with the fully-qualified function name. - Strip the leading slash from the events-2023 bootstrap require so the path does not double up the trailing slash on SUT_WP_CONTENT_DIR. - Align the theme test bootstrap with the rest of the suite: hook muplugins_loaded and document the loader function. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
render_block_core/searchfilter to change the search form action URL and inject active filter values as hidden inputsTest plan
Fixes #1167
Generated with Claude Code