Move screen_meta() to admin header. Add all meta boxes before requiring admin-header.

git-svn-id: http://svn.automattic.com/wordpress/trunk@9620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-11-11 22:40:16 +00:00
parent 0e8ff11d74
commit cc7c443f62
23 changed files with 50 additions and 69 deletions

View File

@ -105,6 +105,8 @@ if ( function_exists('mb_strlen') ) {
<?php <?php
do_action('admin_notices'); do_action('admin_notices');
screen_meta($pagenow);
if ( $parent_file == 'options-general.php' ) { if ( $parent_file == 'options-general.php' ) {
require(ABSPATH . 'wp-admin/options-head.php'); require(ABSPATH . 'wp-admin/options-head.php');
} }

View File

@ -131,8 +131,6 @@ $messages[4] = __('Category not added.');
$messages[5] = __('Category not updated.'); $messages[5] = __('Category not updated.');
?> ?>
<?php screen_meta('edit-categories') ?>
<div class="wrap nosubsub"> <div class="wrap nosubsub">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -81,8 +81,6 @@ $post_id = isset($_GET['p']) ? (int) $_GET['p'] : 0;
$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : ''; $search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
$search = attribute_escape( $search_dirty ); ?> $search = attribute_escape( $search_dirty ); ?>
<?php screen_meta('edit-comments') ?>
<div class="wrap"> <div class="wrap">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -465,8 +465,13 @@ function post_revisions_meta_box($post) {
add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core'); add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core');
endif; endif;
do_action('do_meta_boxes', 'post', 'normal', $post);
do_action('do_meta_boxes', 'post', 'advanced', $post);
do_action('do_meta_boxes', 'post', 'side', $post);
require_once('admin-header.php');
?> ?>
<?php screen_meta('post'); ?>
<?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?> <?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
<input type="hidden" name="mode" value="bookmarklet" /> <input type="hidden" name="mode" value="bookmarklet" />

View File

@ -60,8 +60,6 @@ $messages[4] = __('Category not added.');
$messages[5] = __('Category not updated.'); $messages[5] = __('Category not updated.');
$messages[6] = __('Categories deleted.'); ?> $messages[6] = __('Categories deleted.'); ?>
<?php screen_meta('edit-link-categories') ?>
<div class="wrap nosubsub"> <div class="wrap nosubsub">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -16,7 +16,7 @@ if ( ! empty($cat_ID) ) {
/** /**
* @var string * @var string
*/ */
$heading = ''; $heading = '<h2>' . __('Edit Category') . '</h2>';
$submit_text = __('Edit Category'); $submit_text = __('Edit Category');
$form = '<form name="editcat" id="editcat" method="post" action="link-category.php" class="validate">'; $form = '<form name="editcat" id="editcat" method="post" action="link-category.php" class="validate">';
$action = 'editedcat'; $action = 'editedcat';

View File

@ -307,13 +307,29 @@ function link_advanced_meta_box($link) {
</table> </table>
<?php <?php
} }
add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'normal', 'core'); ?> add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'normal', 'core');
do_action('do_meta_boxes', 'link', 'normal', $link);
do_action('do_meta_boxes', 'link', 'advanced', $link);
do_action('do_meta_boxes', 'link', 'side', $link);
require_once ('admin-header.php');
?>
<?php screen_meta('link') ?>
<div class="wrap"> <div class="wrap">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>
<?php
$link_added = ( isset($_GET['added']) && '' != $_POST['link_name'] ) ?
'<div id="message" class="updated fade"><p>' . __('Link added.') . '</p></div>' : '';
?>
<?php if ( isset( $_GET['added'] ) && '' != $_POST['link_name']) : ?>
<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
<?php endif; ?>
<?php <?php
if ( !empty($form) ) if ( !empty($form) )
echo $form; echo $form;

View File

