Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




trackback [ WordPress Function ]

trackback ( $trackback_url, $title, $excerpt, $ID )
Parameters:
  • (string) $trackback_url URL to send trackbacks.
  • (string) $title Title of post.
  • (string) $excerpt Excerpt of post.
  • (int) $ID Post ID.
Uses:
  • $wpdb
Returns:
  • (mixed) Database query from update.
Defined at:



Send a Trackback.

Updates database when sending trackback to prevent duplicates.

Source


<?php
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) );
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics