Make WordPress Core


Ignore:
Timestamp:
06/15/2016 11:22:52 AM (8 years ago)
Author:
swissspidy
Message:

Embeds: Improve performance when embedding a post from the current site.

When the post being embedded is from the same site, there's no reason to do an HTTP request for it. The data can be fetched directly using get_oembed_response_data().

Fixes #36767 for trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-oembed.php

    r37518 r37708  
    316316     */
    317317    public function get_html( $url, $args = '' ) {
     318        /**
     319         * Filters the oEmbed result before any HTTP requests are made.
     320         *
     321         * This allows one to short-circuit the default logic, perhaps by
     322         * replacing it with a routine that is more optimal for your setup.
     323         *
     324         * Passing a non-null value to the filter will effectively short-circuit retrieval,
     325         * returning the passed value instead.
     326         *
     327         * @since 4.5.3
     328         *
     329         * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.
     330         * @param string      $url    The URL to the content that should be attempted to be embedded.
     331         * @param array       $args   Optional. Arguments, usually passed from a shortcode. Default empty.
     332         */
     333        $pre = apply_filters( 'pre_oembed_result', null, $url, $args );
     334
     335        if ( null !== $pre ) {
     336            return $pre;
     337        }
     338
    318339        $provider = $this->get_provider( $url, $args );
    319340
    320         if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) )
    321             return false;
     341        if ( ! $provider || false === $data = $this->fetch( $provider, $url, $args ) ) {
     342            return false;
     343        }
    322344
    323345        /**
Note: See TracChangeset for help on using the changeset viewer.