| 1 | Index: wp-admin/includes/ajax-actions.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/includes/ajax-actions.php (revision 22833) |
|---|
| 4 | +++ wp-admin/includes/ajax-actions.php (working copy) |
|---|
| 5 | @@ -1780,10 +1780,10 @@ |
|---|
| 6 | * @since 3.5.0 |
|---|
| 7 | */ |
|---|
| 8 | function wp_ajax_get_attachment() { |
|---|
| 9 | - if ( ! isset( $_REQUEST['id'] ) ) |
|---|
| 10 | + if ( ! isset( $_REQUEST['post_id'] ) ) |
|---|
| 11 | wp_send_json_error(); |
|---|
| 12 | |
|---|
| 13 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|---|
| 14 | + if ( ! $id = absint( $_REQUEST['post_id'] ) ) |
|---|
| 15 | wp_send_json_error(); |
|---|
| 16 | |
|---|
| 17 | if ( ! current_user_can( 'read_post', $id ) ) |
|---|
| 18 | @@ -1826,10 +1826,10 @@ |
|---|
| 19 | * @since 3.5.0 |
|---|
| 20 | */ |
|---|
| 21 | function wp_ajax_save_attachment() { |
|---|
| 22 | - if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) |
|---|
| 23 | + if ( ! isset( $_REQUEST['post_id'] ) || ! isset( $_REQUEST['changes'] ) ) |
|---|
| 24 | wp_send_json_error(); |
|---|
| 25 | |
|---|
| 26 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|---|
| 27 | + if ( ! $id = absint( $_REQUEST['post_id'] ) ) |
|---|
| 28 | wp_send_json_error(); |
|---|
| 29 | |
|---|
| 30 | check_ajax_referer( 'save-attachment', 'nonce' ); |
|---|
| 31 | @@ -1868,10 +1868,10 @@ |
|---|
| 32 | * @since 3.5.0 |
|---|
| 33 | */ |
|---|
| 34 | function wp_ajax_save_attachment_compat() { |
|---|
| 35 | - if ( ! isset( $_REQUEST['id'] ) ) |
|---|
| 36 | + if ( ! isset( $_REQUEST['post_id'] ) ) |
|---|
| 37 | wp_send_json_error(); |
|---|
| 38 | |
|---|
| 39 | - if ( ! $id = absint( $_REQUEST['id'] ) ) |
|---|
| 40 | + if ( ! $id = absint( $_REQUEST['post_id'] ) ) |
|---|
| 41 | wp_send_json_error(); |
|---|
| 42 | |
|---|
| 43 | if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) |
|---|
| 44 | Index: wp-includes/js/media-editor.js |
|---|
| 45 | =================================================================== |
|---|
| 46 | --- wp-includes/js/media-editor.js (revision 22833) |
|---|
| 47 | +++ wp-includes/js/media-editor.js (working copy) |
|---|
| 48 | @@ -448,7 +448,8 @@ |
|---|
| 49 | return media.post( 'send-attachment-to-editor', { |
|---|
| 50 | nonce: wp.media.view.settings.nonce.sendToEditor, |
|---|
| 51 | attachment: options, |
|---|
| 52 | - html: html |
|---|
| 53 | + html: html, |
|---|
| 54 | + post_id: wp.media.view.settings.postId |
|---|
| 55 | }).done( function( resp ) { |
|---|
| 56 | wp.media.editor.insert( resp ); |
|---|
| 57 | }); |
|---|
| 58 | @@ -456,10 +457,11 @@ |
|---|
| 59 | |
|---|
| 60 | link: function( embed ) { |
|---|
| 61 | return media.post( 'send-link-to-editor', { |
|---|
| 62 | - nonce: wp.media.view.settings.nonce.sendToEditor, |
|---|
| 63 | - src: embed.linkUrl, |
|---|
| 64 | - title: embed.title, |
|---|
| 65 | - html: wp.media.string.link( embed ) |
|---|
| 66 | + nonce: wp.media.view.settings.nonce.sendToEditor, |
|---|
| 67 | + src: embed.linkUrl, |
|---|
| 68 | + title: embed.title, |
|---|
| 69 | + html: wp.media.string.link( embed ), |
|---|
| 70 | + post_id: wp.media.view.settings.postId |
|---|
| 71 | }).done( function( resp ) { |
|---|
| 72 | wp.media.editor.insert( resp ); |
|---|
| 73 | }); |
|---|
| 74 | Index: wp-includes/js/media-models.js |
|---|
| 75 | =================================================================== |
|---|
| 76 | --- wp-includes/js/media-models.js (revision 22833) |
|---|
| 77 | +++ wp-includes/js/media-models.js (working copy) |
|---|
| 78 | @@ -223,8 +223,8 @@ |
|---|
| 79 | options = options || {}; |
|---|
| 80 | options.context = this; |
|---|
| 81 | options.data = _.extend( options.data || {}, { |
|---|
| 82 | - action: 'get-attachment', |
|---|
| 83 | - id: this.id |
|---|
| 84 | + action: 'get-attachment', |
|---|
| 85 | + post_id: this.id |
|---|
| 86 | }); |
|---|
| 87 | return media.ajax( options ); |
|---|
| 88 | |
|---|
| 89 | @@ -235,9 +235,9 @@ |
|---|
| 90 | |
|---|
| 91 | // Set the action and ID. |
|---|
| 92 | options.data = _.extend( options.data || {}, { |
|---|
| 93 | - action: 'save-attachment', |
|---|
| 94 | - id: this.id, |
|---|
| 95 | - nonce: media.model.settings.saveAttachmentNonce |
|---|
| 96 | + action: 'save-attachment', |
|---|
| 97 | + post_id: this.id, |
|---|
| 98 | + nonce: media.model.settings.saveAttachmentNonce |
|---|
| 99 | }); |
|---|
| 100 | |
|---|
| 101 | // Record the values of the changed attributes. |
|---|
| 102 | @@ -268,8 +268,8 @@ |
|---|
| 103 | var model = this; |
|---|
| 104 | |
|---|
| 105 | return media.post( 'save-attachment-compat', _.defaults({ |
|---|
| 106 | - id: this.id, |
|---|
| 107 | - nonce: l10n.saveAttachmentNonce |
|---|
| 108 | + post_id: this.id, |
|---|
| 109 | + nonce: l10n.saveAttachmentNonce |
|---|
| 110 | }, data ) ).done( function( resp, status, xhr ) { |
|---|
| 111 | model.set( model.parse( resp, xhr ), options ); |
|---|
| 112 | }); |
|---|
| 113 | @@ -619,6 +619,11 @@ |
|---|
| 114 | if ( -1 !== args.posts_per_page ) |
|---|
| 115 | args.paged = Math.floor( this.length / args.posts_per_page ) + 1; |
|---|
| 116 | |
|---|
| 117 | + // Check if a post ID has been specified as a context. |
|---|
| 118 | + if ( args.context ) |
|---|
| 119 | + options.data.post_id = args.context; |
|---|
| 120 | + delete args.context; |
|---|
| 121 | + |
|---|
| 122 | options.data.query = args; |
|---|
| 123 | return media.ajax( options ); |
|---|
| 124 | |
|---|
| 125 | Index: wp-includes/js/media-views.js |
|---|
| 126 | =================================================================== |
|---|
| 127 | --- wp-includes/js/media-views.js (revision 22833) |
|---|
| 128 | +++ wp-includes/js/media-views.js (working copy) |
|---|
| 129 | @@ -12,6 +12,10 @@ |
|---|
| 130 | media.view.settings = l10n.settings || {}; |
|---|
| 131 | delete l10n.settings; |
|---|
| 132 | |
|---|
| 133 | + // Set the post ID as the default context of attachment queries. |
|---|
| 134 | + if ( ! _.isUndefined( media.view.settings.postId ) ) |
|---|
| 135 | + media.model.Query.defaultProps.context = media.view.settings.postId; |
|---|
| 136 | + |
|---|
| 137 | // Check if the browser supports CSS 3.0 transitions |
|---|
| 138 | $.support.transition = (function(){ |
|---|
| 139 | var style = document.documentElement.style, |
|---|