-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dbf6c6
commit 8a710d7
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
37 changes: 37 additions & 0 deletions
37
tests/cypress/wordpress-files/test-plugins/filter-instant-results-facet-terms.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Filter Instant Results Taxonomy Terms | ||
* Description: Filters the Instant Results taxonomy terms for test purposes. | ||
* Version: 1.0.0 | ||
* Author: 10up Inc. | ||
* License: GPLv2 or later | ||
* | ||
* @package ElasticPress_Tests_E2e | ||
*/ | ||
|
||
/** | ||
* Limit the Instant Results facet terms to only the "Classic" term. | ||
*/ | ||
add_action( | ||
'wp_footer', | ||
function (): void { | ||
?> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const filterCategoryTerms = (terms, taxonomyName) => { | ||
|
||
if (taxonomyName !== 'tax-category') { | ||
return terms; | ||
} | ||
|
||
// keep only Term Classic | ||
const filteredTerms = terms.filter(term => term.label === 'Classic'); | ||
return filteredTerms; | ||
} | ||
|
||
wp.hooks.addFilter('ep.InstantResults.facet.taxonomy.terms', 'ep-test', filterCategoryTerms); | ||
}); | ||
</script> | ||
<?php | ||
} | ||
); |