wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



trackback › WordPress Function

Seit0.71
Veraltetn/v
trackback ( $trackback_url, $title, $excerpt, $post_id )
Parameter: (4)
  • (string) $trackback_url URL to send trackbacks.
    Erforderlich: Ja
  • (string) $title Title of post.
    Erforderlich: Ja
  • (string) $excerpt Excerpt of post.
    Erforderlich: Ja
  • (int) $post_id Post ID.
    Erforderlich: Ja
Gibt zurück:
  • (int|false|void) Database query from update.
Definiert in:
Codex:

Sends a Trackback.

Updates database when sending trackback to prevent duplicates.


Quellcode

function trackback( $trackback_url, $title, $excerpt, $post_id ) {
	global $wpdb;

	if ( empty( $trackback_url ) ) {
		return;
	}

	$options            = array();
	$options['timeout'] = 10;
	$options['body']    = array(
		'title'     => $title,
		'url'       => get_permalink( $post_id ),
		'blog_name' => get_option( 'blogname' ),
		'excerpt'   => $excerpt,
	);

	$response = wp_safe_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, $post_id ) );
	return $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $post_id ) );
}