Make WordPress Core

Ticket #22743: 22743.4b.diff

File 22743.4b.diff, 7.4 KB (added by lessbloat, 12 years ago)
  • 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                                <# } #>
    1699                                 <# if ( ! data.uploading && data.can.remove ) { #>
    1700                                         <div class="delete-attachment">
    1701                                                 <a href="#"><?php _e( 'Delete Permanently' ); ?></a>
    1702                                         </div>
     1702                                <# if ( ! data.uploading && ( data.can.save || data.can.remove ) ) { #>
     1703                                <div class="modify-attachment">
     1704                                        <# if ( data.can.save ) { #>
     1705                                                <span class="edit-attachment">
     1706                                                        <a href="{{ data.editLink }}&amp;image-editor" target="_blank"><?php _e( 'Edit Image' ); ?></a>
     1707                                                </span>
     1708                                        <# } #>
     1709                                        <# if ( data.can.remove ) { #>
     1710                                                <span class="delete-attachment">
     1711                                                        <a href="#"><?php _e( 'Delete Permanently' ); ?></a>
     1712                                                </span>
     1713                                        <# } #>
    17031714                                <# } #>
    17041715                                <div class="compat-meta">
    17051716                                        <# if ( data.compat && data.compat.meta ) { #>
  • wp-includes/css/media-views-rtl.css

     
    259259        float: right;
    260260}
    261261
     262.attachment-info .modify-attachment span {
     263        margin-right: 0;
     264        margin-left: 10px;
     265}
     266
     267.attachment-info .modify-attachment span:last-child {
     268        margin-left: 0;
     269}
     270
    262271/**
    263272 * Attachment Display Settings
    264273 */
  • wp-includes/css/media-views.css

     
    13261326        float: left;
    13271327        font-size: 12px;
    13281328        max-width: 100%;
     1329        line-height: 16px;
     1330        margin-bottom: 13px;
    13291331}
    13301332
    1331 .attachment-info .delete-attachment a {
    1332         color: red;
    1333         padding: 2px 4px;
    1334         margin: -2px -4px;
     1333.attachment-info .modify-attachment span {
     1334        display: block;
     1335}
     1336
     1337.attachment-info .modify-attachment span:last-child {
     1338        margin-right: 0;
     1339}
     1340
     1341.attachment-info .modify-attachment span a {
    13351342        text-decoration: none;
    13361343        white-space: nowrap;
    13371344}
    13381345
     1346.attachment-info .delete-attachment a {
     1347        color: #bc0b0b;
     1348}
     1349
    13391350.attachment-info .delete-attachment a:hover {
    1340         color: #fff;
    1341         background: red;
     1351        color: red;
    13421352}
    13431353
    13441354/**
  • 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 *
  • wp-admin/includes/image-edit.php

     
    191191        </td></tr>
    192192        </tbody></table>
    193193        <div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
    194         <script type="text/javascript">imageEdit.init(<?php echo $post_id; ?>);</script>
     194        <script type="text/javascript">jQuery( function() { imageEdit.init(<?php echo $post_id; ?>); });</script>
    195195        <div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e("There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor."); ?></div>
    196196        </div>
    197197<?php
  • wp-admin/includes/media.php

     
    22622262function edit_form_image_editor() {
    22632263        $post = get_post();
    22642264
     2265        $open = isset( $_GET['image-editor'] );
     2266        if ( $open )
     2267                require_once ABSPATH . 'wp-admin/includes/image-edit.php';
     2268
    22652269        $thumb_url = false;
    22662270        if ( $attachment_id = intval( $post->ID ) )
    2267                 $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 600 ), true );
     2271                $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );
    22682272
    22692273        $filename = esc_html( basename( $post->guid ) );
    22702274        $title = esc_attr( $post->post_title );
    22712275        $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
    22722276
    2273         $media_dims = '';
    2274         $meta = wp_get_attachment_metadata( $post->ID );
    2275         if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
    2276                 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
    2277         $media_dims = apply_filters( 'media_meta', $media_dims, $post );
    2278 
    22792277        $att_url = wp_get_attachment_url( $post->ID );
    22802278
    22812279        $image_edit_button = '';
     
    22882286        <div class="wp_attachment_holder">
    22892287                <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
    22902288
    2291                 <div class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>">
     2289                <div<?php if ( $open ) echo ' style="display:none"'; ?> class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>">
    22922290                        <p id="thumbnail-head-<?php echo $attachment_id; ?>"><img class="thumbnail" src="<?php echo set_url_scheme( $thumb_url[0] ); ?>" style="max-width:100%" alt="" /></p>
    22932291                        <p><?php echo $image_edit_button; ?></p>
    22942292                </div>
    2295                 <div style="display:none" class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"></div>
     2293                <div<?php if ( ! $open ) echo ' style="display:none"'; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>">
     2294                        <?php if ( $open ) wp_image_editor( $attachment_id ); ?>
     2295                </div>
    22962296        </div>
    22972297
    22982298        <div class="wp_attachment_details">