WordPress.org

Make WordPress Core

Changeset 6762


Ignore:
Timestamp:
02/08/2008 09:06:15 PM (14 years ago)
Author:
ryan
Message:

Separate meta box context into page and context to accommodate postbox API changes. see #5798

Location:
trunk/wp-admin
Files:
4 edited

Legend:

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

    r6761 r6762  
    220220</div>
    221221
    222 <?php do_meta_boxes('edit_post', $post); ?>
     222<?php do_meta_boxes('post', 'normal', $post); ?>
    223223
    224224<?php do_action('edit_form_advanced'); ?>
     
    319319<?php endif; ?>
    320320
    321 <?php do_meta_boxes('edit_post_advanced', $post); ?>
     321<?php do_meta_boxes('post', 'advanced', $post); ?>
    322322
    323323<?php do_action('dbx_post_sidebar'); ?>
  • trunk/wp-admin/edit-link-form.php

    r6761 r6762  
    9999</div>
    100100</div>
     101
     102<?php do_meta_boxes('link', 'normal', $link); ?>
    101103
    102104<h2><?php _e('Advanced Options'); ?></h2>
     
    275277</div>
    276278
     279<?php do_meta_boxes('link', 'advanced', $link); ?>
     280
    277281<?php if ( $link_id ) : ?>
    278282<input type="hidden" name="action" value="save" />
  • trunk/wp-admin/edit-page-form.php

    r6761 r6762  
    134134</p>
    135135
     136<?php do_meta_boxes('post', 'normal', $post); ?>
     137
    136138<?php do_action('edit_page_form'); ?>
    137139
     
    225227<?php endif; ?>
    226228
     229<?php do_meta_boxes('page', 'advanced', $post); ?>
     230
    227231</div>
    228232
  • trunk/wp-admin/includes/template.php

    r6758 r6762  
    854854 * @param string $title Title of the meta box
    855855 * @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')
    857858 */
    858 function add_meta_box($id, $title, $callback, $context) {
     859function add_meta_box($id, $title, $callback, $page, $context = 'advanced') {
    859860    global $wp_meta_boxes;
    860861
    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
     872function do_meta_boxes($page, $context, $object) {
    865873    global $wp_meta_boxes;
    866874
    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]) )
    868876        return;
    869877
    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";
    872880        echo "<h3>{$box['title']}</h3>\n";
    873881        echo '<div class="inside">' . "\n";
     
    878886}
    879887
    880 ?>
     888function test_box($post) {
     889    echo "Hello $post->ID";
     890}
     891
     892add_meta_box('test', 'Test', 'test_box', 'post');
     893?>
Note: See TracChangeset for help on using the changeset viewer.