Make set_current_screen() taxonomy aware. Use current_screen when setting up table headers for edit-tags.php. see #13783

git-svn-id: http://svn.automattic.com/wordpress/trunk@15175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-06-08 15:34:42 +00:00
parent d68747d9af
commit 1849b362b0
3 changed files with 17 additions and 8 deletions

View File

@ -81,10 +81,15 @@ if ( isset($_GET['page']) ) {
} }
if ( isset($_GET['post_type']) ) if ( isset($_GET['post_type']) )
$typenow = sanitize_user($_GET['post_type'], true); $typenow = sanitize_key($_GET['post_type']);
else else
$typenow = ''; $typenow = '';
if ( isset($_GET['taxonomy']) )
$taxnow = sanitize_key($_GET['taxonomy']);
else
$taxnow = '';
require(ABSPATH . 'wp-admin/menu.php'); require(ABSPATH . 'wp-admin/menu.php');
if ( current_user_can( 'manage_options' ) ) if ( current_user_can( 'manage_options' ) )

View File

@ -296,17 +296,16 @@ if ( $page_links )
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<?php $table_type = ('category' == $taxonomy ? 'categories' : 'edit-tags'); ?>
<table class="widefat tag fixed" cellspacing="0"> <table class="widefat tag fixed" cellspacing="0">
<thead> <thead>
<tr> <tr>
<?php print_column_headers($table_type); ?> <?php print_column_headers($current_screen); ?>
</tr> </tr>
</thead> </thead>
<tfoot> <tfoot>
<tr> <tr>
<?php print_column_headers($table_type, false); ?> <?php print_column_headers($current_screen, false); ?>
</tr> </tr>
</tfoot> </tfoot>

View File

@ -396,7 +396,7 @@ function wp_link_category_checklist( $link_id = 0 ) {
* @return unknown * @return unknown
*/ */
function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) { function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {
global $post_type; global $post_type, $current_screen;
static $row_class = ''; static $row_class = '';
$row_class = ($row_class == '' ? ' class="alternate"' : ''); $row_class = ($row_class == '' ? ' class="alternate"' : '');
@ -422,8 +422,8 @@ function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {
$out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>'; $out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
$columns = get_column_headers('edit-tags'); $columns = get_column_headers($current_screen);
$hidden = get_hidden_columns('edit-tags'); $hidden = get_hidden_columns($current_screen);
$default_term = get_option('default_' . $taxonomy); $default_term = get_option('default_' . $taxonomy);
foreach ( $columns as $column_name => $column_display_name ) { foreach ( $columns as $column_name => $column_display_name ) {
$class = "class=\"$column_name column-$column_name\""; $class = "class=\"$column_name column-$column_name\"";
@ -3900,7 +3900,7 @@ function compression_test() {
* @param string $id Screen id, optional. * @param string $id Screen id, optional.
*/ */
function set_current_screen( $id = '' ) { function set_current_screen( $id = '' ) {
global $current_screen, $hook_suffix, $typenow; global $current_screen, $hook_suffix, $typenow, $taxnow;
if ( empty($id) ) { if ( empty($id) ) {
$current_screen = $hook_suffix; $current_screen = $hook_suffix;
@ -3932,6 +3932,11 @@ function set_current_screen( $id = '' ) {
$typenow = 'post'; $typenow = 'post';
$current_screen->id = $typenow; $current_screen->id = $typenow;
$current_screen->post_type = $typenow; $current_screen->post_type = $typenow;
} elseif ( 'edit-tags' == $current_screen->id ) {
if ( empty($taxnow) )
$taxnow = 'post_tag';
$current_screen->id = 'edit-' . $taxnow;
$current_screen->taxonomy = $taxnow;
} }
$current_screen = apply_filters('current_screen', $current_screen); $current_screen = apply_filters('current_screen', $current_screen);