Separate meta box context into page and context to accommodate postbox API changes. see #5798
git-svn-id: https://develop.svn.wordpress.org/trunk@6762 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4c6d9571f9
commit
2c80b3fb04
@ -219,7 +219,7 @@ else
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php do_meta_boxes('edit_post', $post); ?>
|
<?php do_meta_boxes('post', 'normal', $post); ?>
|
||||||
|
|
||||||
<?php do_action('edit_form_advanced'); ?>
|
<?php do_action('edit_form_advanced'); ?>
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ if ( $authors && count( $authors ) > 1 ) :
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php do_meta_boxes('edit_post_advanced', $post); ?>
|
<?php do_meta_boxes('post', 'advanced', $post); ?>
|
||||||
|
|
||||||
<?php do_action('dbx_post_sidebar'); ?>
|
<?php do_action('dbx_post_sidebar'); ?>
|
||||||
|
|
||||||
|
@ -99,6 +99,8 @@ function xfn_check($class, $value = '', $deprecated = '') {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php do_meta_boxes('link', 'normal', $link); ?>
|
||||||
|
|
||||||
<h2><?php _e('Advanced Options'); ?></h2>
|
<h2><?php _e('Advanced Options'); ?></h2>
|
||||||
|
|
||||||
<div id="linktargetdiv" class="postbox <?php echo postbox_classes('linktargetdiv', 'link'); ?>">
|
<div id="linktargetdiv" class="postbox <?php echo postbox_classes('linktargetdiv', 'link'); ?>">
|
||||||
@ -274,6 +276,8 @@ function xfn_check($class, $value = '', $deprecated = '') {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php do_meta_boxes('link', 'advanced', $link); ?>
|
||||||
|
|
||||||
<?php if ( $link_id ) : ?>
|
<?php if ( $link_id ) : ?>
|
||||||
<input type="hidden" name="action" value="save" />
|
<input type="hidden" name="action" value="save" />
|
||||||
<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
|
<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
|
||||||
|
@ -133,6 +133,8 @@ if ( ('edit' == $action) && current_user_can('delete_page', $post_ID) )
|
|||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<?php do_meta_boxes('post', 'normal', $post); ?>
|
||||||
|
|
||||||
<?php do_action('edit_page_form'); ?>
|
<?php do_action('edit_page_form'); ?>
|
||||||
|
|
||||||
<h2><?php _e('Advanced Options'); ?></h2>
|
<h2><?php _e('Advanced Options'); ?></h2>
|
||||||
@ -224,6 +226,8 @@ if ( $authors && count( $authors ) > 1 ) :
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php do_meta_boxes('page', 'advanced', $post); ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -853,22 +853,30 @@ function wp_remember_old_slug() {
|
|||||||
* @param string $id String for use in the 'id' attribute of tags.
|
* @param string $id String for use in the 'id' attribute of tags.
|
||||||
* @param string $title Title of the meta box
|
* @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 $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...
|
* @param string $page The type of edit page on which to show the box (post, page, link)
|
||||||
|
* @param string $context The context within the page where the boxes should show ('normal', 'advanced')
|
||||||
*/
|
*/
|
||||||
function add_meta_box($id, $title, $callback, $context) {
|
function add_meta_box($id, $title, $callback, $page, $context = 'advanced') {
|
||||||
global $wp_meta_boxes;
|
global $wp_meta_boxes;
|
||||||
|
|
||||||
$wp_meta_boxes[$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback);
|
if ( !isset($wp_meta_boxes) )
|
||||||
|
$wp_meta_boxes = array();
|
||||||
|
if ( !isset($wp_meta_boxes[$page]) )
|
||||||
|
$wp_meta_boxes[$page] = array();
|
||||||
|
if ( !isset($wp_meta_boxes[$page][$context]) )
|
||||||
|
$wp_meta_boxes[$page][$context] = array();
|
||||||
|
|
||||||
|
$wp_meta_boxes[$page][$context][] = array('id' => $id, 'title' => $title, 'callback' => $callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_meta_boxes($context, $object) {
|
function do_meta_boxes($page, $context, $object) {
|
||||||
global $wp_meta_boxes;
|
global $wp_meta_boxes;
|
||||||
|
|
||||||
if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$context]) )
|
if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach ( (array) $wp_meta_boxes[$context] as $box ) {
|
foreach ( (array) $wp_meta_boxes[$page][$context] as $box ) {
|
||||||
echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id']) . '">' . "\n";
|
echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '">' . "\n";
|
||||||
echo "<h3>{$box['title']}</h3>\n";
|
echo "<h3>{$box['title']}</h3>\n";
|
||||||
echo '<div class="inside">' . "\n";
|
echo '<div class="inside">' . "\n";
|
||||||
call_user_func($box['callback'], $object);
|
call_user_func($box['callback'], $object);
|
||||||
@ -877,4 +885,9 @@ function do_meta_boxes($context, $object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_box($post) {
|
||||||
|
echo "Hello $post->ID";
|
||||||
|
}
|
||||||
|
|
||||||
|
add_meta_box('test', 'Test', 'test_box', 'post');
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user