Manage->Pages design update
git-svn-id: http://svn.automattic.com/wordpress/trunk@6796 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9528af34a0
commit
48df0bbc2c
|
@ -6,11 +6,12 @@ wp_enqueue_script( 'wp-lists' );
|
|||
require_once('admin-header.php');
|
||||
|
||||
$post_stati = array( // array( adj, noun )
|
||||
'publish' => array(__('Published'), __('Published pages')),
|
||||
'draft' => array(__('Draft'), __('Draft pages')),
|
||||
'private' => array(__('Private'), __('Private pages'))
|
||||
);
|
||||
|
||||
'publish' => array(__('Published'), __('Published pages'), __('Published (%s)')),
|
||||
'future' => array(__('Scheduled'), __('Scheduled pages'), __('Scheduled (%s)')),
|
||||
'pending' => array(__('Pending Review'), __('Pending pages'), __('Pending Review (%s)')),
|
||||
'draft' => array(__('Draft'), _c('Drafts|manage posts header'), _c('Draft (%s)|manage posts header')),
|
||||
'private' => array(__('Private'), __('Private pages'), __('Private (%s)'))
|
||||
);
|
||||
|
||||
$post_status_label = __('Pages');
|
||||
$post_status_q = '';
|
||||
|
@ -26,6 +27,7 @@ jQuery(function($){$('#the-list').wpList();});
|
|||
/* ]]> */
|
||||
</script>
|
||||
<div class="wrap">
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<h2><?php
|
||||
// Use $_GET instead of is_ since they can override each other
|
||||
$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : '';
|
||||
|
@ -37,32 +39,47 @@ if ( isset($_GET['author']) && $_GET['author'] ) {
|
|||
printf( _c( '%1$s%2$s%3$s|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search );
|
||||
?></h2>
|
||||
|
||||
<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page »'); ?></a></p>
|
||||
<ul class="subsubsub">
|
||||
<?php
|
||||
|
||||
<form name="searchform" id="searchform" action="" method="get">
|
||||
<fieldset><legend><?php _e('Search Terms…') ?></legend>
|
||||
<input type="text" name="s" id="s" value="<?php echo attribute_escape( stripslashes( $_GET['s'] ) ); ?>" size="17" />
|
||||
</fieldset>
|
||||
$avail_post_stati = get_available_post_statuses('page');
|
||||
|
||||
$status_links = array();
|
||||
foreach ( $post_stati as $status => $label ) {
|
||||
$class = '';
|
||||
|
||||
if ( !in_array($status, $avail_post_stati) )
|
||||
continue;
|
||||
|
||||
<fieldset><legend><?php _e('Page Type…'); ?></legend>
|
||||
<select name='post_status'>
|
||||
<option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
|
||||
<?php foreach ( $post_stati as $status => $label ) : ?>
|
||||
<option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</fieldset>
|
||||
$num_posts = wp_count_posts('page', $status);
|
||||
if ( $status == $_GET['post_status'] )
|
||||
$class = ' class="current"';
|
||||
|
||||
<?php $editable_ids = get_editable_user_ids( $user_ID ); if ( $editable_ids && count( $editable_ids ) > 1 ) : ?>
|
||||
$status_links[] = "<li><a href=\"edit-pages.php?post_status=$status\"$class>" .
|
||||
sprintf($label[2], $num_posts) . '</a>';
|
||||
}
|
||||
$class = empty($_GET['post_status']) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href=\"edit-pages.php\"$class>All Pages</a>";
|
||||
echo implode(' |</li>', $status_links) . '</li>';
|
||||
unset($status_links);
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<fieldset><legend><?php _e('Author…'); ?></legend>
|
||||
<?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?>
|
||||
</fieldset>
|
||||
<p id="post-search">
|
||||
<input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
|
||||
<input type="submit" value="<?php _e( 'Search Posts' ); ?>" />
|
||||
</p>
|
||||
|
||||
<?php endif; ?>
|
||||
<br style="clear:both;" />
|
||||
|
||||
<input type="submit" id="post-query-submit" value="<?php _e('Filter »'); ?>" class="button" />
|
||||
<div class="tablenav">
|
||||
|
||||
<div style="float: left">
|
||||
<input type="button" value="<?php _e('Delete'); ?>" name="deleteit" />
|
||||
</div>
|
||||
|
||||
<br style="clear:both;" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<br style="clear:both;" />
|
||||
|
@ -79,11 +96,10 @@ if ($posts) {
|
|||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" style="text-align: center"><?php _e('ID') ?></th>
|
||||
<th scope="col"><?php _e('Title') ?></th>
|
||||
<th scope="col"><?php _e('Owner') ?></th>
|
||||
<th scope="col"><?php _e('Updated') ?></th>
|
||||
<th scope="col" colspan="3" style="text-align: center"><?php _e('Action'); ?></th>
|
||||
<?php $posts_columns = wp_manage_pages_columns(); ?>
|
||||
<?php foreach($posts_columns as $column_display_name) { ?>
|
||||
<th scope="col"><?php echo $column_display_name; ?></th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="the-list" class="list:page">
|
||||
|
@ -101,8 +117,6 @@ if ($posts) {
|
|||
} // end if ($posts)
|
||||
?>
|
||||
|
||||
<h3><a href="page-new.php"><?php _e('Create New Page »'); ?></a></h3>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include('admin-footer.php'); ?>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
|
||||
<?php $posts_columns = wp_manage_posts_columns(); ?>
|
||||
<?php foreach($posts_columns as $column_display_name) { ?>
|
||||
<th scope="col"><?php echo $column_display_name; ?></th>
|
||||
<?php } ?>
|
||||
|
|
|
@ -25,11 +25,6 @@ endif;
|
|||
|
||||
<div class="wrap">
|
||||
|
||||
<?php
|
||||
$posts_columns = wp_manage_posts_columns();
|
||||
|
||||
?>
|
||||
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<h2><?php
|
||||
if ( is_single() ) {
|
||||
|
|
|
@ -481,6 +481,13 @@ function _relocate_children( $old_ID, $new_ID ) {
|
|||
return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" );
|
||||
}
|
||||
|
||||
function get_available_post_statuses($type = 'post') {
|
||||
global $wpdb;
|
||||
|
||||
$stati = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = %s", $type));
|
||||
return $stati;
|
||||
}
|
||||
|
||||
function wp_edit_posts_query( $q = false ) {
|
||||
global $wpdb;
|
||||
if ( false === $q )
|
||||
|
@ -495,7 +502,7 @@ function wp_edit_posts_query( $q = false ) {
|
|||
'private' => array(__('Private'), __('Private posts'), __('Private (%s)'))
|
||||
);
|
||||
|
||||
$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'");
|
||||
$avail_post_stati = get_available_post_statuses('post');
|
||||
|
||||
$post_status_q = '';
|
||||
if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) )
|
||||
|
|
|
@ -318,6 +318,24 @@ function wp_manage_posts_columns() {
|
|||
$posts_columns['status'] = __('Status');
|
||||
$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
|
||||
|
||||
return $posts_columns;
|
||||
}
|
||||
|
||||
function wp_manage_pages_columns() {
|
||||
$posts_columns = array();
|
||||
$posts_columns['cb'] = '<div style="text-align: center"><input type="checkbox" name="TODO" /></div>';
|
||||
if ( 'draft' === $_GET['post_status'] )
|
||||
$posts_columns['modified'] = __('Modified');
|
||||
elseif ( 'pending' === $_GET['post_status'] )
|
||||
$posts_columns['modified'] = __('Submitted');
|
||||
else
|
||||
$posts_columns['date'] = __('Date');
|
||||
$posts_columns['title'] = __('Title');
|
||||
$posts_columns['author'] = __('Author');
|
||||
if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
|
||||
$posts_columns['comments'] = '<div style="text-align: center"><img alt="" src="images/comment-grey-bubble.png" /></div>';
|
||||
$posts_columns['status'] = __('Status');
|
||||
$posts_columns = apply_filters('manage_pages_columns', $posts_columns);
|
||||
|
||||
return $posts_columns;
|
||||
}
|
||||
|
@ -337,19 +355,109 @@ function display_page_row( $page, &$children_pages, $level = 0 ) {
|
|||
$pad = str_repeat( '— ', $level );
|
||||
$id = (int) $page->ID;
|
||||
$class = ('alternate' == $class ) ? '' : 'alternate';
|
||||
|
||||
$posts_columns = wp_manage_pages_columns();
|
||||
?>
|
||||
<tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
|
||||
<th scope="row" style="text-align: center"><?php echo $page->ID; ?></th>
|
||||
<td>
|
||||
<?php echo $pad; ?><?php the_title(); ?>
|
||||
</td>
|
||||
<td><?php the_author() ?></td>
|
||||
<td><?php if ( '0000-00-00 00:00:00' ==$page->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $page->post_modified ); ?></td>
|
||||
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e( 'View' ); ?></a></td>
|
||||
<td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td>
|
||||
<td><?php if ( current_user_can( 'delete_page', $id ) ) { echo "<a href='" . wp_nonce_url( "page.php?action=delete&post=$id", 'delete-page_' . $id ) . "' class='delete:the-list:page-$id delete'>" . __( 'Delete' ) . "</a>"; } ?></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
foreach ($posts_columns as $column_name=>$column_display_name) {
|
||||
|
||||
switch ($column_name) {
|
||||
|
||||
case 'cb':
|
||||
?>
|
||||
<th scope="row" style="text-align: center"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?>" /></th>
|
||||
<?php
|
||||
break;
|
||||
case 'modified':
|
||||
?>
|
||||
<td><?php if ( '0000-00-00 00:00:00' ==$page->post_modified ) _e('Never'); else the_modified_time(__('Y/m/d \<\b\r \/\> g:i:s a')); ?></td>
|
||||
<?php
|
||||
break;
|
||||
case 'date':
|
||||
?>
|
||||
<td><a href="<?php the_permalink(); ?>" rel="permalink">
|
||||
<?php
|
||||
if ( '0000-00-00 00:00:00' ==$page->post_date ) {
|
||||
_e('Unpublished');
|
||||
} else {
|
||||
if ( ( abs(time() - get_post_time()) ) < 86400 ) {
|
||||
if ( ( 'future' == $page->post_status) )
|
||||
echo sprintf( __('%s from now'), human_time_diff( get_post_time() ) );
|
||||
else
|
||||
echo sprintf( __('%s ago'), human_time_diff( get_post_time() ) );
|
||||
} else {
|
||||
the_time(__('Y/m/d'));
|
||||
}
|
||||
}
|
||||
?></a></td>
|
||||
<?php
|
||||
break;
|
||||
case 'title':
|
||||
?>
|
||||
<td><strong><a href="page.php?action=edit&post=<?php the_ID(); ?>"><?php echo $pad; the_title() ?></a></strong>
|
||||
<?php if ('private' == $page->post_status) _e(' — <strong>Private</strong>'); ?></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
?>
|
||||
<td style="text-align: center">
|
||||
<?php
|
||||
$left = get_pending_comments_num( $page->ID );
|
||||
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
||||
if ( $left )
|
||||
echo '<strong>';
|
||||
comments_number("<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('0') . '</span></a>', "<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('1') . '</span></a>', "<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('%') . '</span></a>');
|
||||
if ( $left )
|
||||
echo '</strong>';
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'author':
|
||||
?>
|
||||
<td><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
?>
|
||||
<td>
|
||||
<?php
|
||||
switch ( $page->post_status ) {
|
||||
case 'publish' :
|
||||
case 'private' :
|
||||
_e('Published');
|
||||
break;
|
||||
case 'future' :
|
||||
_e('Scheduled');
|
||||
break;
|
||||
case 'pending' :
|
||||
_e('Pending Review');
|
||||
break;
|
||||
case 'draft' :
|
||||
_e('Unpublished');
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
default:
|
||||
?>
|
||||
<td><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
|
|
Loading…
Reference in New Issue