When fetching in `media/views/embed/link.js`, call `abort()` on any existing XHRs.
Use `$.ajax` instead of `wp.ajax.send()` to allow this. Pass `this` as `context` to the options to remove the need to bind callbacks. Fixes #32035. Built from https://develop.svn.wordpress.org/trunk@32460 git-svn-id: http://core.svn.wordpress.org/trunk@32430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
31f46f5363
commit
af326241ff
|
@ -4561,28 +4561,39 @@ EmbedLink = wp.media.view.Settings.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( this.dfd && 'pending' === this.dfd.state() ) {
|
||||||
|
this.dfd.abort();
|
||||||
|
}
|
||||||
|
|
||||||
embed = new wp.shortcode({
|
embed = new wp.shortcode({
|
||||||
tag: 'embed',
|
tag: 'embed',
|
||||||
attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ),
|
attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ),
|
||||||
content: this.model.get('url')
|
content: this.model.get('url')
|
||||||
});
|
});
|
||||||
|
|
||||||
wp.ajax.send( 'parse-embed', {
|
this.dfd = $.ajax({
|
||||||
data : {
|
type: 'POST',
|
||||||
|
url: wp.ajax.settings.url,
|
||||||
|
context: this,
|
||||||
|
data: {
|
||||||
|
action: 'parse-embed',
|
||||||
post_ID: wp.media.view.settings.post.id,
|
post_ID: wp.media.view.settings.post.id,
|
||||||
shortcode: embed.string()
|
shortcode: embed.string()
|
||||||
}
|
}
|
||||||
} )
|
})
|
||||||
.done( _.bind( this.renderoEmbed, this ) )
|
.done( this.renderoEmbed )
|
||||||
.fail( _.bind( this.renderFail, this ) );
|
.fail( this.renderFail );
|
||||||
},
|
},
|
||||||
|
|
||||||
renderFail: function () {
|
renderFail: function ( response, status ) {
|
||||||
|
if ( 'abort' === status ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$( '.link-text' ).show();
|
this.$( '.link-text' ).show();
|
||||||
},
|
},
|
||||||
|
|
||||||
renderoEmbed: function( response ) {
|
renderoEmbed: function( response ) {
|
||||||
var html = ( response && response.body ) || '';
|
var html = ( response && response.data && response.data.body ) || '';
|
||||||
|
|
||||||
if ( html ) {
|
if ( html ) {
|
||||||
this.$('.embed-container').show().find('.embed-preview').html( html );
|
this.$('.embed-container').show().find('.embed-preview').html( html );
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-32459';
|
$wp_version = '4.3-alpha-32460';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue