Make WordPress Core

Opened 10 years ago

Last modified 6 years ago

#28956 reviewing enhancement

Moving taxonomy metabox

Reported by: riisdesign's profile RIISdesign Owned by: chriscct7's profile chriscct7
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: ui, administration Cc:

Description

As far as I know, if you want to move a taxonomy meta box, you must currently use "remove_meta_box" and then use "add_meta_box" with the context and priority as parameters. Take this link for instance: http://stackoverflow.com/questions/14512203/wordpress-custom-taxonomy-move-meta-box

Shouldn't this rather be an option inside $args using "register_taxonomy"? It would be so much easier and intuitive.

You could e.g. write:

$args = array(
    'context' => 'normal', 'priority' => 'high'
);

There should also be a "move_meta_box" function for already created taxonomies such as "tags", where you simply pass these paramters along with the taxonomy name.
It could look like this:

move_meta_box( $id, $page, $context, $priority );

I just think that removing and then adding a meta box only to move its location is so hacky and unintuitive, and this would make it easier so we can create better UIs for our customers!

Attachments (2)

28956.diff (1.3 KB) - added by theorboman 10 years ago.
Add apply filters to both meta_box context and priority in add_meta_box()
28956.1.patch (3.6 KB) - added by keesiemeijer 8 years ago.
Add meta_box_context and meta_box_priority parameters

Download all attachments as: .zip

Change History (10)

#1 follow-up: @DrewAPicture
10 years ago

Hi RIISdesign, welcome to Trac :)

This is actually a pretty good idea.

Just thinking out loud here ... in the short term, it might be worth simply adding a filter just before the taxonomy meta boxes are added that would allow modifying the context and priority, maybe as an array of values. Or we could just add the filter inside add_meta_box().

Implementing a filter in either place would open the door in the long term to adding an argument to register_taxonomy() as you suggested -- maybe as meta_box_context or something, then core filtering the values just before/while the meta boxes are added.

Food for thought. Care to try your hand at submitting a patch?

#2 in reply to: ↑ 1 @RIISdesign
10 years ago

  • Keywords needs-patch added

Replying to DrewAPicture:

Hi RIISdesign, welcome to Trac :)

This is actually a pretty good idea.

Just thinking out loud here ... in the short term, it might be worth simply adding a filter just before the taxonomy meta boxes are added that would allow modifying the context and priority, maybe as an array of values. Or we could just add the filter inside add_meta_box().

Implementing a filter in either place would open the door in the long term to adding an argument to register_taxonomy() as you suggested -- maybe as meta_box_context or something, then core filtering the values just before/while the meta boxes are added.

Food for thought. Care to try your hand at submitting a patch?

Hey DrewAPicture, thanks for welcoming me!

Glad to hear I've something useful to say. Your idea seems great, but I'm not proficient to submitting a patch atm unfortunately. I hope someone else cares to try though :)

Sorry for the delayed answer by the way and thanks for contributing to my idea.

@theorboman
10 years ago

Add apply filters to both meta_box context and priority in add_meta_box()

#3 @theorboman
10 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed

This seems interesting. I added a patch to add_meta_box() with an apply_filters() call for $priority and $context.

I've added the meta box $id as a second argument and $page (aka $screen->id) as a third argument, but I'm not really sure it's necessary.

Any thoughts? Might this be a valid approach to the ticket?

I wasn't sure what to do with the @since argument in the doc block so I just went ahead and added 4.1.0. A man can dream :)

#4 @chriscct7
9 years ago

  • Owner set to chriscct7
  • Status changed from new to reviewing

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


9 years ago

#6 @boonebgorges
9 years ago

  • Keywords needs-patch good-first-bug added; has-patch dev-feedback removed
  • Milestone changed from Awaiting Review to Future Release

I'm +1 to this functionality.

Filters in add_meta_box() are interesting, but are awfully broad for this specific issue. Contra @DrewAPicture in comment 1, I would suggest that 'meta_box_priority' and 'meta_box_context' params for register_taxonomy() are more lightweight for core to adopt, and easier for implementors to use. Unless there's objection, let's see a patch along those lines.

@keesiemeijer
8 years ago

Add meta_box_context and meta_box_priority parameters

#7 @keesiemeijer
8 years ago

  • Keywords has-patch added; needs-patch removed

In 28956.1.patch the meta_box_context and meta_box_priority arguments are added to the register_taxonomy() function and WP_Taxonomy class.

The defaults for these parameters are taken from the hard-coded parameter values used in edit-form-advanced.php to add taxonomy meta boxes in the post edit screens.

#8 @flixos90
6 years ago

  • Keywords good-first-bug removed
Note: See TracTickets for help on using tickets.