Begin rework of plugins list table. Props edward mindreantre. See #15318

git-svn-id: http://svn.automattic.com/wordpress/trunk@16345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-11-13 15:58:23 +00:00
parent 4b927768fd
commit bdbfca56a7
3 changed files with 49 additions and 33 deletions

View File

@ -383,7 +383,8 @@ class WP_Plugins_List_Table extends WP_List_Table {
$actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
$class = $is_active ? 'active' : 'inactive'; $class = $is_active ? 'active' : 'inactive';
$checkbox = in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' />"; $checkbox_id = md5($plugin_data['Name']) . "_checkbox";
$checkbox = in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $plugin_data['Name'] . "</label>";
if ( 'dropins' != $status ) { if ( 'dropins' != $status ) {
$description = '<p>' . $plugin_data['Description'] . '</p>'; $description = '<p>' . $plugin_data['Description'] . '</p>';
$plugin_name = $plugin_data['Name']; $plugin_name = $plugin_data['Name'];
@ -394,17 +395,21 @@ class WP_Plugins_List_Table extends WP_List_Table {
echo " echo "
<tr id='$id' class='$class'> <tr id='$id' class='$class'>
<th scope='row' class='check-column'>$checkbox</th> <th scope='row' class='check-column'>$checkbox</th>
<td class='plugin-title'><strong>$plugin_name</strong></td> <td class='plugin-title'>
<td class='desc'>$description</td> <strong>$plugin_name</strong>
</tr> ";
<tr class='$class second'>
<td></td>
<td class='plugin-title'>";
echo $this->row_actions( $actions, true ); echo $this->row_actions( $actions, true );
echo "</td> echo "
<td class='desc'>"; </td>
<td class='column-description desc'>
<div class='plugin-description'>
$description
</div>
<div class='$class second plugin-version-author-uri'>
";
$plugin_meta = array(); $plugin_meta = array();
if ( !empty( $plugin_data['Version'] ) ) if ( !empty( $plugin_data['Version'] ) )
$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
@ -419,8 +424,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status ); $plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
echo implode( ' | ', $plugin_meta ); echo implode( ' | ', $plugin_meta );
echo "</td>
</tr>\n"; echo "
</div>
</td>
</tr>
";
do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status ); do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status );
do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status ); do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status );

View File

@ -123,18 +123,23 @@ $(document).ready(function(){ adminMenu.init(); });
// show/hide/save table columns // show/hide/save table columns
columns = { columns = {
init : function() { init : function() {
var that = this;
$('.hide-column-tog', '#adv-settings').click( function() {
var $t = $(this), column = $t.val();
if ( $t.attr('checked') )
that.checked(column);
else
that.unchecked(column);
this.toggleView( $('.hide-column-tog', '#adv-settings').attr('checked'), $('.hide-column-tog', '#adv-settings').val() );
$('.column-name').css("width", "auto"); // Otherwise it only wants 50% column width...
$('.hide-column-tog', '#adv-settings').click( function() {
columns.toggleView( $(this).attr('checked'), $(this).val() );
columns.saveManageColumnsState(); columns.saveManageColumnsState();
}); });
}, },
toggleView : function(checked, column) {
if ( checked )
this.checked(column);
else
this.unchecked(column);
},
saveManageColumnsState : function() { saveManageColumnsState : function() {
var hidden = this.hidden(); var hidden = this.hidden();
$.post(ajaxurl, { $.post(ajaxurl, {

View File

@ -108,6 +108,8 @@ window.listTable = {
$('th.column-cb :input').attr('checked', false); $('th.column-cb :input').attr('checked', false);
columns.init(); // To rehide the hidden columns.
if ( this._callback ) if ( this._callback )
this._callback(); this._callback();
} }