Opened 13 years ago
Closed 13 years ago
#18506 closed enhancement (fixed)
Filter to allow pingback URLs to be added (from custom fields, etc.)
Reported by: | alexkingorg | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | normal | Version: | 3.2.1 |
Component: | Pings/Trackbacks | Keywords: | 3.4-early has-patch |
Focuses: | Cc: |
Description
The current pingback code does not allow for this URL to be added to the pingback stack programatically - there are no filters to use. The attached patch allows URLs to be filtered into the list, before they are compared against the "pung" list. This means nothing else needs to change in the code flow, and the feature should "just work".
This would be useful in a number of scenarios, here is one:
plugin/theme stores a URL value as structured data in a custom field (post meta) for a link post. This URL is the focus of the post and should generate a pingback.
Example code that would use this filter:
function pingback_format_link_url($post_links, $post_id) { $url = get_post_meta($post_id, '_format_link_url', true); if (!empty($url) && !in_array($url, $post_links)) { $post_links[] = $url; } return $post_links; } add_filter('pre_ping_post_links', 'pingback_format_link_url', 10, 2);
Attachments (2)
Change History (14)
#1
@
13 years ago
While I'm all in favour of more flexibility, your use case suggestions seems slightly odd - what percentage of people would write a post that has another post as a particular focus, and not mention / link to that original post at some point in their new post?
#2
@
13 years ago
- Milestone changed from Awaiting Review to 3.3
Many sites can't or don't treat content as one big editable field. Use case makes sense to me.
#3
@
13 years ago
I suppose if you've got a CPT which doesn't make use of the Editor, then some other way of pinging another post does indeed make sense. +1.
#4
@
13 years ago
- Keywords 3.4-early added
- Milestone changed from 3.3 to Future Release
This sounds like a reasonable idea but at this point in the 3.3 cycle we need to focus on regressions and polish of the new features.
Making as a 3.4 candidate.
#5
@
13 years ago
I certainly understand the need to cut off new features to get a release out, but this is just adding a simple filter. Are you sure this can't be added in for 3.3?
FWIW, I've got a code that helps provide some admin UI for post formats that I've been hoping to share with the larger WP dev community that I've been waiting to release on getting this filter in core.
https://github.com/crowdfavorite/wp-post-formats
As there is no other hook that can be utilized, delaying this addition is effectively pushing this feature out a few more months (limiting the usefulness of formats).
#8
@
13 years ago
This filter should be enough, actually:
do_action_ref_array('pre_ping', array(&$post_links, &$pung));
We could then add $post_ID to that, like so:
do_action_ref_array('pre_ping', array(&$post_links, &$pung, $post_ID));
#9
@
13 years ago
Agreed, with the $post_ID added, that would be fine. I didn't know if it was preferable to change an existing hook or create a new one.
#10
@
13 years ago
- Milestone changed from Future Release to 3.4
- Owner set to nacin
- Status changed from new to accepted
add pre_ping_post_links filter