Make WordPress Core


Ignore:
Timestamp:
12/04/2012 06:33:51 PM (12 years ago)
Author:
ryan
Message:

Only show Delete in media modal if the user can delete.

Props nacin, koopersmith
fixes #22711

File:
1 edited

Legend:

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

    r23021 r23032  
    13351335        'dateFormatted' => mysql2date( get_option('date_format'), $attachment->post_date ),
    13361336        'nonces'      => array(
    1337             'update' => wp_create_nonce( 'update-post_' . $attachment->ID ),
    1338             'delete' => wp_create_nonce( 'delete-post_' . $attachment->ID ),
     1337            'update' => false,
     1338            'delete' => false,
    13391339        ),
    13401340    );
     1341
     1342    if ( current_user_can( 'edit_post', $attachment->ID ) )
     1343        $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID );
     1344
     1345    if ( current_user_can( 'delete_post', $attachment->ID ) )
     1346        $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID );
    13411347
    13421348    if ( $meta && 'image' === $type ) {
     
    16911697                    <div class="dimensions">{{ data.width }} &times; {{ data.height }}</div>
    16921698                <# } #>
    1693                 <# if ( ! data.uploading ) { #>
     1699                <# if ( ! data.uploading && data.can.remove ) { #>
    16941700                    <div class="delete-attachment">
    16951701                        <a href="#"><?php _e( 'Delete Permanently' ); ?></a>
Note: See TracChangeset for help on using the changeset viewer.