Make WordPress Core


Ignore:
Timestamp:
12/14/2018 03:19:48 AM (6 years ago)
Author:
pento
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.

Merges [43810] from the 5.0 branch to trunk.

Props danielbachhuber, imath, swissspidy.
Fixes #45142.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/class-wp-oembed-controller.php

    r43571 r44154  
    182182        }
    183183
     184        // Short-circuit process for URLs belonging to the current site.
     185        $data = get_oembed_response_data_for_url( $url, $args );
     186
     187        if ( $data ) {
     188            return $data;
     189        }
     190
    184191        $data = _wp_oembed_get_object()->get_data( $url, $args );
    185192
     
    187194            return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) );
    188195        }
     196
     197        /** This filter is documented in wp-includes/class-oembed.php */
     198        $data->html = apply_filters( 'oembed_result', _wp_oembed_get_object()->data2html( (object) $data, $url ), $url, $args );
    189199
    190200        /**
Note: See TracChangeset for help on using the changeset viewer.