Consolidate column header code. Add column hiding to taxonomy pages (incomplete). see #7725

git-svn-id: http://svn.automattic.com/wordpress/trunk@8923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-09-18 05:41:45 +00:00
parent 55b94822e0
commit 24823f8c9e
11 changed files with 194 additions and 107 deletions

View File

@ -134,6 +134,19 @@ endif; ?>
<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('Advanced Options') ?></a>
<a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Options') ?></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('category') ?>
<br class="clear" />
</div></div>
</div>
<h2><?php printf( current_user_can('manage_categories') ? __('Categories (<a href="%s">Add New</a>)') : __('Manage Tags'), '#addcat' ); ?></h2>
<br class="clear" />
@ -175,10 +188,7 @@ if ( $page_links )
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th scope="col"><?php _e('Name') ?></th>
<th scope="col"><?php _e('Description') ?></th>
<th scope="col" class="num"><?php _e('Posts') ?></th>
<?php print_column_headers('category'); ?>
</tr>
</thead>
<tbody id="the-list" class="list:cat">
@ -187,6 +197,9 @@ cat_rows(0, 0, 0, $pagenum, $catsperpage);
?>
</tbody>
</table>
<?php wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); ?>
</form>
<div class="tablenav">

View File

@ -11,28 +11,7 @@ if ( ! defined('ABSPATH') ) die();
<table class="widefat">
<thead>
<tr>
<?php
$posts_columns = wp_manage_media_columns();
$hidden = (array) get_user_option( 'manage-media-columns-hidden' );
?>
<?php 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="manage-column column-comments num"';
elseif ( 'modified' === $post_column_key )
$class = ' class="manage-column column-date"';
else
$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 "id=\"$post_column_key\""; echo $class; echo $style?>><?php echo $column_display_name; ?></th>
<?php } ?>
<?php print_column_headers('media'); ?>
</tr>
</thead>
<tbody id="the-list" class="list:post">
@ -52,7 +31,7 @@ if ( empty($att_title) )
<tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
<?php
$posts_columns = wp_manage_media_columns();
foreach ($posts_columns as $column_name => $column_display_name ) {
$class = "class=\"$column_name column-$column_name\"";

View File

@ -75,6 +75,19 @@ endif; ?>
<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('Advanced Options') ?></a>
<a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Options') ?></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('link-category') ?>
<br class="clear" />
</div></div>
</div>
<h2><?php printf( current_user_can('manage_categories') ? __('Link Categories (<a href="%s">Add New</a>)') : __('Manage Tags'), '#addcat' ); ?></h2>
<br class="clear" />
@ -116,10 +129,7 @@ if ( $page_links )
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th scope="col"><?php _e('Name') ?></th>
<th scope="col"><?php _e('Description') ?></th>
<th scope="col" class="num" style="width: 90px;"><?php _e('Links') ?></th>
<?php print_column_headers('link-category'); ?>
</tr>
</thead>
<tbody id="the-list" class="list:link-cat">
@ -144,6 +154,9 @@ if ( $categories ) {
?>
</tbody>
</table>
<?php wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); ?>
</form>
<div class="tablenav">

View File

@ -192,25 +192,7 @@ if ($posts) {
<table class="widefat">
<thead>
<tr>
<?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="manage-column column-comments num"';
elseif ( 'modified' === $post_column_key )
$class = ' class="manage-column column-date"';
else
$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 "id=\"$post_column_key\""; echo $class; echo $style?>><?php echo $column_display_name; ?></th>
<?php } ?>
<?php print_column_headers('page'); ?>
</tr>
</thead>
<tbody>

View File

@ -11,27 +11,7 @@ if ( ! defined('ABSPATH') ) die();
<table class="widefat">
<thead>
<tr>
<?php
$posts_columns = wp_manage_posts_columns();
$hidden = (array) get_user_option( 'manage-post-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="manage-column column-comments num"';
elseif ( 'modified' === $post_column_key )
$class = ' class="manage-column column-date"';
else
$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 "id=\"$post_column_key\""; echo $class; echo $style?>><?php echo $column_display_name; ?></th>
<?php } ?>
<?php print_column_headers('post'); ?>
</tr>
</thead>
<tbody>

View File

@ -141,6 +141,19 @@ endif; ?>
<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('Advanced Options') ?></a>
<a href="#edit_settings" id="hide-settings-link" class="hide-if-js hide-if-no-js"><?php _e('Hide Options') ?></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('tag') ?>
<br class="clear" />
</div></div>
</div>
<h2><?php printf( current_user_can('manage_categories') ? __('Tags (<a href="%s">Add New</a>)') : __('Manage Tags'), '#addtag' ); ?></h2>
<br class="clear" />
@ -182,9 +195,7 @@ if ( $page_links )
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th scope="col"><?php _e('Name') ?></th>
<th scope="col" class="num" style="width: 90px"><?php _e('Posts') ?></th>
<?php print_column_headers('tag'); ?>
</tr>
</thead>
<tbody id="the-list" class="list:tag">

View File

@ -443,16 +443,90 @@ function wp_manage_pages_columns() {
return $posts_columns;
}
function wp_manage_links_columns() {
$link_columns = array(
'name' => __('Name'),
'url' => __('URL'),
'categories' => __('Categories'),
'rel' => __('rel'),
'visible' => __('Visible'),
);
function get_column_headers($page) {
switch ($page) {
case 'post':
return wp_manage_posts_columns();
case 'page':
return wp_manage_pages_columns();
case 'link':
$columns = array(
'cb' => '<input type="checkbox" />',
'name' => __('Name'),
'url' => __('URL'),
'categories' => __('Categories'),
'rel' => __('rel'),
'visible' => __('Visible')
);
return apply_filters('manage_link_columns', $link_columns);
return apply_filters('manage_link_columns', $columns);
case 'media':
return wp_manage_media_columns();
case 'category':
$columns = array(
'cb' => '<input type="checkbox" />',
'name' => __('Name'),
'description' => __('Description'),
'posts' => __('Posts')
);
return apply_filters('manage_categories_columns', $columns);
case 'link-category':
$columns = array(
'cb' => '<input type="checkbox" />',
'name' => __('Name'),
'description' => __('Description'),
'links' => __('Links')
);
return apply_filters('manage_link_categories_columns', $columns);
case 'tag':
$columns = array(
'cb' => '<input type="checkbox" />',
'name' => __('Name'),
'posts' => __('Posts')
);
return apply_filters('manage_link_categories_columns', $columns);
}
return $columns;
}
function print_column_headers( $type ) {
$columns = get_column_headers( $type );
$hidden = (array) get_user_option( "manage-$type-columns-hidden" );
$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 ) {
$class = ' class="manage-column';
if ( 'modified' == $column_key )
$column_key = 'date';
$class .= " column-$column_key";
if ( 'cb' == $column_key )
$class .= ' check-column';
elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
$class .= ' num';
$class .= '"';
$style = '';
if ( in_array($column_key, $hidden) )
$style = 'display:none;';
if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
$style .= ' ' . $styles[$type][$column_key];
$style = ' style="' . $style . '"';
?>
<th scope="col"<?php echo "id=\"$column_key\""; echo $class; echo $style?>><?php echo $column_display_name; ?></th>
<?php }
}
function inline_edit_row( $type ) {
@ -2034,15 +2108,7 @@ function do_settings_fields($page, $section) {
}
function manage_columns_prefs($page) {
if ( 'post' == $page )
$columns = wp_manage_posts_columns();
elseif ( 'page' == $page )
$columns = wp_manage_pages_columns();
elseif ( 'link' == $page )
$columns = wp_manage_links_columns();
elseif ( 'media' == $page )
$columns = wp_manage_media_columns();
else return;
$columns = get_column_headers($page);
$hidden = (array) get_user_option( "manage-$page-columns-hidden" );

View File

@ -20,4 +20,31 @@ jQuery(function($) {
$('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
else
$('#the-list').wpList();
if ( jQuery('#link-category-search').size() ) {
columns.init('link-category');
} else {
columns.init('category');
}
// 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;
});
});

View File

@ -18,4 +18,27 @@ jQuery(function($) {
$('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
else
$('#the-list').wpList();
columns.init('tag');
// 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;
});
});

View File

@ -156,7 +156,7 @@ if ( !empty($_GET['s']) )
$args['search'] = $_GET['s'];
$links = get_bookmarks( $args );
if ( $links ) {
$link_columns = wp_manage_links_columns();
$link_columns = get_column_headers('link');
$hidden = (array) get_user_option( 'manage-link-columns-hidden' );
?>
@ -164,17 +164,7 @@ if ( $links ) {
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<?php foreach($link_columns as $column_name => $column_display_name) {
$class = " class=\"manage-column column-$column_name\"";
$style = '';
if ( in_array($column_name, $hidden) )
$style = ' style="display:none;"';
if ( 'visible' == $column_name )
$style = empty($style) ? ' style="text-align: center;"' : ' style="text-align: center; display: none;"';
?>
<th scope="col"<?php echo "id=\"$column_name\""; echo $class; echo $style ?>><?php echo $column_display_name; ?></th>
<?php } ?>
<?php print_column_headers('link'); ?>
</tr>
</thead>
<tbody>
@ -196,7 +186,6 @@ if ( $links ) {
++ $alt;
$edit_link = get_edit_bookmark_link();
?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>';
foreach($link_columns as $column_name=>$column_display_name) {
$class = "class=\"column-$column_name\"";
@ -208,6 +197,9 @@ if ( $links ) {
$attributes = "$class$style";
switch($column_name) {
case 'cb':
echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></th>';
break;
case 'name':
echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "'>$link->link_name</a></strong><br />";
@ -264,6 +256,7 @@ if ( $links ) {
<?php } else { ?>
<p><?php _e('No links found.') ?></p>
<?php } ?>
<?php wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); ?>
</form>
<div id="ajax-response"></div>

View File

@ -149,8 +149,8 @@ function wp_default_scripts( &$scripts ) {
'add' => attribute_escape(__('Add')),
'how' => __('Separate multiple categories with commas.')
) );
$scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20071031' );
$scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20071031' );
$scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns'), '20071031' );
$scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns'), '20071031' );
$scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
$scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20080824' );
$scripts->localize( 'password-strength-meter', 'pwsL10n', array(