diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 2c287e1589..40f8f5d195 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -2714,21 +2714,14 @@ function wp_ajax_parse_embed() { } $shortcode = wp_unslash( $_POST['shortcode'] ); - - preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches ); - $atts = shortcode_parse_atts( $matches[3] ); - if ( ! empty( $matches[5] ) ) { - $url = $matches[5]; - } elseif ( ! empty( $atts['src'] ) ) { - $url = $atts['src']; - } + $url = str_replace( '[embed]', '', str_replace( '[/embed]', '', $shortcode ) ); $parsed = false; setup_postdata( $post ); $wp_embed->return_false_on_fail = true; - if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) { + if ( is_ssl() && preg_match( '%^\\[embed[^\\]]*\\]http://%i', $shortcode ) ) { // Admin is ssl and the user pasted non-ssl URL. // Check if the provider supports ssl embeds and use that for the preview. $ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode ); @@ -2781,8 +2774,7 @@ function wp_ajax_parse_embed() { } wp_send_json_success( array( - 'body' => $parsed, - 'attr' => $wp_embed->last_attr + 'body' => $parsed ) ); } diff --git a/src/wp-includes/class-wp-embed.php b/src/wp-includes/class-wp-embed.php index 9af3c224fe..9569f38df3 100644 --- a/src/wp-includes/class-wp-embed.php +++ b/src/wp-includes/class-wp-embed.php @@ -11,8 +11,6 @@ class WP_Embed { public $post_ID; public $usecache = true; public $linkifunknown = true; - public $last_attr = array(); - public $last_url = ''; /** * When an URL cannot be embedded, return false instead of returning a link @@ -136,18 +134,13 @@ class WP_Embed { $url = $attr['src']; } - $this->last_url = $url; - if ( empty( $url ) ) { - $this->last_attr = $attr; + if ( empty( $url ) ) return ''; - } $rawattr = $attr; $attr = wp_parse_args( $attr, wp_embed_defaults( $url ) ); - $this->last_attr = $attr; - // kses converts & into & and we need to undo this // See https://core.trac.wordpress.org/ticket/11311 $url = str_replace( '&', '&', $url ); diff --git a/src/wp-includes/css/media-views.css b/src/wp-includes/css/media-views.css index 1e8050fbc6..3d41c252a1 100644 --- a/src/wp-includes/css/media-views.css +++ b/src/wp-includes/css/media-views.css @@ -1981,29 +1981,6 @@ clear: both; } -.embed-link-settings .setting { - display: none; -} - -.embed-link-dimensions:after { - content: ''; - display: block; - clear: both; -} - -.embed-link-dimensions .width, -.embed-link-dimensions .height { - float: left; - width: 125px; - clear: none; - margin-right: 10px; -} - -.embed-link-dimensions input { - width: auto; - max-width: 110px; -} - .image-details .embed-media-settings .setting { float: none; width: auto; @@ -2050,7 +2027,6 @@ .media-embed .setting span { display: block; width: 200px; - max-width: 100%; font-size: 13px; line-height: 24px; color: #666; diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index 1c6b02b485..eab4560c82 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -818,12 +818,11 @@ window.wp = window.wp || {}; edit: function( text, update ) { var media = wp.media.embed, frame = media.edit( text, this.url ), - self = this, - events = 'change:url change:width change:height'; + self = this; this.pausePlayers(); - frame.state( 'embed' ).props.on( events, function( model, url ) { + frame.state( 'embed' ).props.on( 'change:url', function( model, url ) { if ( url && model.get( 'url' ) ) { frame.state( 'embed' ).metadata = model.toJSON(); } @@ -832,7 +831,7 @@ window.wp = window.wp || {}; frame.state( 'embed' ).on( 'select', function() { var data = frame.state( 'embed' ).metadata; - if ( self.url && ! data.width ) { + if ( self.url ) { update( data.url ); } else { update( media.shortcode( data ).string() ); diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 184a0aefff..605459f4a9 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -4535,7 +4535,7 @@ EmbedLink = wp.media.view.Settings.extend({ initialize: function() { this.spinner = $(''); this.$el.append( this.spinner[0] ); - this.listenTo( this.model, 'change:url change:width change:height', this.updateoEmbed ); + this.listenTo( this.model, 'change:url', this.updateoEmbed ); }, updateoEmbed: _.debounce( function() { @@ -4554,23 +4554,15 @@ EmbedLink = wp.media.view.Settings.extend({ }, 600 ), fetch: function() { - var embed; - // check if they haven't typed in 500 ms if ( $('#embed-url-field').val() !== this.model.get('url') ) { return; } - embed = new wp.shortcode({ - tag: 'embed', - attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ), - content: this.model.get('url') - }); - wp.ajax.send( 'parse-embed', { data : { post_ID: wp.media.view.settings.post.id, - shortcode: embed.string() + shortcode: '[embed]' + this.model.get('url') + '[/embed]' } } ) .done( _.bind( this.renderoEmbed, this ) ) @@ -4578,38 +4570,17 @@ EmbedLink = wp.media.view.Settings.extend({ }, renderFail: function () { - this.$( '.setting' ).hide().filter( '.link-text' ).show(); + this.$( '.link-text' ).show(); }, renderoEmbed: function( response ) { - var html = ( response && response.body ) || '', - attr = {}, - opts = { silent: true }; + var html = ( response && response.body ) || ''; - this.$( '.setting' ).hide() - .filter( '.link-text' )[ html ? 'hide' : 'show' ](); - - if ( response && response.attr ) { - attr = response.attr; - - _.each( [ 'width', 'height' ], function ( key ) { - var $el = this.$( '.setting.' + key ), - value = attr[ key ]; - - if ( value ) { - this.model.set( key, value, opts ); - $el.show().find( 'input' ).val( value ); - } else { - this.model.unset( key, opts ); - $el.hide().find( 'input' ).val( '' ); - } - }, this ); + if ( html ) { + this.$('.embed-container').show().find('.embed-preview').html( html ); } else { - this.model.unset( 'height', opts ); - this.model.unset( 'width', opts ); + this.renderFail(); } - - this.$('.embed-container').show().find('.embed-preview').html( html ); } }); diff --git a/src/wp-includes/js/media/views/embed/link.js b/src/wp-includes/js/media/views/embed/link.js index ac28d442d3..4a30230105 100644 --- a/src/wp-includes/js/media/views/embed/link.js +++ b/src/wp-includes/js/media/views/embed/link.js @@ -19,7 +19,7 @@ EmbedLink = wp.media.view.Settings.extend({ initialize: function() { this.spinner = $(''); this.$el.append( this.spinner[0] ); - this.listenTo( this.model, 'change:url change:width change:height', this.updateoEmbed ); + this.listenTo( this.model, 'change:url', this.updateoEmbed ); }, updateoEmbed: _.debounce( function() { @@ -38,23 +38,15 @@ EmbedLink = wp.media.view.Settings.extend({ }, 600 ), fetch: function() { - var embed; - // check if they haven't typed in 500 ms if ( $('#embed-url-field').val() !== this.model.get('url') ) { return; } - embed = new wp.shortcode({ - tag: 'embed', - attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ), - content: this.model.get('url') - }); - wp.ajax.send( 'parse-embed', { data : { post_ID: wp.media.view.settings.post.id, - shortcode: embed.string() + shortcode: '[embed]' + this.model.get('url') + '[/embed]' } } ) .done( _.bind( this.renderoEmbed, this ) ) @@ -62,38 +54,17 @@ EmbedLink = wp.media.view.Settings.extend({ }, renderFail: function () { - this.$( '.setting' ).hide().filter( '.link-text' ).show(); + this.$( '.link-text' ).show(); }, renderoEmbed: function( response ) { - var html = ( response && response.body ) || '', - attr = {}, - opts = { silent: true }; + var html = ( response && response.body ) || ''; - this.$( '.setting' ).hide() - .filter( '.link-text' )[ html ? 'hide' : 'show' ](); - - if ( response && response.attr ) { - attr = response.attr; - - _.each( [ 'width', 'height' ], function ( key ) { - var $el = this.$( '.setting.' + key ), - value = attr[ key ]; - - if ( value ) { - this.model.set( key, value, opts ); - $el.show().find( 'input' ).val( value ); - } else { - this.model.unset( key, opts ); - $el.hide().find( 'input' ).val( '' ); - } - }, this ); + if ( html ) { + this.$('.embed-container').show().find('.embed-preview').html( html ); } else { - this.model.unset( 'height', opts ); - this.model.unset( 'width', opts ); + this.renderFail(); } - - this.$('.embed-container').show().find('.embed-preview').html( html ); } }); diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 65b9b15597..6999f1bdf3 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -819,16 +819,6 @@ function wp_print_media_templates() { -