Make WordPress Core

Changeset 41346


Ignore:
Timestamp:
09/08/2017 02:02:43 PM (7 years ago)
Author:
swissspidy
Message:

Editor: In _WP_Editors::wp_link_query, allow filtering empty results.

Previously, it was not possible to hook into the wp_link_query filter to add custom entries when the
query returned no posts.

Props mitraval192, msebel.
Fixes #41825.

Location:
trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-editor.php

    r41152 r41346  
    16241624        $get_posts = new WP_Query;
    16251625        $posts = $get_posts->query( $query );
    1626         // Check if any posts were found.
    1627         if ( ! $get_posts->post_count )
    1628             return false;
    16291626
    16301627        // Build results.
     
    16661663         * @param array $query  An array of WP_Query arguments.
    16671664         */
    1668         return apply_filters( 'wp_link_query', $results, $query );
     1665        $results = apply_filters( 'wp_link_query', $results, $query );
     1666
     1667        return ! empty( $results ) ? $results : false;
    16691668    }
    16701669
Note: See TracChangeset for help on using the changeset viewer.