New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple select support for wp_dropdown_categories #790
Conversation
Adds a new argument to the $args array for wp_dropdown_categories, allowing to pass either empty string or `multiple`. If left empty, the select defaults to a single select, if `multiple` is passed the Select will allow for multiple selection and pass an `[]` to the name attribute value as well. This was tested on several installs of mine (I use to replace said function with a custom one). Also tested this particular commit on my local install Example usage: `wp_dropdown_categories( array('multiple' => 'multiple') );`
This pull request has been mentioned on ClassicPress Forums. There might be relevant details there: |
This pull request has been mentioned on ClassicPress Forums. There might be relevant details there: |
Needs testing (including automated tests) and revision (changing |
- Changes Version @SInCE annotation to not use `CP-` prefix - Changes new attribute to be boolean instead of string - Adds boolean validation - Changes logic to display `multiple` HTML 5 attribute based on boolean input
... when multiple is false, pass empty string.
Pushed 2 commits that:
Tested locally for functionality as well. |
This shouldn't be closed. |
I suspect this auto closed due to fork where PR originated being deleted. |
Ah, ups - I guess that would have been me then when I cleaned up old CP repos lying around in my repo. But I've seen other such things getting "reopened", so I guess this can be done here too? |
Unfortunately, the branch is closed. Needs re-opening. |
As per latest decisions it seems CP will be re-forked, re-synced with WP, so I think the changes of this PR (and all others I committed in the past improving similar functions) can/should be discarded, since they add new features not in WP and thus would just complicate the keeping-in-sync process. |
Description
Adds a new argument to the $args array for
wp_dropdown_categories
, allowing to pass either empty string ormultiple
.If left empty, the select defaults to a single select, if
multiple
is passed the Select will allow for multiple selection and pass an[]
to the name attribute value as well.See also https://forums.classicpress.net/t/update-wp-dropdown-categories-to-allow-for-multiple-selection/
Motivation and context
The requirement to produce a Categories or else Custom taxonomy Dropdown with multiselect support has been around for years (google search will show what I mean).
I use to replace said function in my plugins with this (and other) amendments and thus I think it is time to have this tiny, but powerful change in core.
How has this been tested?
This was tested on several installs of mine (I use to replace said function with a custom one). Also tested this particular commit on my local install
Example usage:
wp_dropdown_categories( array('multiple' => 'multiple') );
Screenshots
Before
After
NOTE:
This now also allows for Select2 MultiSelects, of course (the developer just needs to instantiate S2 on the select input produced...)
Types of changes