mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 19:46:21 +00:00
Column hiding for pages. see #7725
git-svn-id: http://svn.automattic.com/wordpress/trunk@8860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
589df9dcfd
commit
b8ed2c0bec
@ -45,6 +45,7 @@ $title = __('Pages');
|
||||
$parent_file = 'edit.php';
|
||||
wp_enqueue_script('admin-forms');
|
||||
wp_enqueue_script('inline-edit');
|
||||
wp_enqueue_script('pages');
|
||||
|
||||
$post_stati = array( // array( adj, noun )
|
||||
'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')),
|
||||
@ -77,6 +78,19 @@ require_once('admin-header.php');
|
||||
?>
|
||||
<div class="wrap">
|
||||
<form id="posts-filter" action="" method="get">
|
||||
|
||||
<div id="show-settings"><a href="#edit_settings" id="show-settings-link" class="hide-if-no-js"><?php _e('Show Settings') ?></a>
|
||||
<a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Settings') ?></a></div>
|
||||
|
||||
<div id="edit-settings" class="hide-if-js hide-if-no-js">
|
||||
<div id="edit-settings-wrap">
|
||||
<h5><?php _e('Show on screen') ?></h5>
|
||||
<div class="metabox-prefs">
|
||||
<?php manage_columns_prefs('page') ?>
|
||||
<br class="clear" />
|
||||
</div></div>
|
||||
</div>
|
||||
|
||||
<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'] ) ) ) : '';
|
||||
@ -175,16 +189,24 @@ if ($posts) {
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php $posts_columns = wp_manage_pages_columns(); ?>
|
||||
<?php foreach($posts_columns as $post_column_key => $column_display_name) {
|
||||
<?php
|
||||
$posts_columns = wp_manage_pages_columns();
|
||||
$hidden = (array) get_user_option( 'manage-page-columns-hidden' );
|
||||
foreach($posts_columns as $post_column_key => $column_display_name) {
|
||||
if ( 'cb' === $post_column_key )
|
||||
$class = ' class="check-column"';
|
||||
elseif ( 'comments' === $post_column_key )
|
||||
$class = ' class="num"';
|
||||
$class = ' class="manage-column column-comments num"';
|
||||
elseif ( 'modified' === $post_column_key )
|
||||
$class = ' class="manage-column column-date"';
|
||||
else
|
||||
$class = '';
|
||||
$class = " class=\"manage-column column-$post_column_key\"";
|
||||
|
||||
$style = '';
|
||||
if ( in_array($post_column_key, $hidden) )
|
||||
$style = ' style="display:none;"';
|
||||
?>
|
||||
<th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
|
||||
<th scope="col"<?php echo "id=\"$post_column_key\""; echo $class; echo $style?>><?php echo $column_display_name; ?></th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -194,6 +216,8 @@ if ($posts) {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); ?>
|
||||
|
||||
</form>
|
||||
|
||||
<div id="ajax-response"></div>
|
||||
|
@ -891,6 +891,7 @@ function display_page_row( $page, $level = 0 ) {
|
||||
$id = (int) $page->ID;
|
||||
$class = ('alternate' == $class ) ? '' : 'alternate';
|
||||
$posts_columns = wp_manage_pages_columns();
|
||||
$hidden = (array) get_user_option( 'manage-page-columns-hidden' );
|
||||
$title = get_the_title();
|
||||
if ( empty($title) )
|
||||
$title = __('(no title)');
|
||||
@ -901,6 +902,13 @@ function display_page_row( $page, $level = 0 ) {
|
||||
<?php
|
||||
|
||||
foreach ($posts_columns as $column_name=>$column_display_name) {
|
||||
$class = "class=\"$column_name column-$column_name\"";
|
||||
|
||||
$style = '';
|
||||
if ( in_array($column_name, $hidden) )
|
||||
$style = ' style="display:none;"';
|
||||
|
||||
$attributes = "$class$style";
|
||||
|
||||
switch ($column_name) {
|
||||
|
||||
@ -911,6 +919,7 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
|
||||
break;
|
||||
case 'modified':
|
||||
case 'date':
|
||||
$attributes = 'class="date column-date"' . $style;
|
||||
if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
|
||||
$t_time = $h_time = __('Unpublished');
|
||||
} else {
|
||||
@ -933,19 +942,17 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td class="date"><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td>
|
||||
<td <?php echo $attributes ?>><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td>
|
||||
<?php
|
||||
break;
|
||||
case 'title':
|
||||
$attributes = 'class="post-title page-title column-title"' . $style;
|
||||
$edit_link = get_edit_post_link( $page->ID );
|
||||
?>
|
||||
<td class="post-title"><strong><?php if ( current_user_can( 'edit_post', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; } ?></strong>
|
||||
<td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; } ?></strong>
|
||||
<?php
|
||||
if ( !empty($post->post_password) ) { _e(' — <strong>Protected</strong>'); } elseif ('private' == $post->post_status) { _e(' — <strong>Private</strong>'); }
|
||||
|
||||
if ( 'excerpt' == $mode )
|
||||
the_excerpt();
|
||||
|
||||
$actions = array();
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
||||
$actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
|
||||
@ -963,8 +970,9 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
$attributes = 'class="comments column-comments num"' . $style;
|
||||
?>
|
||||
<td class="comments num"><div class="post-com-count-wrapper">
|
||||
<td <?php echo $attributes ?>><div class="post-com-count-wrapper">
|
||||
<?php
|
||||
$left = get_pending_comments_num( $page->ID );
|
||||
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
||||
@ -980,13 +988,13 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
|
||||
|
||||
case 'author':
|
||||
?>
|
||||
<td class="author"><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
|
||||
<td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
?>
|
||||
<td class="status">
|
||||
<td <?php echo $attributes ?>>
|
||||
<a href="<?php the_permalink(); ?>" title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?>" rel="permalink">
|
||||
<?php
|
||||
switch ( $page->post_status ) {
|
||||
|
24
wp-admin/js/pages.js
Normal file
24
wp-admin/js/pages.js
Normal file
@ -0,0 +1,24 @@
|
||||
jQuery(document).ready( function($) {
|
||||
columns.init('page');
|
||||
|
||||
// Edit Settings
|
||||
$('#show-settings-link').click(function () {
|
||||
$('#edit-settings').slideDown('normal', function(){
|
||||
$('#show-settings-link').hide();
|
||||
$('#hide-settings-link').show();
|
||||
|
||||
});
|
||||
$('#show-settings').addClass('show-settings-opened');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#hide-settings-link').click(function () {
|
||||
$('#edit-settings').slideUp('normal', function(){
|
||||
$('#hide-settings-link').hide();
|
||||
$('#show-settings-link').show();
|
||||
$('#show-settings').removeClass('show-settings-opened');
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
@ -259,6 +259,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
) );
|
||||
|
||||
$scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns'), '20080910' );
|
||||
$scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns'), '20080910' );
|
||||
|
||||
$scripts->add( 'columns', '/wp-admin/js/columns.js', false, '20080910' );
|
||||
$scripts->localize( 'columns', 'columnsL10n', array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user