Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#47685 closed enhancement (fixed)

Allow developers to filter the authors list on quick edit dropdown

Reported by: mista-flo's profile Mista-Flo Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.6 Priority: normal
Severity: normal Version:
Component: Quick/Bulk Edit Keywords: has-patch commit has-dev-note
Focuses: administration Cc:

Description

Hello,

I want to find a way to filter the author list displayed in quick edit dropdown. I basically want to remove some roles of this list.

But there is currently no hook so I have to go through the wp_dropdown_users function, then use wp_dropdown_users_args filter, but this functions is also called on a lot of other parts of the backend, so I have to be sure that I'm only affecting the quick edit query.

So it would be nice to just add a particular filter for this quick edit author dropdown.

Attachments (4)

47685.1.patch (991 bytes) - added by Mista-Flo 5 years ago.
47685.2.patch (1022 bytes) - added by Mista-Flo 4 years ago.
47685.3.diff (977 bytes) - added by garrett-eclipse 4 years ago.
Minor refresh to improve the filter docblock and rename it quick_edit_dropdown_authors_args to coincide with the existing quick_edit_dropdown_pages_args filter.
47685.3-10192020-1803.gif (2.8 MB) - added by hellofromTonya 4 years ago.
Screen capture showing before filter is applied and when filtering 'rolein' => array( 'editor', 'administrator' ).

Change History (19)

@Mista-Flo
5 years ago

#1 @Mista-Flo
5 years ago

  • Keywords has-patch added; needs-patch removed

#2 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @davidbaumwald
5 years ago

  • Keywords commit added

@SergeyBiryukov Can this one be moved forward for version 5.3 Beta 1 tomorrow? The patch looks clean. Would this need a small Dev Note as well?

#4 @davidbaumwald
5 years ago

  • Keywords commit removed
  • Milestone changed from 5.3 to Future Release

With 5.3 Beta 1 being released today, I’m punting this to Future Release.

@Mista-Flo
4 years ago

#5 @Mista-Flo
4 years ago

Hey @SergeyBiryukov I have updated my patch so it will be applied with last version of trunk. Hopefully it can now be part of 5.6 release :)

#6 @SergeyBiryukov
4 years ago

  • Milestone changed from Future Release to 5.6

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


4 years ago

#8 @hellofromTonya
4 years ago

  • Keywords needs-dev-note added

New filter. Tagging for a mention in the general dev note.

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


4 years ago

@garrett-eclipse
4 years ago

Minor refresh to improve the filter docblock and rename it quick_edit_dropdown_authors_args to coincide with the existing quick_edit_dropdown_pages_args filter.

#10 @garrett-eclipse
4 years ago

  • Keywords needs-testing added

Thanks for the enhancement @Mista-Flo I've refreshed your patch in 47685.3.diff to slightly improve the docblock and rename the filter quick_edit_dropdown_authors_args (previously quick_edit_authors_query_args) to coincide with the existing quick_edit_dropdown_pages_args filter.

I think this just needs some testing on the latest patch and it's ready for committers review.

@hellofromTonya
4 years ago

Screen capture showing before filter is applied and when filtering 'rolein' => array( 'editor', 'administrator' ).

#11 @hellofromTonya
4 years ago

  • Keywords commit added; needs-testing removed

Tested with this code:

<?php

add_filter( 'quick_edit_dropdown_authors_args', function ( $users ) {
        $users['role__in']                = [ 'editor', 'administrator' ];
        $users['who']                     = '';
        $users['hide_if_only_one_author'] = false;

        return $users;
} );

Works as expected.

Removing needs-testing. This ticket is ready for commit.

#12 @Mista-Flo
4 years ago

Thanks for the test @hellofromTonya, looks good to me as well, thanks for the refresh @garrett-eclipse

#13 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 49238:

Quick/Bulk Edit: Introduce quick_edit_dropdown_authors_args filter.

This allows for customizing the arguments used to generate the Quick Edit authors drop-down.

Additionally, pass the $bulk argument to the quick_edit_dropdown_pages_args filter, for consistency.

Props Mista-Flo, garrett-eclipse, hellofromTonya.
Fixes #47685.

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


4 years ago

Note: See TracTickets for help on using tickets.