Make WordPress Core


Ignore:
Timestamp:
07/10/2014 08:59:12 PM (10 years ago)
Author:
wonderboymusic
Message:

Media Grid: Move toggling of visible fields to Screen Options. This moves us in a better direction... but this will probably need to be massaged again.

See #24716.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media-template.php

    r29065 r29077  
    230230    </script>
    231231
    232     <script type="text/html" id="tmpl-media-grid-field-options">
    233         <label class="setting">
    234             <span><?php _e( 'Name' ); ?></span>
    235             <input type="checkbox" data-setting="title" {{ '' === getUserSetting( 'hidegridtitle' ) && 'checked' }} />
    236         </label>
    237         <label class="setting">
    238             <span><?php _e( 'Uploaded to' ); ?></span>
    239             <input type="checkbox" data-setting="uploadedTo" {{ '' === getUserSetting( 'hidegriduploadedTo' ) && 'checked' }} />
    240         </label>
    241         <label class="setting">
    242             <span><?php _e( 'Date' ); ?></span>
    243             <input type="checkbox" data-setting="dateFormatted" {{ '' === getUserSetting( 'hidegriddateFormatted' ) && 'checked' }} />
    244         </label>
    245         <label class="setting">
    246             <span><?php _e( 'Mime-type' ); ?></span>
    247             <input type="checkbox" data-setting="mime" {{ '' === getUserSetting( 'hidegridmime' ) && 'checked' }} />
    248         </label>
    249     </script>
    250 
    251232    <script type="text/html" id="tmpl-uploader-status">
    252233        <h3><?php _e( 'Uploading' ); ?></h3>
     
    438419        if ( _.contains( data.controller.options.mode, 'grid' ) ) { #>
    439420        <div class="data-fields">
    440         <# _.each( data.showAttachmentFields, function( field ) {
    441             var className = 'data-field data-hidden';
    442             if ( '' === getUserSetting( 'hidegrid' + field ) ) {
    443                 className = 'data-field data-visible';
    444             }
    445         #>
    446             <div class="{{ className }} data-{{ field }}"><#
    447                 if ( 'uploadedTo' === field ) {
    448                     if ( data[ field ] ) {
     421        <?php
     422        $hidden = get_hidden_columns( get_current_screen() );
     423        $fields = array( 'title', 'uploadedTo', 'dateFormatted', 'mime' );
     424        foreach ( $fields as $field ):
     425            $class_name = in_array( $field, $hidden ) ? 'data-field data-hidden' : 'data-field data-visible';
     426        ?>
     427            <div class="<?php echo $class_name ?> data-<?php echo $field ?>"><#
     428                if ( 'uploadedTo' === '<?php echo $field ?>' ) {
     429                    if ( data[ '<?php echo $field ?>' ] ) {
    449430                    #><?php _e( 'Uploaded To: ' ) ?><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a><#
    450431                    } else {
    451432                    #><?php _e( 'Unattached' ) ?><#
    452433                    }
    453                 } else if ( 'title' === field && ! data[ field ] ) {
     434                } else if ( 'title' === '<?php echo $field ?>' && ! data[ '<?php echo $field ?>' ] ) {
    454435                #><?php _e( '(No title)' ) ?><#
    455                 } else if ( data[ field ] ) {
    456                 #>{{ data[ field ] }}<#
     436                } else if ( data[ '<?php echo $field ?>' ] ) {
     437                #>{{ data[ '<?php echo $field ?>' ] }}<#
    457438                }
    458439            #></div>
    459         <# }); #>
     440        <?php endforeach ?>
    460441        </div>
    461442        <# } #>
Note: See TracChangeset for help on using the changeset viewer.