Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#6316 closed defect (bug) (fixed)

No context for user_func called by 'do_meta_boxes'

Reported by: henrikmelin Owned by: ryan
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.5
Component: Administration Keywords: meta-box admin
Focuses: Cc:


The user function specified in 'add_meta_box' has no context of what box called it. Passing $box, in addition to $object to the user_func in the function 'do_meta_boxes', would be really useful when populating boxes programatically.


call_user_func($boxcallback?, $object);


call_user_func($boxcallback?, $object, $box);


Change History (5)

#1 @ryan
13 years ago

Are you registering a function that handles multiple boxes? I usually register a specific function for each box so there's no need to pass the box.

#2 @henrikmelin
13 years ago

Yes. Have a look at:


which details the plugin that enables the user to create any number boxes without editing code. These boxes can be made out of text, selects and textareas.

Curretly, I use JS to position the box after creating it in the footer, but I really see using 'add_meta_box' as much more elegant, and integrating better into the WP framework.

The function that builds the content of a box (i.e. the callback function) would in this instance need to know what box is being build.


#3 @henrikmelin
13 years ago

I've worked around this by using the 'edit_form_advanced' action, appearing just after the creation of the meta boxes. I still see some potential benefit in having all the meta boxes in the $wp_meta_boxes variable tough, which is not possible now.


#4 @ryan
13 years ago

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

(In [7514]) Pass box to add_meta_box() callback. Props henrikmelin. fixes #6316

#5 @ryan
13 years ago

  • Milestone changed from 2.6 to 2.5
Note: See TracTickets for help on using tickets.