Ticket #6820: 6820.2.diff
File 6820.2.diff, 5.1 KB (added by , 10 years ago) |
---|
-
src/wp-admin/admin-ajax.php
61 61 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 62 62 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', 63 63 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail', 64 'parse-media-shortcode', 'destroy-sessions' 64 'parse-media-shortcode', 'destroy-sessions', 'detach-from-parent' 65 65 ); 66 66 67 67 // Register core Ajax calls. -
src/wp-admin/includes/ajax-actions.php
2224 2224 if ( 'attachment' != $post['post_type'] ) 2225 2225 wp_send_json_error(); 2226 2226 2227 if ( isset( $changes['parent'] ) ) 2228 $post['post_parent'] = $changes['parent']; 2229 2227 2230 if ( isset( $changes['title'] ) ) 2228 2231 $post['post_title'] = $changes['title']; 2229 2232 … … 2805 2808 2806 2809 wp_send_json_success( array( 'message' => $message ) ); 2807 2810 } 2811 2812 /** 2813 * AJAX handler for detaching an attachment from its parent 2814 * 2815 * @since 4.2.0 2816 */ 2817 function wp_ajax_detach_from_parent() { 2818 $post = get_post( (int) $_POST['id'] ); 2819 if ( ! $post || ! $post->post_parent || ! current_user_can( 'edit_post', $post->ID ) ) { 2820 wp_send_json_error(); 2821 } 2822 2823 if ( ! wp_update_post( array( 'post_parent' => 0, 'ID' => $post->ID ) ) ) { 2824 wp_send_json_error(); 2825 } 2826 2827 wp_send_json_success(); 2828 } -
src/wp-admin/includes/class-wp-media-list-table.php
411 411 } else { 412 412 echo $title; 413 413 } ?></strong>, 414 <?php echo get_the_time( __( 'Y/m/d' ) ); ?> 414 <?php echo get_the_time( __( 'Y/m/d' ) ); ?><br /> 415 <?php if ( $user_can_edit ) { ?> 416 <a class="hide-if-no-js detach-from-parent" data-id="<?php echo $post->ID ?>" href="#the-list"><?php _e( 'Detach' ); ?></a> 417 <?php } ?> 415 418 </td> 416 419 <?php 417 420 } else { -
src/wp-admin/js/media.js
110 110 $( '.find-box-inside' ).on( 'click', 'tr', function() { 111 111 $( this ).find( '.found-radio input' ).prop( 'checked', true ); 112 112 }); 113 114 // Needs to work for list table rows and the grid details modal 115 $( '.wp-list-table' ).on( 'click', '.detach-from-parent', function (e) { 116 e.preventDefault(); 117 118 var $el = $( e.currentTarget ), id, url; 119 120 id = $el.data( 'id' ); 121 122 $.ajax({ 123 url: ajaxurl, 124 type: 'post', 125 data: { 126 id: id, 127 action: 'detach-from-parent' 128 } 129 }).done( function () { 130 url = window.location.href.split('#')[0]; 131 url = url.replace(/[\?&]detached-[0-9]+/, ''); 132 url += url.indexOf( '?' ) > -1 ? '&' : '?'; 133 url += 'detached-' + id; 134 window.location = url + '#post-' + id; 135 } ); 136 } ); 113 137 }); 114 138 })( jQuery ); -
src/wp-includes/js/media-views.js
5121 5121 this.listenTo( this.model, 'change', this.render ); 5122 5122 } else { 5123 5123 this.listenTo( this.model, 'change:percent', this.progress ); 5124 this.listenTo( this.model, 'change:parent', this.render ); 5124 5125 } 5125 5126 this.listenTo( this.model, 'change:title', this._syncTitle ); 5126 5127 this.listenTo( this.model, 'change:caption', this._syncCaption ); … … 7061 7062 'click .untrash-attachment': 'untrashAttachment', 7062 7063 'click .edit-attachment': 'editAttachment', 7063 7064 'click .refresh-attachment': 'refreshAttachment', 7064 'keydown': 'toggleSelectionHandler' 7065 'keydown': 'toggleSelectionHandler', 7066 'click .detach-from-parent': 'detachFromParent' 7065 7067 }, 7066 7068 7067 7069 initialize: function() { … … 7160 7162 this.controller.trigger( 'attachment:keydown:arrow', event ); 7161 7163 return; 7162 7164 } 7165 }, 7166 /** 7167 * @param {Object} event 7168 */ 7169 detachFromParent: function( event ) { 7170 event.preventDefault(); 7171 7172 this.model.save({ 7173 'parent' : 0, 7174 'uploadedTo' : 0, 7175 'uploadedToLink' : '', 7176 'uploadedToTitle' : '' 7177 }); 7163 7178 } 7164 7179 }); 7165 7180 -
src/wp-includes/media-template.php
418 418 <# } else { #> 419 419 <span class="value">{{ data.uploadedToTitle }}</span> 420 420 <# } #> 421 <# if ( data.nonces.edit ) { #> 422 <a class="detach-from-parent" data-id="{{ data.id }}" href="#">(<?php _e( 'Detach' ); ?>)</a> 423 <# } #> 421 424 </label> 422 425 <# } #> 423 426 <div class="attachment-compat"></div>