public static $early_providers = array();
/**
- * A list of private/protected methods, used for backwards compatibility.
+ * A list of private/protected methods, used for backward compatibility.
*
* @since 4.2.0
* @access private
self::$early_providers = array();
/**
- * Filter the list of whitelisted oEmbed providers.
+ * Filters the list of whitelisted oEmbed providers.
*
* Since WordPress 4.4, oEmbed discovery is enabled for all users and allows embedding of sanitized
* iframes. The providers in this list are whitelisted, meaning they are trusted and allowed to
}
/**
- * Exposes private/protected methods for backwards compatibility.
+ * Exposes private/protected methods for backward compatibility.
*
* @since 4.0.0
* @access public
* @return false|string False on failure, otherwise the oEmbed provider URL.
*/
public function get_provider( $url, $args = '' ) {
+ $args = wp_parse_args( $args );
$provider = false;
* @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
*/
public function get_html( $url, $args = '' ) {
+ $args = wp_parse_args( $args );
+
+ /**
+ * Filters the oEmbed result before any HTTP requests are made.
+ *
+ * This allows one to short-circuit the default logic, perhaps by
+ * replacing it with a routine that is more optimal for your setup.
+ *
+ * Passing a non-null value to the filter will effectively short-circuit retrieval,
+ * returning the passed value instead.
+ *
+ * @since 4.5.3
+ *
+ * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.
+ * @param string $url The URL to the content that should be attempted to be embedded.
+ * @param array $args Optional. Arguments, usually passed from a shortcode. Default empty.
+ */
+ $pre = apply_filters( 'pre_oembed_result', null, $url, $args );
+
+ if ( null !== $pre ) {
+ return $pre;
+ }
+
$provider = $this->get_provider( $url, $args );
- if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) )
+ if ( ! $provider || false === $data = $this->fetch( $provider, $url, $args ) ) {
return false;
+ }
/**
- * Filter the HTML returned by the oEmbed provider.
+ * Filters the HTML returned by the oEmbed provider.
*
* @since 2.9.0
*
);
/**
- * Filter oEmbed remote get arguments.
+ * Filters oEmbed remote get arguments.
*
* @since 4.0.0
*
if ( $html = wp_remote_retrieve_body( $request ) ) {
/**
- * Filter the link types that contain oEmbed provider URLs.
+ * Filters the link types that contain oEmbed provider URLs.
*
* @since 2.9.0
*
$provider = add_query_arg( 'url', urlencode($url), $provider );
/**
- * Filter the oEmbed URL to be fetched.
+ * Filters the oEmbed URL to be fetched.
*
* @since 2.9.0
*
}
/**
- * Filter the returned oEmbed HTML.
+ * Filters the returned oEmbed HTML.
*
* Use this filter to add support for custom data types, or to filter the result.
*