WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 20 months ago

#18042 closed enhancement

Need a way to override wp_link_query() — at Version 23

Reported by: philfreo Owned by:
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.2
Component: Editor Keywords: has-patch commit
Focuses: Cc:

Description (last modified by DrewAPicture)

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.

Change History (25)

comment:1 @nacin4 years ago

  • Type changed from defect (bug) to enhancement

We definitely need hooks here. +1

comment:2 @bainternet4 years ago

  • Cc bainternet added
  • Version changed from 3.2 to 3.2.1

comment:3 @dd324 years ago

  • Version changed from 3.2.1 to 3.2

The version field is used to track when a bug was first reported.

comment:4 @bainternet4 years ago

@dd32yea sorry about that,


anyway +1 for either hooks or pluggable.

comment:5 @hereswhatidid4 years ago

Definitely +1 for a hook or pluggable. Need a way to add items other than just published posts to the list of available items to link to.

comment:6 @pavelevap4 years ago

  • Cc pavelevap@… added

comment:7 @nohalfpixels3 years ago

is there a date set for updating this feature?

comment:8 @DrewAPicture3 years ago

  • Cc xoodrew@… added

#19718 closed as duplicate

comment:9 @heinrichgeps3 years ago

Definitely +1 for a hook or pluggable.

comment:10 @rliverman3 years ago

Agreed, unfortunately looks like a core hack for the time being...ugh. +1 for hook or pluggable.

comment:12 @mordauk3 years ago

  • Cc pippin@… added

comment:13 @ocean903 years ago

  • Keywords needs-patch added

Duplicate: #21861

comment:14 @CoenJacobs3 years ago

  • Cc coenjacobs@… added

comment:15 @goldenapples3 years ago

  • Cc goldenapplesdesign@… added

@goldenapples3 years ago

Since #21861 was closed, I've moved @CoenJacobs's patch from that ticket here. Also added a filter on the return value so plugins can rearrange the order that custom post types appear in the returned array.

comment:16 @goldenapples3 years ago

  • Keywords has-patch added; needs-patch removed

comment:17 @bradyvercher3 years ago

  • Cc brady@… added

A hook would definitely be nice here.

I developed a plugin a few months ago (Better Internal Link Search), without realizing this ticket existed, to modify the results and ended up having to filter the AJAX request and recreate a bit of wp_link_query(). The plugin adds a whole lot of useful features and improvements and can be easily extended for anyone that needs this functionality right away. If any of it looks useful for core, I'm happy to help learn how to contribute.

comment:18 @SergeyBiryukov2 years ago

#23241 was marked as a duplicate.

comment:19 @SergeyBiryukov2 years ago

  • Component changed from Plugins to Editor
  • Milestone changed from Awaiting Review to 3.6

comment:20 @lumpysimon2 years ago

  • Cc piemanek@… added

comment:21 @lumpysimon2 years ago

+1 for this making it into 3.6

@SergeyBiryukov2 years ago

comment:22 @SergeyBiryukov2 years ago

18042.2.diff passes $query to the resulting filter too.

comment:23 @DrewAPicture2 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.