WP_Comments_List_Table::get_views(): array<string,
- Source
wp-admin/includes/class-wp-comments-list-table.php:250
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.
Return value
array<string,- string> Comment status HTML links keyed by view.
Performance profile
How much work a call to WP_Comments_List_Table::get_views() 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
- Heavy
- Scaling
- Scales with input
- Instructions
- 64–76
- Plugin surface
- 1 hook
- Called by
- 0
Reaches the database via get_comments().
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 165.
Third-party callbacks on 'comment_status_links' 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
- querycontent query
get_comments()called directly - hookthird-party callbacks
apply_filters()called directly - cacheobject cache
wp_cache_get()one call below WP_Comments_List_Table::get_views()
Further down the call graph this can also reach option, 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 WP_Comments_List_Table::get_views() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 64–70 | wp_count_comments(), _nx_noop(), _nx_noop(), _nx_noop(), _nx_noop(), _nx_noop(), _nx_noop(), admin_url(), ->get_views_links(), apply_filters() |
!empty($comment_type) && $comment_type !== "all" | 72–76 | wp_count_comments(), _nx_noop(), _nx_noop(), _nx_noop(), _nx_noop(), _nx_noop(), _nx_noop(), admin_url(), add_query_arg(), ->get_views_links(), apply_filters() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 163 | 63–75 | 11 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 165 | 64–76 | 11 | |
| 8.4 | 165 | 64–76 | 11 | |
| 8.3 | 165 | 64–76 | 11 | |
| 8.2 | 165 | 64–76 | 11 | |
| 8.1 | 165 | 64–76 | 11 | |
| 7.4 | 165 | 64–76 | 11 |
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_Comments_List_Table::get_views() runs, in this order:
- apply_filters( comment_status_links )filterline 365 (+115 into the body)
Filters the comment status links.
Uses · 13
- wp_count_comments()Retrieves the total comment counts for the whole site or a single post.
- _nx_noop()Registers plural strings with gettext context in POT file, but does not translate them.
- admin_url()Retrieves the URL to the admin area for the current site.
- add_query_arg()Retrieves a modified URL query string.
- get_current_user_id()Gets the current user's ID.
- get_comments()Retrieves a list of comments.
- remove_query_arg()Removes an item or items from a query string.
- absint()Converts a value to non-negative integer.
- esc_url()Checks and cleans a URL.
- translate_nooped_plural()Translates and returns the singular or plural form of a string that's been registered with _n_noop() or _nx_noop().
- number_format_i18n()Converts float number to format based on the locale.
- apply_filters()Calls the callback functions that have been added to a filter hook.
Show all 13
- WP_Comments_List_Table::get_views_links()
Source code
protected function get_views() { global $post_id, $comment_status, $comment_type; $status_links = array(); $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments(); $statuses = array( /* translators: %s: Number of comments. */ 'all' => _nx_noop( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', 'comments' ), // Singular not used. /* translators: %s: Number of comments. */ 'mine' => _nx_noop( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', 'comments' ), /* translators: %s: Number of comments. */ 'moderated' => _nx_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'comments' ), /* translators: %s: Number of comments. */ 'approved' => _nx_noop( 'Approved <span class="count">(%s)</span>', 'Approved <span class="count">(%s)</span>', 'comments' ), /* translators: %s: Number of comments. */ 'spam' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'comments' ), /* translators: %s: Number of comments. */ 'trash' => _nx_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'comments' ), ); if ( ! EMPTY_TRASH_DAYS ) { unset( $statuses['trash'] ); } $link = admin_url( 'edit-comments.php' ); if ( ! empty( $comment_type ) && 'all' !== $comment_type ) { $link = add_query_arg( 'comment_type', $comment_type, $link ); } foreach ( $statuses as $status => $label ) { if ( 'mine' === $status ) { $current_user_id = get_current_user_id(); $num_comments->mine = get_comments( array( 'post_id' => $post_id ? $post_id : 0, 'user_id' => $current_user_id, 'count' => true, 'orderby' => 'none', ) ); $link = add_query_arg( 'user_id', $current_user_id, $link ); } else { $link = remove_query_arg( 'user_id', $link ); } if ( ! isset( $num_comments->$status ) ) { $num_comments->$status = 10; }Changelog
One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
none to array<string,.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.