Merge edit-pages.php into edit.php. see #9674

git-svn-id: http://svn.automattic.com/wordpress/trunk@12728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-01-15 16:58:36 +00:00
parent 61e1249bf0
commit 05bf7382ff
21 changed files with 321 additions and 662 deletions

View File

@ -1003,8 +1003,11 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
case 'autosave-generate-nonces' : case 'autosave-generate-nonces' :
check_ajax_referer( 'autosave', 'autosavenonce' ); check_ajax_referer( 'autosave', 'autosavenonce' );
$ID = (int) $_POST['post_ID']; $ID = (int) $_POST['post_ID'];
$post_type = ( 'page' == $_POST['post_type'] ) ? 'page' : 'post'; $post_type = $_POST['post_type'];
if ( current_user_can( "edit_{$post_type}", $ID ) ) $post_type_object = get_post_type_object($post_type);
if ( !$post_type_object )
die('0');
if ( current_user_can( $post_type_object->edit_cap, $ID ) )
die( json_encode( array( 'updateNonce' => wp_create_nonce( "update-{$post_type}_{$ID}" ), 'deleteURL' => str_replace( '&', '&', wp_nonce_url( admin_url( $post_type . '.php?action=trash&post=' . $ID ), "trash-{$post_type}_{$ID}" ) ) ) ) ); die( json_encode( array( 'updateNonce' => wp_create_nonce( "update-{$post_type}_{$ID}" ), 'deleteURL' => str_replace( '&', '&', wp_nonce_url( admin_url( $post_type . '.php?action=trash&post=' . $ID ), "trash-{$post_type}_{$ID}" ) ) ) ) );
do_action('autosave_generate_nonces'); do_action('autosave_generate_nonces');
die('0'); die('0');

View File

