trackback()
Sends a Trackback.
Updates database when sending trackback to prevent duplicates.
Хуков нет.
Возвращает
int|false|null
. Database query from update.
Использование
trackback( $trackback_url, $title, $excerpt, $post_id );
- $trackback_url(строка) (обязательный)
- URL to send trackbacks.
- $title(строка) (обязательный)
- Title of post.
- $excerpt(строка) (обязательный)
- Excerpt of post.
- $post_id(int) (обязательный)
- Post ID.
Заметки
- Global. wpdb. $wpdb WordPress database abstraction object.
Список изменений
С версии 0.71 | Введена. |
Код trackback() trackback WP 6.6.1
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 ) ); }