Make WordPress Core

Changeset 29577


Ignore:
Timestamp:
08/22/2014 06:54:08 PM (12 years ago)
Author:
azaozz
Message:

TinyMCE wpView: fix showing errors for non-embeddable URLs, no-ssl or no items. Props avryl, fixes #29114, see #29268.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r29559 r29577  
    27242724
    27252725    if ( empty( $shortcode ) ) {
    2726         wp_send_json_error( array( 'statusText' => __( 'No items found.' ) ) );
     2726        wp_send_json_error( array(
     2727            'type' => 'no-items',
     2728            'message' => __( 'No items found.' ),
     2729        ) );
    27272730    }
    27282731
  • trunk/src/wp-includes/js/mce-view.js

    r29571 r29577  
    562562                if ( this.parsed ) {
    563563                    this.setIframes( this.parsed );
    564                 } else if ( this.parsed === false ) {
    565                     this.setContent( '<p>' + this.original + '</p>', 'replace' );
     564                } else {
     565                    this.fail();
    566566                }
    567567            },
     
    577577                    }
    578578                } )
    579                 .always( function() {
    580                     self.parsed = false;
    581                 } )
    582579                .done( function( response ) {
    583580                    if ( response ) {
    584581                        self.parsed = response;
    585582                        self.setIframes( response );
     583                    } else {
     584                        self.fail( true );
    586585                    }
    587586                } )
    588587                .fail( function( response ) {
    589                     if ( response && response.message ) {
    590                         if ( ( response.type === 'not-embeddable' && self.type === 'embed' ) ||
    591                             response.type === 'not-ssl' ) {
    592 
    593                             self.setError( response.message, 'admin-media' );
    594                         } else {
    595                             self.setContent( '<p>' + self.original + '</p>', 'replace' );
    596                         }
    597                     } else if ( response && response.statusText ) {
    598                         self.setError( response.statusText, 'admin-media' );
    599                     }
     588                    self.fail( response || true );
    600589                } );
     590            },
     591
     592            fail: function( error ) {
     593                if ( ! this.error ) {
     594                    if ( error ) {
     595                        this.error = error
     596                    } else {
     597                        return;
     598                    }
     599                }
     600
     601                if ( this.error.message ) {
     602                    if ( ( this.error.type === 'not-embeddable' && this.type === 'embed' ) || this.error.type === 'not-ssl' ||
     603                        this.error.type === 'no-items' ) {
     604
     605                        this.setError( this.error.message, 'admin-media' );
     606                    } else {
     607                        this.setContent( '<p>' + this.original + '</p>', 'replace' );
     608                    }
     609                } else if ( this.error.statusText ) {
     610                    this.setError( this.error.statusText, 'admin-media' );
     611                } else if ( this.original ) {
     612                    this.setContent( '<p>' + this.original + '</p>', 'replace' );
     613                }
    601614            },
    602615
Note: See TracChangeset for help on using the changeset viewer.