Changeset 6762 for trunk/wp-admin/includes/template.php
- Timestamp:
- 02/08/2008 09:06:15 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r6758 r6762 854 854 * @param string $title Title of the meta box 855 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... 856 * @param string $page The type of edit page on which to show the box (post, page, link) 857 * @param string $context The context within the page where the boxes should show ('normal', 'advanced') 857 858 */ 858 function add_meta_box($id, $title, $callback, $ context) {859 function add_meta_box($id, $title, $callback, $page, $context = 'advanced') { 859 860 global $wp_meta_boxes; 860 861 861 $wp_meta_boxes[$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback); 862 } 863 864 function do_meta_boxes($context, $object) { 862 if ( !isset($wp_meta_boxes) ) 863 $wp_meta_boxes = array(); 864 if ( !isset($wp_meta_boxes[$page]) ) 865 $wp_meta_boxes[$page] = array(); 866 if ( !isset($wp_meta_boxes[$page][$context]) ) 867 $wp_meta_boxes[$page][$context] = array(); 868 869 $wp_meta_boxes[$page][$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback); 870 } 871 872 function do_meta_boxes($page, $context, $object) { 865 873 global $wp_meta_boxes; 866 874 867 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$ context]) )875 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) 868 876 return; 869 877 870 foreach ( (array) $wp_meta_boxes[$ context] as $box ) {871 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'] ) . '">' . "\n";878 foreach ( (array) $wp_meta_boxes[$page][$context] as $box ) { 879 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n"; 872 880 echo "<h3>{$box['title']}</h3>\n"; 873 881 echo '<div class="inside">' . "\n"; … … 878 886 } 879 887 880 ?> 888 function test_box($post) { 889 echo "Hello $post->ID"; 890 } 891 892 add_meta_box('test', 'Test', 'test_box', 'post'); 893 ?>
Note: See TracChangeset
for help on using the changeset viewer.