Title: WP_Privacy_Requests_Table::get_views
Published: October 5, 2018
Last modified: February 24, 2026

---

# WP_Privacy_Requests_Table::get_views(): string[]

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#wp--skip-link--target)

Gets an associative array ( id => link ) with the list of views available on this
table.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#return)󠁿

 string[] An array of HTML links keyed by their view.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#source)󠁿

    ```php
    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 );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-privacy-requests-table.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/class-wp-privacy-requests-table.php#L151)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/class-wp-privacy-requests-table.php#L151-L205)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Privacy_Requests_Table::get_admin_url()](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_admin_url/)`wp-admin/includes/class-wp-privacy-requests-table.php` |

Normalizes the admin URL to the current page (by request_type).

  | 
| [_wp_privacy_statuses()](https://developer.wordpress.org/reference/functions/_wp_privacy_statuses/)`wp-includes/post.php` |

Returns statuses for privacy requests.

  | 
| [WP_Privacy_Requests_Table::get_request_counts()](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_request_counts/)`wp-admin/includes/class-wp-privacy-requests-table.php` |

Counts the number of requests for each status.

  | 
| [translate_nooped_plural()](https://developer.wordpress.org/reference/functions/translate_nooped_plural/)`wp-includes/l10n.php` |

Translates and returns the singular or plural form of a string that’s been registered with [_n_noop()](https://developer.wordpress.org/reference/functions/_n_noop/) or [_nx_noop()](https://developer.wordpress.org/reference/functions/_nx_noop/) .

  | 
| [_nx()](https://developer.wordpress.org/reference/functions/_nx/)`wp-includes/l10n.php` |

Translates and retrieves the singular or plural form based on the supplied number, with gettext context.

  | 
| [get_post_status_object()](https://developer.wordpress.org/reference/functions/get_post_status_object/)`wp-includes/post.php` |

Retrieves a post status object by name.

  | 
| [sanitize_text_field()](https://developer.wordpress.org/reference/functions/sanitize_text_field/)`wp-includes/formatting.php` |

Sanitizes a string from user input or from the database.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [absint()](https://developer.wordpress.org/reference/functions/absint/)`wp-includes/load.php` |

Converts a value to non-negative integer.

  | 
| [add_query_arg()](https://developer.wordpress.org/reference/functions/add_query_arg/)`wp-includes/functions.php` |

Retrieves a modified URL query string.

  | 
| [number_format_i18n()](https://developer.wordpress.org/reference/functions/number_format_i18n/)`wp-includes/functions.php` |

Converts float number to format based on the locale.

  |

[Show 6 more](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.6](https://developer.wordpress.org/reference/since/4.9.6/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_privacy_requests_table%2Fget_views%2F)
before being able to contribute a note or feedback.