| 848 | /** |
| 849 | * add_meta_box() - Add a meta box to an edit form |
| 850 | * |
| 851 | * @since 2.5 |
| 852 | * |
| 853 | * @param string $id String for use in the 'id' attribute of tags. |
| 854 | * @param string $title Title of the meta box |
| 855 | * @param string $callback Function that fills the box with the desired content. The function should echo its output. |
| 856 | * @param string $context The context in which the box should be displayed. edit_post, edit_page, edit_link, edit_post_advanced... |
| 857 | */ |
| 858 | function add_meta_box($id, $title, $callback, $context) { |
| 859 | global $wp_meta_boxes; |
| 860 | |
| 861 | $wp_meta_boxes[$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback); |
| 862 | } |
| 863 | |
| 864 | function do_meta_boxes($context, $object) { |
| 865 | global $wp_meta_boxes; |
| 866 | |
| 867 | if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$context]) ) |
| 868 | return; |
| 869 | |
| 870 | foreach ( (array) $wp_meta_boxes[$context] as $box ) { |
| 871 | echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id']) . '">' . "\n"; |
| 872 | echo "<h3>{$box['title']}</h3>\n"; |
| 873 | echo '<div class="inside">' . "\n"; |
| 874 | call_user_func($box['callback'], $object); |
| 875 | echo "</div>\n"; |
| 876 | echo "</div>\n"; |
| 877 | } |
| 878 | } |
| 879 | |