WP_Privacy_Requests_Table::get_request_counts(): object
- Since
- 4.9.6
- Source
wp-admin/includes/class-wp-privacy-requests-table.php:109
Counts the number of requests for each status.
Return
object- Number of posts for each status.
Uses · 3
- wp_cache_get()Retrieves the cache contents from the cache by key and group.
- get_post_stati()Gets a list of post statuses.
- wp_cache_set()Saves the data to the cache.
Used by · 1
- WP_Privacy_Requests_Table::get_views()Gets an associative array ( id => link ) with the list of views available on this table.
Source
protected function get_request_counts() { global $wpdb; $cache_key = $this->post_type . '-' . $this->request_type; $counts = wp_cache_get( $cache_key, 'counts' ); if ( false !== $counts ) { return $counts; } $results = (array) $wpdb->get_results( $wpdb->prepare( "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s AND post_name = %s GROUP BY post_status", $this->post_type, $this->request_type ), ARRAY_A ); $counts = array_fill_keys( get_post_stati(), 0 ); foreach ( $results as $row ) { $counts[ $row['post_status'] ] = $row['num_posts']; } $counts = (object) $counts; wp_cache_set( $cache_key, $counts, 'counts' ); return $counts; }History
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.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.