@ -369,9 +369,13 @@ function page_revisions_meta_box($post) {
} }
add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'normal', 'core'); add_meta_box('revisionsdiv', __('Page Revisions'), 'page_revisions_meta_box', 'page', 'normal', 'core');
endif; endif;
?>
<?php screen_meta('page'); ?> do_action('do_meta_boxes', 'page', 'normal', $post);
do_action('do_meta_boxes', 'page', 'advanced', $post);
do_action('do_meta_boxes', 'page', 'side', $post);
require_once('admin-header.php');
?>
<div class="wrap"> <div class="wrap">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -101,8 +101,6 @@ if ( is_singular() ) {
require_once('admin-header.php'); ?> require_once('admin-header.php'); ?>
<?php screen_meta('edit-pages') ?>
<div class="wrap"> <div class="wrap">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -129,8 +129,6 @@ $messages[4] = __('Tag not added.');
$messages[5] = __('Tag not updated.'); $messages[5] = __('Tag not updated.');
$messages[6] = __('Tags deleted.'); ?> $messages[6] = __('Tags deleted.'); ?>
<?php screen_meta('edit-tags') ?>
<div class="wrap nosubsub"> <div class="wrap nosubsub">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -90,8 +90,6 @@ if ( empty($_GET['mode']) )
else else
$mode = attribute_escape($_GET['mode']); ?> $mode = attribute_escape($_GET['mode']); ?>
<?php screen_meta('edit-posts') ?>
<div class="wrap"> <div class="wrap">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -2650,7 +2650,7 @@ function do_meta_boxes($page, $context, $object) {
global $wp_meta_boxes; global $wp_meta_boxes;
static $already_sorted = false; static $already_sorted = false;
do_action('do_meta_boxes', $page, $context, $object); //do_action('do_meta_boxes', $page, $context, $object);
$hidden = (array) get_user_option( "meta-box-hidden_$page" ); $hidden = (array) get_user_option( "meta-box-hidden_$page" );
@ -3177,10 +3177,19 @@ function _post_states($post) {
function screen_meta($screen) { function screen_meta($screen) {
global $wp_meta_boxes; global $wp_meta_boxes;
$column_screens = array('edit-posts' => 'post', 'edit-pages' => 'page', 'edit-tags' => 'tag', 'edit-categories' => 'category', $screen = str_replace('.php', '', $screen);
'edit-link-categories' => 'link-category', 'edit-links' => 'link', 'edit-users' => 'user', 'edit-media' => 'media',
$column_screens = array('edit' => 'post', 'edit-pages' => 'page', 'edit-tags' => 'tag', 'categories' => 'category',
'edit-link-categories' => 'link-category', 'link-manager' => 'link', 'users' => 'user', 'upload' => 'media',
'edit-comments' => 'comment'); 'edit-comments' => 'comment');
$screen = str_replace('-new', '', $screen);
$screen = str_replace('-add', '', $screen);
$meta_screens = array('index' => 'dashboard');
if ( isset($meta_screens[$screen]) )
$screen = $meta_screens[$screen];
error_log("screen: $screen");
$show_screen = false; $show_screen = false;
if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens[$screen]) ) if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens[$screen]) )
$show_screen = true; $show_screen = true;

View File

@ -28,8 +28,6 @@ require_once('admin-header.php');
$today = current_time('mysql', 1); $today = current_time('mysql', 1);
?> ?>
<?php screen_meta('dashboard'); ?>
<div class="wrap"> <div class="wrap">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -20,17 +20,6 @@ wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
wp_enqueue_script('link'); wp_enqueue_script('link');
wp_enqueue_script('xfn'); wp_enqueue_script('xfn');
$link_added = ( isset($_GET['added']) && '' != $_POST['link_name'] ) ?
'<div id="message" class="updated fade"><p>' . __('Link added.') . '</p></div>' : '';
require('admin-header.php');
?>
<?php if ( isset( $_GET['added'] ) && '' != $_POST['link_name']) : ?>
<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
<?php endif; ?>
<?php
$link = get_default_link_to_edit(); $link = get_default_link_to_edit();
include('edit-link-form.php'); include('edit-link-form.php');

View File

@ -74,8 +74,6 @@ switch ($order_by) {
break; break;
} ?> } ?>
<?php screen_meta('edit-links') ?>
<div class="wrap nosubsub"> <div class="wrap nosubsub">
<h2><?php echo wp_specialchars( $title ); ?></h2> <h2><?php echo wp_specialchars( $title ); ?></h2>

