WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#14206 closed enhancement (fixed)

Custom taxonomy meta box callback

Reported by: johnbillion Owned by: nacin
Milestone: 3.7 Priority: normal
Severity: trivial Version: 3.0
Component: Taxonomy Keywords: has-patch commit
Focuses: Cc:

Description

I'd like to be able to specify my own meta box function for my custom taxonomies.

Currently if I want to specify my own meta box for my custom taxonomy, I must set the public parameter to false and then add my own meta box using add_meta_box(). It would be nice to just do this with a callback function parameter in register_taxonomy().

Example:

register_taxonomy( 'foo', 'bar', array(
    'meta_box_callback' => 'my_meta_box'
) );

I'll write up a patch if there's a chance of it going in.

Attachments (3)

garyc40-14206.patch (1.6 KB) - added by garyc40 10 years ago.
there's a patch for that
14206.diff (1.8 KB) - added by wonderboymusic 7 years ago.
14206.2.diff (3.7 KB) - added by helen 7 years ago.

Download all attachments as: .zip

Change History (26)

#1 @scribu
10 years ago

+1 on the idea.

Just to avoid confusion, in register_post_type() there's a 'register_meta_box_cb' argument which receives a callback. In that callback, you are supposed to call add_meta_box() or remove_meta_box(), as necessary.

#2 @nacin
10 years ago

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

#3 @garyc40
10 years ago

  • Owner set to garyc40
  • Status changed from new to assigned

@garyc40
10 years ago

there's a patch for that

#4 @garyc40
10 years ago

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

#5 @scribu
9 years ago

  • Keywords needs-testing 3.2-early removed
  • Owner changed from garyc40 to scribu
  • Severity changed from normal to trivial
  • Status changed from assigned to reviewing

This can wait.

#6 @scribu
9 years ago

  • Owner changed from scribu to garyc40

#7 @diddledan
8 years ago

  • Keywords close added

This appears to work for me in 3.5 out-of-the-box. Has the patch been silently added to the repo without updating this ticket?

#8 @scribu
8 years ago

  • Keywords close removed

There is no code in 3.5 for handling the 'meta_box_callback' argument. You probably have a plugin installed or something.

#9 @scribu
8 years ago

Related: #14877

#10 @diddledan
8 years ago

The name is different, but it appears that the same functionality is referenced in wp-includes/post.php around line 1178 and 1336

you're looking for 'register_meta_box_cb'

#11 @scribu
8 years ago

The idea was to pass the callback directly to register_taxonomy(), whereas 'register_meta_box_cb' is an argument you pass to register_post_type().

@wonderboymusic
7 years ago

#12 @wonderboymusic
7 years ago

  • Milestone changed from Future Release to 3.7
  • Owner garyc40 deleted

Refreshed against trunk

#13 @wonderboymusic
7 years ago

  • Keywords commit added

#14 @nacin
7 years ago

I'm hesitating a bit on this because of the difference between register_meta_box_cb and meta_box_callback. It is clear why the different functionality is needed — you may want to add a bunch of meta boxes for a single post type, while this is for replacing the taxonomy box — but the names are too similar. Explaining what register_meta_box_cb does is kind of awkward as it is.

I think we can solve this by clearly documenting the meta_box_callback parameter (missing from this patch) and seeing if the documentation for register_meta_box_cb can be improved as well.

#15 @wonderboymusic
7 years ago

  • Keywords needs-docs added; commit removed

@helen
7 years ago

#16 @helen
7 years ago

  • Keywords needs-docs removed

14206.2.diff - refreshed, added and massaged some docs. Renamed it meta_box_cb to parallel register_meta_box_cb. I agree that they're similar, but perhaps keeping the same base of the name will indicate that they function differently on purpose.

#17 @helen
7 years ago

  • Keywords commit added
  • Owner set to nacin

nacin says he will test and get it in. Really, I just wanted to link to that chat log.

#18 @ocean90
7 years ago

meta_box_cb looks good for me too. +1 for 14206.2.diff​.

#19 @alex-ye
7 years ago

  • Cc nashwan.doaqan@… added

#20 @nacin
7 years ago

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

In 25572:

Introduce a meta_box_cb argument for register_taxonomy().

The specified callback function is used as the meta box callback for the taxonomy.

props garyc40, helen.
fixes #14206.

#21 follow-up: @johnbillion
7 years ago

I wonder if we should also allow boolean false in the meta_box_cb argument to disable the meta box?

#22 @helen
7 years ago

#21543 was marked as a duplicate.

#23 in reply to: ↑ 21 @helen
7 years ago

Replying to johnbillion:

I wonder if we should also allow boolean false in the meta_box_cb argument to disable the meta box?

I think we should - using #21543 for that.

Note: See TracTickets for help on using tickets.