WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/23/2018 05:47:28 PM (3 years ago)
Author:
danielbachhuber
Message:

Embeds: Filter HTML response in oEmbed proxy controller.

Adapts the response from WP_oEmbed_Controller::get_proxy_item() so that the response is correctly filtered and embeds work properly in JavaSccript editors. Introduces new get_oembed_response_data_for_url() function for preparing internal oEmbed responses.

Props danielbachhuber, imath, swissspidy.
Fixes #45142.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/class-wp-oembed-controller.php

    r41162 r43810  
    174174        }
    175175
     176        // Short-circuit process for URLs belonging to the current site.
     177        $data = get_oembed_response_data_for_url( $url, $args );
     178
     179        if ( $data ) {
     180            return $data;
     181        }
     182
    176183        $data = _wp_oembed_get_object()->get_data( $url, $args );
    177184
     
    179186            return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) );
    180187        }
     188
     189        /** This filter is documented in wp-includes/class-oembed.php */
     190        $data->html = apply_filters( 'oembed_result', _wp_oembed_get_object()->data2html( (object) $data, $url ), $url, $args );
    181191
    182192        /**
Note: See TracChangeset for help on using the changeset viewer.