wppaste
WordPress

twentyten_comment( WP_Comment $comment, array $args, int $depth )

Since
Twenty Ten 1.0
Source
wp-content/themes/twentyten/functions.php:468
Template for comments and pingbacks.

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

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
9–110

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 137.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • optionoption read or writeget_option()one call below twentyten_comment()
  • hookthird-party callbacksapply_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.

WhenInstructionsCalls it makes
always9–18none
always26–34_e(), comment_author_link(), __(), edit_comment_link()
always102–110comment_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

PHPCompiledExecutedBranchesNotes
8.6-dev1379–1107
8.51379–1107
8.41379–11071 fewer instruction than PHP 8.3
8.31389–1117
8.21389–11171 more instruction than PHP 8.1
8.11379–11571 fewer instruction than PHP 7.4
7.413810–1167

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

Show all 15

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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.