WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#41825 closed enhancement

wp_link_query not applied if method finds nothing — at Initial Version

Reported by: msebel Owned by:
Milestone: 4.9 Priority: normal
Severity: normal Version: 3.7
Component: Editor Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description

In class-wp-editor.php
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-editor.php

We have the public static function wp_link_query, which allows tos earch for internal links. There's also the possibility to alter the query 'wp_link_query_args' and to filter the results with 'wp_link_query'

Now the problem is, if a plugin *adds* additional search results in wp_link_query, that is possible, but if the WordPress Query itself finds nothign we return false. It would be nice to apply the filter there as well, as a plugin may be able to find more results, even if WP_Query finds nothing.

So I'd propose to change

if ( ! $get_posts->post_count )

return false;

to

if ( ! $get_posts->post_count )

return apply_filters( 'wp_link_query', false, $query );

Behold, as I'm planning to discuss and maybe change this with @swissspidy at a contributor day tomorrow in bern switzerland.

Change History (1)

@mitraval192
3 years ago

Added patch

Note: See TracTickets for help on using tickets.