Skip to content

Commit

Permalink
Add filter around fetch link suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Oct 22, 2021
1 parent 630db5d commit 64bc7ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/core-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@wordpress/data": "file:../data",
"@wordpress/deprecated": "file:../deprecated",
"@wordpress/element": "file:../element",
"@wordpress/hooks": "file:../hooks",
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
"@wordpress/is-shallow-equal": "file:../is-shallow-equal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';
import { applyFilters } from '@wordpress/hooks';
import { decodeEntities } from '@wordpress/html-entities';
import { __ } from '@wordpress/i18n';

Expand Down Expand Up @@ -154,7 +155,12 @@ const fetchLinkSuggestions = async (
}

return Promise.all( queries ).then( ( results ) => {
return results
const filteredResults = applyFilters(
'editor.fetchLink.suggestions',
results,
search
);
return filteredResults
.reduce(
( accumulator, current ) => accumulator.concat( current ), //flatten list
[]
Expand Down

0 comments on commit 64bc7ae

Please sign in to comment.