wppaste
WordPress

WP_Comments_List_Table::extra_tablenav( string $which )

Source
wp-admin/includes/class-wp-comments-list-table.php:395

Compatibility

WordPress
core
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

$whichstring

Performance profile

How much work a call to WP_Comments_List_Table::extra_tablenav() 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
19–73

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

Plugin surface
2 hooks

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

Called by
0

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

What it touches

  • hookthird-party callbacksdo_action()called directly

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

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

WhenInstructionsCalls it makes
isset($has_items) && $which !== "top"19–21do_action()
!isset($has_items) && $which !== "top"22–24->has_items(), do_action()
isset($has_items) && $which !== "top" && !current_user_can()23–25current_user_can(), do_action()
!isset($has_items) && $which !== "top" && !current_user_can()26–28->has_items(), current_user_can(), do_action()
isset($has_items) && $which === "top" && empty($output)32–34ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), do_action()
isset($has_items) && $which === "top" && !empty($output) && !->has_items()35–37ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), do_action()
!isset($has_items) && $which === "top" && empty($output)35–37->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), do_action()
isset($has_items) && $which === "top" && empty($output) && !current_user_can()36–38ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), current_user_can(), do_action()
!isset($has_items) && $which === "top" && !empty($output) && !->has_items()38–40->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), do_action()
isset($has_items) && $which === "top" && !empty($output) && !->has_items() && !current_user_can()39–41ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), current_user_can(), do_action()
!isset($has_items) && $which === "top" && empty($output) && !current_user_can()39–41->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), current_user_can(), do_action()
isset($has_items) && $which !== "top" && current_user_can()40–43current_user_can(), wp_nonce_field(), esc_attr__(), submit_button(), do_action()
12 further outcomes, up to 73 instructions
!isset($has_items) && $which === "top" && !empty($output) && !->has_items() && !current_user_can()42–44->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), current_user_can(), do_action()
!isset($has_items) && $which !== "top" && current_user_can()43–46->has_items(), current_user_can(), wp_nonce_field(), esc_attr__(), submit_button(), do_action()
isset($has_items) && $which === "top" && !empty($output) && ->has_items()46–48ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), __(), submit_button(), do_action()
!isset($has_items) && $which === "top" && !empty($output) && ->has_items()49–51->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), __(), submit_button(), do_action()
isset($has_items) && $which === "top" && !empty($output) && ->has_items() && !current_user_can()50–52ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), __(), submit_button(), current_user_can(), do_action()
isset($has_items) && $which === "top" && empty($output) && current_user_can()53–56ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), current_user_can(), wp_nonce_field(), esc_attr__(), submit_button(), do_action()
!isset($has_items) && $which === "top" && !empty($output) && ->has_items() && !current_user_can()53–55->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), __(), submit_button(), current_user_can(), do_action()
isset($has_items) && $which === "top" && !empty($output) && !->has_items() && current_user_can()56–59ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), current_user_can(), wp_nonce_field(), esc_attr__(), submit_button(), do_action()
!isset($has_items) && $which === "top" && empty($output) && current_user_can()56–59->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), current_user_can(), wp_nonce_field(), esc_attr__(), submit_button(), do_action()
!isset($has_items) && $which === "top" && !empty($output) && !->has_items() && current_user_can()59–62->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), current_user_can(), wp_nonce_field(), esc_attr__(), submit_button(), do_action()
isset($has_items) && $which === "top" && !empty($output) && ->has_items() && current_user_can()67–70ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), __(), submit_button(), current_user_can(), wp_nonce_field(), esc_attr__(), submit_button(), do_action()
!isset($has_items) && $which === "top" && !empty($output) && ->has_items() && current_user_can()70–73->has_items(), ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), ->has_items(), __(), submit_button(), current_user_can(), wp_nonce_field(), esc_attr__(), submit_button(), do_action()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev7519–7292 fewer instructions than PHP 8.5
8.57719–739
8.47719–739
8.37719–739
8.27719–739
8.17719–739
7.47719–739

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

2 hooks fire while WP_Comments_List_Table::extra_tablenav() runs, in this order:

  1. do_action( restrict_manage_comments )actionline 415 (+20 into the body)

    Fires just before the Filter submit button for comment types.

  2. do_action( manage_comments_nav )actionline 442 (+47 into the body)

    Fires after the Filter submit button for comment types.

Uses · 8

Source code

	protected function extra_tablenav( $which ) {		global $comment_status, $comment_type;		static $has_items; 		if ( ! isset( $has_items ) ) {			$has_items = $this->has_items();		} 		echo '<div class="alignleft actions">'; 		if ( 'top' === $which ) {			ob_start(); 			$this->comment_type_dropdown( $comment_type ); 			/**			 * Fires just before the Filter submit button for comment types.			 *			 * @since 3.5.0			 */			do_action( 'restrict_manage_comments' ); 			$output = ob_get_clean(); 			if ( ! empty( $output ) && $this->has_items() ) {				echo $output;				submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );			}		} 		if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && $has_items			&& current_user_can( 'moderate_comments' )		) {			wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );			$title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );			submit_button( $title, 'apply', 'delete_all', false );		} 		/**		 * Fires after the Filter submit button for comment types.		 *		 * @since 2.5.0		 * @since 5.6.0 The `$which` parameter was added.		 *		 * @param string $comment_status The comment status name. Default 'All'.		 * @param string $which          The location of the extra table nav markup: Either 'top' or 'bottom'.		 */		do_action( 'manage_comments_nav', $comment_status, $which ); 		echo '</div>';	}

Changelog

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 6.7.7 tag, from src/wp-admin/includes/class-wp-comments-list-table.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.