feat(search-ordering): allow removing posts from custom search results#4327
Open
faisalahammad wants to merge 1 commit into
Open
feat(search-ordering): allow removing posts from custom search results#4327faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Fixes 10up#4245 - Adds excludedPosts tracking in the Custom Search Results UI. - Persists excluded post IDs in ep-pointer post meta. - Filters excluded posts from the final search results query. - Adds PHPUnit tests for save, filter, and search-term change behaviors.
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
Added ability to remove individual posts from a custom search result.
Excluded posts are now stored and filtered out from the final search results for that query.
Fixes #4245
Changes
Frontend (
assets/js/ordering/pointers.js)Before:
After:
Why: Differentiates between custom-added results (should be excluded) and reordered defaults (should be returned to original position).
Backend (
includes/classes/Feature/SearchOrdering/SearchOrdering.php)Before:
After:
Why: Persists the exclusion list per custom search result and applies it to query results.
Tests (
tests/php/features/TestSearchOrdering.php)Added three new PHPUnit tests:
testSavePostWithExcludedPoststestPostsResultsFiltersExcludedPoststestExcludedPostsClearedOnSearchTermChangeTesting
Test 1: Exclude a post from a custom search result
Result: The excluded post does not appear in the search results.
Test 2: Automated tests pass
Run
composer run test --filter TestSearchOrdering.Result: All tests pass.