Merge page-new.php into post-new.php. Start abstracting column headers and prefs. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@12702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6cab12999b
commit
5316b4fc2d
|
@ -55,7 +55,7 @@ var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = '<?php ech
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php', 'page-new.php') ) ) {
|
if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php') ) ) {
|
||||||
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
|
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
|
||||||
wp_enqueue_script('quicktags');
|
wp_enqueue_script('quicktags');
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
|
||||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
||||||
|
|
||||||
if ( strpos($sendback, 'page.php') !== false )
|
if ( strpos($sendback, 'page.php') !== false )
|
||||||
$sendback = admin_url('page-new.php');
|
$sendback = admin_url('post-new.php?post_type=page');
|
||||||
|
|
||||||
if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
|
if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
|
||||||
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
|
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
|
||||||
|
@ -141,7 +141,7 @@ require_once('admin-header.php'); ?>
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?php screen_icon(); ?>
|
<?php screen_icon(); ?>
|
||||||
<h2><?php echo esc_html( $title ); ?> <a href="page-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'page'); ?></a> <?php
|
<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'] )
|
if ( isset($_GET['s']) && $_GET['s'] )
|
||||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?>
|
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
|
@ -324,9 +324,10 @@ function bulk_edit_posts( $post_data = null ) {
|
||||||
*
|
*
|
||||||
* @since unknown
|
* @since unknown
|
||||||
*
|
*
|
||||||
|
*@param string A post type string, defaults to 'post'.
|
||||||
* @return object stdClass object containing all the default post data as attributes
|
* @return object stdClass object containing all the default post data as attributes
|
||||||
*/
|
*/
|
||||||
function get_default_post_to_edit() {
|
function get_default_post_to_edit( $post_type = 'post' ) {
|
||||||
|
|
||||||
$post_title = '';
|
$post_title = '';
|
||||||
if ( !empty( $_REQUEST['post_title'] ) )
|
if ( !empty( $_REQUEST['post_title'] ) )
|
||||||
|
@ -347,7 +348,7 @@ function get_default_post_to_edit() {
|
||||||
$post->post_date_gmt = '';
|
$post->post_date_gmt = '';
|
||||||
$post->post_password = '';
|
$post->post_password = '';
|
||||||
$post->post_status = 'draft';
|
$post->post_status = 'draft';
|
||||||
$post->post_type = 'post';
|
$post->post_type = $post_type;
|
||||||
$post->to_ping = '';
|
$post->to_ping = '';
|
||||||
$post->pinged = '';
|
$post->pinged = '';
|
||||||
$post->comment_status = get_option( 'default_comment_status' );
|
$post->comment_status = get_option( 'default_comment_status' );
|
||||||
|
|
|
@ -748,15 +748,19 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'po
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function wp_manage_posts_columns() {
|
function wp_manage_posts_columns() {
|
||||||
|
global $typenow;
|
||||||
|
|
||||||
$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('Post', 'column name');
|
||||||
$posts_columns['author'] = __('Author');
|
$posts_columns['author'] = __('Author');
|
||||||
$posts_columns['categories'] = __('Categories');
|
if ( empty($typenow) || is_object_in_taxonomy($typenow, 'category') )
|
||||||
$posts_columns['tags'] = __('Tags');
|
$posts_columns['categories'] = __('Categories');
|
||||||
|
if ( empty($typenow) || is_object_in_taxonomy($typenow, 'category') )
|
||||||
|
$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') ) )
|
if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($typenow) || post_type_supports($typenow, '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');
|
||||||
$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
|
$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
|
||||||
|
@ -826,11 +830,16 @@ function get_column_headers($page) {
|
||||||
if ( !isset($_wp_column_headers) )
|
if ( !isset($_wp_column_headers) )
|
||||||
$_wp_column_headers = array();
|
$_wp_column_headers = array();
|
||||||
|
|
||||||
|
$map_screen = $page;
|
||||||
|
$type = str_replace('edit-', '', $map_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[$page]) )
|
||||||
return $_wp_column_headers[$page];
|
return $_wp_column_headers[$page];
|
||||||
|
|
||||||
switch ($page) {
|
switch ($map_screen) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$_wp_column_headers[$page] = wp_manage_posts_columns();
|
$_wp_column_headers[$page] = wp_manage_posts_columns();
|
||||||
break;
|
break;
|
||||||
|
@ -924,10 +933,6 @@ function print_column_headers( $type, $id = true ) {
|
||||||
$columns = get_column_headers( $type );
|
$columns = get_column_headers( $type );
|
||||||
$hidden = get_hidden_columns($type);
|
$hidden = get_hidden_columns($type);
|
||||||
$styles = array();
|
$styles = array();
|
||||||
// $styles['tag']['posts'] = 'width: 90px;';
|
|
||||||
// $styles['link-category']['links'] = 'width: 90px;';
|
|
||||||
// $styles['category']['posts'] = 'width: 90px;';
|
|
||||||
// $styles['link']['visible'] = 'text-align: center;';
|
|
||||||
|
|
||||||
foreach ( $columns as $column_key => $column_display_name ) {
|
foreach ( $columns as $column_key => $column_display_name ) {
|
||||||
$class = ' class="manage-column';
|
$class = ' class="manage-column';
|
||||||
|
@ -3494,6 +3499,10 @@ function screen_meta($screen) {
|
||||||
if ( !empty($typenow) )
|
if ( !empty($typenow) )
|
||||||
$screen = $typenow;
|
$screen = $typenow;
|
||||||
}
|
}
|
||||||
|
if ( 'edit' == $screen ) {
|
||||||
|
if ( !empty($typenow) )
|
||||||
|
$screen = 'edit-' . $typenow;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset($meta_screens[$screen]) )
|
if ( isset($meta_screens[$screen]) )
|
||||||
$screen = $meta_screens[$screen];
|
$screen = $meta_screens[$screen];
|
||||||
|
@ -3707,7 +3716,12 @@ function screen_layout($screen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function screen_options($screen) {
|
function screen_options($screen) {
|
||||||
switch ( $screen ) {
|
$map_screen = $screen;
|
||||||
|
$type = str_replace('edit-', '', $map_screen);
|
||||||
|
if ( in_array($type, get_post_types()) )
|
||||||
|
$map_screen = 'edit';
|
||||||
|
|
||||||
|
switch ( $map_screen ) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$per_page_label = __('Posts per page:');
|
$per_page_label = __('Posts per page:');
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -71,7 +71,7 @@ $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-to
|
||||||
$menu[20] = array( __('Pages'), 'edit_pages', 'edit-pages.php', '', 'menu-top', 'menu-pages', 'div' );
|
$menu[20] = array( __('Pages'), 'edit_pages', 'edit-pages.php', '', 'menu-top', 'menu-pages', 'div' );
|
||||||
$submenu['edit-pages.php'][5] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
|
$submenu['edit-pages.php'][5] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
|
||||||
/* translators: add new page */
|
/* translators: add new page */
|
||||||
$submenu['edit-pages.php'][10] = array( _x('Add New', 'page'), 'edit_pages', 'page-new.php' );
|
$submenu['edit-pages.php'][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' );
|
||||||
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* New page administration panel.
|
|
||||||
*
|
|
||||||
* @package WordPress
|
|
||||||
* @subpackage Administration
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** WordPress Administration Bootstrap */
|
|
||||||
require_once('admin.php');
|
|
||||||
|
|
||||||
$post_type = 'page';
|
|
||||||
|
|
||||||
$title = __('Add New Page');
|
|
||||||
$parent_file = 'edit-pages.php';
|
|
||||||
$editing = true;
|
|
||||||
wp_enqueue_script('autosave');
|
|
||||||
wp_enqueue_script('post');
|
|
||||||
if ( user_can_richedit() )
|
|
||||||
wp_enqueue_script('editor');
|
|
||||||
add_thickbox();
|
|
||||||
wp_enqueue_script('media-upload');
|
|
||||||
wp_enqueue_script('word-count');
|
|
||||||
|
|
||||||
if ( current_user_can('edit_pages') ) {
|
|
||||||
$action = 'post';
|
|
||||||
$post = get_default_page_to_edit();
|
|
||||||
|
|
||||||
include('edit-form-advanced.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
include('admin-footer.php');
|
|
||||||
|
|
||||||
?>
|
|
|
@ -73,7 +73,7 @@ elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
|
||||||
$action = 'preview';
|
$action = 'preview';
|
||||||
|
|
||||||
$sendback = wp_get_referer();
|
$sendback = wp_get_referer();
|
||||||
if ( strpos($sendback, 'page.php') !== false || strpos($sendback, 'page-new.php') !== false )
|
if ( strpos($sendback, 'page.php') !== false || strpos($sendback, 'post-new.php') !== false )
|
||||||
$sendback = admin_url('edit-pages.php');
|
$sendback = admin_url('edit-pages.php');
|
||||||
else
|
else
|
||||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
|
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
/** Load WordPress Administration Bootstrap */
|
/** Load WordPress Administration Bootstrap */
|
||||||
require_once('admin.php');
|
require_once('admin.php');
|
||||||
|
|
||||||
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';
|
||||||
|
@ -17,6 +17,8 @@ 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';
|
||||||
|
@ -35,7 +37,7 @@ add_thickbox();
|
||||||
wp_enqueue_script('media-upload');
|
wp_enqueue_script('media-upload');
|
||||||
wp_enqueue_script('word-count');
|
wp_enqueue_script('word-count');
|
||||||
|
|
||||||
if ( ! current_user_can('edit_posts') ) {
|
if ( 'post' == $post_type && !current_user_can('edit_posts') ) {
|
||||||
require_once ('./admin-header.php'); ?>
|
require_once ('./admin-header.php'); ?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<p><?php printf(__('Since you’re a newcomer, you’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’re a newcomer, you’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 />
|
||||||
|
@ -49,9 +51,10 @@ When you’re promoted, just reload this page and you’ll be able to bl
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show post form.
|
// Show post form.
|
||||||
$post = get_default_post_to_edit();
|
if ( current_user_can('edit_' . $post_type_object->capability_type . 's') ) {
|
||||||
$post->post_type = $post_type;
|
$post = get_default_post_to_edit( $post_type );
|
||||||
include('edit-form-advanced.php');
|
include('edit-form-advanced.php');
|
||||||
|
}
|
||||||
|
|
||||||
include('admin-footer.php');
|
include('admin-footer.php');
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue