Posts list table: Add Standard option to Formats filter dropdown - #12775
Posts list table: Add Standard option to Formats filter dropdown#12775shrivastavanolo wants to merge 4 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. |
There was a problem hiding this comment.
Pull request overview
This PR adds a “Standard” option to the admin Posts list table “Formats” filter so users can filter for posts without an assigned post format (i.e., standard posts), aligning the workflow with other filters like Categories.
Changes:
- Add a “Standard” option to the Formats dropdown in the posts list table.
- Extend
_post_format_request()to translatepost_format=standardinto atax_queryusingNOT EXISTSto match posts with no format term.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/wp-includes/post-formats.php |
Adds request parsing for post_format=standard by building a NOT EXISTS tax_query. |
src/wp-admin/includes/class-wp-posts-list-table.php |
Adds a “Standard” option to the Formats filter dropdown in the admin list table UI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/wp-includes/post-formats.php:177
- The new
post_format=standardbehavior (translating it into atax_querywithNOT EXISTS) is not covered by unit tests. Adding a test that creates one formatted post and one unformatted post and asserts thatnew WP_Query( array( 'post_format' => 'standard' ) )only returns the unformatted post would help prevent regressions.
if ( 'standard' === $qvs['post_format'] ) {
unset( $qvs['post_format'] );
$qvs['tax_query'][] = array(
'taxonomy' => 'post_format',
'operator' => 'NOT EXISTS',
);
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/wp-includes/post-formats.php:177
- The new "standard" handling in
_post_format_request()is behaviorally important (it changes howpost_format=standardis parsed into atax_querywithNOT EXISTS). There are existing post format unit tests, but none currently cover request parsing; adding a test would prevent regressions (e.g., ensuringpost_formatis unset, aNOT EXISTSclause is added, and admin queries don’t havepost_typeoverridden).
if ( 'standard' === $qvs['post_format'] ) {
unset( $qvs['post_format'] );
$qvs['tax_query'][] = array(
'taxonomy' => 'post_format',
'operator' => 'NOT EXISTS',
);
src/wp-includes/post-formats.php:184
- The
if ( ! is_admin() ) {guard was removed but the closing brace remains, which leaves a stray}and causes a PHP parse error. It also makes$qvs['post_type']get set unconditionally. Restore theis_admin()conditional so the filter remains valid and doesn’t modify admin queries.
$tax = get_taxonomy( 'post_format' );
$qvs['post_type'] = $tax->object_type;
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
src/wp-includes/post-formats.php:177
- New behavior for handling post_format=standard (mapping it to a NOT EXISTS tax_query) isn’t covered by tests. Adding PHPUnit coverage for _post_format_request (e.g., asserting it produces a NOT EXISTS tax_query and does not emit warnings when tax_query is initially absent) would help prevent regressions.
if ( 'standard' === $qvs['post_format'] ) {
unset( $qvs['post_format'] );
$qvs['tax_query'][] = array(
'taxonomy' => 'post_format',
'operator' => 'NOT EXISTS',
);
src/wp-includes/post-formats.php:178
- Appending to $qvs['tax_query'][] without ensuring the key exists (and is an array) can trigger PHP 8+ “Undefined array key 'tax_query'” warnings when handling the admin list table request. Initialize tax_query to an array before appending the NOT EXISTS clause.
unset( $qvs['post_format'] );
$qvs['tax_query'][] = array(
'taxonomy' => 'post_format',
'operator' => 'NOT EXISTS',
);
src/wp-admin/includes/class-wp-posts-list-table.php:544
- The new “Standard” option in the Formats filter dropdown is a user-facing behavior change but currently has no automated coverage. Consider adding an admin list table PHPUnit test that asserts the option renders when formats exist and that selecting it filters to posts with no post_format term.
<option<?php selected( $displayed_post_format, 'standard' ); ?> value="standard"><?php echo esc_html( get_post_format_string( 'standard' ) ); ?></option>
The Formats filter dropdown in the admin posts list table did not have a "Standard" option, so users could not filter for posts without an assigned post format. This was inconsistent with the Categories filter (which has an "Uncategorized" option) and removed a workflow that existed before the formats dropdown was introduced — distinguishing standard posts from formatted ones.
Added a "Standard" option that uses a NOT EXISTS tax_query to correctly find posts without a format.
Trac ticket:
https://core.trac.wordpress.org/ticket/47675
Use of AI Tools
AI assistance: Yes
Tool(s): Opencode
Model(s): DeepSeek V4 Flash
Used for: Initial code skeleton; final implementation was edited and tested by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.