do_trackbacks( int|WP_Post $post ): void|false
- Since
- 1.5.0, 4.7.0
- Source
wp-includes/comment.php:3025
Compatibility
- WordPress
- since 4.7.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$postint|WP_Post- Post ID or object to do trackbacks on.
Return value
void|false- Returns false on failure.
Performance profile
How much work a call to do_trackbacks() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Expensive
- Scaling
- Scales with input
- Instructions
- 8–59
- Plugin surface
- 3 hooks
- Called by
- 1
Reaches an outbound HTTP request via wp_safe_remote_post().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 108.
Third-party callbacks on 'the_content', 'the_excerpt', 'the_title' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- querycontent query
get_post()called directly - hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()one call below do_trackbacks() - httpoutbound HTTP request
wp_safe_remote_post()one call below do_trackbacks()
Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 3 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost do_trackbacks() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 8 | get_post() |
empty($to_ping) | 27 | get_post(), get_to_ping(), get_pung(), ID() |
!empty($to_ping) | 51–59 | get_post(), get_to_ping(), get_pung(), apply_filters(), wp_html_excerpt(), apply_filters(), strip_tags() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 108 | 8–59 | 7 | |
| 8.5 | 108 | 8–59 | 7 | |
| 8.4 | 108 | 8–59 | 7 | 8 fewer instructions than PHP 8.3 |
| 8.3 | 116 | 8–62 | 7 | |
| 8.2 | 116 | 8–62 | 7 | |
| 8.1 | 116 | 8–62 | 7 | |
| 7.4 | 116 | 8–62 | 7 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 3
3 hooks fire while do_trackbacks() runs, in this order:
Uses · 6
- get_post()Retrieves post data given a post ID or post object.
- get_to_ping()Retrieves URLs that need to be pinged.
- get_pung()Retrieves URLs already pinged for a post.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_html_excerpt()Safely extracts not more than the first $count characters from HTML string.
- trackback()Sends a Trackback.
Used by · 1
- do_all_trackbacks()Performs all trackbacks.
Source code
function do_trackbacks( $post ) { global $wpdb; $post = get_post( $post ); if ( ! $post ) { return false; } $to_ping = get_to_ping( $post ); $pinged = get_pung( $post ); if ( empty( $to_ping ) ) { $wpdb->update( $wpdb->posts, array( 'to_ping' => '' ), array( 'ID' => $post->ID ) ); return; } if ( empty( $post->post_excerpt ) ) { /** This filter is documented in wp-includes/post-template.php */ $excerpt = apply_filters( 'the_content', $post->post_content, $post->ID ); } else { /** This filter is documented in wp-includes/post-template.php */ $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt ); } $excerpt = str_replace( ']]>', ']]>', $excerpt ); $excerpt = wp_html_excerpt( $excerpt, 252, '…' ); /** This filter is documented in wp-includes/post-template.php */ $post_title = apply_filters( 'the_title', $post->post_title, $post->ID ); $post_title = strip_tags( $post_title ); if ( $to_ping ) { foreach ( (array) $to_ping as $tb_ping ) { $tb_ping = trim( $tb_ping ); if ( ! in_array( $tb_ping, $pinged, true ) ) { trackback( $tb_ping, $post_title, $excerpt, $post->ID ); $pinged[] = $tb_ping; } else { $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post->ID ) ); } } }}Changelog
Introduced in 1.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$post can be a WP_Post object.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-includes/comment.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.