Introduce WP_List_Table::get_column_count() and take care of update notice <tr>. Props ocean90 for initial patch. Fixes #15318
git-svn-id: http://svn.automattic.com/wordpress/trunk@16368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d81d7b7f4a
commit
a41a7b5b5b
|
@ -549,6 +549,20 @@ class WP_List_Table {
|
|||
return $this->_column_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of visible columns
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function get_column_count() {
|
||||
list ( $columns, $hidden ) = $this->get_column_info();
|
||||
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
|
||||
return count( $columns ) - count( $hidden );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print column headers, accounting for hidden and sortable columns.
|
||||
*
|
||||
|
|
|
@ -703,9 +703,6 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
$flat_taxonomies[] = $taxonomy;
|
||||
}
|
||||
|
||||
list( $columns, $hidden ) = $this->get_column_info();
|
||||
|
||||
$col_count = count( $columns ) - count( $hidden );
|
||||
$m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
|
||||
$can_publish = current_user_can( $post_type_object->cap->publish_posts );
|
||||
$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
|
||||
|
@ -720,12 +717,10 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
|
||||
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
|
||||
echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";
|
||||
?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
|
||||
?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
|
||||
|
||||
<fieldset class="inline-edit-col-left"><div class="inline-edit-col">
|
||||
<h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
if ( post_type_supports( $screen->post_type, 'title' ) ) :
|
||||
|
@ -976,6 +971,8 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
</div></fieldset>
|
||||
|
||||
<?php
|
||||
list( $columns ) = $this->get_column_info();
|
||||
|
||||
foreach ( $columns as $column_name => $column_display_name ) {
|
||||
if ( isset( $core_columns[$column_name] ) )
|
||||
continue;
|
||||
|
|
|
@ -308,14 +308,10 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
|
||||
if ( ! current_user_can( $tax->cap->edit_terms ) )
|
||||
return;
|
||||
|
||||
list( $columns, $hidden ) = $this->get_column_info();
|
||||
|
||||
$col_count = count( $columns ) - count( $hidden );
|
||||
?>
|
||||
?>
|
||||
|
||||
<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
|
||||
<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
|
||||
<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
|
||||
|
||||
<fieldset><div class="inline-edit-col">
|
||||
<h4><?php _e( 'Quick Edit' ); ?></h4>
|
||||
|
@ -330,12 +326,13 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
|
||||
</label>
|
||||
<?php } ?>
|
||||
|
||||
</div></fieldset>
|
||||
<?php
|
||||
|
||||
$core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
|
||||
|
||||
list( $columns ) = $this->get_column_info();
|
||||
|
||||
foreach ( $columns as $column_name => $column_display_name ) {
|
||||
if ( isset( $core_columns[$column_name] ) )
|
||||
continue;
|
||||
|
|
|
@ -331,14 +331,10 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
|
|||
|
||||
$wp_list_table = get_list_table('WP_Comments_List_Table');
|
||||
|
||||
list ( $columns, $hidden ) = $wp_list_table->get_column_info();
|
||||
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
|
||||
$col_count = count($columns) - count($hidden);
|
||||
|
||||
?>
|
||||
<form method="get" action="">
|
||||
<?php if ( $table_row ) : ?>
|
||||
<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $col_count; ?>">
|
||||
<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
|
||||
<?php else : ?>
|
||||
<div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -192,8 +192,10 @@ function wp_plugin_update_row( $file, $plugin_data ) {
|
|||
|
||||
$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&TB_iframe=true&width=600&height=800');
|
||||
|
||||
$wp_list_table = get_list_table('WP_Plugins_List_Table');
|
||||
|
||||
if ( is_network_admin() || !is_multisite() ) {
|
||||
echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">';
|
||||
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
|
||||
if ( ! current_user_can('update_plugins') )
|
||||
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
|
||||
else if ( empty($r->package) )
|
||||
|
@ -266,7 +268,9 @@ function wp_theme_update_row( $theme_key, $theme ) {
|
|||
|
||||
$details_url = self_admin_url("theme-install.php?tab=theme-information&theme=$theme_key&TB_iframe=true&width=600&height=400");
|
||||
|
||||
echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">';
|
||||
$wp_list_table = get_list_table('WP_MS_Themes_List_Table');
|
||||
|
||||
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
|
||||
if ( ! current_user_can('update_themes') )
|
||||
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version );
|
||||
else if ( empty( $r['package'] ) )
|
||||
|
|
|
@ -147,10 +147,12 @@ columns = {
|
|||
|
||||
checked : function(column) {
|
||||
$('.column-' + column).show();
|
||||
this.colSpanChange(+1);
|
||||
},
|
||||
|
||||
unchecked : function(column) {
|
||||
$('.column-' + column).hide();
|
||||
this.colSpanChange(-1);
|
||||
},
|
||||
|
||||
hidden : function() {
|
||||
|
@ -164,6 +166,14 @@ columns = {
|
|||
return id.substring( id, id.length - 5 );
|
||||
}).get().join(',');
|
||||
};
|
||||
},
|
||||
|
||||
colSpanChange : function(diff) {
|
||||
var $t = $('table').find('.colspanchange');
|
||||
if ( !$t.length )
|
||||
return;
|
||||
var n = parseInt( $t.attr('colspan'), 10 ) + diff;
|
||||
$t.attr('colspan', n.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -64,7 +64,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
|
||||
|
||||
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20101007' );
|
||||
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20101114' );
|
||||
$scripts->add_data( 'common', 'group', 1 );
|
||||
$scripts->localize( 'common', 'commonL10n', array(
|
||||
'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
|
||||
|
|
Loading…
Reference in New Issue