WP_Privacy_Requests_Table::get_views(): string[]
- Since
- 4.9.6
- Source
wp-admin/includes/class-wp-privacy-requests-table.php:151
Compatibility
- WordPress
- since 4.9.6
- 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
string[]- An array of HTML links keyed by their view.
Performance profile
How much work a call to WP_Privacy_Requests_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
- Light
- Scaling
- Scales with input
- Instructions
- 52–60
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
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 104.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below WP_Privacy_Requests_Table::get_views()
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 · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Privacy_Requests_Table::get_views() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($value) | 52–53 | _wp_privacy_statuses(), ->get_request_counts(), array_sum(), absint(), ->get_admin_url(), _nx(), number_format_i18n(), sprintf(), esc_url(), ->get_views_links() |
isset($value) | 59–60 | sanitize_text_field(), _wp_privacy_statuses(), ->get_request_counts(), array_sum(), absint(), ->get_admin_url(), _nx(), number_format_i18n(), sprintf(), esc_url(), ->get_views_links() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 103 | 52–59 | 5 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 104 | 52–60 | 5 | |
| 8.4 | 104 | 52–60 | 5 | |
| 8.3 | 104 | 52–60 | 5 | |
| 8.2 | 104 | 52–60 | 5 | |
| 8.1 | 104 | 52–60 | 5 | |
| 7.4 | 104 | 52–60 | 5 |
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 · 12
- sanitize_text_field()Sanitizes a string from user input or from the database.
- _wp_privacy_statuses()Returns statuses for privacy requests.
- absint()Converts a value to non-negative integer.
- _nx()Translates and retrieves the singular or plural form based on the supplied number, with gettext context.
- number_format_i18n()Converts float number to format based on the locale.
- esc_url()Checks and cleans a URL.
- get_post_status_object()Retrieves a post status object by name.
- translate_nooped_plural()Translates and returns the singular or plural form of a string that's been registered with _n_noop() or _nx_noop().
- add_query_arg()Retrieves a modified URL query string.
- WP_Privacy_Requests_Table::get_request_counts()Counts the number of requests for each status.
- WP_Privacy_Requests_Table::get_admin_url()Normalizes the admin URL to the current page (by request_type).
- WP_Privacy_Requests_Table::get_views_links()
Source code
protected function get_views() { $current_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : ''; $statuses = _wp_privacy_statuses(); $views = array(); $counts = $this->get_request_counts(); $total_requests = absint( array_sum( (array) $counts ) ); // Normalized admin URL. $admin_url = $this->get_admin_url(); $status_label = sprintf( /* translators: %s: Number of requests. */ _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_requests, 'requests' ), number_format_i18n( $total_requests ) ); $views['all'] = array( 'url' => esc_url( $admin_url ), 'label' => $status_label, 'current' => empty( $current_status ), ); foreach ( $statuses as $status => $label ) { $post_status = get_post_status_object( $status ); if ( ! $post_status ) { continue; } $total_status_requests = absint( $counts->{$status} ); if ( ! $total_status_requests ) { continue; } $status_label = sprintf( translate_nooped_plural( $post_status->label_count, $total_status_requests ), number_format_i18n( $total_status_requests ) ); $status_link = add_query_arg( 'filter-status', $status, $admin_url ); $views[ $status ] = array( 'url' => esc_url( $status_link ), 'label' => $status_label, 'current' => $status === $current_status, ); } return $this->get_views_links( $views ); }Changelog
Introduced in 4.9.6. 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-privacy-requests-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.