Make WordPress Core


Ignore:
Timestamp:
08/14/2014 06:30:49 PM (11 years ago)
Author:
wonderboymusic
Message:

Media Grid, support MEDIA_TRASH:

  • Add a setting to _wpMediaViewsL10n.settings: mediaTrash
  • In the attachment edit modal, properly toggle between Trash/Untrash
  • In media.view.Attachment, add a method for untrashAttachment
  • When creating the grid toolbar, switch the setting order of subviews so that media.view.DeleteSelectedButton can listen to the instance of media.view.AttachmentFilters.All to update the text in its UI.
  • Add a new filter to media.view.AttachmentFilters.All, trash, when settings.mediaTrash is true
  • Allow the cached queries in Query.get() to be flushed when race conditions exist and collections need to be refreshed. This is currently only being used when MEDIA_TRASH is set, to refresh the filtered/mirrored collections related to all, trash, and any already queried filter.
  • Cleanup the bootstrapping of media.view.MediaFrame.Manage
  • Allow wp_ajax_query_attachments() to return items from the trash when MEDIA_TRASH is true
  • Allow wp_ajax_save_attachment() to set post_status when MEDIA_TRASH is true. It allows wp_delete_post() to be called, which will trash the attachment instead of deleting when the flag is set.

Props koop for the knowledge sharing and thought partnership.
See #29145.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r29454 r29490  
    21622162
    21632163    $query['post_type'] = 'attachment';
    2164     $query['post_status'] = 'inherit';
     2164    if ( MEDIA_TRASH
     2165        && ! empty( $_REQUEST['query']['post_status'] )
     2166        && 'trash' === $_REQUEST['query']['post_status'] ) {
     2167        $query['post_status'] = 'trash';
     2168    } else {
     2169        $query['post_status'] = 'inherit';
     2170    }
     2171
    21652172    if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
    21662173        $query['post_status'] .= ',private';
     
    22162223    if ( isset( $changes['description'] ) )
    22172224        $post['post_content'] = $changes['description'];
     2225
     2226    if ( MEDIA_TRASH && isset( $changes['status'] ) )
     2227        $post['post_status'] = $changes['status'];
    22182228
    22192229    if ( isset( $changes['alt'] ) ) {
     
    22442254    }
    22452255
    2246     wp_update_post( $post );
     2256    if ( MEDIA_TRASH && isset( $changes['status'] ) && 'trash' === $changes['status'] ) {
     2257        wp_delete_post( $id );
     2258    } else {
     2259        wp_update_post( $post );
     2260    }
     2261
    22472262    wp_send_json_success();
    22482263}
Note: See TracChangeset for help on using the changeset viewer.