-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3382 from 10up/filter-epas-request-args
Add filter to autosuggest fetch config
- Loading branch information
Showing
4 changed files
with
70 additions
and
5 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
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
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
26 changes: 26 additions & 0 deletions
26
tests/cypress/wordpress-files/test-plugins/custom-headers-for-autosuggest.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,26 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Custom Header for Autosuggest | ||
* Description: Customizes the headers using fetchOptions. | ||
* Version: 1.0.0 | ||
* Author: 10up Inc. | ||
* License: GPLv2 or later | ||
* | ||
* @package ElasticPress_Tests_E2e | ||
*/ | ||
|
||
add_action( | ||
'wp_enqueue_scripts', | ||
function() { | ||
wp_add_inline_script( | ||
'elasticpress-autosuggest', | ||
"const epAutosuggestFetchOptions = (fetchOptions) => { | ||
fetchOptions.headers['X-ElasticPress-Request-ID'] = 'CustomRequestId123'; | ||
return fetchOptions; | ||
}; | ||
wp.hooks.addFilter('ep.Autosuggest.fetchOptions', 'myTheme/epAutosuggestFetchOptions', epAutosuggestFetchOptions);", | ||
'before' | ||
); | ||
}, | ||
11 | ||
); |