wppaste
WordPress

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

Since
Twenty Eleven 1.0
Source
wp-content/themes/twentyeleven/functions.php:766
Template for comments and pingbacks.

Description

To override this walker in a child theme without modifying the comments template simply create your own twentyeleven_comment(), and that function will be used instead.

Used as a callback by wp_list_comments() for displaying the comments.

Compatibility

WordPress
since Twenty Eleven 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 twentyeleven_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
28–126

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

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

  • hookthird-party callbacksapply_filters()one call below twentyeleven_comment()
  • optionoption read or writeget_option()one call below twentyeleven_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 · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost twentyeleven_comment() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always28–32_e(), comment_author_link(), __(), edit_comment_link()
always117–126comment_class(), comment_ID(), comment_ID(), get_avatar(), __(), get_comment_author_link(), get_comment_link(), esc_url(), get_comment_time(), __(), get_comment_date(), get_comment_time(), sprintf(), sprintf(), printf(), __(), edit_comment_link(), wp_get_current_commenter(), __(), comment_text(), __(), reply_text(), array_merge()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev15028–1266
8.515028–1266
8.415028–12661 fewer instruction than PHP 8.3
8.315128–1276
8.215128–1276
8.115128–12761 fewer instruction than PHP 7.4
7.415229–1286

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 twentyeleven_comment( $comment, $args, $depth ) {		$GLOBALS['comment'] = $comment;		switch ( $comment->comment_type ) :			case 'pingback':			case 'trackback':				?>		<li class="post pingback">		<p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>				<?php				break;			default:				?>		<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">		<article id="comment-<?php comment_ID(); ?>" class="comment">			<footer class="comment-meta">				<div class="comment-author vcard">					<?php					$avatar_size = 68; 					if ( '0' !== $comment->comment_parent ) {						$avatar_size = 39;					} 					echo get_avatar( $comment, $avatar_size ); 					printf(						/* translators: 1: Comment author, 2: Date and time. */						__( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),						sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),						sprintf(							'<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',							esc_url( get_comment_link( $comment->comment_ID ) ),							get_comment_time( 'c' ),							/* translators: 1: Date, 2: Time. */							sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )						)					);					?> 					<?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>					</div><!-- .comment-author .vcard --> 					<?php					$commenter = wp_get_current_commenter();					if ( $commenter['comment_author_email'] ) {						$moderation_note = __( 'Your comment is awaiting moderation.', 'twentyeleven' );					} else {						$moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.', 'twentyeleven' );					}					?> 					<?php if ( '0' === $comment->comment_approved ) : ?>					<em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>					<br />					<?php endif; ?> 				</footer> 				<div class="comment-content"><?php comment_text(); ?></div> 				<div class="reply">					<?php					comment_reply_link(						array_merge(							$args,							array(								'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ),								'depth'      => $depth,								'max_depth'  => $args['max_depth'],							)						)					);					?>				</div><!-- .reply -->			</article><!-- #comment-## --> 				<?php				break;		endswitch;	}

Changelog

Introduced in Twenty Eleven 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/twentyeleven/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.