Advertisements

trackback

Definition:
function trackback($trackback_url, $title, $excerpt, $ID) {}

Send a Trackback.
Updates database when sending trackback to prevent duplicates.

Parameters

  • string $trackback_url: URL to send trackbacks.
  • string $title: Title of post.
  • string $excerpt: Excerpt of post.
  • int $ID: Post ID.

Return values

returns:Database query from update.

Source code

function trackback($trackback_url, $title, $excerpt, $ID) {

	global $wpdb;



	if ( empty($trackback_url) )

		return;



	$options = array();

	$options['timeout'] = 4;

	$options['body'] = array(

		'title' => $title,

		'url' => get_permalink($ID),

		'blog_name' => get_option('blogname'),

		'excerpt' => $excerpt

	);



	$response = wp_remote_post($trackback_url, $options);



	if ( is_wp_error( $response ) )

		return;



	$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) );

	return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) );

}

3069

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: