On this page
trackback( string $trackback_url, string $title, string $excerpt, int $ID ): int|false|void
Sends a Trackback.
Description
Updates database when sending trackback to prevent duplicates.
Parameters
$trackback_urlstring Required-
URL to send trackbacks.
$titlestring Required-
Title of post.
$excerptstring Required-
Excerpt of post.
$IDint Required-
Post ID.
Return
int|false|void Database query from update.
Source
File: wp-includes/comment.php. View all references
function trackback( $trackback_url, $title, $excerpt, $ID ) {
global $wpdb;
if ( empty( $trackback_url ) ) {
return;
}
$options = array();
$options['timeout'] = 10;
$options['body'] = array(
'title' => $title,
'url' => get_permalink( $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, $ID ) );
return $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID ) );
}
Related
Uses
| Uses | Description |
|---|---|
| wp_safe_remote_post() wp-includes/http.php | Retrieve the raw response from a safe HTTP request using the POST method. |
| wpdb::query() wp-includes/class-wpdb.php | Performs a database query, using current database connection. |
| get_permalink() wp-includes/link-template.php | Retrieves the full permalink for the current post or post ID. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
| wpdb::prepare() wp-includes/class-wpdb.php | Prepares a SQL query for safe execution. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Used By
| Used By | Description |
|---|---|
| trackback_url_list() wp-includes/post.php | Does trackbacks for a list of URLs. |
| do_trackbacks() wp-includes/comment.php | Performs trackbacks. |
Changelog
| Version | Description |
|---|---|
| 0.71 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/trackback