Make WordPress Core

Changeset 19252


Ignore:
Timestamp:
11/11/2011 03:04:54 PM (15 years ago)
Author:
ryan
Message:

Check caps when showing media edit and attach links. Clean up formatting. Props kurtpayne, DH-Shredder, solarissmoke. fixes #17419

File:
1 edited

Legend:

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

    r18931 r19252  
    165165
    166166                while ( have_posts() ) : the_post();
     167                        $user_can_edit = current_user_can( 'edit_post', $post->ID );
    167168
    168169                        if ( $this->is_trash && $post->post_status != 'trash'
     
    191192        case 'cb':
    192193?>
    193                 <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /><?php } ?></th>
     194                <th scope="row" class="check-column">
     195                        <?php if ( $user_can_edit ) { ?>
     196                                <input type="checkbox" name="media[]" value="<?php the_ID(); ?>" />
     197                        <?php } ?>
     198                </th>
    194199<?php
    195200                break;
     
    200205                <td <?php echo $attributes ?>><?php
    201206                        if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
    202                                 if ( $this->is_trash ) {
     207                                if ( $this->is_trash || ! $user_can_edit ) {
    203208                                        echo $thumb;
    204209                                } else {
     
    217222        case 'title':
    218223?>
    219                 <td <?php echo $attributes ?>><strong><?php if ( $this->is_trash ) echo $att_title; else { ?><a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>"><?php echo $att_title; ?></a><?php }; _media_states( $post ); ?></strong>
     224                <td <?php echo $attributes ?>><strong>
     225                        <?php if ( $this->is_trash || ! $user_can_edit ) {
     226                                echo $att_title;
     227                        } else { ?>
     228                        <a href="<?php echo get_edit_post_link( $post->ID, true ); ?>"
     229                                title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
     230                                <?php echo $att_title; ?></a>
     231                        <?php };
     232                        _media_states( $post ); ?></strong>
    220233                        <p>
    221234<?php
     
    289302                        }
    290303?>
    291                         <td <?php echo $attributes ?>>
    292                                 <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>,
     304                        <td <?php echo $attributes ?>><strong>
     305                                <?php if( current_user_can( 'edit_post', $post->post_parent ) ) { ?>
     306                                        <a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
     307                                                <?php echo $title ?></a>
     308                                <?php } else {
     309                                        echo $title;
     310                                } ?></strong>,
    293311                                <?php echo get_the_time( __( 'Y/m/d' ) ); ?>
    294312                        </td>
     
    297315?>
    298316                        <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
    299                         <a class="hide-if-no-js" onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' );return false;" href="#the-list"><?php _e( 'Attach' ); ?></a></td>
     317                        <?php if( $user_can_edit ) {?>
     318                                <a class="hide-if-no-js"
     319                                        onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
     320                                        href="#the-list">
     321                                        <?php _e( 'Attach' ); ?></a>
     322                        <?php } ?></td>
    300323<?php
    301324                }
Note: See TracChangeset for help on using the changeset viewer.