Column hiding for links. see #7725
git-svn-id: https://develop.svn.wordpress.org/trunk@8888 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9ed961489b
commit
e97af14335
@ -406,6 +406,18 @@ function wp_manage_pages_columns() {
|
|||||||
return $posts_columns;
|
return $posts_columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wp_manage_links_columns() {
|
||||||
|
$link_columns = array(
|
||||||
|
'name' => __('Name'),
|
||||||
|
'url' => __('URL'),
|
||||||
|
'categories' => __('Categories'),
|
||||||
|
'rel' => __('rel'),
|
||||||
|
'visible' => __('Visible'),
|
||||||
|
);
|
||||||
|
|
||||||
|
return apply_filters('manage_link_columns', $link_columns);
|
||||||
|
}
|
||||||
|
|
||||||
function inline_edit_row( $type ) {
|
function inline_edit_row( $type ) {
|
||||||
global $current_user;
|
global $current_user;
|
||||||
|
|
||||||
@ -1970,6 +1982,8 @@ function manage_columns_prefs($page) {
|
|||||||
$columns = wp_manage_posts_columns();
|
$columns = wp_manage_posts_columns();
|
||||||
elseif ( 'page' == $page )
|
elseif ( 'page' == $page )
|
||||||
$columns = wp_manage_pages_columns();
|
$columns = wp_manage_pages_columns();
|
||||||
|
elseif ( 'link' == $page )
|
||||||
|
$columns = wp_manage_links_columns();
|
||||||
elseif ( 'media' == $page )
|
elseif ( 'media' == $page )
|
||||||
$columns = wp_manage_media_columns();
|
$columns = wp_manage_media_columns();
|
||||||
else return;
|
else return;
|
||||||
@ -1978,7 +1992,7 @@ function manage_columns_prefs($page) {
|
|||||||
|
|
||||||
foreach ( $columns as $column => $title ) {
|
foreach ( $columns as $column => $title ) {
|
||||||
// Can't hide these
|
// Can't hide these
|
||||||
if ( 'cb' == $column || 'title' == $column )
|
if ( 'cb' == $column || 'title' == $column || 'name' == $column )
|
||||||
continue;
|
continue;
|
||||||
if ( 'comments' == $column )
|
if ( 'comments' == $column )
|
||||||
$title = __('Comments');
|
$title = __('Comments');
|
||||||
|
24
wp-admin/js/links.js
Normal file
24
wp-admin/js/links.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
jQuery(document).ready( function($) {
|
||||||
|
columns.init('link');
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
});
|
||||||
|
});
|
@ -34,6 +34,7 @@ if ( isset($_GET['action']) && isset($_GET['linkcheck']) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wp_enqueue_script('admin-forms');
|
wp_enqueue_script('admin-forms');
|
||||||
|
wp_enqueue_script('links');
|
||||||
|
|
||||||
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
|
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
|
||||||
|
|
||||||
@ -94,6 +95,19 @@ if ( isset($_GET['deleted']) ) {
|
|||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
|
|
||||||
<form id="links-filter" action="" method="get">
|
<form id="links-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') ?>
|
||||||
|
<br class="clear" />
|
||||||
|
</div></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h2><?php printf( __('Links (<a href="%s">Add New</a>)' ), 'link-add.php' ); ?></h2>
|
<h2><?php printf( __('Links (<a href="%s">Add New</a>)' ), 'link-add.php' ); ?></h2>
|
||||||
|
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
@ -134,17 +148,6 @@ echo $select_order;
|
|||||||
|
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
|
|
||||||
<?php
|
|
||||||
$link_columns = array(
|
|
||||||
'name' => '<th style="width: 15%;">' . __('Name') . '</th>',
|
|
||||||
'url' => '<th>' . __('URL') . '</th>',
|
|
||||||
'categories' => '<th>' . __('Categories') . '</th>',
|
|
||||||
'rel' => '<th style="text-align: center">' . __('rel') . '</th>',
|
|
||||||
'visible' => '<th style="text-align: center">' . __('Visible') . '</th>',
|
|
||||||
);
|
|
||||||
$link_columns = apply_filters('manage_link_columns', $link_columns);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( 'all' == $cat_id )
|
if ( 'all' == $cat_id )
|
||||||
$cat_id = '';
|
$cat_id = '';
|
||||||
@ -153,6 +156,8 @@ if ( !empty($_GET['s']) )
|
|||||||
$args['search'] = $_GET['s'];
|
$args['search'] = $_GET['s'];
|
||||||
$links = get_bookmarks( $args );
|
$links = get_bookmarks( $args );
|
||||||
if ( $links ) {
|
if ( $links ) {
|
||||||
|
$link_columns = wp_manage_links_columns();
|
||||||
|
$hidden = (array) get_user_option( 'manage-link-columns-hidden' );
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php wp_nonce_field('bulk-bookmarks') ?>
|
<?php wp_nonce_field('bulk-bookmarks') ?>
|
||||||
@ -160,9 +165,16 @@ if ( $links ) {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" class="check-column"><input type="checkbox" /></th>
|
<th scope="col" class="check-column"><input type="checkbox" /></th>
|
||||||
<?php foreach($link_columns as $column_display_name) {
|
<?php foreach($link_columns as $column_name => $column_display_name) {
|
||||||
echo $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 } ?>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -186,10 +198,19 @@ if ( $links ) {
|
|||||||
?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
|
?><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>';
|
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) {
|
foreach($link_columns as $column_name=>$column_display_name) {
|
||||||
|
$class = "class=\"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;"';
|
||||||
|
$attributes = "$class$style";
|
||||||
|
|
||||||
switch($column_name) {
|
switch($column_name) {
|
||||||
case 'name':
|
case 'name':
|
||||||
|
|
||||||
echo "<td><strong><a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $link->link_name)) . "'>$link->link_name</a></strong><br />";
|
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 />";
|
||||||
$actions = array();
|
$actions = array();
|
||||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
||||||
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf( __("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
|
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf( __("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
|
||||||
@ -203,10 +224,10 @@ if ( $links ) {
|
|||||||
echo '</td>';
|
echo '</td>';
|
||||||
break;
|
break;
|
||||||
case 'url':
|
case 'url':
|
||||||
echo "<td><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
|
echo "<td $attributes><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
|
||||||
break;
|
break;
|
||||||
case 'categories':
|
case 'categories':
|
||||||
?><td><?php
|
?><td <?php echo $attributes ?>><?php
|
||||||
$cat_names = array();
|
$cat_names = array();
|
||||||
foreach ($link->link_category as $category) {
|
foreach ($link->link_category as $category) {
|
||||||
$cat = get_term($category, 'link_category', OBJECT, 'display');
|
$cat = get_term($category, 'link_category', OBJECT, 'display');
|
||||||
@ -221,10 +242,10 @@ if ( $links ) {
|
|||||||
?></td><?php
|
?></td><?php
|
||||||
break;
|
break;
|
||||||
case 'rel':
|
case 'rel':
|
||||||
?><td><?php echo $link->link_rel; ?></td><?php
|
?><td <?php echo $attributes ?>><?php echo $link->link_rel; ?></td><?php
|
||||||
break;
|
break;
|
||||||
case 'visible':
|
case 'visible':
|
||||||
?><td style='text-align: center;'><?php echo $visible; ?></td><?php
|
?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
?>
|
?>
|
||||||
|
@ -262,6 +262,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
|
|
||||||
$scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns'), '20080910' );
|
$scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns'), '20080910' );
|
||||||
$scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns'), '20080910' );
|
$scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns'), '20080910' );
|
||||||
|
$scripts->add( 'links', '/wp-admin/js/links.js', array('columns'), '20080913' );
|
||||||
|
|
||||||
$scripts->add( 'columns', '/wp-admin/js/columns.js', false, '20080910' );
|
$scripts->add( 'columns', '/wp-admin/js/columns.js', false, '20080910' );
|
||||||
$scripts->localize( 'columns', 'columnsL10n', array(
|
$scripts->localize( 'columns', 'columnsL10n', array(
|
||||||
|
Loading…
Reference in New Issue
Block a user