WordPress.org

Make WordPress Core

Ticket #40919: 40919.diff

File 40919.diff, 5.1 KB (added by jnylen0, 4 years ago)
  • wp-admin/js/widgets/media-video-widget.js

    diff --git a/wp-admin/js/widgets/media-video-widget.js b/wp-admin/js/widgets/media-video-widget.js
    index 07b203f..cf4301a 100644
    a b  
    110110                                control.fetchEmbedDfd.abort();
    111111                        }
    112112
    113                         control.fetchEmbedDfd = jQuery.ajax({
     113                        control.fetchEmbedDfd = wp.RESTRequest({
    114114                                url: wp.media.view.settings.oEmbedProxyUrl,
    115115                                data: {
    116116                                        url: control.model.get( 'url' ),
  • wp-admin/js/widgets/media-widgets.js

    diff --git a/wp-admin/js/widgets/media-widgets.js b/wp-admin/js/widgets/media-widgets.js
    index 54862f5..849eee5 100644
    a b wp.mediaWidgets = ( function( $ ) { 
    184184                                                        return;
    185185                                                }
    186186
    187                                                 embedLinkView.dfd = $.ajax({
     187                                                embedLinkView.dfd = wp.RESTRequest({
    188188                                                        url: wp.media.view.settings.oEmbedProxyUrl,
    189189                                                        data: {
    190190                                                                url: embedLinkView.model.get( 'url' ),
  • wp-includes/js/media-views.js

    diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js
    index 75cf452..ab106f9 100644
    a b EmbedLink = wp.media.view.Settings.extend({ 
    46344634                        this.dfd.abort();
    46354635                }
    46364636
    4637                 this.dfd = $.ajax({
     4637                this.dfd = wp.RESTRequest({
    46384638                        url: wp.media.view.settings.oEmbedProxyUrl,
    46394639                        data: {
    46404640                                url: this.model.get( 'url' ),
  • new file wp-includes/js/rest-request.js

    diff --git a/wp-includes/js/rest-request.js b/wp-includes/js/rest-request.js
    new file mode 100644
    index 0000000..ab457bc
    - +  
     1/**
     2 * Thin jQuery.ajax wrapper for REST API requests that do not use the
     3 * `wp-api.js` Backbone client library.  Allows overriding these requests as
     4 * needed by customized WP installations.
     5 *
     6 * @summary   Call jQuery.ajax, intended for use with the WP REST API.
     7 *
     8 * @namespace wp.RESTRequest
     9 * @since     4.8.1
     10 */
     11
     12( function( $ ) {
     13        function RESTRequest( options ) {
     14                return $.ajax( options );
     15        }
     16        window.wp = window.wp || {};
     17        window.wp.RESTRequest = RESTRequest;
     18} )( jQuery );
  • wp-includes/script-loader.php

    diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
    index ff7d8bb..cabdff3 100644
    a b function wp_default_scripts( &$scripts ) { 
    133133                'broken' => __('An unidentified error has occurred.')
    134134        ) );
    135135
     136        $scripts->add( 'wp-rest-request', "/wp-includes/js/rest-request$suffix.js", array( 'jquery' ), false, 1 );
     137
    136138        $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
    137139        did_action( 'init' ) && $scripts->localize( 'wp-pointer', 'wpPointerL10n', array(
    138140                'dismiss' => __('Dismiss'),
    function wp_default_scripts( &$scripts ) { 
    499501
    500502        // To enqueue media-views or media-editor, call wp_enqueue_media().
    501503        // Both rely on numerous settings, styles, and templates to operate correctly.
    502         $scripts->add( 'media-views',  "/wp-includes/js/media-views$suffix.js",  array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement' ), false, 1 );
     504        $scripts->add( 'media-views',  "/wp-includes/js/media-views$suffix.js",  array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-rest-request' ), false, 1 );
    503505        $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
    504506        $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
    505507        $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
    function wp_default_scripts( &$scripts ) { 
    602604                $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
    603605
    604606                $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
    605                 $scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views' ) );
     607                $scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views', 'wp-rest-request' ) );
    606608                $scripts->add_inline_script( 'media-widgets', 'wp.mediaWidgets.init();', 'after' );
    607609
    608610                $scripts->add( 'media-audio-widget', "/wp-admin/js/widgets/media-audio-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) );
    609611                $scripts->add( 'media-image-widget', "/wp-admin/js/widgets/media-image-widget$suffix.js", array( 'media-widgets' ) );
    610                 $scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) );
     612                $scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo', 'wp-rest-request' ) );
    611613                $scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util' ) );
    612614                $scripts->add_inline_script( 'text-widgets', 'wp.textWidgets.init();', 'after' );
    613615