Ticket #31139: 31139.diff
File 31139.diff, 6.6 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
2705 2705 } 2706 2706 2707 2707 $shortcode = wp_unslash( $_POST['shortcode'] ); 2708 $url = str_replace( '[embed]', '', str_replace( '[/embed]', '', $shortcode ) ); 2708 2709 preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches ); 2710 $atts = shortcode_parse_atts( $matches[3] ); 2711 if ( ! empty( $atts[5] ) ) { 2712 $url = $atts[5]; 2713 } elseif ( ! empty( $atts['src'] ) ) { 2714 $url = $atts['src']; 2715 } 2716 2709 2717 $parsed = false; 2710 2718 setup_postdata( $post ); 2711 2719 2712 2720 $wp_embed->return_false_on_fail = true; 2713 2721 2714 if ( is_ssl() && preg_match( '%^\\[embed[^\\]]*\\]http://%i', $shortcode) ) {2722 if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) { 2715 2723 // Admin is ssl and the user pasted non-ssl URL. 2716 2724 // Check if the provider supports ssl embeds and use that for the preview. 2717 2725 $ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode ); … … 2764 2772 } 2765 2773 2766 2774 wp_send_json_success( array( 2767 'body' => $parsed 2775 'body' => $parsed, 2776 'attr' => $wp_embed->last_attr 2768 2777 ) ); 2769 2778 } 2770 2779 -
src/wp-includes/class-wp-embed.php
11 11 public $post_ID; 12 12 public $usecache = true; 13 13 public $linkifunknown = true; 14 public $last_attr = array(); 15 public $last_url = ''; 14 16 15 17 /** 16 18 * When an URL cannot be embedded, return false instead of returning a link … … 134 136 $url = $attr['src']; 135 137 } 136 138 137 if ( empty( $url ) ) 139 $this->last_url = $url; 140 141 if ( empty( $url ) ) { 142 $this->last_attr = $attr; 138 143 return ''; 144 } 139 145 140 146 $rawattr = $attr; 141 147 $attr = wp_parse_args( $attr, wp_embed_defaults( $url ) ); 142 148 149 $this->last_attr = $attr; 150 143 151 // kses converts & into & and we need to undo this 144 152 // See https://core.trac.wordpress.org/ticket/11311 145 153 $url = str_replace( '&', '&', $url ); -
src/wp-includes/js/media/views/embed/link.js
20 20 initialize: function() { 21 21 this.spinner = $('<span class="spinner" />'); 22 22 this.$el.append( this.spinner[0] ); 23 this.listenTo( this.model, 'change:url ', this.updateoEmbed );23 this.listenTo( this.model, 'change:url change:width change:height', this.updateoEmbed ); 24 24 }, 25 25 26 26 updateoEmbed: function() { … … 41 41 }, 42 42 43 43 fetch: function() { 44 var embed; 45 44 46 // check if they haven't typed in 500 ms 45 47 if ( $('#embed-url-field').val() !== this.model.get('url') ) { 46 48 return; 47 49 } 48 50 51 embed = new wp.shortcode({ 52 tag: 'embed', 53 attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ), 54 content: this.model.get('url') 55 }); 56 49 57 wp.ajax.send( 'parse-embed', { 50 58 data : { 51 59 post_ID: wp.media.view.settings.post.id, 52 shortcode: '[embed]' + this.model.get('url') + '[/embed]'60 shortcode: embed.string() 53 61 } 54 62 } ).done( _.bind( this.renderoEmbed, this ) ); 55 63 }, 56 64 57 65 renderoEmbed: function( response ) { 58 var html = ( response && response.body ) || ''; 66 var html = ( response && response.body ) || '', 67 attr = {}, 68 opts = { silent: true }; 59 69 70 if ( response && response.attr ) { 71 attr = response.attr; 72 73 _.each( [ 'width', 'height' ], function ( key ) { 74 var $el = this.$( '.setting.' + key ), 75 value = attr[ key ]; 76 77 if ( value ) { 78 this.model.set( key, value, opts ); 79 $el.show().find( 'input' ).val( value ); 80 } else { 81 this.model.unset( key, opts ); 82 $el.hide().find( 'input' ).val( '' ); 83 } 84 }, this ); 85 } else { 86 this.model.unset( 'height', opts ); 87 this.model.unset( 'width', opts ); 88 } 89 60 90 this.spinner.hide(); 61 91 62 92 this.$('.setting.title').hide(); -
src/wp-includes/js/media/views.js
4581 4581 initialize: function() { 4582 4582 this.spinner = $('<span class="spinner" />'); 4583 4583 this.$el.append( this.spinner[0] ); 4584 this.listenTo( this.model, 'change:url ', this.updateoEmbed );4584 this.listenTo( this.model, 'change:url change:width change:height', this.updateoEmbed ); 4585 4585 }, 4586 4586 4587 4587 updateoEmbed: function() { … … 4602 4602 }, 4603 4603 4604 4604 fetch: function() { 4605 var embed; 4606 4605 4607 // check if they haven't typed in 500 ms 4606 4608 if ( $('#embed-url-field').val() !== this.model.get('url') ) { 4607 4609 return; 4608 4610 } 4609 4611 4612 embed = new wp.shortcode({ 4613 tag: 'embed', 4614 attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ), 4615 content: this.model.get('url') 4616 }); 4617 4610 4618 wp.ajax.send( 'parse-embed', { 4611 4619 data : { 4612 4620 post_ID: wp.media.view.settings.post.id, 4613 shortcode: '[embed]' + this.model.get('url') + '[/embed]'4621 shortcode: embed.string() 4614 4622 } 4615 4623 } ).done( _.bind( this.renderoEmbed, this ) ); 4616 4624 }, 4617 4625 4618 4626 renderoEmbed: function( response ) { 4619 var html = ( response && response.body ) || ''; 4627 var html = ( response && response.body ) || '', 4628 attr = {}, 4629 opts = { silent: true }; 4620 4630 4631 if ( response && response.attr ) { 4632 attr = response.attr; 4633 4634 _.each( [ 'width', 'height' ], function ( key ) { 4635 var $el = this.$( '.setting.' + key ), 4636 value = attr[ key ]; 4637 4638 if ( value ) { 4639 this.model.set( key, value, opts ); 4640 $el.show().find( 'input' ).val( value ); 4641 } else { 4642 this.model.unset( key, opts ); 4643 $el.hide().find( 'input' ).val( '' ); 4644 } 4645 }, this ); 4646 } else { 4647 this.model.unset( 'height', opts ); 4648 this.model.unset( 'width', opts ); 4649 } 4650 4621 4651 this.spinner.hide(); 4622 4652 4623 4653 this.$('.setting.title').hide(); -
src/wp-includes/media-template.php
816 816 <span><?php _e( 'Title' ); ?></span> 817 817 <input type="text" class="alignment" data-setting="title" /> 818 818 </label> 819 <label class="setting width"> 820 <span><?php _e( 'Width' ); ?></span> 821 <input type="text" class="alignment" data-setting="width" /> 822 </label> 823 <label class="setting height"> 824 <span><?php _e( 'Height' ); ?></span> 825 <input type="text" class="alignment" data-setting="height" /> 826 </label> 819 827 <div class="embed-container" style="display: none;"> 820 828 <div class="embed-preview"></div> 821 829 </div>