Repository navigation
REST API: Add item counts to the page view list in the view config endpoint - #14070
im3dabasia wants to merge 5 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Do we have Trac ticket for this backport? |
Hey! Nope, this doesn’t have it as of now. In the past, I’ve had trouble creating a Trac ticket. I don’t see the “Submit” button to create a new ticket. I’ll check if I can create a ticket for this regardless. |
… counts for partial view config requests
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
Backports the PHP changes from WordPress/gutenberg#82247. The JS ships through the package sync.
What
GET /wp/v2/view-config?kind=postType&name=pagenow adds acountto each view list entry whose total a status count can answer:status(is/isAny) counts those statuses.The counts are added in
WP_REST_View_Config_Controller::get_items()after everyget_entity_view_config_*filter has run, so they describe the final view list, including views added or changed by plugins. Onewp_count_posts( 'page', 'readable' )call supplies every count, which keeps private pages the current user can't read out of the totals. The item schema now includesview_list[].count.Why
Users can't tell how many drafts or pending items exist without opening each tab, while classic wp-admin shows these counts. This adds the server side of the status tab counts in the site editor's post list.
Files
src/wp-includes/view-config.php: adds_wp_add_counts_to_view_list()and_wp_get_view_list_entry_statuses().src/wp-includes/rest-api/endpoints/class-wp-rest-view-config-controller.php: adds the counts inget_items()andcountto the item schema.tests/phpunit/tests/rest-api/rest-view-config-controller.php: three count tests, andtest_get_items_matches_underlying_confignow expects the counts.Testing Instructions
await wp.apiFetch( { path: '/wp/v2/view-config?kind=postType&name=page' } )view_listhas acountmatching its status, and thatallcounts every page except trashed ones.npm run test:php -- --group view-configUse of AI Tools
Ported with Claude Code (Claude Opus 5.5). I reviewed every change and ran the tests locally.