Media Grid: make registering Screen Options for non-list tables more generic.

See #24716.

Built from https://develop.svn.wordpress.org/trunk@29079


git-svn-id: http://core.svn.wordpress.org/trunk@28865 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-07-10 21:44:16 +00:00
parent a9fb59151b
commit b16d3bd6ad
4 changed files with 23 additions and 17 deletions

View File

@ -1022,7 +1022,7 @@ final class WP_Screen {
<?php if (
isset( $wp_meta_boxes[ $this->id ] )
|| $this->get_option( 'per_page' )
|| $this->get_option( 'media_grid_title' )
|| $this->get_option( 'misc_screen_options' )
|| ( $columns && empty( $columns['_title'] ) )
) : ?>
<h5><?php _e( 'Show on screen' ); ?></h5>
@ -1076,19 +1076,24 @@ final class WP_Screen {
?>
<br class="clear" />
</div>
<?php elseif ( $this->get_option( 'media_grid_title' ) ): ?>
<div class="metabox-prefs media-grid-prefs">
<?php elseif ( $this->get_option( 'misc_screen_options' ) ):
$misc_options = $this->get_option( 'misc_screen_options' );
?>
<div class="metabox-prefs misc-screen-options" data-id="<?php echo esc_attr( $misc_options['id'] ) ?>">
<?php
$option = get_user_option( 'manageuploadgridcolumnshidden' );
$option = get_user_option( $misc_options['option'] );
$hidden = array();
if ( ! empty( $option ) ) {
$hidden = $option;
}
foreach ( $this->_options as $column => $args ) {
if ( 'misc_screen_options' === $column ) {
continue;
}
$id = "$column-hide";
echo '<label for="' . $id . '">';
$saved = str_replace( 'media_grid_', '', $column );
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $saved, $hidden ), true, false ) . ' />';
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $column, $hidden ), true, false ) . ' />';
echo $args['label'] . "</label>\n";
} ?>
<br class="clear" />

View File

@ -27,11 +27,11 @@ columns = {
},
saveManageColumnsState : function() {
var hidden, page;
if ( $( '#media_grid_title-hide' ).length ) {
var hidden, page, opts = $( '.misc-screen-options' );
if ( opts.length ) {
hidden = [];
$( '.hide-column-tog', '.media-grid-prefs' ).each( function() {
var $el, field = this.value.replace( 'media_grid_', '' );
opts.find( '.hide-column-tog' ).each( function() {
var $el, field = this.value;
$el = $( '.data-' + field );
if ( ! this.checked ) {
hidden.push( field );
@ -40,7 +40,7 @@ columns = {
$el.removeClass( 'data-hidden' ).addClass( 'data-visible' );
}
} );
page = pagenow + 'grid';
page = pagenow + opts.data( 'id' );
hidden = hidden.join( ',' );
} else {
page = pagenow;

File diff suppressed because one or more lines are too long

View File

@ -26,10 +26,11 @@ if ( 'grid' === $mode ) {
wp_enqueue_script( 'media' );
wp_localize_script( 'media-grid', 'mediaGridSettings', array( 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ) ) );
add_screen_option( 'media_grid_title', array( 'label' => __( 'Name' ) ) );
add_screen_option( 'media_grid_uploadedTo', array( 'label' => __( 'Uploaded To' ) ) );
add_screen_option( 'media_grid_dateFormatted', array( 'label' => __( 'Date' ) ) );
add_screen_option( 'media_grid_mime', array( 'label' => __( 'Mime-type' ) ) );
add_screen_option( 'misc_screen_options', array( 'option' => 'manageuploadgridcolumnshidden', 'id' => 'grid' ) );
add_screen_option( 'title', array( 'label' => __( 'Name' ) ) );
add_screen_option( 'uploadedTo', array( 'label' => __( 'Uploaded To' ) ) );
add_screen_option( 'dateFormatted', array( 'label' => __( 'Date' ) ) );
add_screen_option( 'mime', array( 'label' => __( 'Mime-type' ) ) );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
include( ABSPATH . 'wp-admin/admin-footer.php' );