Media Grid: Screen Options for grid have to play nice with Screen Options for list. This was fun.

See #24716.


git-svn-id: https://develop.svn.wordpress.org/trunk@29078 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-07-10 21:25:49 +00:00
parent 3ebde0c4d6
commit d5cbf00457
3 changed files with 19 additions and 4 deletions

View File

@ -1078,7 +1078,13 @@ final class WP_Screen {
</div> </div>
<?php elseif ( $this->get_option( 'media_grid_title' ) ): ?> <?php elseif ( $this->get_option( 'media_grid_title' ) ): ?>
<div class="metabox-prefs media-grid-prefs"> <div class="metabox-prefs media-grid-prefs">
<?php foreach ( $this->_options as $column => $args ) { <?php
$option = get_user_option( 'manageuploadgridcolumnshidden' );
$hidden = array();
if ( ! empty( $option ) ) {
$hidden = $option;
}
foreach ( $this->_options as $column => $args ) {
$id = "$column-hide"; $id = "$column-hide";
echo '<label for="' . $id . '">'; echo '<label for="' . $id . '">';
$saved = str_replace( 'media_grid_', '', $column ); $saved = str_replace( 'media_grid_', '', $column );

View File

@ -27,7 +27,7 @@ columns = {
}, },
saveManageColumnsState : function() { saveManageColumnsState : function() {
var hidden = this.hidden(); var hidden, page;
if ( $( '#media_grid_title-hide' ).length ) { if ( $( '#media_grid_title-hide' ).length ) {
hidden = []; hidden = [];
$( '.hide-column-tog', '.media-grid-prefs' ).each( function() { $( '.hide-column-tog', '.media-grid-prefs' ).each( function() {
@ -40,13 +40,18 @@ columns = {
$el.removeClass( 'data-hidden' ).addClass( 'data-visible' ); $el.removeClass( 'data-hidden' ).addClass( 'data-visible' );
} }
} ); } );
page = pagenow + 'grid';
hidden = hidden.join( ',' ); hidden = hidden.join( ',' );
} else {
page = pagenow;
hidden = this.hidden();
} }
$.post(ajaxurl, { $.post(ajaxurl, {
action: 'hidden-columns', action: 'hidden-columns',
hidden: hidden, hidden: hidden,
screenoptionnonce: $('#screenoptionnonce').val(), screenoptionnonce: $('#screenoptionnonce').val(),
page: pagenow page: page
}); });
}, },

View File

@ -419,7 +419,11 @@ function wp_print_media_templates() {
if ( _.contains( data.controller.options.mode, 'grid' ) ) { #> if ( _.contains( data.controller.options.mode, 'grid' ) ) { #>
<div class="data-fields"> <div class="data-fields">
<?php <?php
$hidden = get_hidden_columns( get_current_screen() ); $option = get_user_option( 'manageuploadgridcolumnshidden' );
$hidden = array();
if ( ! empty( $option ) ) {
$hidden = $option;
}
$fields = array( 'title', 'uploadedTo', 'dateFormatted', 'mime' ); $fields = array( 'title', 'uploadedTo', 'dateFormatted', 'mime' );
foreach ( $fields as $field ): foreach ( $fields as $field ):
$class_name = in_array( $field, $hidden ) ? 'data-field data-hidden' : 'data-field data-visible'; $class_name = in_array( $field, $hidden ) ? 'data-field data-hidden' : 'data-field data-visible';