Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: oembed_remote_get_args

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
316            * Filter oEmbed remote get arguments.
317            *
318            * @since 4.0.0
319            *
320            * @see WP_Http::request()
321            *
322            * @param array  $args oEmbed remote get arguments.
323            * @param string $url  URL to be inspected.
324            */
325           $args = apply_filters( 'oembed_remote_get_args', array(), $url );
326
327           // Fetch URL content
328           $request = wp_safe_remote_get( $url, $args );
329           if ( $html = wp_remote_retrieve_body( $request ) ) {
330
331                /**
332                 * Filter the link types that contain oEmbed provider URLs.
333                 *
334                 * @since 2.9.0
 
Line Code
421       * @access private
422       * @param string $provider_url_with_args URL to the provider with full arguments list (url, maxheight, etc.)
423       * @param string $format Format to use
424       * @return false|object|WP_Error False on failure, otherwise the result in the form of an object.
425       */
426      private function _fetch_with_format( $provider_url_with_args, $format ) {
427           $provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args );
428
429           /** This filter is documented in wp-includes/class-oembed.php */
430           $args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args );
431
432           $response = wp_safe_remote_get( $provider_url_with_args, $args );
433           if ( 501 == wp_remote_retrieve_response_code( $response ) )
434                return new WP_Error( 'not-implemented' );
435           if ( ! $body = wp_remote_retrieve_body( $response ) )
436                return false;
437           $parse_method = "_parse_$format";
438           return $this->$parse_method( $body );
439      }