Make WordPress Core


Ignore:
Timestamp:
07/14/2015 05:23:42 PM (10 years ago)
Author:
obenland
Message:

Media: Reduce link noise between icons and titles in list view.

Props afercia.
Fixes #32254.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r33179 r33268  
    339339        list( $mime ) = explode( '/', $post->post_mime_type );
    340340
    341         $user_can_edit = current_user_can( 'edit_post', $post->ID );
    342         $att_title = _draft_or_post_title();
     341        $title = _draft_or_post_title();
     342        $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );
     343        $link_start = $link_end = '';
     344
     345        if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
     346            $link_start = '<a href="' . get_edit_post_link( $post->ID ) . '">';
     347            $link_end = '</a>';
     348        }
     349
    343350        ?>
    344         <div class="media-icon <?php echo $mime ?>-icon">
    345         <?php
    346 
    347         $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true );
    348         if ( $thumb ) {
    349             if ( $this->is_trash || ! $user_can_edit ) {
    350                 echo $thumb;
    351             } else { ?>
    352             <a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php
    353                 echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) );
    354             ?>"><?php echo $thumb; ?></a><?php
    355             }
    356         }
    357 
    358         ?>
    359         </div>
    360         <div class="media-info">
    361             <strong>
    362             <?php
    363                 if ( $this->is_trash || ! $user_can_edit ) {
    364                     echo $att_title;
    365                 } else { ?>
    366                     <a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php
    367                         echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) );
    368                     ?>"><?php echo $att_title; ?></a><?php
    369                 }
    370                 _media_states( $post );
    371             ?>
    372             </strong>
    373             <p class="filename"><?php echo wp_basename( $post->guid ); ?></p>
    374         </div>
     351        <strong>
     352            <?php echo $link_start; ?>
     353                <?php if ( $thumb ) : ?>
     354                <span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span>
     355                <?php endif; ?>
     356
     357                <span aria-hidden="true"><?php echo $title; ?></span>
     358                <span class="screen-reader-text"><?php printf( __( 'Edit &#8220;%s&#8221;' ), $title ); ?></span>
     359            <?php echo $link_end; ?>
     360            <?php _media_states( $post ); ?>
     361        </strong>
     362        <p class="filename"><span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span><?php echo wp_basename( $post->guid ); ?></p>
    375363        <?php
    376364    }
Note: See TracChangeset for help on using the changeset viewer.