Changeset 6758

Show
Ignore:
Timestamp:
02/08/08 18:51:37 (5 months ago)
Author:
ryan
Message:

add_meta_box(). see #5798

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/edit-form-advanced.php

    r6739 r6758  
    219219</div> 
    220220 
     221<?php do_meta_boxes('edit_post', $post); ?> 
     222 
    221223<?php do_action('edit_form_advanced'); ?> 
    222224 
     
    316318<?php endif; ?> 
    317319 
     320<?php do_meta_boxes('edit_post_advanced', $post); ?> 
     321 
    318322<?php do_action('dbx_post_sidebar'); ?> 
    319323 
  • trunk/wp-admin/includes/template.php

    r6727 r6758  
    846846} 
    847847 
    848 ?> 
     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 */ 
     858function 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 
     864function 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 
     880?>