Make WordPress Core

Ticket #22743: 22743.2.diff

File 22743.2.diff, 2.8 KB (added by nacin, 12 years ago)

Strings up an edit link, which needs styling.

  • wp-includes/media.php

     
    13371337                        'update' => false,
    13381338                        'delete' => false,
    13391339                ),
     1340                'editLink'   => false,
    13401341        );
    13411342
    1342         if ( current_user_can( 'edit_post', $attachment->ID ) )
     1343        if ( current_user_can( 'edit_post', $attachment->ID ) ) {
    13431344                $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID );
     1345                $response['editLink'] = get_edit_post_link( $attachment->ID, 'raw' );
     1346        }
    13441347
    13451348        if ( current_user_can( 'delete_post', $attachment->ID ) )
    13461349                $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID );
     
    16961699                                <# if ( 'image' === data.type && ! data.uploading && data.width && data.height ) { #>
    16971700                                        <div class="dimensions">{{ data.width }} &times; {{ data.height }}</div>
    16981701                                <# } #>
     1702                                <# if ( ! data.uploading && data.can.save ) { #>
     1703                                        <div class="edit-attachment">
     1704                                                <a href="{{ data.editLink }}" target="_blank"><?php _ex( 'Edit', 'media item' ); ?></a>
     1705                                        </div>
     1706                                <# } #>
    16991707                                <# if ( ! data.uploading && data.can.remove ) { #>
    17001708                                        <div class="delete-attachment">
    17011709                                                <a href="#"><?php _e( 'Delete Permanently' ); ?></a>
  • wp-admin/includes/ajax-actions.php

     
    18371837                wp_send_json_error();
    18381838
    18391839        $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
     1840
    18401841        $query = array_intersect_key( $query, array_flip( array(
    18411842                's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type',
    1842                 'post_parent', 'post__in', 'post__not_in',
     1843                'post_parent', 'post__in', 'post__not_in', '_query_attachments_post_modified_gmt_since'
    18431844        ) ) );
    18441845
    18451846        $query['post_type'] = 'attachment';
     
    18471848        if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
    18481849                $query['post_status'] .= ',private';
    18491850
     1851        add_filter( 'posts_where', '_query_attachments_post_modified_gmt_since', 10, 2 );
    18501852        $query = new WP_Query( $query );
     1853        remove_filter( 'posts_where', '_query_attachments_post_modified_gmt_since', 10 );
    18511854
    18521855        $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts );
    18531856        $posts = array_filter( $posts );
     
    18551858        wp_send_json_success( $posts );
    18561859}
    18571860
     1861function _query_attachments_post_modified_gmt_since( $where, $query ) {
     1862        global $wpdb;
     1863
     1864        if ( $modified_since = absint( $query->get('_query_attachments_post_modified_gmt_since') ) ) {
     1865                $modified_since = gmdate( 'Y-m-d H:i:s', $modified_since );
     1866                $where .= $wpdb->prepare( " AND $wpdb->posts.post_modified_gmt > %s", $modified_since );
     1867        }
     1868
     1869        return $where;
     1870}
     1871
    18581872/**
    18591873 * Save attachment attributes.
    18601874 *