[wp-trac] [WordPress Trac] #41825: wp_link_query not applied if method finds nothing

WordPress Trac noreply at wordpress.org
Fri Sep 8 08:37:55 UTC 2017


#41825: wp_link_query not applied if method finds nothing
-------------------------+------------------------------
 Reporter:  msebel       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Editor       |     Version:  3.7
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------
Changes (by swissspidy):

 * version:  trunk => 3.7


Old 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.

New 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 to search
 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
 nothing 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.

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41825#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list