Make WordPress Core

Ticket #22588: 22588.diff

File 22588.diff, 4.6 KB (added by koopersmith, 13 years ago)
  • wp-admin/includes/ajax-actions.php

     
    17801780 * @since 3.5.0
    17811781 */
    17821782function wp_ajax_get_attachment() {
    1783         if ( ! isset( $_REQUEST['id'] ) )
     1783        if ( ! isset( $_REQUEST['post_id'] ) )
    17841784                wp_send_json_error();
    17851785
    1786         if ( ! $id = absint( $_REQUEST['id'] ) )
     1786        if ( ! $id = absint( $_REQUEST['post_id'] ) )
    17871787                wp_send_json_error();
    17881788
    17891789        if ( ! current_user_can( 'read_post', $id ) )
     
    18261826 * @since 3.5.0
    18271827 */
    18281828function wp_ajax_save_attachment() {
    1829         if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) )
     1829        if ( ! isset( $_REQUEST['post_id'] ) || ! isset( $_REQUEST['changes'] ) )
    18301830                wp_send_json_error();
    18311831
    1832         if ( ! $id = absint( $_REQUEST['id'] ) )
     1832        if ( ! $id = absint( $_REQUEST['post_id'] ) )
    18331833                wp_send_json_error();
    18341834
    18351835        check_ajax_referer( 'save-attachment', 'nonce' );
     
    18681868 * @since 3.5.0
    18691869 */
    18701870function wp_ajax_save_attachment_compat() {
    1871         if ( ! isset( $_REQUEST['id'] ) )
     1871        if ( ! isset( $_REQUEST['post_id'] ) )
    18721872                wp_send_json_error();
    18731873
    1874         if ( ! $id = absint( $_REQUEST['id'] ) )
     1874        if ( ! $id = absint( $_REQUEST['post_id'] ) )
    18751875                wp_send_json_error();
    18761876
    18771877        if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) )
  • wp-includes/js/media-editor.js

     
    448448                                return media.post( 'send-attachment-to-editor', {
    449449                                        nonce:      wp.media.view.settings.nonce.sendToEditor,
    450450                                        attachment: options,
    451                                         html:       html
     451                                        html:       html,
     452                                        post_id:    wp.media.view.settings.postId
    452453                                }).done( function( resp ) {
    453454                                        wp.media.editor.insert( resp );
    454455                                });
     
    456457
    457458                        link: function( embed ) {
    458459                                return media.post( 'send-link-to-editor', {
    459                                         nonce: wp.media.view.settings.nonce.sendToEditor,
    460                                         src:   embed.linkUrl,
    461                                         title: embed.title,
    462                                         html:  wp.media.string.link( embed )
     460                                        nonce:   wp.media.view.settings.nonce.sendToEditor,
     461                                        src:     embed.linkUrl,
     462                                        title:   embed.title,
     463                                        html:    wp.media.string.link( embed ),
     464                                        post_id: wp.media.view.settings.postId
    463465                                }).done( function( resp ) {
    464466                                        wp.media.editor.insert( resp );
    465467                                });
  • wp-includes/js/media-models.js

     
    223223                                options = options || {};
    224224                                options.context = this;
    225225                                options.data = _.extend( options.data || {}, {
    226                                         action: 'get-attachment',
    227                                         id: this.id
     226                                        action:  'get-attachment',
     227                                        post_id: this.id
    228228                                });
    229229                                return media.ajax( options );
    230230
     
    235235
    236236                                // Set the action and ID.
    237237                                options.data = _.extend( options.data || {}, {
    238                                         action: 'save-attachment',
    239                                         id:    this.id,
    240                                         nonce:  media.model.settings.saveAttachmentNonce
     238                                        action:  'save-attachment',
     239                                        post_id: this.id,
     240                                        nonce:   media.model.settings.saveAttachmentNonce
    241241                                });
    242242
    243243                                // Record the values of the changed attributes.
     
    268268                        var model = this;
    269269
    270270                        return media.post( 'save-attachment-compat', _.defaults({
    271                                 id:    this.id,
    272                                 nonce:  l10n.saveAttachmentNonce
     271                                post_id: this.id,
     272                                nonce:   l10n.saveAttachmentNonce
    273273                        }, data ) ).done( function( resp, status, xhr ) {
    274274                                model.set( model.parse( resp, xhr ), options );
    275275                        });
     
    619619                                if ( -1 !== args.posts_per_page )
    620620                                        args.paged = Math.floor( this.length / args.posts_per_page ) + 1;
    621621
     622                                // Check if a post ID has been specified as a context.
     623                                if ( args.context )
     624                                        options.data.post_id = args.context;
     625                                delete args.context;
     626
    622627                                options.data.query = args;
    623628                                return media.ajax( options );
    624629
  • wp-includes/js/media-views.js

     
    1212        media.view.settings = l10n.settings || {};
    1313        delete l10n.settings;
    1414
     15        // Set the post ID as the default context of attachment queries.
     16        if ( ! _.isUndefined( media.view.settings.postId ) )
     17                media.model.Query.defaultProps.context = media.view.settings.postId;
     18
    1519        // Check if the browser supports CSS 3.0 transitions
    1620        $.support.transition = (function(){
    1721                var style = document.documentElement.style,