twentyten_comment( WP_Comment $comment, array $args, int $depth )
- Since
- Twenty Ten 1.0
- Source
wp-content/themes/twentyten/functions.php:468
Description
To override this walker in a child theme without modifying the comments template simply create your own twentyten_comment(), and that function will be used instead.
Used as a callback by wp_list_comments() for displaying the comments.
Compatibility
- WordPress
- since Twenty Ten 1.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
$commentWP_Comment- The comment object.
$argsarray- An array of comment arguments. @see get_comment_reply_link()
$depthint- The depth of the comment.
Performance profile
How much work a call to twentyten_comment() 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
- Moderate
- Scaling
- Constant
- Instructions
- 9–110
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 137.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- optionoption read or write
get_option()one call below twentyten_comment() - hookthird-party callbacks
apply_filters()one call below twentyten_comment()
Further down the call graph this can also reach query, 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 twentyten_comment() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 9–18 | none |
| always | 26–34 | _e(), comment_author_link(), __(), edit_comment_link() |
| always | 102–110 | comment_class(), comment_ID(), comment_ID(), get_avatar(), __(), get_comment_author_link(), printf(), wp_get_current_commenter(), __(), get_comment_link(), esc_url(), __(), get_comment_date(), get_comment_time(), printf(), __(), edit_comment_link(), comment_text(), depth(), array_merge() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 137 | 9–110 | 7 | |
| 8.5 | 137 | 9–110 | 7 | |
| 8.4 | 137 | 9–110 | 7 | 1 fewer instruction than PHP 8.3 |
| 8.3 | 138 | 9–111 | 7 | |
| 8.2 | 138 | 9–111 | 7 | 1 more instruction than PHP 8.1 |
| 8.1 | 137 | 9–115 | 7 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 138 | 10–116 | 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.
Uses · 15
- comment_class()Generates semantic classes for each comment element.
- comment_ID()Displays the comment ID of the current comment.
- get_avatar()Retrieves the avatar `` tag for a user, email address, MD5 hash, comment, or post.
- __()Retrieves the translation of $text.
- get_comment_author_link()Retrieves the HTML link to the URL of the author of the current comment.
- wp_get_current_commenter()Gets current commenter's name, email, and URL.
- esc_url()Checks and cleans a URL.
- get_comment_link()Retrieves the link to a given comment.
- get_comment_date()Retrieves the comment date of the current comment.
- get_comment_time()Retrieves the comment time of the current comment.
- edit_comment_link()Displays the edit comment link with formatting.
- comment_text()Displays the text of the current comment.
Show all 15
- comment_reply_link()Displays the HTML content for reply to comment link.
- _e()Displays translated text.
- comment_author_link()Displays the HTML link to the URL of the author of the current comment.
Source code
function twentyten_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '': case 'comment': ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> <div id="comment-<?php comment_ID(); ?>"> <div class="comment-author vcard"> <?php echo get_avatar( $comment, 40 ); ?> <?php /* translators: %s: Author display name. */ printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?> </div><!-- .comment-author .vcard --> <?php $commenter = wp_get_current_commenter(); if ( $commenter['comment_author_email'] ) { $moderation_note = __( 'Your comment is awaiting moderation.', 'twentyten' ); } else { $moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.', 'twentyten' ); } ?> <?php if ( '0' === $comment->comment_approved ) : ?> <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em> <br /> <?php endif; ?> <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> <?php /* translators: 1: Date, 2: Time. */ printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?> </a> <?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?> </div><!-- .comment-meta .commentmetadata --> <div class="comment-body"><?php comment_text(); ?></div> <div class="reply"> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'], ) ) ); ?> </div><!-- .reply --> </div><!-- #comment-## --> <?php break; case 'pingback': case 'trackback': ?> <li class="post pingback"> <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p> <?php break; endswitch; }Changelog
Introduced in Twenty Ten 1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-content/themes/twentyten/functions.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.