View File

@ -106,7 +106,6 @@ switch ($action) {
if (!$link = get_link_to_edit($link_id)) if (!$link = get_link_to_edit($link_id))
wp_die(__('Link not found.')); wp_die(__('Link not found.'));
include_once ('admin-header.php');
include ('edit-link-form.php'); include ('edit-link-form.php');
include ('admin-footer.php'); include ('admin-footer.php');
break; break;

View File

@ -19,20 +19,13 @@ add_thickbox();
wp_enqueue_script('media-upload'); wp_enqueue_script('media-upload');
wp_enqueue_script('word-count'); wp_enqueue_script('word-count');
require_once('admin-header.php');
?>
<?php if ( (isset($_GET['posted']) && $_GET['posted']) || isset($_GET['saved']) ) : ?>
<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?></strong> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_page_link( isset($_GET['posted']) ? $_GET['posted'] : $_GET['saved'] ); ?>"><?php _e('View page') ; ?></a></p></div>
<?php endif; ?>
<?php
if ( current_user_can('edit_pages') ) { if ( current_user_can('edit_pages') ) {
$action = 'post'; $action = 'post';
$post = get_default_page_to_edit(); $post = get_default_page_to_edit();
include('edit-page-form.php'); include('edit-page-form.php');
} }
?>
<?php include('admin-footer.php'); ?> include('admin-footer.php');
?>

View File

@ -115,8 +115,6 @@ case 'edit':
} }
} }
require_once('admin-header.php');
if ( !current_user_can('edit_page', $page_ID) ) if ( !current_user_can('edit_page', $page_ID) )
die ( __('You are not allowed to edit this page.') ); die ( __('You are not allowed to edit this page.') );

View File

@ -19,9 +19,8 @@ add_thickbox();
wp_enqueue_script('media-upload'); wp_enqueue_script('media-upload');
wp_enqueue_script('word-count'); wp_enqueue_script('word-count');
require_once ('./admin-header.php'); if ( ! current_user_can('edit_posts') ) {
require_once ('./admin-header.php'); ?>
if ( ! current_user_can('edit_posts') ) { ?>
<div class="wrap"> <div class="wrap">
<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br /> <p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br />
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br /> You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
@ -33,15 +32,6 @@ When you&#8217;re promoted, just reload this page and you&#8217;ll be able to bl
exit(); exit();
} }
if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>
<?php
endif;
?>
<?php
// Show post form. // Show post form.
$post = get_default_post_to_edit(); $post = get_default_post_to_edit();
include('edit-form-advanced.php'); include('edit-form-advanced.php');

View File

@ -158,8 +158,6 @@ case 'edit':
$title = __('Edit Post'); $title = __('Edit Post');
require_once('admin-header.php');
if ( !current_user_can('edit_post', $post_ID) ) if ( !current_user_can('edit_post', $post_ID) )
die ( __('You are not allowed to edit this post.') ); die ( __('You are not allowed to edit this post.') );

View File

@ -145,8 +145,6 @@ if ( is_singular() ) {
require_once('admin-header.php'); ?> require_once('admin-header.php'); ?>
<?php screen_meta('edit-media') ?>
<?php <?php
if ( isset($_GET['posted']) && (int) $_GET['posted'] ) { if ( isset($_GET['posted']) && (int) $_GET['posted'] ) {
$_GET['message'] = '1'; $_GET['message'] = '1';

View File

@ -41,8 +41,6 @@ wp_enqueue_script('admin-forms');
require_once ('admin-header.php'); require_once ('admin-header.php');
screen_meta('user');
?> ?>
<div class="wrap"> <div class="wrap">
<h2 id="add-new-user"><?php _e('Add New User') ?></h2> <h2 id="add-new-user"><?php _e('Add New User') ?></h2>

View File

@ -220,8 +220,6 @@ default:
} }
endif; ?> endif; ?>
<?php screen_meta('edit-users') ?>
<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?> <?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
<div class="error"> <div class="error">
<ul> <ul>