wppaste
WordPress

wp_comment_reply( int $position = 1, bool $checkbox = false, string $mode = 'single', bool $table_row = true )

Since
2.7.0
Source
wp-admin/includes/template.php:415
Outputs the in-line comment reply-to form in the Comments list table.

Compatibility

WordPress
since 2.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

$positionintoptional
The value of the 'position' input field. Default 1.Default: 1
$checkboxbooloptional
The value of the 'checkbox' input field. Default false.Default: false
$modestringoptional
If set to 'single', will use WP_Post_Comments_List_Table, otherwise WP_Comments_List_Table. Default 'single'.Default: 'single'
$table_rowbooloptional
Whether to use a table instead of a div element. Default true.Default: true

Performance profile

How much work a call to wp_comment_reply() 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
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
18–120

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

Plugin surface
1 hook

Third-party callbacks on 'wp_comment_reply' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly

Further down the call graph this can also reach option, cache, serialize, query 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 · 9 distinct outcomes

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

WhenInstructionsCalls it makes
!empty($content)18position()
empty($content) && !current_user_can()101–103position(), _e(), _e(), _e(), _e(), wp_editor(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), wp_admin_notice(), esc_attr(), wp_nonce_field(), current_user_can()
empty($content) && current_user_can()106–108position(), _e(), _e(), _e(), _e(), wp_editor(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), wp_admin_notice(), esc_attr(), wp_nonce_field(), current_user_can(), wp_nonce_field()
empty($content) && !current_user_can()106–108position(), ->get_column_count(), _e(), _e(), _e(), _e(), wp_editor(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), wp_admin_notice(), esc_attr(), wp_nonce_field(), current_user_can()
empty($content) && !current_user_can()107–110position(), _get_list_table(), _e(), _e(), _e(), _e(), wp_editor(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), wp_admin_notice(), esc_attr(), wp_nonce_field(), current_user_can()
empty($content) && current_user_can()111–113position(), ->get_column_count(), _e(), _e(), _e(), _e(), wp_editor(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), wp_admin_notice(), esc_attr(), wp_nonce_field(), current_user_can(), wp_nonce_field()
empty($content) && current_user_can()112–115position(), _get_list_table(), _e(), _e(), _e(), _e(), wp_editor(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), wp_admin_notice(), esc_attr(), wp_nonce_field(), current_user_can(), wp_nonce_field()
empty($content) && !current_user_can()112–115position(), _get_list_table(), ->get_column_count(), _e(), _e(), _e(), _e(), wp_editor(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), wp_admin_notice(), esc_attr(), wp_nonce_field(), current_user_can()
empty($content) && current_user_can()117–120position(), _get_list_table(), ->get_column_count(), _e(), _e(), _e(), _e(), wp_editor(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), wp_admin_notice(), esc_attr(), wp_nonce_field(), current_user_can(), wp_nonce_field()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 129 instructions, 18–120 executed per call, 7 branches. The work does not change between versions.

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 · 1

One hook fires while wp_comment_reply() runs, in this order:

  1. apply_filters( wp_comment_reply )filterline 432 (+17 into the body)

    Filters the in-line comment reply-to form output in the Comments list table.

Uses · 8

Used by · 1

Source code

function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) {	global $wp_list_table;	/**	 * Filters the in-line comment reply-to form output in the Comments	 * list table.	 *	 * Returning a non-empty value here will short-circuit display	 * of the in-line comment-reply form in the Comments list table,	 * echoing the returned value instead.	 *	 * @since 2.7.0	 *	 * @see wp_comment_reply()	 *	 * @param string $content The reply-to form content.	 * @param array  $args    An array of default args.	 */	$content = apply_filters(		'wp_comment_reply',		'',		array(			'position' => $position,			'checkbox' => $checkbox,			'mode'     => $mode,		)	); 	if ( ! empty( $content ) ) {		echo $content;		return;	} 	if ( ! $wp_list_table ) {		if ( 'single' === $mode ) {			$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );		} else {			$wp_list_table = _get_list_table( 'WP_Comments_List_Table' );		}	} 	?><form method="get">	<?php if ( $table_row ) : ?><table style="display:none;"><tbody id="com-reply"><tr id="replyrow" class="inline-edit-row" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange"><?php else : ?><div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;"><?php endif; ?>	<fieldset class="comment-reply">	<legend>		<span class="hidden" id="editlegend"><?php _e( 'Edit Comment' ); ?></span>		<span class="hidden" id="replyhead"><?php _e( 'Reply to Comment' ); ?></span>		<span class="hidden" id="addhead"><?php _e( 'Add Comment' ); ?></span>	</legend> 	<div id="replycontainer">	<label for="replycontent" class="screen-reader-text">		<?php		/* translators: Hidden accessibility text. */		_e( 'Comment' );		?>	</label>	<?php	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );	wp_editor(		'',		'replycontent',		array(			'media_buttons' => false,			'tinymce'       => false,			'quicktags'     => $quicktags_settings,		)	);	?>	</div> 	<div id="edithead" style="display:none;">		<div class="inside">		<label for="author-name"><?php _e( 'Name' ); ?></label>		<input type="text" name="newcomment_author" size="50" value="" id="author-name" />		</div>

Changelog

Introduced in 2.7.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-admin/includes/template.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.