wppaste
WordPress

WP_Privacy_Requests_Table::get_views(): string[]

Since
4.9.6
Source
wp-admin/includes/class-wp-privacy-requests-table.php:151
Gets an associative array ( id => link ) with the list of views available on this table.

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

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
52–60

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

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

What it touches

  • hookthird-party callbacksapply_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.

WhenInstructionsCalls 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–60sanitize_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

PHPCompiledExecutedBranchesNotes
8.6-dev10352–5951 fewer instruction than PHP 8.5
8.510452–605
8.410452–605
8.310452–605
8.210452–605
8.110452–605
7.410452–605

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

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.

  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.8.8 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.