Categories
Wordpress

Changes to execute-pings.php

In my disagreement with the powers-that-be of the WordPress creators and coders, I expressed the need for Trackbacks to take precedence over Pingbacks. They marked my trac ticket as WONTFIX so I did it myself.

I simply rearranged the order in which the pings are sent putting trackbacks before pingbacks:
<?php
require_once('../wp-config.php');
// Do Enclosures
while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
do_enclose($enclosure->post_content, $enclosure->ID);
}
// Do Trackbacks
$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status != 'draft'");
if ( is_array($trackbacks) ) {
foreach ( $trackbacks as $trackback ) {
do_trackbacks($trackback->ID);
}
}
// Do pingbacks
while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
$wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
pingback($ping->post_content, $ping->ID);
}
?>

It seems to be working and it makes much more sense this way.

You can download the updated file here.

You may then test this out by using this post. If you include a trackback and a ping back the trackback will be sent out first ensuring its reception.

This post is considered “Open Trackback” with no time limits.

8 replies on “Changes to execute-pings.php”

[…] This morning I was on his site reading this post, “Changes to execute-pings.php” and I thought I’d try his fix. This involved changing the execute-pings.php as one might surmise, and I did so, then uploaded it to overwrite the old file. I then put it to the test by trackbacking to “third world county“. Yesterday I sent a trackback to David’s Friday OTA–more later post and it showed as a ping. The one I sent for the test to the same post showed as a trackback as it should have. Smart kitty […]

It’s probably my fault because I copied the code and WordPress took out the opening <?php (as it should). I fixed my posts to include it. Sorry for the mixup.

I’m going to post a copy for download.

Wiiiiizzzz Zooooom!…

Wow! Has anybody noticed how much faster WordPress 2.0.5 – Ronan is? Pages are opening up nice and fast compared to the previous versions. It's making my site appear faster anyway.  Just thought I'd ask.  yo can all go back to doing w…

Comments are closed.