[wp-trac] [WordPress Trac] #22938: Presentation of hierarchical taxonomy in Media modal should be checkboxes rather than comma-separated tag list

WordPress Trac noreply at wordpress.org
Fri May 1 19:37:00 UTC 2015

#22938: Presentation of hierarchical taxonomy in Media modal should be checkboxes
rather than comma-separated tag list
 Reporter:  yeswework    |       Owner:  wonderboymusic
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  Future Release
Component:  Media        |     Version:  3.5
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:  ui, javascript
Changes (by boonebgorges):

 * keywords:  has-patch dev-feedback needs-testing => needs-patch


 Thanks for the initial patch, jessepollak. Some thoughts:

 > 1. I use `wp_terms_checklist()` which in turn relies on
 `Walker_Category_Checklist` which is relatively inflexible. Primarily, it
 can only output inputs of the form `name=post_category[]` or
 `tax_input[$taxonomy]`. That's a different form than what's used to saved
 `AttachmentCompat`'s in Backbone, so I have to `str_replace` to get it in
 the correct form. I know this is horrible, but I'm not sure what the best
 way to proceed is — should I rewrite `Walker_Category_Checklist`, so it
 can be more modular?

 Yeah, definitely feel free to refactor, but it might be awkward in this
 case, since it looks like you need the `$name` to contain a reference to
 the attachment ID. You could make this work with the creative use of a
 filter, or perhaps by breaking the `$name` logic into a separate method of
 `Walker_Category_Checklist` and then subclassing it so as to override.

 > 2. `wp_terms_checklist()` outputs to the buffer, so I use `ob_start()`
 etc to get the content which is passed via AJAX. Is this acceptable or —
 again — should I refactor to make it possible to get it as a string rather
 than output?

 Definitely yes. An `'echo'` param would be good.

 > 3. In the `media.view.AttachmentCompat` class, I add an if statement in
 the `save` method that handles the case where the input is a series of
 checkboxes (before this, they were always a single input of `type=text` or
 `type=hidden`). Is this acceptable or should I subclass
 `media.view.AttachmentCompat` specifically for ones that are taxonomies of
 some sort.

 What you've done in the patch seems OK to me. If this is the only change
 necessary, let's not overengineer.

 > 4. I've only been testing this in the Attachment Edit & Create pages and
 with the `category` taxonomy. Can anyone think of other objects and/or
 taxonomies I should be testing on?

 I don't think you need to handle other objects with this ticket. For
 taxonomies, you should handle any taxonomy where `'hierarchical' => true`.

Ticket URL: <https://core.trac.wordpress.org/ticket/22938#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list