Make WordPress Core

Opened 9 years ago

Last modified 2 weeks ago

#36237 reviewing enhancement

Add filter for post statuses in quickedit

Reported by: kakomap's profile kakomap Owned by: johnbillion's profile johnbillion
Milestone: 6.9 Priority: normal
Severity: normal Version: 4.4.2
Component: Posts, Post Types Keywords: has-patch has-test-info
Focuses: administration Cc:

Description (last modified by johnbillion)

To make changes to the quick edit status list, one has to use JS or action quick_edit_custom_box to add extra fields. In instances where some of the statuses need to be removed, JS is required.

I propose that the statuses in wp-admin/includes/class-wp-posts-list-table.php (line 1284-1300) be stored in an array then filtered using quick_edit_statuses before the array is iterated through to create the select options.

I'm available to submit a patch that does this

Attachments (2)

quick_edit_statuses.png (44.8 KB) - added by kakomap 9 years ago.
Quick Edits
36237.patch (3.4 KB) - added by kakomap 9 years ago.
Use quick_edit_statuses filter for the statuses

Download all attachments as: .zip

Change History (15)

@kakomap
9 years ago

Quick Edits

#1 @johnbillion
9 years ago

  • Description modified (diff)
  • Focuses administration added
  • Keywords needs-patch added
  • Summary changed from Add filter for ticket statuses in quickedit to Add filter for post statuses in quickedit

#2 @kakomap
9 years ago

Thanks @johnbillion. May I proceed to propose a patch?

@kakomap
9 years ago

Use quick_edit_statuses filter for the statuses

#5 @kakomap
9 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

This ticket was mentioned in PR #9041 on WordPress/wordpress-develop by @SirLouen.


3 weeks ago
#6

Refreshing and Improving 36237.patch
I've code reviewed it and compared to the original version, there was a little difference on the conditionals (adding Private status type too early).
I am not sure if this was implemented by the original author on purpose @kakomap because there doesn't seem to be an explanation on this.

Apart from this, everything looks good, a nice DRY refactor, meant to include the filter accordingly.

I will be posting a test to this refresh
Automated could be done through Playwright. But I would leave this for further iterations. If anyone wants to add this feel free.
Trac ticket: [](https://core.trac.wordpress.org/ticket/36237)

#8 @SirLouen
3 weeks ago

  • Keywords has-test-info added; needs-testing removed

Test Report

Description

✅ This report validates that the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/9041.diff

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 137.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-One 2.5
  • MU Plugins: None activated
  • Plugins:
    • Remove Draft from Quick Edit 1.0.0
    • Test Reports 1.2.0

Testing Instructions

  1. Add the code provided in supplemental artifacts to a plugin, functions.php or wherever it can be executed
  2. Create a post or two
  3. Quick edit them and check if "Draft" status appears under the status Select. It should not appear.

Actual Results

  1. ✅ Issue resolved with patch.

Some extra Testing Results

  • Given that the logic changes a bit, I've tested around
  1. ✅ Private only appears on bulk edit
  2. ✅ No Change appears only on bulk edit
  3. ✅ Scheduled, Future, Draft and Pending Review appear when the user has capabilities
  4. ✅ Testing with a user without capabilities (i.e. Contributor), Schedule, Private and Scheduled doesn't appear as expected, only Draft and Pending Review as expected.

Additional Notes

  • I edited a little the code in the original patch because it was adding "Private" to members without the right capability
  • Also added some docs to the filter
  • Added a little note referencing this #63612 to avoid future confusion.
  • Apart from this, the rest is the same. It brings a pretty nice refactor.

Supplemental Artifacts

Test code

function remove_draft_from_quick_edit_statuses( $statuses ) {
	if ( isset( $statuses['draft'] ) ) {
		unset( $statuses['draft'] );
	}
	return $statuses;
}
add_filter( 'quick_edit_statuses', 'remove_draft_from_quick_edit_statuses' ); 

This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.


3 weeks ago

#10 @iamadisingh
3 weeks ago

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/9041.diff

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.3
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 137.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.2
  • MU Plugins: None activated
  • Plugins:
    • Test Quick Edit Filter
    • Test Reports 1.2.0

Testing Instructions

  1. Create and activate the test plugin with the this provided filter code
  2. Create test posts with various statuses (Published, Draft, Pending Review)
  3. Navigate to Posts > All Posts in WordPress admin
  4. Test Quick Edit functionality:
    • Hover over any post and click "Quick Edit"
    • Verify that "Draft" status is removed from the Status dropdown
    • Check that other statuses (Published, Pending Review) remain available

Actual Results

  1. ✅ Issue resolved with patch.

Additional Notes

  • Filter works consistently across both Quick Edit and Bulk Edit interfaces

Supplemental Artifacts

Test Plugin Code:

<?php
<?php
/**
 * Plugin Name: Test Quick Edit Filter
 * Description: Tests the quick_edit_statuses filter
 */

function remove_draft_from_quick_edit_statuses( $statuses ) {
    if ( isset( $statuses['draft'] ) ) {
        unset( $statuses['draft'] );
    }
    return $statuses;
}
add_filter( 'quick_edit_statuses', 'remove_draft_from_quick_edit_statuses' );

function add_custom_status_to_quick_edit( $statuses ) {
    $statuses['custom_status'] = __( 'Custom Status' );
    return $statuses;
}
add_filter( 'quick_edit_statuses', 'add_custom_status_to_quick_edit' );

Visual Evidence: https://ibb.co/MD2rZPQW

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


2 weeks ago

#12 @johnbillion
2 weeks ago

  • Milestone set to 6.9
  • Owner set to johnbillion
  • Status changed from new to reviewing

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


2 weeks ago

Note: See TracTickets for help on using tickets.