[wp-trac] [WordPress Trac] #18042: Need a way to override wp_link_query()

WordPress Trac noreply at wordpress.org
Sun May 5 04:16:50 UTC 2013


#18042: Need a way to override wp_link_query()
-------------------------+------------------
 Reporter:  philfreo     |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  3.6
Component:  Editor       |     Version:  3.2
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------
Description changed by DrewAPicture:

Old description:

> In previous versions of WordPress, we were able to write a plugin which
> called add_filter on "tiny_mce_before_init" and then we were able to
> specify "external_link_list_url" which we gave it a list of all of the
> URLs on our site (we primarily linked to non-WordPress URLs on our site
> from this tool). Then when an author created a Link in the post tool the
> little popup would include a dropdown of all of the URLs/page titles that
> we specified.
>
> In WordPress 3.2 you have the new fancy "link to existing content"
> feature in the popup.
>
> The problem is that there is NO hook, filter, or pluggable function
> whatsoever to allow you to override the functionality of this.
>
> I needed to make the search results box return a list of pages (urls and
> titles) that I specified from a different database. In order order to do
> that I had to re-create the entire wp_link_query() function from wp-
> admin/includes/internal-linking.php to make it return search results from
> my own database. I put that function into a Plugin (to keep it out of
> Core) but then I had to hack core to rename wp_link_query() to
> wp_link_query_ORIGINAL() to get it to use my function and not the
> existing one.
>
> Either wp_link_query() needs to be a pluggable function or there need to
> be hooks that let you completely replace how it works.

New description:

 In previous versions of !WordPress, we were able to write a plugin which
 called add_filter on `tiny_mce_before_init` and then we were able to
 specify `external_link_list_url` which we gave it a list of all of the
 URLs on our site (we primarily linked to non-WordPress URLs on our site
 from this tool). Then when an author created a Link in the post tool the
 little popup would include a dropdown of all of the URLs/page titles that
 we specified.

 In !WordPress 3.2 you have the new fancy "link to existing content"
 feature in the popup.

 The problem is that there is NO hook, filter, or pluggable function
 whatsoever to allow you to override the functionality of this.

 I needed to make the search results box return a list of pages (urls and
 titles) that I specified from a different database. In order order to do
 that I had to re-create the entire `wp_link_query()` function from wp-
 admin/includes/internal-linking.php to make it return search results from
 my own database. I put that function into a Plugin (to keep it out of
 Core) but then I had to hack core to rename `wp_link_query()` to
 `wp_link_query_ORIGINAL()` to get it to use my function and not the
 existing one.

 Either `wp_link_query()` needs to be a pluggable function or there need to
 be hooks that let you completely replace how it works.

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18042#comment:23>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list