#6316 closed defect (bug) (fixed)
No context for user_func called by 'do_meta_boxes'
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.5 |
Component: | Administration | Keywords: | meta-box admin |
Focuses: | Cc: |
Description
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.
i.e.
call_user_func($boxcallback?, $object);
to
call_user_func($boxcallback?, $object, $box);
Thoughts?
Henrik.
Change History (5)
#2
@
17 years ago
Yes. Have a look at:
http://labs.dagensskiva.com/plugins/more-fields/
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.
Cheers,
Henrik.
#3
@
17 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.
Cheers,
Henrik.
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.