Changeset 32258
- Timestamp:
- 04/21/2015 10:40:23 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r32079 r32258 2715 2715 2716 2716 $shortcode = wp_unslash( $_POST['shortcode'] ); 2717 2718 preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches ); 2719 $atts = shortcode_parse_atts( $matches[3] ); 2720 if ( ! empty( $matches[5] ) ) { 2721 $url = $matches[5]; 2722 } elseif ( ! empty( $atts['src'] ) ) { 2723 $url = $atts['src']; 2724 } 2717 $url = str_replace( '[embed]', '', str_replace( '[/embed]', '', $shortcode ) ); 2725 2718 2726 2719 $parsed = false; … … 2729 2722 $wp_embed->return_false_on_fail = true; 2730 2723 2731 if ( is_ssl() && 0 === strpos( $url, 'http://') ) {2724 if ( is_ssl() && preg_match( '%^\\[embed[^\\]]*\\]http://%i', $shortcode ) ) { 2732 2725 // Admin is ssl and the user pasted non-ssl URL. 2733 2726 // Check if the provider supports ssl embeds and use that for the preview. … … 2782 2775 2783 2776 wp_send_json_success( array( 2784 'body' => $parsed, 2785 'attr' => $wp_embed->last_attr 2777 'body' => $parsed 2786 2778 ) ); 2787 2779 } -
trunk/src/wp-includes/class-wp-embed.php
r31620 r32258 12 12 public $usecache = true; 13 13 public $linkifunknown = true; 14 public $last_attr = array();15 public $last_url = '';16 14 17 15 /** … … 137 135 } 138 136 139 $this->last_url = $url; 140 141 if ( empty( $url ) ) { 142 $this->last_attr = $attr; 137 138 if ( empty( $url ) ) 143 139 return ''; 144 }145 140 146 141 $rawattr = $attr; 147 142 $attr = wp_parse_args( $attr, wp_embed_defaults( $url ) ); 148 149 $this->last_attr = $attr;150 143 151 144 // kses converts & into & and we need to undo this -
trunk/src/wp-includes/css/media-views.css
r32125 r32258 1982 1982 } 1983 1983 1984 .embed-link-settings .setting {1985 display: none;1986 }1987 1988 .embed-link-dimensions:after {1989 content: '';1990 display: block;1991 clear: both;1992 }1993 1994 .embed-link-dimensions .width,1995 .embed-link-dimensions .height {1996 float: left;1997 width: 125px;1998 clear: none;1999 margin-right: 10px;2000 }2001 2002 .embed-link-dimensions input {2003 width: auto;2004 max-width: 110px;2005 }2006 2007 1984 .image-details .embed-media-settings .setting { 2008 1985 float: none; … … 2051 2028 display: block; 2052 2029 width: 200px; 2053 max-width: 100%;2054 2030 font-size: 13px; 2055 2031 line-height: 24px; -
trunk/src/wp-includes/js/mce-view.js
r32255 r32258 819 819 var media = wp.media.embed, 820 820 frame = media.edit( text, this.url ), 821 self = this, 822 events = 'change:url change:width change:height'; 821 self = this; 823 822 824 823 this.pausePlayers(); 825 824 826 frame.state( 'embed' ).props.on( events, function( model, url ) {825 frame.state( 'embed' ).props.on( 'change:url', function( model, url ) { 827 826 if ( url && model.get( 'url' ) ) { 828 827 frame.state( 'embed' ).metadata = model.toJSON(); … … 833 832 var data = frame.state( 'embed' ).metadata; 834 833 835 if ( self.url && ! data.width) {834 if ( self.url ) { 836 835 update( data.url ); 837 836 } else { -
trunk/src/wp-includes/js/media-views.js
r32228 r32258 4536 4536 this.spinner = $('<span class="spinner" />'); 4537 4537 this.$el.append( this.spinner[0] ); 4538 this.listenTo( this.model, 'change:url change:width change:height', this.updateoEmbed );4538 this.listenTo( this.model, 'change:url', this.updateoEmbed ); 4539 4539 }, 4540 4540 … … 4555 4555 4556 4556 fetch: function() { 4557 var embed;4558 4559 4557 // check if they haven't typed in 500 ms 4560 4558 if ( $('#embed-url-field').val() !== this.model.get('url') ) { … … 4562 4560 } 4563 4561 4564 embed = new wp.shortcode({4565 tag: 'embed',4566 attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ),4567 content: this.model.get('url')4568 });4569 4570 4562 wp.ajax.send( 'parse-embed', { 4571 4563 data : { 4572 4564 post_ID: wp.media.view.settings.post.id, 4573 shortcode: embed.string()4565 shortcode: '[embed]' + this.model.get('url') + '[/embed]' 4574 4566 } 4575 4567 } ) … … 4579 4571 4580 4572 renderFail: function () { 4581 this.$( '. setting' ).hide().filter( '.link-text' ).show();4573 this.$( '.link-text' ).show(); 4582 4574 }, 4583 4575 4584 4576 renderoEmbed: function( response ) { 4585 var html = ( response && response.body ) || '', 4586 attr = {}, 4587 opts = { silent: true }; 4588 4589 this.$( '.setting' ).hide() 4590 .filter( '.link-text' )[ html ? 'hide' : 'show' ](); 4591 4592 if ( response && response.attr ) { 4593 attr = response.attr; 4594 4595 _.each( [ 'width', 'height' ], function ( key ) { 4596 var $el = this.$( '.setting.' + key ), 4597 value = attr[ key ]; 4598 4599 if ( value ) { 4600 this.model.set( key, value, opts ); 4601 $el.show().find( 'input' ).val( value ); 4602 } else { 4603 this.model.unset( key, opts ); 4604 $el.hide().find( 'input' ).val( '' ); 4605 } 4606 }, this ); 4577 var html = ( response && response.body ) || ''; 4578 4579 if ( html ) { 4580 this.$('.embed-container').show().find('.embed-preview').html( html ); 4607 4581 } else { 4608 this.model.unset( 'height', opts ); 4609 this.model.unset( 'width', opts ); 4610 } 4611 4612 this.$('.embed-container').show().find('.embed-preview').html( html ); 4582 this.renderFail(); 4583 } 4613 4584 } 4614 4585 }); -
trunk/src/wp-includes/js/media/views/embed/link.js
r32101 r32258 20 20 this.spinner = $('<span class="spinner" />'); 21 21 this.$el.append( this.spinner[0] ); 22 this.listenTo( this.model, 'change:url change:width change:height', this.updateoEmbed );22 this.listenTo( this.model, 'change:url', this.updateoEmbed ); 23 23 }, 24 24 … … 39 39 40 40 fetch: function() { 41 var embed;42 43 41 // check if they haven't typed in 500 ms 44 42 if ( $('#embed-url-field').val() !== this.model.get('url') ) { … … 46 44 } 47 45 48 embed = new wp.shortcode({49 tag: 'embed',50 attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ),51 content: this.model.get('url')52 });53 54 46 wp.ajax.send( 'parse-embed', { 55 47 data : { 56 48 post_ID: wp.media.view.settings.post.id, 57 shortcode: embed.string()49 shortcode: '[embed]' + this.model.get('url') + '[/embed]' 58 50 } 59 51 } ) … … 63 55 64 56 renderFail: function () { 65 this.$( '. setting' ).hide().filter( '.link-text' ).show();57 this.$( '.link-text' ).show(); 66 58 }, 67 59 68 60 renderoEmbed: function( response ) { 69 var html = ( response && response.body ) || '', 70 attr = {}, 71 opts = { silent: true }; 61 var html = ( response && response.body ) || ''; 72 62 73 this.$( '.setting' ).hide() 74 .filter( '.link-text' )[ html ? 'hide' : 'show' ](); 75 76 if ( response && response.attr ) { 77 attr = response.attr; 78 79 _.each( [ 'width', 'height' ], function ( key ) { 80 var $el = this.$( '.setting.' + key ), 81 value = attr[ key ]; 82 83 if ( value ) { 84 this.model.set( key, value, opts ); 85 $el.show().find( 'input' ).val( value ); 86 } else { 87 this.model.unset( key, opts ); 88 $el.hide().find( 'input' ).val( '' ); 89 } 90 }, this ); 63 if ( html ) { 64 this.$('.embed-container').show().find('.embed-preview').html( html ); 91 65 } else { 92 this.model.unset( 'height', opts ); 93 this.model.unset( 'width', opts ); 66 this.renderFail(); 94 67 } 95 96 this.$('.embed-container').show().find('.embed-preview').html( html );97 68 } 98 69 }); -
trunk/src/wp-includes/media-template.php
r32055 r32258 819 819 <div class="embed-container" style="display: none;"> 820 820 <div class="embed-preview"></div> 821 </div>822 <div class="embed-link-dimensions">823 <label class="setting width">824 <span><?php _e( 'Maximum Width' ); ?></span>825 <input type="text" class="alignment" data-setting="width" />826 </label>827 <label class="setting height">828 <span><?php _e( 'Maximum Height' ); ?></span>829 <input type="text" class="alignment" data-setting="height" />830 </label>831 821 </div> 832 822 </script>
Note: See TracChangeset
for help on using the changeset viewer.