From 5c5d1aef4dace429157579c4ebabdf287e382acd Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 17 Nov 2008 19:16:26 +0000 Subject: [PATCH] Key screen meta off of page hook. fixes #8246 git-svn-id: http://svn.automattic.com/wordpress/trunk@9735 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/categories.php | 4 +- wp-admin/edit-comments.php | 4 +- wp-admin/edit-link-categories.php | 8 +- wp-admin/edit-pages.php | 6 +- wp-admin/edit-post-rows.php | 4 +- wp-admin/edit-tags.php | 4 +- wp-admin/edit.php | 2 +- wp-admin/includes/template.php | 120 ++++++++++++++++++------------ wp-admin/js/categories.js | 6 +- wp-admin/js/edit-comments.js | 2 +- wp-admin/js/tags.js | 2 +- wp-admin/js/users.js | 2 +- wp-admin/link-manager.php | 10 +-- wp-admin/upload.php | 2 +- wp-admin/users.php | 4 +- wp-includes/script-loader.php | 8 +- 16 files changed, 105 insertions(+), 83 deletions(-) diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 70fab86072..7fdc3b8a8f 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -192,13 +192,13 @@ if ( $page_links ) - + - + diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 234da8033f..cd0db8f21f 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -251,13 +251,13 @@ if ( 'spam' == $comment_status ) {
- + - + diff --git a/wp-admin/edit-link-categories.php b/wp-admin/edit-link-categories.php index b7558a5c96..5463252c15 100644 --- a/wp-admin/edit-link-categories.php +++ b/wp-admin/edit-link-categories.php @@ -69,8 +69,8 @@ endif; ?> @@ -120,13 +120,13 @@ if ( $page_links )
- + - + diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php index b0c76e6336..e5c74715de 100644 --- a/wp-admin/edit-pages.php +++ b/wp-admin/edit-pages.php @@ -216,13 +216,13 @@ if ($posts) {
- + - + @@ -316,7 +316,7 @@ endif; // posts; }); }); })(jQuery); -columns.init('page'); +columns.init('edit-pages'); /* ]]> */ diff --git a/wp-admin/edit-post-rows.php b/wp-admin/edit-post-rows.php index 2a960854b3..decfbe3501 100644 --- a/wp-admin/edit-post-rows.php +++ b/wp-admin/edit-post-rows.php @@ -11,13 +11,13 @@ if ( ! defined('ABSPATH') ) die();
- + - + diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index 6923e2b384..caec12c80a 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -188,13 +188,13 @@ if ( $page_links )
- + - + diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 2ca561da6e..9d2ea5a6ae 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -330,7 +330,7 @@ endif; // posts; }); }); })(jQuery); -columns.init('post'); +columns.init('edit'); /* ]]> */ diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 6bd7d65e57..e958cb54f9 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -144,8 +144,8 @@ function _cat_row( $category, $level, $name_override = false ) { $posts_count = ( $category->count > 0 ) ? "$category->count" : $category->count; $output = ""; - $columns = get_column_headers('category'); - $hidden = (array) get_user_option( 'manage-category-columns-hidden' ); + $columns = get_column_headers('categories'); + $hidden = get_hidden_columns('categories'); foreach ( $columns as $column_name => $column_display_name ) { $class = "class=\"$column_name column-$column_name\""; @@ -305,8 +305,8 @@ function link_cat_row( $category, $name_override = false ) { $category->count = number_format_i18n( $category->count ); $count = ( $category->count > 0 ) ? "$category->count" : $category->count; $output = ""; - $columns = get_column_headers('link-category'); - $hidden = (array) get_user_option( 'manage-link-category-columns-hidden' ); + $columns = get_column_headers('edit-link-categories'); + $hidden = get_hidden_columns('edit-link-categories'); foreach ( $columns as $column_name => $column_display_name ) { $class = "class=\"$column_name column-$column_name\""; @@ -584,8 +584,8 @@ function _tag_row( $tag, $class = '' ) { $edit_link = "edit-tags.php?action=edit&tag_ID=$tag->term_id"; $out = ''; $out .= ''; - $columns = get_column_headers('tag'); - $hidden = (array) get_user_option( 'manage-tag-columns-hidden' ); + $columns = get_column_headers('edit-tags'); + $hidden = get_hidden_columns('edit-tags'); foreach ( $columns as $column_name => $column_display_name ) { $class = "class=\"$column_name column-$column_name\""; @@ -748,13 +748,21 @@ function wp_manage_pages_columns() { * @return unknown */ function get_column_headers($page) { + static $columns = array(); + + // Store in static to avoid running filters on each call + if ( isset($columns[$page]) ) + return $columns[$page]; + switch ($page) { - case 'post': - return wp_manage_posts_columns(); - case 'page': - return wp_manage_pages_columns(); - case 'comment': - $columns = array( + case 'edit': + $columns[$page] = wp_manage_posts_columns(); + break; + case 'edit-pages': + $columns[$page] = wp_manage_pages_columns(); + break; + case 'edit-comments': + $columns[$page] = array( 'cb' => '', 'comment' => __('Comment'), 'author' => __('Author'), @@ -762,9 +770,9 @@ function get_column_headers($page) { 'response' => __('In Response To') ); - return apply_filters('manage_comments_columns', $columns); - case 'link': - $columns = array( + break; + case 'link-manager': + $columns[$page] = array( 'cb' => '', 'name' => __('Name'), 'url' => __('URL'), @@ -773,11 +781,12 @@ function get_column_headers($page) { 'visible' => __('Visible') ); - return apply_filters('manage_link_columns', $columns); - case 'media': - return wp_manage_media_columns(); - case 'category': - $columns = array( + break; + case 'upload': + $columns[$page] = wp_manage_media_columns(); + break; + case 'categories': + $columns[$page] = array( 'cb' => '', 'name' => __('Name'), 'description' => __('Description'), @@ -785,27 +794,27 @@ function get_column_headers($page) { 'posts' => __('Posts') ); - return apply_filters('manage_categories_columns', $columns); - case 'link-category': - $columns = array( + break; + case 'edit-link-categories': + $columns[$page] = array( 'cb' => '', 'name' => __('Name'), 'description' => __('Description'), 'links' => __('Links') ); - return apply_filters('manage_link_categories_columns', $columns); - case 'tag': - $columns = array( + break; + case 'edit-tags': + $columns[$page] = array( 'cb' => '', 'name' => __('Name'), 'slug' => __('Slug'), 'posts' => __('Posts') ); - return apply_filters('manage_link_categories_columns', $columns); - case 'user': - $columns = array( + break; + case 'users': + $columns[$page] = array( 'cb' => '', 'username' => __('Username'), 'name' => __('Name'), @@ -813,10 +822,13 @@ function get_column_headers($page) { 'role' => __('Role'), 'posts' => __('Posts') ); - return apply_filters('manage_users_columns', $columns); + break; default : - return apply_filters('manage_' . $page . '_columns', array()); + $columns[$page] = array(); } + + $columns[$page] = apply_filters('manage_' . $page . '_columns', $columns[$page]); + return $columns[$page]; } /** @@ -828,8 +840,9 @@ function get_column_headers($page) { * @param unknown_type $id */ function print_column_headers( $type, $id = true ) { + $type = str_replace('.php', '', $type); $columns = get_column_headers( $type ); - $hidden = (array) get_user_option( "manage-$type-columns-hidden" ); + $hidden = get_hidden_columns($type); $styles = array(); // $styles['tag']['posts'] = 'width: 90px;'; // $styles['link-category']['links'] = 'width: 90px;'; @@ -860,6 +873,18 @@ function print_column_headers( $type, $id = true ) { post_status ); ?> iedit' valign="top"> $column_display_name ) { $class = "class=\"$column_name column-$column_name\""; @@ -1448,8 +1473,8 @@ function display_page_row( $page, $level = 0 ) { $pad = str_repeat( '— ', $level ); $id = (int) $page->ID; $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; - $posts_columns = wp_manage_pages_columns(); - $hidden = (array) get_user_option( 'manage-page-columns-hidden' ); + $posts_columns = get_column_headers('edit-pages'); + $hidden = get_hidden_columns('edit-pages'); $title = _draft_or_post_title(); ?> @@ -1751,8 +1776,8 @@ function user_row( $user_object, $style = '', $role = '' ) { } $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None'); $r = ""; - $columns = get_column_headers('user'); - $hidden = (array) get_user_option( 'manage-user-columns-hidden' ); + $columns = get_column_headers('users'); + $hidden = get_hidden_columns('users'); $avatar = get_avatar( $user_object->user_email, 32 ); foreach ( $columns as $column_name => $column_display_name ) { $class = "class=\"$column_name column-$column_name\""; @@ -1906,8 +1931,8 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); echo ""; - $columns = get_column_headers('comment'); - $hidden = (array) get_user_option( 'manage-comment-columns-hidden' ); + $columns = get_column_headers('edit-comments'); + $hidden = get_hidden_columns('edit-comments'); foreach ( $columns as $column_name => $column_display_name ) { $class = "class=\"$column_name column-$column_name\""; @@ -2862,7 +2887,7 @@ function do_settings_fields($page, $section) { function manage_columns_prefs($page) { $columns = get_column_headers($page); - $hidden = (array) get_user_option( "manage-$page-columns-hidden" ); + $hidden = get_hidden_columns($page); foreach ( $columns as $column => $title ) { // Can't hide these @@ -3180,19 +3205,16 @@ function screen_meta($screen) { global $wp_meta_boxes; $screen = str_replace('.php', '', $screen); - - $column_screens = array('edit' => 'post', 'edit-pages' => 'page', 'edit-tags' => 'tag', 'categories' => 'category', - 'edit-link-categories' => 'link-category', 'link-manager' => 'link', 'users' => 'user', 'upload' => 'media', - 'edit-comments' => 'comment'); - $screen = str_replace('-new', '', $screen); $screen = str_replace('-add', '', $screen); + + $column_screens = get_column_headers($screen); $meta_screens = array('index' => 'dashboard'); if ( isset($meta_screens[$screen]) ) $screen = $meta_screens[$screen]; $show_screen = false; - if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens[$screen]) ) + if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) $show_screen = true; ?>
@@ -3204,8 +3226,8 @@ function screen_meta($screen) {
diff --git a/wp-admin/js/categories.js b/wp-admin/js/categories.js index 6a9a2a3e13..2b8ae20889 100644 --- a/wp-admin/js/categories.js +++ b/wp-admin/js/categories.js @@ -29,9 +29,9 @@ jQuery(function($) { else $('#the-list').wpList({ addAfter: addAfter2 }); - if ( jQuery('#link-category-search').size() ) { - columns.init('link-category'); + if ( jQuery('#link-category-search-input').size() ) { + columns.init('edit-link-categories'); } else { - columns.init('category'); + columns.init('categories'); } }); diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index 470d4edc6e..3615035b96 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -283,7 +283,7 @@ commentReply = { }; $(document).ready(function(){ - columns.init('comment'); + columns.init('edit-comments'); commentReply.init(); if ( typeof QTags != 'undefined' ) diff --git a/wp-admin/js/tags.js b/wp-admin/js/tags.js index cfc2024caf..c5b2d6f28a 100644 --- a/wp-admin/js/tags.js +++ b/wp-admin/js/tags.js @@ -26,5 +26,5 @@ jQuery(function($) { else $('#the-list').wpList({ addAfter: addAfter2 }); - columns.init('tag'); + columns.init('edit-tags'); }); \ No newline at end of file diff --git a/wp-admin/js/users.js b/wp-admin/js/users.js index eaf6d3aa94..db7d5c6b30 100644 --- a/wp-admin/js/users.js +++ b/wp-admin/js/users.js @@ -1,5 +1,5 @@ jQuery( function($) { $('#users').wpList(); - columns.init('user'); + columns.init('users'); }); diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index a65075fc48..1a32851c1e 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -139,21 +139,21 @@ if ( !empty($_GET['s']) ) $args['search'] = $_GET['s']; $links = get_bookmarks( $args ); if ( $links ) { - $link_columns = get_column_headers('link'); - $hidden = (array) get_user_option( 'manage-link-columns-hidden' ); + $link_columns = get_column_headers('link-manager'); + $hidden = (array) get_user_option( 'manage-link-manager-columns-hidden' ); ?>
- + - + @@ -278,7 +278,7 @@ if ( $links ) { }); }); })(jQuery); -columns.init('link'); +columns.init('link-manager'); /* ]]> */ diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 72533c7348..6e9111e397 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -463,7 +463,7 @@ endif; // posts; }); }); })(jQuery); -columns.init('media'); +columns.init('upload'); /* ]]> */ diff --git a/wp-admin/users.php b/wp-admin/users.php index a0d09b7c15..fcaf5a059a 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -331,13 +331,13 @@ unset($role_links);
- + - + diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 23bb7f991b..961213f642 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -145,8 +145,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'), '20080925' ); - $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20080925' ); + $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20081117' ); + $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20081117' ); $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'), '20081021' ); $scripts->localize( 'password-strength-meter', 'pwsL10n', array( @@ -156,12 +156,12 @@ function wp_default_scripts( &$scripts ) { 'good' => __('Medium'), 'strong' => __('Strong') ) ); - $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081115b' ); + $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20081117' ); $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']) ) ); - $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20080925' ); + $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20081117' ); $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081109' ); $scripts->localize( 'postbox', 'postboxL10n', array(