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:
parent
a9fb59151b
commit
b16d3bd6ad
|
@ -1022,7 +1022,7 @@ final class WP_Screen {
|
||||||
<?php if (
|
<?php if (
|
||||||
isset( $wp_meta_boxes[ $this->id ] )
|
isset( $wp_meta_boxes[ $this->id ] )
|
||||||
|| $this->get_option( 'per_page' )
|
|| $this->get_option( 'per_page' )
|
||||||
|| $this->get_option( 'media_grid_title' )
|
|| $this->get_option( 'misc_screen_options' )
|
||||||
|| ( $columns && empty( $columns['_title'] ) )
|
|| ( $columns && empty( $columns['_title'] ) )
|
||||||
) : ?>
|
) : ?>
|
||||||
<h5><?php _e( 'Show on screen' ); ?></h5>
|
<h5><?php _e( 'Show on screen' ); ?></h5>
|
||||||
|
@ -1076,19 +1076,24 @@ final class WP_Screen {
|
||||||
?>
|
?>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
</div>
|
</div>
|
||||||
<?php elseif ( $this->get_option( 'media_grid_title' ) ): ?>
|
<?php elseif ( $this->get_option( 'misc_screen_options' ) ):
|
||||||
<div class="metabox-prefs media-grid-prefs">
|
$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
|
<?php
|
||||||
$option = get_user_option( 'manageuploadgridcolumnshidden' );
|
|
||||||
|
$option = get_user_option( $misc_options['option'] );
|
||||||
$hidden = array();
|
$hidden = array();
|
||||||
if ( ! empty( $option ) ) {
|
if ( ! empty( $option ) ) {
|
||||||
$hidden = $option;
|
$hidden = $option;
|
||||||
}
|
}
|
||||||
foreach ( $this->_options as $column => $args ) {
|
foreach ( $this->_options as $column => $args ) {
|
||||||
|
if ( 'misc_screen_options' === $column ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = "$column-hide";
|
$id = "$column-hide";
|
||||||
echo '<label for="' . $id . '">';
|
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( $column, $hidden ), true, false ) . ' />';
|
||||||
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $saved, $hidden ), true, false ) . ' />';
|
|
||||||
echo $args['label'] . "</label>\n";
|
echo $args['label'] . "</label>\n";
|
||||||
} ?>
|
} ?>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
|
|
|
@ -27,11 +27,11 @@ columns = {
|
||||||
},
|
},
|
||||||
|
|
||||||
saveManageColumnsState : function() {
|
saveManageColumnsState : function() {
|
||||||
var hidden, page;
|
var hidden, page, opts = $( '.misc-screen-options' );
|
||||||
if ( $( '#media_grid_title-hide' ).length ) {
|
if ( opts.length ) {
|
||||||
hidden = [];
|
hidden = [];
|
||||||
$( '.hide-column-tog', '.media-grid-prefs' ).each( function() {
|
opts.find( '.hide-column-tog' ).each( function() {
|
||||||
var $el, field = this.value.replace( 'media_grid_', '' );
|
var $el, field = this.value;
|
||||||
$el = $( '.data-' + field );
|
$el = $( '.data-' + field );
|
||||||
if ( ! this.checked ) {
|
if ( ! this.checked ) {
|
||||||
hidden.push( field );
|
hidden.push( field );
|
||||||
|
@ -40,13 +40,13 @@ columns = {
|
||||||
$el.removeClass( 'data-hidden' ).addClass( 'data-visible' );
|
$el.removeClass( 'data-hidden' ).addClass( 'data-visible' );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
page = pagenow + 'grid';
|
page = pagenow + opts.data( 'id' );
|
||||||
hidden = hidden.join( ',' );
|
hidden = hidden.join( ',' );
|
||||||
} else {
|
} else {
|
||||||
page = pagenow;
|
page = pagenow;
|
||||||
hidden = this.hidden();
|
hidden = this.hidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post(ajaxurl, {
|
$.post(ajaxurl, {
|
||||||
action: 'hidden-columns',
|
action: 'hidden-columns',
|
||||||
hidden: hidden,
|
hidden: hidden,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -26,10 +26,11 @@ if ( 'grid' === $mode ) {
|
||||||
wp_enqueue_script( 'media' );
|
wp_enqueue_script( 'media' );
|
||||||
wp_localize_script( 'media-grid', 'mediaGridSettings', array( 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ) ) );
|
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( 'misc_screen_options', array( 'option' => 'manageuploadgridcolumnshidden', 'id' => 'grid' ) );
|
||||||
add_screen_option( 'media_grid_uploadedTo', array( 'label' => __( 'Uploaded To' ) ) );
|
add_screen_option( 'title', array( 'label' => __( 'Name' ) ) );
|
||||||
add_screen_option( 'media_grid_dateFormatted', array( 'label' => __( 'Date' ) ) );
|
add_screen_option( 'uploadedTo', array( 'label' => __( 'Uploaded To' ) ) );
|
||||||
add_screen_option( 'media_grid_mime', array( 'label' => __( 'Mime-type' ) ) );
|
add_screen_option( 'dateFormatted', array( 'label' => __( 'Date' ) ) );
|
||||||
|
add_screen_option( 'mime', array( 'label' => __( 'Mime-type' ) ) );
|
||||||
|
|
||||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||||
|
|
Loading…
Reference in New Issue