register_column_headers()

git-svn-id: https://develop.svn.wordpress.org/trunk@9763 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-11-18 20:49:39 +00:00
parent 720a14ba90
commit 284fc1d040
1 changed files with 36 additions and 15 deletions

View File

@ -745,21 +745,24 @@ function wp_manage_pages_columns() {
* @return unknown * @return unknown
*/ */
function get_column_headers($page) { function get_column_headers($page) {
static $columns = array(); global $_wp_column_headers;
if ( !isset($_wp_column_headers) )
$_wp_column_headers = array();
// Store in static to avoid running filters on each call // Store in static to avoid running filters on each call
if ( isset($columns[$page]) ) if ( isset($_wp_column_headers[$page]) )
return $columns[$page]; return $_wp_column_headers[$page];
switch ($page) { switch ($page) {
case 'edit': case 'edit':
$columns[$page] = wp_manage_posts_columns(); $_wp_column_headers[$page] = wp_manage_posts_columns();
break; break;
case 'edit-pages': case 'edit-pages':
$columns[$page] = wp_manage_pages_columns(); $_wp_column_headers[$page] = wp_manage_pages_columns();
break; break;
case 'edit-comments': case 'edit-comments':
$columns[$page] = array( $_wp_column_headers[$page] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'comment' => __('Comment'), 'comment' => __('Comment'),
'author' => __('Author'), 'author' => __('Author'),
@ -769,7 +772,7 @@ function get_column_headers($page) {
break; break;
case 'link-manager': case 'link-manager':
$columns[$page] = array( $_wp_column_headers[$page] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'name' => __('Name'), 'name' => __('Name'),
'url' => __('URL'), 'url' => __('URL'),
@ -780,10 +783,10 @@ function get_column_headers($page) {
break; break;
case 'upload': case 'upload':
$columns[$page] = wp_manage_media_columns(); $_wp_column_headers[$page] = wp_manage_media_columns();
break; break;
case 'categories': case 'categories':
$columns[$page] = array( $_wp_column_headers[$page] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'name' => __('Name'), 'name' => __('Name'),
'description' => __('Description'), 'description' => __('Description'),
@ -793,7 +796,7 @@ function get_column_headers($page) {
break; break;
case 'edit-link-categories': case 'edit-link-categories':
$columns[$page] = array( $_wp_column_headers[$page] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'name' => __('Name'), 'name' => __('Name'),
'description' => __('Description'), 'description' => __('Description'),
@ -802,7 +805,7 @@ function get_column_headers($page) {
break; break;
case 'edit-tags': case 'edit-tags':
$columns[$page] = array( $_wp_column_headers[$page] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'name' => __('Name'), 'name' => __('Name'),
'slug' => __('Slug'), 'slug' => __('Slug'),
@ -811,7 +814,7 @@ function get_column_headers($page) {
break; break;
case 'users': case 'users':
$columns[$page] = array( $_wp_column_headers[$page] = array(
'cb' => '<input type="checkbox" />', 'cb' => '<input type="checkbox" />',
'username' => __('Username'), 'username' => __('Username'),
'name' => __('Name'), 'name' => __('Name'),
@ -821,11 +824,11 @@ function get_column_headers($page) {
); );
break; break;
default : default :
$columns[$page] = array(); $_wp_column_headers[$page] = array();
} }
$columns[$page] = apply_filters('manage_' . $page . '_columns', $columns[$page]); $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
return $columns[$page]; return $_wp_column_headers[$page];
} }
/** /**
@ -870,6 +873,24 @@ function print_column_headers( $type, $id = true ) {
<?php } <?php }
} }
/**
* Register column headers for a particular screen. The header names will be listed in the Screen Options.
*
* @since 2.7.0
*
* @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
* @param array $columns An array of columns with column IDs as the keys and translated column names as the values
* @see get_column_headers(), print_column_headers(), get_hidden_columns()
*/
function register_column_headers($screen, $columns) {
global $_wp_column_headers;
if ( !isset($_wp_column_headers) )
$_wp_column_headers = array();
$_wp_column_headers[$screen] = $columns;
}
/** /**
* {@internal Missing Short Description}} * {@internal Missing Short Description}}
* *