@ -29,21 +29,6 @@ if ( is_multisite() )
wp_admin_css( 'css/ms' ); wp_admin_css( 'css/ms' );
wp_enqueue_script('utils'); wp_enqueue_script('utils');
$hook_suffix = '';
if ( isset($page_hook) )
$hook_suffix = $page_hook;
else if ( isset($plugin_page) )
$hook_suffix = $plugin_page;
else if ( isset($pagenow) )
$hook_suffix = $pagenow;
if ( isset($submenu_file) && (false !== $pos = strpos($submenu_file, 'post_type=')) )
$typenow = substr($submenu_file, $pos + 10);
elseif ( isset($parent_file) && (false !== $pos = strpos($parent_file, 'post_type=')) )
$typenow = substr($parent_file, $pos + 10);
else
$typenow = '';
$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -119,16 +104,22 @@ if ( function_exists('mb_strlen') ) {
<a href="<?php echo wp_logout_url() ?>" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a></p> <a href="<?php echo wp_logout_url() ?>" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a></p>
</div> </div>
<?php favorite_actions($hook_suffix); ?> <?php favorite_actions($current_screen); ?>
</div> </div>
</div> </div>
<div id="wpbody"> <div id="wpbody">
<?php require(ABSPATH . 'wp-admin/menu-header.php'); ?> <?php
require(ABSPATH . 'wp-admin/menu-header.php');
$current_screen->parent_file = $parent_file;
$current_screen->parent_base = preg_replace('/\?.*$/', '', $parent_file);
$current_screen->parent_base = str_replace('.php', '', $current_screen->parent_base);
?>
<div id="wpbody-content"> <div id="wpbody-content">
<?php <?php
screen_meta($hook_suffix); screen_meta($current_screen);
do_action('admin_notices'); do_action('admin_notices');

View File

@ -177,4 +177,43 @@ if (isset($plugin_page)) {
if ( !empty($_REQUEST['action']) ) if ( !empty($_REQUEST['action']) )
do_action('admin_action_' . $_REQUEST['action']); do_action('admin_action_' . $_REQUEST['action']);
$hook_suffix = '';
if ( isset($page_hook) )
$hook_suffix = $page_hook;
else if ( isset($plugin_page) )
$hook_suffix = $plugin_page;
else if ( isset($pagenow) )
$hook_suffix = $pagenow;
if ( isset($_GET['post_type']) )
$typenow = $_GET['post_type'];
else
$typenow = '';
// @todo validate typenow against post types.
/**
* Global object containing info about the current screen.
*/
$current_screen = $hook_suffix;
$current_screen = str_replace('.php', '', $current_screen);
$current_screen = str_replace('-new', '', $current_screen);
$current_screen = str_replace('-add', '', $current_screen);
$current_screen = array('id' => $current_screen, 'base' => $current_screen);
$current_screen = (object) $current_screen;
if ( 'edit' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id .= '-' . $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'post' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id = $typenow;
$current_screen->post_type = $typenow;
} else {
$typenow = '';
}
$current_screen = apply_filters('current_screen', $current_screen);
?> ?>

View File

@ -142,6 +142,8 @@ do_action('do_meta_boxes', $post_type, 'normal', $post);
do_action('do_meta_boxes', $post_type, 'advanced', $post); do_action('do_meta_boxes', $post_type, 'advanced', $post);
do_action('do_meta_boxes', $post_type, 'side', $post); do_action('do_meta_boxes', $post_type, 'side', $post);
add_contextual_help($current_screen, drag_drop_help());
require_once('admin-header.php'); require_once('admin-header.php');
?> ?>

View File

@ -34,6 +34,8 @@ do_action('do_meta_boxes', 'link', 'normal', $link);
do_action('do_meta_boxes', 'link', 'advanced', $link); do_action('do_meta_boxes', 'link', 'advanced', $link);
do_action('do_meta_boxes', 'link', 'side', $link); do_action('do_meta_boxes', 'link', 'side', $link);
add_contextual_help($current_screen, drag_drop_help());
require_once ('admin-header.php'); require_once ('admin-header.php');
?> ?>

View File

@ -1,384 +0,0 @@
<?php
/**
* Edit Pages Administration Panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('admin.php');
if ( !current_user_can('edit_pages') )
wp_die(__('Cheatin&#8217; uh?'));
// Handle bulk actions
if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
check_admin_referer('bulk-pages');
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
if ( strpos($sendback, 'page.php') !== false )
$sendback = admin_url('post-new.php?post_type=page');
if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = %s", $post_status ) );
$doaction = 'delete';
} elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) {
$post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']);
$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
} else {
wp_redirect( admin_url('edit-pages.php') );
}
switch ( $doaction ) {
case 'trash':
$trashed = 0;
foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can('delete_page', $post_id) )
wp_die( __('You are not allowed to move this page to the trash.') );
if ( !wp_trash_post($post_id) )
wp_die( __('Error in moving to trash...') );
$trashed++;
}
$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids)), $sendback );
break;
case 'untrash':
$untrashed = 0;
foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can('delete_page', $post_id) )
wp_die( __('You are not allowed to restore this page from the trash.') );
if ( !wp_untrash_post($post_id) )
wp_die( __('Error in restoring from trash...') );
$untrashed++;
}
$sendback = add_query_arg('untrashed', $untrashed, $sendback);
break;
case 'delete':
$deleted = 0;
foreach( (array) $post_ids as $post_id ) {
$post_del = & get_post($post_id);
if ( !current_user_can('delete_page', $post_id) )
wp_die( __('You are not allowed to delete this page.') );
if ( $post_del->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($post_id) )
wp_die( __('Error in deleting...') );
} else {
if ( !wp_delete_post($post_id) )
wp_die( __('Error in deleting...') );
}
$deleted++;
}
$sendback = add_query_arg('deleted', $deleted, $sendback);
break;
case 'edit':
$_GET['post_type'] = 'page';
$done = bulk_edit_posts($_GET);
if ( is_array($done) ) {
$done['updated'] = count( $done['updated'] );
$done['skipped'] = count( $done['skipped'] );
$done['locked'] = count( $done['locked'] );
$sendback = add_query_arg( $done, $sendback );
}
break;
}
if ( isset($_GET['action']) )
$sendback = remove_query_arg( array('action', 'action2', 'post_parent', 'page_template', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view', 'post_type'), $sendback );
wp_redirect($sendback);
exit();
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
exit;
}
if ( empty($title) )
$title = __('Edit Pages');
$parent_file = 'edit-pages.php';
wp_enqueue_script('inline-edit-post');
$post_stati = array( // array( adj, noun )
'publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>', 'page')),
'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')),
'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>', 'page')),
'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'page')),
'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')),
'trash' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page'))
);
if ( !EMPTY_TRASH_DAYS )
unset($post_stati['trash']);
$post_stati = apply_filters('page_stati', $post_stati);
$query = array('post_type' => 'page', 'orderby' => 'menu_order title',
'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc');
$post_status_label = __('Pages');
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
$post_status_label = $post_stati[$_GET['post_status']][1];
$query['post_status'] = $_GET['post_status'];
$query['perm'] = 'readable';
}
$query = apply_filters('manage_pages_query', $query);
wp($query);
if ( is_singular() ) {
wp_enqueue_script( 'admin-comments' );
enqueue_comment_hotkeys_js();
}
require_once('admin-header.php'); ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?> <a href="post-new.php?post_type=page" class="button add-new-h2"><?php echo esc_html_x('Add New', 'page'); ?></a> <?php
if ( isset($_GET['s']) && $_GET['s'] )
printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
</h2>
<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?>
<div id="message" class="updated"><p>
<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
unset($_GET['updated']);
}
if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) {
printf( _n( '%s page not updated, invalid parent page specified.', '%s pages not updated, invalid parent page specified.', $_GET['skipped'] ), number_format_i18n( $_GET['skipped'] ) );
unset($_GET['skipped']);
}
if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
printf( _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['skipped'] ) );
unset($_GET['locked']);
}
if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
printf( _n( 'Page permanently deleted.', '%s pages permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
unset($_GET['deleted']);
}
if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
printf( _n( 'Page moved to the trash.', '%s pages moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
echo ' <a href="' . esc_url( wp_nonce_url( "edit-pages.php?doaction=undo&action=untrash&ids=$ids", "bulk-pages" ) ) . '">' . __('Undo') . '</a><br />';
unset($_GET['trashed']);
}
if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
printf( _n( 'Page restored from the trash.', '%s pages restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
unset($_GET['untrashed']);
}
$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );
?>
</p></div>
<?php } ?>
<?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
<div id="message" class="updated"><p><strong><?php _e('Your page has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View page'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit page'); ?></a></p></div>
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
endif; ?>
<form id="posts-filter" action="<?php echo admin_url('edit-pages.php'); ?>" method="get">
<ul class="subsubsub">
<?php
$avail_post_stati = get_available_post_statuses('page');
if ( empty($locked_post_status) ) :
$status_links = array();
$num_posts = wp_count_posts('page', 'readable');
$total_posts = array_sum( (array) $num_posts ) - $num_posts->trash;
$class = empty($_GET['post_status']) ? ' class="current"' : '';
$status_links[] = "<li><a href='edit-pages.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'pages' ), number_format_i18n( $total_posts ) ) . '</a>';
foreach ( $post_stati as $status => $label ) {
$class = '';
if ( !in_array($status, $avail_post_stati) || $num_posts->$status <= 0 )
continue;
if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] )
$class = ' class="current"';
$status_links[] = "<li><a href='edit-pages.php?post_status=$status'$class>" . sprintf( _nx( $label[2][0], $label[2][1], $num_posts->$status, $label[2][2] ), number_format_i18n( $num_posts->$status ) ) . '</a>';
}
echo implode( " |</li>\n", $status_links ) . '</li>';
unset($status_links);
endif;
?>
</ul>
<p class="search-box">
<label class="screen-reader-text" for="page-search-input"><?php _e( 'Search Pages' ); ?>:</label>
<input type="text" id="page-search-input" name="s" value="<?php _admin_search_query(); ?>" />
<input type="submit" value="<?php esc_attr_e( 'Search Pages' ); ?>" class="button" />
</p>
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" />
<?php if ($posts) { ?>
<div class="tablenav">
<?php
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
$per_page = (int) get_user_option( 'edit_pages_per_page' );
if ( empty( $per_page ) || $per_page < 1 )
$per_page = 20;
$per_page = apply_filters( 'edit_pages_per_page', $per_page );
$num_pages = ceil($wp_query->post_count / $per_page);
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ),
'format' => '',
'prev_text' => __('&laquo;'),
'next_text' => __('&raquo;'),
'total' => $num_pages,
'current' => $pagenum
));
$is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash';
if ( $page_links ) : ?>
<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
number_format_i18n( min( $pagenum * $per_page, $wp_query->post_count ) ),
number_format_i18n( $wp_query->post_count ),
$page_links
); echo $page_links_text; ?></div>
<?php endif; ?>
<div class="alignleft actions">
<select name="action">
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
<?php if ( $is_trash ) { ?>
<option value="untrash"><?php _e('Restore'); ?></option>
<?php } else { ?>
<option value="edit"><?php _e('Edit'); ?></option>
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
<option value="delete"><?php _e('Delete Permanently'); ?></option>
<?php } else { ?>
<option value="trash"><?php _e('Move to Trash'); ?></option>
<?php } ?>
</select>
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-pages'); ?>
<?php if ( $is_trash ) { ?>
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
<?php } ?>
</div>
<br class="clear" />
</div>
<div class="clear"></div>
<table class="widefat page fixed" cellspacing="0">
<thead>
<tr>
<?php print_column_headers('edit-pages'); ?>
</tr>
</thead>
<tfoot>
<tr>
<?php print_column_headers('edit-pages', false); ?>
</tr>
</tfoot>
<tbody>
<?php page_rows($posts, $pagenum, $per_page); ?>
</tbody>
</table>
<div class="tablenav">
<?php
if ( $page_links )
echo "<div class='tablenav-pages'>$page_links_text</div>";
?>
<div class="alignleft actions">
<select name="action2">
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
<?php if ( $is_trash ) { ?>
<option value="untrash"><?php _e('Restore'); ?></option>
<?php } else { ?>
<option value="edit"><?php _e('Edit'); ?></option>
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
<option value="delete"><?php _e('Delete Permanently'); ?></option>
<?php } else { ?>
<option value="trash"><?php _e('Move to Trash'); ?></option>
<?php } ?>
</select>
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
<?php if ( $is_trash ) { ?>
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
<?php } ?>
</div>
<br class="clear" />
</div>
<?php } else { ?>
<div class="clear"></div>
<p><?php _e('No pages found.') ?></p>
<?php
} // end if ($posts)
?>
</form>
<?php inline_edit_row( 'page' ) ?>
<div id="ajax-response"></div>
<?php
if ( 1 == count($posts) && is_singular() ) :
$comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
if ( $comments ) :
// Make sure comments, post, and post_author are cached
update_comment_cache($comments);
$post = get_post($id);
$authordata = get_userdata($post->post_author);
?>
<br class="clear" />
<table class="widefat" cellspacing="0">
<thead>
<tr>
<th scope="col" class="column-comment">
<?php /* translators: column name */ echo _x('Comment', 'column name') ?>
</th>
<th scope="col" class="column-author"><?php _e('Author') ?></th>
<th scope="col" class="column-date"><?php _e('Submitted') ?></th>
</tr>
</thead>
<tbody id="the-comment-list" class="list:comment">
<?php
foreach ($comments as $comment)
_wp_comment_row( $comment->comment_ID, 'single', false, false );
?>
</tbody>
</table>
<?php
wp_comment_reply();
endif; // comments
endif; // posts;
?>
</div>
<?php
include('admin-footer.php');

View File

@ -13,17 +13,22 @@ if ( !defined('ABSPATH') )
<table class="widefat post fixed" cellspacing="0"> <table class="widefat post fixed" cellspacing="0">
<thead> <thead>
<tr> <tr>
<?php print_column_headers('edit'); ?> <?php print_column_headers( $current_screen ); ?>
</tr> </tr>
</thead> </thead>
<tfoot> <tfoot>
<tr> <tr>
<?php print_column_headers('edit', false); ?> <?php print_column_headers($current_screen, false); ?>
</tr> </tr>
</tfoot> </tfoot>
<tbody> <tbody>
<?php post_rows(); ?> <?php
if ( $post_type_object->hierarchical )
page_rows($posts, $pagenum, $per_page);
else
post_rows();
?>
</tbody> </tbody>
</table> </table>

View File

@ -20,13 +20,14 @@ if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['pag
unset( $_redirect ); unset( $_redirect );
} }
if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) ) if ( isset($_GET['post_type']) && ( in_array( $_GET['post_type'], get_post_types( array('_show' => true ) ) ) || in_array( $_GET['post_type'], get_post_types( array('_builtin' => true ) ) ) ) )
$post_type = $_GET['post_type']; $post_type = $_GET['post_type'];
else else
$post_type = 'post'; $post_type = 'post';
$_GET['post_type'] = $post_type; $_GET['post_type'] = $post_type;
$post_type_object = get_post_type_object($post_type); $post_type_object = get_post_type_object($post_type);
$post_type_cap = $post_type_object->capability_type;
if ( 'post' != $post_type ) { if ( 'post' != $post_type ) {
$parent_file = "edit.php?post_type=$post_type"; $parent_file = "edit.php?post_type=$post_type";
@ -38,6 +39,16 @@ if ( 'post' != $post_type ) {
$post_new_file = 'post-new.php'; $post_new_file = 'post-new.php';
} }
$pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
if ( empty($pagenum) )
$pagenum = 1;
$per_page = 'edit_' . $post_type . '_per_page';
$per_page = (int) get_user_option( $per_page );
if ( empty( $per_page ) || $per_page < 1 )
$per_page = 15;
// @todo filter based on type
$per_page = apply_filters( 'edit_posts_per_page', $per_page );
// Handle bulk actions // Handle bulk actions
if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
check_admin_referer('bulk-posts'); check_admin_referer('bulk-posts');
@ -61,8 +72,8 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
case 'trash': case 'trash':
$trashed = 0; $trashed = 0;
foreach( (array) $post_ids as $post_id ) { foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can('delete_post', $post_id) ) if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
wp_die( __('You are not allowed to move this post to the trash.') ); wp_die( __('You are not allowed to move this item to the trash.') );
if ( !wp_trash_post($post_id) ) if ( !wp_trash_post($post_id) )
wp_die( __('Error in moving to trash...') ); wp_die( __('Error in moving to trash...') );
@ -74,8 +85,8 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
case 'untrash': case 'untrash':
$untrashed = 0; $untrashed = 0;
foreach( (array) $post_ids as $post_id ) { foreach( (array) $post_ids as $post_id ) {
if ( !current_user_can('delete_post', $post_id) ) if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
wp_die( __('You are not allowed to restore this post from the trash.') ); wp_die( __('You are not allowed to restore this item from the trash.') );
if ( !wp_untrash_post($post_id) ) if ( !wp_untrash_post($post_id) )
wp_die( __('Error in restoring from trash...') ); wp_die( __('Error in restoring from trash...') );
@ -89,8 +100,8 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
foreach( (array) $post_ids as $post_id ) { foreach( (array) $post_ids as $post_id ) {
$post_del = & get_post($post_id); $post_del = & get_post($post_id);
if ( !current_user_can('delete_post', $post_id) ) if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
wp_die( __('You are not allowed to delete this post.') ); wp_die( __('You are not allowed to delete this item.') );
if ( $post_del->post_type == 'attachment' ) { if ( $post_del->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($post_id) ) if ( ! wp_delete_attachment($post_id) )
@ -130,7 +141,7 @@ $title = sprintf(__('Edit %s'), $post_type_object->label);
wp_enqueue_script('inline-edit-post'); wp_enqueue_script('inline-edit-post');
$user_posts = false; $user_posts = false;
if ( !current_user_can('edit_others_posts') ) { if ( !current_user_can('edit_others_' . $post_type_cap . 's') ) {
$user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) ); $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) );
$user_posts = true; $user_posts = true;
if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) ) if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) )
@ -139,10 +150,12 @@ if ( !current_user_can('edit_others_posts') ) {
$avail_post_stati = wp_edit_posts_query(); $avail_post_stati = wp_edit_posts_query();
require_once('admin-header.php'); if ( $post_type_object->hierarchical )
$num_pages = ceil($wp_query->post_count / $per_page);
else
$num_pages = $wp_query->max_num_pages;
if ( !isset( $_GET['paged'] ) ) require_once('admin-header.php');
$_GET['paged'] = 1;
if ( empty($_GET['mode']) ) if ( empty($_GET['mode']) )
$mode = 'list'; $mode = 'list';
@ -158,7 +171,7 @@ if ( isset($_GET['s']) && $_GET['s'] )
<?php <?php
if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
<div id="message" class="updated"><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> <div id="message" class="updated"><p><strong><?php _e('This 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 $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
endif; ?> endif; ?>
@ -173,24 +186,24 @@ if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
unset($_GET['skipped']); unset($_GET['skipped']);
if ( isset($_GET['locked']) && (int) $_GET['locked'] ) { if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
printf( _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) ); printf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
unset($_GET['locked']); unset($_GET['locked']);
} }
if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
printf( _n( 'Post permanently deleted.', '%s posts permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); printf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
unset($_GET['deleted']); unset($_GET['deleted']);
} }
if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
printf( _n( 'Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); printf( _n( 'Item moved to the trash.', '%s items moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0; $ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />'; echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
unset($_GET['trashed']); unset($_GET['trashed']);
} }
if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
printf( _n( 'Post restored from the trash.', '%s posts restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); printf( _n( 'Item restored from the trash.', '%s items restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
unset($_GET['undeleted']); unset($_GET['undeleted']);
} }
@ -212,7 +225,7 @@ $allposts = '';
if ( $user_posts ) { if ( $user_posts ) {
if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user->ID ) ) if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user->ID ) )
$class = ' class="current"'; $class = ' class="current"';
$status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'My Posts <span class="count">(%s)</span>', 'My Posts <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>'; $status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>';
$allposts = '?all_posts=1'; $allposts = '?all_posts=1';
} }
@ -261,8 +274,8 @@ $page_links = paginate_links( array(
'format' => '', 'format' => '',
'prev_text' => __('&laquo;'), 'prev_text' => __('&laquo;'),
'next_text' => __('&raquo;'), 'next_text' => __('&raquo;'),
'total' => $wp_query->max_num_pages, 'total' => $num_pages,
'current' => $_GET['paged'] 'current' => $pagenum
)); ));
$is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash'; $is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash';
@ -318,23 +331,25 @@ foreach ($arc_result as $arc_row) {
<?php } ?> <?php } ?>
<?php <?php
if ( is_object_in_taxonomy($post_type, 'category') ) {
$dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1, $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
'show_count' => 0, 'orderby' => 'name', 'selected' => $cat); 'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
wp_dropdown_categories($dropdown_options); wp_dropdown_categories($dropdown_options);
do_action('restrict_manage_posts'); do_action('restrict_manage_posts');
}
?> ?>
<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" /> <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
<?php } <?php }
if ( $is_trash && current_user_can('edit_others_posts') ) { ?> if ( $is_trash && current_user_can('edit_others_' . $post_type_cap .'s') ) { ?>
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
<?php } ?> <?php } ?>
</div> </div>
<?php if ( $page_links ) { ?> <?php if ( $page_links ) { ?>
<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s', <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ), number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ), number_format_i18n( min( $pagenum * $per_page, $wp_query->found_posts ) ),
number_format_i18n( $wp_query->found_posts ), number_format_i18n( $wp_query->found_posts ),
$page_links $page_links
); echo $page_links_text; ?></div> ); echo $page_links_text; ?></div>
@ -373,7 +388,7 @@ if ( $page_links )
<?php } ?> <?php } ?>
</select> </select>
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
<?php if ( $is_trash && current_user_can('edit_others_posts') ) { ?> <?php if ( $is_trash && current_user_can('edit_others_' . $post_type_cap . 's') ) { ?>
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
<?php } ?> <?php } ?>
<br class="clear" /> <br class="clear" />
@ -393,7 +408,7 @@ else
</form> </form>
<?php inline_edit_row( 'post' ); ?> <?php inline_edit_row( $current_screen ); ?>
<div id="ajax-response"></div> <div id="ajax-response"></div>
<br class="clear" /> <br class="clear" />

