From 47ac60f02c927f8fecdd740c538937575e831f15 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 8 Feb 2008 18:51:37 +0000 Subject: [PATCH] add_meta_box(). see #5798 git-svn-id: http://svn.automattic.com/wordpress/trunk@6758 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 4 ++++ wp-admin/includes/template.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 64da6730f4..5aca0a960b 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -218,6 +218,8 @@ else + + 1 ) : + + diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 0b1305add9..a5c7693e55 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -845,4 +845,36 @@ function wp_remember_old_slug() { echo ''; } +/** + * add_meta_box() - Add a meta box to an edit form + * + * @since 2.5 + * + * @param string $id String for use in the 'id' attribute of tags. + * @param string $title Title of the meta box + * @param string $callback Function that fills the box with the desired content. The function should echo its output. + * @param string $context The context in which the box should be displayed. edit_post, edit_page, edit_link, edit_post_advanced... + */ +function add_meta_box($id, $title, $callback, $context) { + global $wp_meta_boxes; + + $wp_meta_boxes[$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback); +} + +function do_meta_boxes($context, $object) { + global $wp_meta_boxes; + + if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$context]) ) + return; + + foreach ( (array) $wp_meta_boxes[$context] as $box ) { + echo '
' . "\n"; + echo "

{$box['title']}

\n"; + echo '
' . "\n"; + call_user_func($box['callback'], $object); + echo "
\n"; + echo "
\n"; + } +} + ?>