Skip to content

Preserve filters when searching on events page#1674

Open
dd32 wants to merge 3 commits into
WordPress:productionfrom
dd32:fix/claude/1167-search-preserves-filters
Open

Preserve filters when searching on events page#1674
dd32 wants to merge 3 commits into
WordPress:productionfrom
dd32:fix/claude/1167-search-preserves-filters

Conversation

@dd32

@dd32 dd32 commented Mar 24, 2026

Copy link
Copy Markdown
Member

Summary

  • The search block on the events page submitted to the default WordPress search results URL, losing any active filters and leaving the events page
  • Fixes this by using the render_block_core/search filter to change the search form action URL and inject active filter values as hidden inputs
  • Includes integration tests for the new functionality

Test plan

  • Go to the events page and apply a filter (e.g. Format: Online)
  • Enter a search term and submit
  • Verify the search results still show on the events page (not the WordPress search results page)
  • Verify the filter is still active after searching
  • Search without any filters active - verify it still works and stays on the events page

Fixes #1167

Generated with Claude Code

@dd32 dd32 added [Component] Events Widget Related to the core dashboard upcoming events widget, syncing process, or Official WP Events plugin [Type] Bug labels Mar 24, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dd32 dd32 force-pushed the fix/claude/1167-search-preserves-filters branch from cf6bf2b to dabb3c8 Compare April 29, 2026 06:27
Copilot AI review requested due to automatic review settings April 29, 2026 06:27

Copilot AI 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.

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/search to 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.

Comment thread public_html/wp-content/themes/wporg-events-2023/inc/events-query.php Outdated
Comment thread public_html/wp-content/themes/wporg-events-2023/tests/test-events-query.php Outdated
Comment thread phpunit-bootstrap.php Outdated
dd32 and others added 2 commits May 12, 2026 15:57
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Component] Events Widget Related to the core dashboard upcoming events widget, syncing process, or Official WP Events plugin [Type] Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Events: Searching removes existing filters.

2 participants