View File

@ -410,7 +410,6 @@ function set_screen_options() {
switch ( $map_option ) { switch ( $map_option ) {
case 'edit_per_page': case 'edit_per_page':
case 'edit_pages_per_page':
case 'edit_comments_per_page': case 'edit_comments_per_page':
case 'upload_per_page': case 'upload_per_page':
case 'categories_per_page': case 'categories_per_page':

View File

@ -819,10 +819,11 @@ function wp_edit_posts_query( $q = false ) {
$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
$post_stati = get_post_stati(); $post_stati = get_post_stati();
if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types( array('_show' => true) ) ) ) if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
$post_type = $q['post_type']; $post_type = $q['post_type'];
else else
$post_type = 'post'; $post_type = 'post';
$post_type_object = get_post_type_object($post_type);
$avail_post_stati = get_available_post_statuses($post_type); $avail_post_stati = get_available_post_statuses($post_type);
@ -842,16 +843,24 @@ function wp_edit_posts_query( $q = false ) {
$orderby = 'date'; $orderby = 'date';
} }
if ( 'post' != $post_type )
$per_page = 'edit_' . $post_type . '_per_page'; $per_page = 'edit_' . $post_type . '_per_page';
else $posts_per_page = (int) get_user_option( $per_page );
$per_page = 'edit_per_page';
$posts_per_page = (int) get_user_option( 'edit_per_page' );
if ( empty( $posts_per_page ) || $posts_per_page < 1 ) if ( empty( $posts_per_page ) || $posts_per_page < 1 )
$posts_per_page = 15; $posts_per_page = 15;
$posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page ); $posts_per_page = apply_filters( $per_page, $posts_per_page );
wp( compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page') );
$query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
// Hierarchical types require special args.
if ( $post_type_object->hierarchical ) {
$query['orderby'] = 'menu_order title';
$query['order'] = 'asc';
$query['posts_per_page'] = -1;
$query['posts_per_archive_page'] = -1;
}
wp( $query );
return $avail_post_stati; return $avail_post_stati;
} }

