WP_Comments_List_Table::extra_tablenav( string $which )
- Source
wp-admin/includes/class-wp-comments-list-table.php:404
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
- Scaling
- Constant
- Instructions
- 19–73
- Plugin surface
- 2 hooks
- Called by
- 0
Touches nothing outside its own arguments.
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 77.
Third-party callbacks on 'restrict_manage_comments', 'manage_comments_nav' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
do_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.
| When | Instructions | Calls it makes |
|---|---|---|
isset($has_items) && $which !== "top" | 19–21 | do_action() |
!isset($has_items) && $which !== "top" | 22–24 | ->has_items(), do_action() |
isset($has_items) && $which !== "top" && !current_user_can() | 23–25 | current_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–34 | ob_start(), ->comment_type_dropdown(), do_action(), ob_get_clean(), do_action() |
isset($has_items) && $which === "top" && !empty($output) && !->has_items() | 35–37 | ob_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–38 | ob_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–41 | ob_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–43 | current_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–48 | 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() | 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–52 | 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) && current_user_can() | 53–56 | 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() | 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–59 | 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) && 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–70 | 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() |
!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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 75 | 19–72 | 9 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 77 | 19–73 | 9 | |
| 8.4 | 77 | 19–73 | 9 | |
| 8.3 | 77 | 19–73 | 9 | |
| 8.2 | 77 | 19–73 | 9 | |
| 8.1 | 77 | 19–73 | 9 | |
| 7.4 | 77 | 19–73 | 9 |
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:
- do_action( restrict_manage_comments )actionline 424 (+20 into the body)
Fires just before the Filter submit button for comment types.
- do_action( manage_comments_nav )actionline 451 (+47 into the body)
Fires after the Filter submit button for comment types.
Uses · 8
- do_action()Calls the callback functions that have been added to an action hook.
- submit_button()Echoes a submit button, with provided text and appropriate class(es).
- __()Retrieves the translation of $text.
- current_user_can()Returns whether the current user has the specified capability.
- wp_nonce_field()Retrieves or display nonce hidden field for forms.
- esc_attr__()Retrieves the translation of $text and escapes it for safe use in an attribute.
- WP_Comments_List_Table::has_items()
- WP_Comments_List_Table::comment_type_dropdown()Displays a comment type drop-down for filtering on the Comments list table.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.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.