Make WordPress Core

Changeset 32258


Ignore:
Timestamp:
04/21/2015 10:40:23 PM (11 years ago)
Author:
azaozz
Message:

Revert editing of video embed parameters in the media modal, [31620] and [31626] for now. Plan on revisiting in 4.3.
Props iseulde. Fixes #31139, fixes #32006.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r32079 r32258  
    27152715
    27162716        $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 ) );
    27252718
    27262719        $parsed = false;
     
    27292722        $wp_embed->return_false_on_fail = true;
    27302723
    2731         if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) {
     2724        if ( is_ssl() && preg_match( '%^\\[embed[^\\]]*\\]http://%i', $shortcode ) ) {
    27322725                // Admin is ssl and the user pasted non-ssl URL.
    27332726                // Check if the provider supports ssl embeds and use that for the preview.
     
    27822775
    27832776        wp_send_json_success( array(
    2784                 'body' => $parsed,
    2785                 'attr' => $wp_embed->last_attr
     2777                'body' => $parsed
    27862778        ) );
    27872779}
  • trunk/src/wp-includes/class-wp-embed.php

    r31620 r32258  
    1212        public $usecache = true;
    1313        public $linkifunknown = true;
    14         public $last_attr = array();
    15         public $last_url = '';
    1614
    1715        /**
     
    137135                }
    138136
    139                 $this->last_url = $url;
    140 
    141                 if ( empty( $url ) ) {
    142                         $this->last_attr = $attr;
     137
     138                if ( empty( $url ) )
    143139                        return '';
    144                 }
    145140
    146141                $rawattr = $attr;
    147142                $attr = wp_parse_args( $attr, wp_embed_defaults( $url ) );
    148 
    149                 $this->last_attr = $attr;
    150143
    151144                // kses converts & into & and we need to undo this
  • trunk/src/wp-includes/css/media-views.css

    r32125 r32258  
    19821982}
    19831983
    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 
    20071984.image-details .embed-media-settings .setting {
    20081985        float: none;
     
    20512028        display: block;
    20522029        width: 200px;
    2053         max-width: 100%;
    20542030        font-size: 13px;
    20552031        line-height: 24px;
  • trunk/src/wp-includes/js/mce-view.js

    r32255 r32258  
    819819                        var media = wp.media.embed,
    820820                                frame = media.edit( text, this.url ),
    821                                 self = this,
    822                                 events = 'change:url change:width change:height';
     821                                self = this;
    823822
    824823                        this.pausePlayers();
    825824
    826                         frame.state( 'embed' ).props.on( events, function( model, url ) {
     825                        frame.state( 'embed' ).props.on( 'change:url', function( model, url ) {
    827826                                if ( url && model.get( 'url' ) ) {
    828827                                        frame.state( 'embed' ).metadata = model.toJSON();
     
    833832                                var data = frame.state( 'embed' ).metadata;
    834833
    835                                 if ( self.url && ! data.width ) {
     834                                if ( self.url ) {
    836835                                        update( data.url );
    837836                                } else {
  • trunk/src/wp-includes/js/media-views.js

    r32228 r32258  
    45364536                this.spinner = $('<span class="spinner" />');
    45374537                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 );
    45394539        },
    45404540
     
    45554555
    45564556        fetch: function() {
    4557                 var embed;
    4558 
    45594557                // check if they haven't typed in 500 ms
    45604558                if ( $('#embed-url-field').val() !== this.model.get('url') ) {
     
    45624560                }
    45634561
    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 
    45704562                wp.ajax.send( 'parse-embed', {
    45714563                        data : {
    45724564                                post_ID: wp.media.view.settings.post.id,
    4573                                 shortcode: embed.string()
     4565                                shortcode: '[embed]' + this.model.get('url') + '[/embed]'
    45744566                        }
    45754567                } )
     
    45794571
    45804572        renderFail: function () {
    4581                 this.$( '.setting' ).hide().filter( '.link-text' ).show();
     4573                this.$( '.link-text' ).show();
    45824574        },
    45834575
    45844576        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 );
    46074581                } 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                }
    46134584        }
    46144585});
  • trunk/src/wp-includes/js/media/views/embed/link.js

    r32101 r32258  
    2020                this.spinner = $('<span class="spinner" />');
    2121                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 );
    2323        },
    2424
     
    3939
    4040        fetch: function() {
    41                 var embed;
    42 
    4341                // check if they haven't typed in 500 ms
    4442                if ( $('#embed-url-field').val() !== this.model.get('url') ) {
     
    4644                }
    4745
    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 
    5446                wp.ajax.send( 'parse-embed', {
    5547                        data : {
    5648                                post_ID: wp.media.view.settings.post.id,
    57                                 shortcode: embed.string()
     49                                shortcode: '[embed]' + this.model.get('url') + '[/embed]'
    5850                        }
    5951                } )
     
    6355
    6456        renderFail: function () {
    65                 this.$( '.setting' ).hide().filter( '.link-text' ).show();
     57                this.$( '.link-text' ).show();
    6658        },
    6759
    6860        renderoEmbed: function( response ) {
    69                 var html = ( response && response.body ) || '',
    70                         attr = {},
    71                         opts = { silent: true };
     61                var html = ( response && response.body ) || '';
    7262
    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 );
    9165                } else {
    92                         this.model.unset( 'height', opts );
    93                         this.model.unset( 'width', opts );
     66                        this.renderFail();
    9467                }
    95 
    96                 this.$('.embed-container').show().find('.embed-preview').html( html );
    9768        }
    9869});
  • trunk/src/wp-includes/media-template.php

    r32055 r32258  
    819819                <div class="embed-container" style="display: none;">
    820820                        <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>
    831821                </div>
    832822        </script>
Note: See TracChangeset for help on using the changeset viewer.