View File

@ -748,22 +748,26 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'po
* *
* @return unknown * @return unknown
*/ */
function wp_manage_posts_columns() { function wp_manage_posts_columns( $screen = '') {
global $typenow; if ( empty($screen) )
$post_type = 'post';
else
$post_type = $screen->post_type;
$posts_columns = array(); $posts_columns = array();
$posts_columns['cb'] = '<input type="checkbox" />'; $posts_columns['cb'] = '<input type="checkbox" />';
/* translators: manage posts column name */ /* translators: manage posts column name */
$posts_columns['title'] = _x('Post', 'column name'); $posts_columns['title'] = _x('Title', 'column name');
$posts_columns['author'] = __('Author'); $posts_columns['author'] = __('Author');
if ( empty($typenow) || is_object_in_taxonomy($typenow, 'category') ) if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )
$posts_columns['categories'] = __('Categories'); $posts_columns['categories'] = __('Categories');
if ( empty($typenow) || is_object_in_taxonomy($typenow, 'category') ) if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )
$posts_columns['tags'] = __('Tags'); $posts_columns['tags'] = __('Tags');
$post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all'; $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($typenow) || post_type_supports($typenow, 'comments') ) ) if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($post_type) || post_type_supports($post_type, 'comments') ) )
$posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>'; $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
$posts_columns['date'] = __('Date'); $posts_columns['date'] = __('Date');
// @todo filter per type
$posts_columns = apply_filters('manage_posts_columns', $posts_columns); $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
return $posts_columns; return $posts_columns;
@ -804,17 +808,7 @@ function wp_manage_media_columns() {
* @return unknown * @return unknown
*/ */
function wp_manage_pages_columns() { function wp_manage_pages_columns() {
$posts_columns = array(); return wp_manage_posts_columns();
$posts_columns['cb'] = '<input type="checkbox" />';
$posts_columns['title'] = __('Title');
$posts_columns['author'] = __('Author');
$post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
if ( !in_array( $post_status, array('pending', 'draft', 'future') ) )
$posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
$posts_columns['date'] = __('Date');
$posts_columns = apply_filters('manage_pages_columns', $posts_columns);
return $posts_columns;
} }
/** /**
@ -822,33 +816,28 @@ function wp_manage_pages_columns() {
* *
* @since unknown * @since unknown
* *
* @param unknown_type $page * @param unknown_type $screen
* @return unknown * @return unknown
*/ */
function get_column_headers($page) { function get_column_headers($screen) {
global $_wp_column_headers; global $_wp_column_headers;
if ( !isset($_wp_column_headers) ) if ( !isset($_wp_column_headers) )
$_wp_column_headers = array(); $_wp_column_headers = array();
$map_screen = $page; if ( is_string($screen) )
$type = str_replace('edit-', '', $map_screen); $screen = convert_to_screen($screen);
if ( in_array($type, get_post_types()) )
$map_screen = 'edit';
// Store in static to avoid running filters on each call // Store in static to avoid running filters on each call
if ( isset($_wp_column_headers[$page]) ) if ( isset($_wp_column_headers[$screen->id]) )
return $_wp_column_headers[$page]; return $_wp_column_headers[$screen->id];
switch ($map_screen) { switch ($screen->base) {
case 'edit': case 'edit':
$_wp_column_headers[$page] = wp_manage_posts_columns(); $_wp_column_headers[$screen->id] = wp_manage_posts_columns( $screen );
break;
case 'edit-pages':
$_wp_column_headers[$page] = wp_manage_pages_columns();
break; break;
case 'edit-comments': case 'edit-comments':
$_wp_column_headers[$page] = array( $_wp_column_headers[$screen->id] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'author' => __('Author'), 'author' => __('Author'),
/* translators: column name */ /* translators: column name */
@ -859,7 +848,7 @@ function get_column_headers($page) {
break; break;
case 'link-manager': case 'link-manager':
$_wp_column_headers[$page] = array( $_wp_column_headers[$screen->id] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'name' => __('Name'), 'name' => __('Name'),
'url' => __('URL'), 'url' => __('URL'),
@ -871,10 +860,10 @@ function get_column_headers($page) {
break; break;
case 'upload': case 'upload':
$_wp_column_headers[$page] = wp_manage_media_columns(); $_wp_column_headers[$screen->id] = wp_manage_media_columns();
break; break;
case 'categories': case 'categories':
$_wp_column_headers[$page] = array( $_wp_column_headers[$screen->id] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'name' => __('Name'), 'name' => __('Name'),
'description' => __('Description'), 'description' => __('Description'),
@ -884,7 +873,7 @@ function get_column_headers($page) {
break; break;
case 'edit-link-categories': case 'edit-link-categories':
$_wp_column_headers[$page] = array( $_wp_column_headers[$screen->id] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'name' => __('Name'), 'name' => __('Name'),
'description' => __('Description'), 'description' => __('Description'),
@ -894,7 +883,7 @@ function get_column_headers($page) {
break; break;
case 'edit-tags': case 'edit-tags':
$_wp_column_headers[$page] = array( $_wp_column_headers[$screen->id] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'name' => __('Name'), 'name' => __('Name'),
'description' => __('Description'), 'description' => __('Description'),
@ -904,7 +893,7 @@ function get_column_headers($page) {
break; break;
case 'users': case 'users':
$_wp_column_headers[$page] = array( $_wp_column_headers[$screen->id] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'username' => __('Username'), 'username' => __('Username'),
'name' => __('Name'), 'name' => __('Name'),
@ -914,11 +903,11 @@ function get_column_headers($page) {
); );
break; break;
default : default :
$_wp_column_headers[$page] = array(); $_wp_column_headers[$screen->id] = array();
} }
$_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]); $_wp_column_headers[$screen->id] = apply_filters('manage_' . $screen->id . '_columns', $_wp_column_headers[$screen->id]);
return $_wp_column_headers[$page]; return $_wp_column_headers[$screen->id];
} }
/** /**
@ -926,13 +915,15 @@ function get_column_headers($page) {
* *
* @since unknown * @since unknown
* *
* @param unknown_type $type * @param unknown_type $screen
* @param unknown_type $id * @param unknown_type $id
*/ */
function print_column_headers( $type, $id = true ) { function print_column_headers( $screen, $id = true ) {
$type = str_replace('.php', '', $type); if ( is_string($screen) )
$columns = get_column_headers( $type ); $screen = convert_to_screen($screen);
$hidden = get_hidden_columns($type);
$columns = get_column_headers( $screen );
$hidden = get_hidden_columns($screen);
$styles = array(); $styles = array();
foreach ( $columns as $column_key => $column_display_name ) { foreach ( $columns as $column_key => $column_display_name ) {
@ -951,8 +942,8 @@ function print_column_headers( $type, $id = true ) {
if ( in_array($column_key, $hidden) ) if ( in_array($column_key, $hidden) )
$style = 'display:none;'; $style = 'display:none;';
if ( isset($styles[$type]) && isset($styles[$type][$column_key]) ) if ( isset($styles[$screen->id]) && isset($styles[$screen->id][$column_key]) )
$style .= ' ' . $styles[$type][$column_key]; $style .= ' ' . $styles[$screen>id][$column_key];
$style = ' style="' . $style . '"'; $style = ' style="' . $style . '"';
?> ?>
<th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th> <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
@ -971,10 +962,13 @@ function print_column_headers( $type, $id = true ) {
function register_column_headers($screen, $columns) { function register_column_headers($screen, $columns) {
global $_wp_column_headers; global $_wp_column_headers;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
if ( !isset($_wp_column_headers) ) if ( !isset($_wp_column_headers) )
$_wp_column_headers = array(); $_wp_column_headers = array();
$_wp_column_headers[$screen] = $columns; $_wp_column_headers[$screen->id] = $columns;
} }
/** /**
@ -982,11 +976,13 @@ function register_column_headers($screen, $columns) {
* *
* @since unknown * @since unknown
* *
* @param unknown_type $page * @param unknown_type $screen
*/ */
function get_hidden_columns($page) { function get_hidden_columns($screen) {
$page = str_replace('.php', '', $page); if ( is_string($screen) )
return (array) get_user_option( 'manage-' . $page . '-columns-hidden' ); $screen = convert_to_screen($screen);
return (array) get_user_option( 'manage-' . $screen->id. '-columns-hidden' );
} }
/** /**
@ -998,23 +994,23 @@ function get_hidden_columns($page) {
* *
* @param string $type 'post' or 'page' * @param string $type 'post' or 'page'
*/ */
function inline_edit_row( $type ) { function inline_edit_row( $screen ) {
global $current_user, $mode; global $current_user, $mode;
$is_page = 'page' == $type; if ( is_string($screen) ) {
if ( $is_page ) { $screen = array('id' => 'edit-' . $screen, 'base' => 'edit', 'post_type' => $screen );
$screen = 'edit-pages'; $screen = (object) $screen;
$post = get_default_page_to_edit();
} else {
$screen = 'edit';
$post = get_default_post_to_edit();
} }
$columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns(); $post = get_default_post_to_edit( $screen->post_type );
$post_type_object = get_post_type_object( $screen->post_type );
$columns = wp_manage_posts_columns($screen);
$hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) ); $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
$col_count = count($columns) - count($hidden); $col_count = count($columns) - count($hidden);
$m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
$can_publish = current_user_can("publish_{$type}s"); // @todo use capability_type
$can_publish = current_user_can("publish_{$screen->post_type}s");
$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
?> ?>
@ -1024,12 +1020,12 @@ function inline_edit_row( $type ) {
$bulk = 0; $bulk = 0;
while ( $bulk < 2 ) { ?> while ( $bulk < 2 ) { ?>
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type "; <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$screen->post_type ";
echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type"; echo $bulk ? "bulk-edit-row bulk-edit-row-$screen->post_type" : "quick-edit-row quick-edit-row-$screen->post_type";
?>" style="display: none"><td colspan="<?php echo $col_count; ?>"> ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
<fieldset class="inline-edit-col-left"><div class="inline-edit-col"> <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
<h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4> <h4><?php echo $bulk ? ( __( 'Bulk Edit' ) ) : __( 'Quick Edit' ); ?></h4>
<?php if ( $bulk ) : ?> <?php if ( $bulk ) : ?>
@ -1062,7 +1058,7 @@ function inline_edit_row( $type ) {
<?php endif; // $bulk <?php endif; // $bulk
$authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM $authors = get_editable_user_ids( $current_user->id, true, $screen->post_type ); // TODO: ROLE SYSTEM
$authors_dropdown = ''; $authors_dropdown = '';
if ( $authors && count( $authors ) > 1 ) : if ( $authors && count( $authors ) > 1 ) :
$users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0); $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0);
@ -1092,7 +1088,7 @@ function inline_edit_row( $type ) {
</em> </em>
<label class="alignleft inline-edit-private"> <label class="alignleft inline-edit-private">
<input type="checkbox" name="keep_private" value="private" /> <input type="checkbox" name="keep_private" value="private" />
<span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span> <span class="checkbox-title"><?php echo __('Private'); ?></span>
</label> </label>
</div> </div>
@ -1100,7 +1096,7 @@ function inline_edit_row( $type ) {
</div></fieldset> </div></fieldset>
<?php if ( !$is_page && !$bulk ) : ?> <?php if ( is_object_in_taxonomy($screen->post_type, 'categories') && !$bulk ) : ?>
<fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
<span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?> <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
@ -1112,7 +1108,7 @@ function inline_edit_row( $type ) {
</ul> </ul>
</div></fieldset> </div></fieldset>
<?php endif; // !$is_page && !$bulk ?> <?php endif; // !hierarchical && !$bulk ?>
<fieldset class="inline-edit-col-right"><div class="inline-edit-col"> <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
@ -1121,7 +1117,7 @@ function inline_edit_row( $type ) {
echo $authors_dropdown; echo $authors_dropdown;
?> ?>
<?php if ( $is_page ) : ?> <?php if ( $post_type_object->hierarchical ) : ?>
<label> <label>
<span class="title"><?php _e( 'Parent' ); ?></span> <span class="title"><?php _e( 'Parent' ); ?></span>
@ -1221,7 +1217,7 @@ function inline_edit_row( $type ) {
</select> </select>
</label> </label>
<?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?> <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
<?php if ( $bulk ) : ?> <?php if ( $bulk ) : ?>
@ -1260,12 +1256,12 @@ function inline_edit_row( $type ) {
<a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a> <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
<?php if ( ! $bulk ) { <?php if ( ! $bulk ) {
wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
$update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' ); $update_text = __( 'Update' );
?> ?>
<a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a> <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
<img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" /> <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
<?php } else { <?php } else {
$update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' ); $update_text = __( 'Update' );
?> ?>
<input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" /> <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
<?php } ?> <?php } ?>
@ -1369,7 +1365,7 @@ function post_rows( $posts = array() ) {
* @param unknown_type $mode * @param unknown_type $mode
*/ */
function _post_row($a_post, $pending_comments, $mode) { function _post_row($a_post, $pending_comments, $mode) {
global $post, $current_user; global $post, $current_user, $current_screen;
static $rowclass; static $rowclass;
$global_post = $post; $global_post = $post;
@ -1383,8 +1379,8 @@ function _post_row($a_post, $pending_comments, $mode) {
?> ?>
<tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top"> <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
<?php <?php
$posts_columns = get_column_headers('edit'); $posts_columns = get_column_headers( $current_screen );
$hidden = get_hidden_columns('edit'); $hidden = get_hidden_columns( $current_screen );
foreach ( $posts_columns as $column_name=>$column_display_name ) { foreach ( $posts_columns as $column_name=>$column_display_name ) {
$class = "class=\"$column_name column-$column_name\""; $class = "class=\"$column_name column-$column_name\"";
@ -1579,7 +1575,7 @@ function _post_row($a_post, $pending_comments, $mode) {
* @param unknown_type $level * @param unknown_type $level
*/ */
function display_page_row( $page, $level = 0 ) { function display_page_row( $page, $level = 0 ) {
global $post; global $post, $current_screen;
static $rowclass; static $rowclass;
$post = $page; $post = $page;
@ -1606,8 +1602,8 @@ function display_page_row( $page, $level = 0 ) {
$pad = str_repeat( '&#8212; ', $level ); $pad = str_repeat( '&#8212; ', $level );
$id = (int) $page->ID; $id = (int) $page->ID;
$rowclass = 'alternate' == $rowclass ? '' : 'alternate'; $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
$posts_columns = get_column_headers('edit-pages'); $posts_columns = get_column_headers( $current_screen );
$hidden = get_hidden_columns('edit-pages'); $hidden = get_hidden_columns( $current_screen );
$title = _draft_or_post_title(); $title = _draft_or_post_title();
?> ?>
<tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit"> <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
@ -3056,19 +3052,22 @@ function remove_meta_box($id, $page, $context) {
* *
* @since unknown * @since unknown
* *
* @param unknown_type $page * @param unknown_type $screen
*/ */
function meta_box_prefs($page) { function meta_box_prefs($screen) {
global $wp_meta_boxes; global $wp_meta_boxes;
if ( empty($wp_meta_boxes[$page]) ) if ( is_string($screen) )
$screen = convert_to_screen($screen);
if ( empty($wp_meta_boxes[$screen->id]) )
return; return;
$hidden = get_hidden_meta_boxes($page); $hidden = get_hidden_meta_boxes($screen);
foreach ( array_keys($wp_meta_boxes[$page]) as $context ) { foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) { foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
if ( false == $box || ! $box['title'] ) if ( false == $box || ! $box['title'] )
continue; continue;
// Submit box cannot be hidden // Submit box cannot be hidden
@ -3083,8 +3082,11 @@ function meta_box_prefs($page) {
} }
} }
function get_hidden_meta_boxes($page) { function get_hidden_meta_boxes($screen) {
$hidden = (array) get_user_option( "meta-box-hidden_$page" ); if ( is_string($screen) )
$screen = convert_to_screen($screen);
$hidden = (array) get_user_option( "meta-box-hidden_$screen->id" );
// Hide slug boxes by default // Hide slug boxes by default
if ( empty($hidden[0]) ) { if ( empty($hidden[0]) ) {
@ -3279,44 +3281,47 @@ function the_post_password() {
* @since unknown * @since unknown
*/ */
function favorite_actions( $screen = null ) { function favorite_actions( $screen = null ) {
switch ( $screen ) { if ( is_string($screen) )
case 'post-new.php': $screen = convert_to_screen($screen);
switch ( $screen->id ) {
case 'post':
$default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts')); $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
break; break;
case 'edit-pages.php': case 'edit-page':
$default_action = array('page-new.php' => array(__('New Page'), 'edit_pages')); $default_action = array('post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'));
break; break;
case 'page-new.php': case 'page':
$default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages')); $default_action = array('edit.php?post_type=page' => array(__('Edit Pages'), 'edit_pages'));
break; break;
case 'upload.php': case 'upload.php':
$default_action = array('media-new.php' => array(__('New Media'), 'upload_files')); $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
break; break;
case 'media-new.php': case 'media':
$default_action = array('upload.php' => array(__('Edit Media'), 'upload_files')); $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
break; break;
case 'link-manager.php': case 'link-manager':
$default_action = array('link-add.php' => array(__('New Link'), 'manage_links')); $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
break; break;
case 'link-add.php': case 'link-add':
$default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links')); $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
break; break;
case 'users.php': case 'users':
$default_action = array('user-new.php' => array(__('New User'), 'create_users')); $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
break; break;
case 'user-new.php': case 'user':
$default_action = array('users.php' => array(__('Edit Users'), 'edit_users')); $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
break; break;
case 'plugins.php': case 'plugins':
$default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins')); $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
break; break;
case 'plugin-install.php': case 'plugin-install':
$default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins')); $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
break; break;
case 'themes.php': case 'themes':
$default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes')); $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
break; break;
case 'theme-install.php': case 'theme-install':
$default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes')); $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
break; break;
default: default:
@ -3484,32 +3489,34 @@ function _post_states($post) {
} }
} }
function screen_meta($screen) { // Convert a screen string to a screen object
global $wp_meta_boxes, $_wp_contextual_help, $typenow; function convert_to_screen( $screen ) {
$screen = str_replace('.php', '', $screen); $screen = str_replace('.php', '', $screen);
$screen = str_replace('-new', '', $screen); $screen = str_replace('-new', '', $screen);
$screen = str_replace('-add', '', $screen); $screen = str_replace('-add', '', $screen);
$screen = apply_filters('screen_meta_screen', $screen); $screen = apply_filters('screen_meta_screen', $screen);
$screen = array('id' => $screen, 'base' => $screen);
return (object) $screen;
}
function screen_meta($screen) {
global $wp_meta_boxes, $_wp_contextual_help, $post_type;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
$column_screens = get_column_headers($screen); $column_screens = get_column_headers($screen);
$meta_screens = array('index' => 'dashboard'); $meta_screens = array('index' => 'dashboard');
// Give post_type pages their own screen if ( isset($meta_screens[$screen->id]) ) {
if ( 'post' == $screen ) { $screen->id = $meta_screens[$screen->id];
if ( !empty($typenow) ) $screen->base = $screen->id;
$screen = $typenow;
}
if ( 'edit' == $screen ) {
if ( !empty($typenow) )
$screen = 'edit-' . $typenow;
} }
if ( isset($meta_screens[$screen]) )
$screen = $meta_screens[$screen];
$show_screen = false; $show_screen = false;
$show_on_screen = false; $show_on_screen = false;
if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) { if ( !empty($wp_meta_boxes[$screen->id]) || !empty($column_screens) ) {
$show_screen = true; $show_screen = true;
$show_on_screen = true; $show_on_screen = true;
} }
@ -3523,49 +3530,8 @@ function screen_meta($screen) {
$settings = ''; $settings = '';
switch ( $screen ) { switch ( $screen->id ) {
case 'post':
if ( !isset($_wp_contextual_help['post']) ) {
$help = drag_drop_help();
$help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>';
$_wp_contextual_help['post'] = $help;
}
break;
case 'page':
if ( !isset($_wp_contextual_help['page']) ) {
$help = drag_drop_help();
$_wp_contextual_help['page'] = $help;
}
break;
case 'dashboard':
if ( !isset($_wp_contextual_help['dashboard']) ) {
$help = '<p>' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "</p>\n";
$help .= drag_drop_help();
$_wp_contextual_help['dashboard'] = $help;
}
break;
case 'link':
if ( !isset($_wp_contextual_help['link']) ) {
$help = drag_drop_help();
$_wp_contextual_help['link'] = $help;
}
break;
case 'options-general':
if ( !isset($_wp_contextual_help['options-general']) )
$_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>');
break;
case 'theme-install':
case 'plugin-install':
if ( ( !isset($_GET['tab']) || 'dashboard' == $_GET['tab'] ) && !isset($_wp_contextual_help[$screen]) ) {
$help = plugins_search_help();
$_wp_contextual_help[$screen] = $help;
}
break;
case 'widgets': case 'widgets':
if ( !isset($_wp_contextual_help['widgets']) ) {
$help = widgets_help();
$_wp_contextual_help['widgets'] = $help;
}
$settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n"; $settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
$show_screen = true; $show_screen = true;
break; break;
@ -3605,12 +3571,12 @@ function screen_meta($screen) {
<div id="contextual-help-wrap" class="hidden"> <div id="contextual-help-wrap" class="hidden">
<?php <?php
$contextual_help = ''; $contextual_help = '';
if ( isset($_wp_contextual_help[$screen]) ) { if ( isset($_wp_contextual_help[$screen->id]) ) {
if ( !empty($title) ) if ( !empty($title) )
$contextual_help .= '<h5>' . sprintf(__('Get help with &#8220;%s&#8221;'), $title) . '</h5>'; $contextual_help .= '<h5>' . sprintf(__('Get help with &#8220;%s&#8221;'), $title) . '</h5>';
else else
$contextual_help .= '<h5>' . __('Get help with this page') . '</h5>'; $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>';
$contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n"; $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen->id] . "</div>\n";
$contextual_help .= '<h5>' . __('Other Help') . '</h5>'; $contextual_help .= '<h5>' . __('Other Help') . '</h5>';
} else { } else {
@ -3652,10 +3618,13 @@ function screen_meta($screen) {
function add_contextual_help($screen, $help) { function add_contextual_help($screen, $help) {
global $_wp_contextual_help; global $_wp_contextual_help;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
if ( !isset($_wp_contextual_help) ) if ( !isset($_wp_contextual_help) )
$_wp_contextual_help = array(); $_wp_contextual_help = array();
$_wp_contextual_help[$screen] = $help; $_wp_contextual_help[$screen->id] = $help;
} }
function drag_drop_help() { function drag_drop_help() {
@ -3675,33 +3644,27 @@ function plugins_search_help() {
'; ';
} }
function widgets_help() {
return '
<p>' . __('Widgets are added and arranged by simple drag &#8217;n&#8217; drop. If you hover your mouse over the titlebar of a widget, you&#8217;ll see a 4-arrow cursor which indicates that the widget is movable. Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you&#8217;ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '</p>
<p>' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '</p>
<p>' . __('To remove a widget from a sidebar <em>and keep its configuration</em>, drag it to Inactive Widgets.') . '</p>
<p>' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '</p>
';
}
function screen_layout($screen) { function screen_layout($screen) {
global $screen_layout_columns; global $screen_layout_columns;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
$columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2); $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2);
// Add custom post types // Add custom post types
foreach ( get_post_types( array('_show' => true) ) as $post_type ) foreach ( get_post_types( array('_show' => true) ) as $post_type )
$columns[$post_type] = 2; $columns[$post_type] = 2;
$columns = apply_filters('screen_layout_columns', $columns, $screen); $columns = apply_filters('screen_layout_columns', $columns, $screen->id, $screen);
if ( !isset($columns[$screen]) ) { if ( !isset($columns[$screen->id]) ) {
$screen_layout_columns = 0; $screen_layout_columns = 0;
return ''; return '';
} }
$screen_layout_columns = get_user_option("screen_layout_$screen"); $screen_layout_columns = get_user_option("screen_layout_$screen->id");
$num = $columns[$screen]; $num = $columns[$screen->id];
if ( ! $screen_layout_columns ) if ( ! $screen_layout_columns )
$screen_layout_columns = 2; $screen_layout_columns = 2;
@ -3717,12 +3680,10 @@ function screen_layout($screen) {
} }
function screen_options($screen) { function screen_options($screen) {
$map_screen = $screen; if ( is_string($screen) )
$type = str_replace('edit-', '', $map_screen); $screen = convert_to_screen($screen);
if ( in_array($type, get_post_types()) )
$map_screen = 'edit';
switch ( $map_screen ) { switch ( $screen->base ) {
case 'edit': case 'edit':
$per_page_label = __('Posts per page:'); $per_page_label = __('Posts per page:');
break; break;
@ -3748,10 +3709,10 @@ function screen_options($screen) {
return ''; return '';
} }
$option = str_replace( '-', '_', "${screen}_per_page" ); $option = str_replace( '-', '_', "{$screen->id}_per_page" );
$per_page = (int) get_user_option( $option ); $per_page = (int) get_user_option( $option );
if ( empty( $per_page ) || $per_page < 1 ) { if ( empty( $per_page ) || $per_page < 1 ) {
if ( 'plugins' == $screen ) if ( 'plugins' == $screen->id )
$per_page = 999; $per_page = 999;
else else
$per_page = 20; $per_page = 20;
@ -3773,18 +3734,19 @@ function screen_options($screen) {
return $return; return $return;
} }
function screen_icon($name = '') { function screen_icon($screen = '') {
global $parent_file, $hook_suffix; global $current_screen;
if ( empty($screen) )
$screen = $current_screen;
elseif ( is_string($screen) )
$name = $screen;
if ( empty($name) ) { if ( empty($name) ) {
if ( isset($parent_file) && !empty($parent_file) ) { if ( !empty($screen->parent_base) )
$name = $parent_file; $name = $screen->parent_base;
if ( false !== $pos = strpos($name, '?post_type=') )
$name = substr($name, 0, $pos);
$name = substr($name, 0, -4);
}
else else
$name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix); $name = $screen->base;
} }
?> ?>
<div id="icon-<?php echo $name; ?>" class="icon32"><br /></div> <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>

View File

@ -23,6 +23,9 @@ add_thickbox();
$title = __('Dashboard'); $title = __('Dashboard');
$parent_file = 'index.php'; $parent_file = 'index.php';
add_contextual_help($current_screen, '<p>' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "</p>\n" . drag_drop_help() );
require_once('admin-header.php'); require_once('admin-header.php');
$today = current_time('mysql', 1); $today = current_time('mysql', 1);

View File

@ -68,10 +68,10 @@ $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-to
$submenu['link-manager.php'][10] = array( _x('Add New', 'links'), 'manage_links', 'link-add.php' ); $submenu['link-manager.php'][10] = array( _x('Add New', 'links'), 'manage_links', 'link-add.php' );
$submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-link-categories.php' ); $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-link-categories.php' );
$menu[20] = array( __('Pages'), 'edit_pages', 'edit-pages.php', '', 'menu-top', 'menu-pages', 'div' ); $menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top', 'menu-pages', 'div' );
$submenu['edit-pages.php'][5] = array( __('Edit'), 'edit_pages', 'edit-pages.php' ); $submenu['edit.php?post_type=page'][5] = array( __('Edit'), 'edit_pages', 'edit.php?post_type=page' );
/* translators: add new page */ /* translators: add new page */
$submenu['edit-pages.php'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' ); $submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' );
$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' ); $menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' );

View File

@ -50,6 +50,8 @@ function add_js() {
} }
add_filter('admin_head', 'add_js'); add_filter('admin_head', 'add_js');
add_contextual_help($current_screen, __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>'));
include('./admin-header.php'); include('./admin-header.php');
?> ?>

View File

@ -52,6 +52,8 @@ $body_id = $tab;
do_action('install_plugins_pre_' . $tab); //Used to override the general interface, Eg, install or plugin information. do_action('install_plugins_pre_' . $tab); //Used to override the general interface, Eg, install or plugin information.
add_contextual_help($current_screen, plugins_search_help());
include('admin-header.php'); include('admin-header.php');
?> ?>
<div class="wrap"> <div class="wrap">

View File

@ -236,7 +236,7 @@ $help .= '<p>' . sprintf(__('If something goes wrong with a plugin and you can&#
$help .= '<p>' . sprintf(__('You can find additional plugins for your site by using the new <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> directly and installing manually. To <em>manually</em> install a plugin you generally just need to upload the plugin file into your <code>%2$s</code> directory. Once a plugin has been installed, you may activate it here.'), 'plugin-install.php', WP_PLUGIN_DIR) . '</p>'; $help .= '<p>' . sprintf(__('You can find additional plugins for your site by using the new <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> directly and installing manually. To <em>manually</em> install a plugin you generally just need to upload the plugin file into your <code>%2$s</code> directory. Once a plugin has been installed, you may activate it here.'), 'plugin-install.php', WP_PLUGIN_DIR) . '</p>';
} }
add_contextual_help('plugins', $help); add_contextual_help($current_screen, $help);
if ( is_multisite() && is_super_admin() ) { if ( is_multisite() && is_super_admin() ) {
$menu_perms = get_site_option('menu_items', array()); $menu_perms = get_site_option('menu_items', array());

View File

@ -17,8 +17,6 @@ else
if ( 'post' != $post_type ) { if ( 'post' != $post_type ) {
$parent_file = "edit.php?post_type=$post_type"; $parent_file = "edit.php?post_type=$post_type";
$submenu_file = "post-new.php?post_type=$post_type"; $submenu_file = "post-new.php?post_type=$post_type";
if ( 'page' == $post_type )
$parent_file = 'edit-pages.php';
} else { } else {
$parent_file = 'edit.php'; $parent_file = 'edit.php';
$submenu_file = 'post-new.php'; $submenu_file = 'post-new.php';

View File

@ -23,15 +23,27 @@ elseif ( isset($_POST['post_ID']) )
else else
$post_id = 0; $post_id = 0;
$post_ID = $post_id; $post_ID = $post_id;
$post = null; $post = null;
$post_type_object = null; $post_type_object = null;
$post_type_cap = null; $post_type_cap = null;
$post_type = null;
if ( $post_id ) { if ( $post_id ) {
$post = get_post($post_id); $post = get_post($post_id);
if ( $post ) { if ( $post ) {
$post_type_object = get_post_type_object($post->post_type); $post_type_object = get_post_type_object($post->post_type);
if ( $post_type_object ) if ( $post_type_object ) {
$post_type = $post->post_type;
$current_screen->post_type = $post->post_type;
$current_screen->id = $current_screen->post_type;
$post_type_cap = $post_type_object->capability_type;
}
}
} elseif ( isset($_POST['post_type']) ) {
$post_type_object = get_post_type_object($_POST['post_type']);
if ( $post_type_object ) {
$post_type = $post_type_object->name;
$current_screen->post_type = $post_type;
$current_screen->id = $current_screen->post_type;
$post_type_cap = $post_type_object->capability_type; $post_type_cap = $post_type_object->capability_type;
} }
} }
@ -108,7 +120,7 @@ case 'postajaxpost':
case 'post': case 'post':
case 'post-quickpress-publish': case 'post-quickpress-publish':
case 'post-quickpress-save': case 'post-quickpress-save':
check_admin_referer('add-post'); check_admin_referer('add-' . $post_type);
if ( 'post-quickpress-publish' == $action ) if ( 'post-quickpress-publish' == $action )
$_POST['publish'] = 'publish'; // tell write_post() to publish $_POST['publish'] = 'publish'; // tell write_post() to publish
@ -163,18 +175,10 @@ case 'edit':
if ( 'post' == $post_type ) { if ( 'post' == $post_type ) {
$parent_file = "edit.php"; $parent_file = "edit.php";
$submenu_file = "edit.php"; $submenu_file = "edit.php";
} elseif ( 'page' == $post_type ) {
$parent_file = "edit-pages.php";
$submenu_file = "edit-pages.php";
} else {
if ( $post_type_object->hierarchical ) {
$parent_file = "edit-pages.php?post_type=$post_type";
$submenu_file = "edit-pages.php?post_type=$post_type";
} else { } else {
$parent_file = "edit.php?post_type=$post_type"; $parent_file = "edit.php?post_type=$post_type";
$submenu_file = "edit.php?post_type=$post_type"; $submenu_file = "edit.php?post_type=$post_type";
} }
}
wp_enqueue_script('post'); wp_enqueue_script('post');
if ( user_can_richedit() ) if ( user_can_richedit() )
@ -213,7 +217,7 @@ case 'editattachment':
wp_update_attachment_metadata( $post_id, $newmeta ); wp_update_attachment_metadata( $post_id, $newmeta );
case 'editpost': case 'editpost':
check_admin_referer('update-' . $post->post_type . '_' . $post_id); check_admin_referer('update-' . $post_type . '_' . $post_id);
$post_id = edit_post(); $post_id = edit_post();
@ -223,7 +227,7 @@ case 'editpost':
break; break;
case 'trash': case 'trash':
check_admin_referer('trash-post_' . $post_id); check_admin_referer('trash-' . $post_type . '_' . $post_id);
$post = & get_post($post_id); $post = & get_post($post_id);
@ -238,7 +242,7 @@ case 'trash':
break; break;
case 'untrash': case 'untrash':
check_admin_referer('untrash-post_' . $post_id); check_admin_referer('untrash-' . $post_type . '_' . $post_id);
if ( !current_user_can('delete_' . $post_type_cap, $post_id) ) if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
wp_die( __('You are not allowed to move this item out of the trash.') ); wp_die( __('You are not allowed to move this item out of the trash.') );
@ -251,7 +255,7 @@ case 'untrash':
break; break;
case 'delete': case 'delete':
check_admin_referer('delete-post_' . $post_id); check_admin_referer('delete-' . $post_type . '_' . $post_id);
if ( !current_user_can('delete_' . $post_type_cap, $post_id) ) if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
wp_die( __('You are not allowed to delete this item.') ); wp_die( __('You are not allowed to delete this item.') );
@ -280,9 +284,6 @@ case 'preview':
break; break;
default: default:
if ( $post_type_object->hierarchical )
wp_redirect('edit-pages.php');
else
wp_redirect('edit.php'); wp_redirect('edit.php');
exit(); exit();
break; break;

View File

@ -52,6 +52,8 @@ $body_id = $tab;
do_action('install_themes_pre_' . $tab); //Used to override the general interface, Eg, install or theme information. do_action('install_themes_pre_' . $tab); //Used to override the general interface, Eg, install or theme information.
add_contextual_help($current_screen, plugins_search_help());
include('admin-header.php'); include('admin-header.php');
?> ?>
<div class="wrap"> <div class="wrap">

View File

@ -61,7 +61,7 @@ if ( current_user_can('install_themes') ) {
$help .= '<p>' . __('Once a theme is uploaded, you should see it on this page.') . '</p>' ; $help .= '<p>' . __('Once a theme is uploaded, you should see it on this page.') . '</p>' ;
} }
add_contextual_help('themes', $help); add_contextual_help($current_screen, $help);
add_thickbox(); add_thickbox();
wp_enqueue_script( 'theme-preview' ); wp_enqueue_script( 'theme-preview' );

View File

@ -33,6 +33,14 @@ do_action( 'sidebar_admin_setup' );
$title = __( 'Widgets' ); $title = __( 'Widgets' );
$parent_file = 'themes.php'; $parent_file = 'themes.php';
$help = '
<p>' . __('Widgets are added and arranged by simple drag &#8217;n&#8217; drop. If you hover your mouse over the titlebar of a widget, you&#8217;ll see a 4-arrow cursor which indicates that the widget is movable. Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you&#8217;ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '</p>
<p>' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '</p>
<p>' . __('To remove a widget from a sidebar <em>and keep its configuration</em>, drag it to Inactive Widgets.') . '</p>
<p>' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '</p>
';
add_contextual_help($current_screen, $help);
// register the inactive_widgets area as sidebar // register the inactive_widgets area as sidebar
register_sidebar(array( register_sidebar(array(
'name' => __('Inactive Widgets'), 'name' => __('Inactive Widgets'),