From bd6a09c708dfdf7d3032975be696ee45f805159e Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Tue, 8 Oct 2013 04:43:10 +0000 Subject: [PATCH] Inline documentation for hooks in wp-includes/class-wp-embed.php. Props swissspidy, kpdesign. Fixes #25515. Built from https://develop.svn.wordpress.org/trunk@25726 git-svn-id: http://core.svn.wordpress.org/trunk@25639 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-embed.php | 52 ++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-embed.php b/wp-includes/class-wp-embed.php index c5381846f4..275c2803b3 100644 --- a/wp-includes/class-wp-embed.php +++ b/wp-includes/class-wp-embed.php @@ -153,6 +153,15 @@ class WP_Embed { foreach ( $handlers as $id => $handler ) { if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) { if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) + /** + * Filter the returned embed handler. + * + * @since 2.9.0 + * + * @param mixed $return The shortcode callback function to call. + * @param string $url The attempted embed URL. + * @param array $attr An array of shortcode attributes. + */ return apply_filters( 'embed_handler_html', $return, $url, $attr ); } } @@ -175,11 +184,29 @@ class WP_Embed { return $this->maybe_make_link( $url ); if ( ! empty( $cache ) ) + /** + * Filter the cached oEmbed HTML. + * + * @since 2.9.0 + * + * @param mixed $cache The cached HTML result, stored in post meta. + * @param string $url The attempted embed URL. + * @param array $attr An array of shortcode attributes. + * @param int $post_ID Post ID. + */ return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID ); } + /** + * Filter whether to inspect the given URL for discoverable tags. + * + * @see WP_oEmbed::discover() + * + * @param bool false Whether to enable tag discovery. Default false. + */ + $attr['discover'] = ( apply_filters( 'embed_oembed_discover', false ) && author_can( $post_ID, 'unfiltered_html' ) ); + // Use oEmbed to get the HTML - $attr['discover'] = ( apply_filters('embed_oembed_discover', false) && author_can( $post_ID, 'unfiltered_html' ) ); $html = wp_oembed_get( $url, $attr ); // Cache the result @@ -187,8 +214,10 @@ class WP_Embed { update_post_meta( $post_ID, $cachekey, $cache ); // If there was a result, return it - if ( $html ) + if ( $html ) { + //duplicate_hook return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_ID ); + } } // Still unknown @@ -219,7 +248,15 @@ class WP_Embed { function cache_oembed( $post_ID ) { $post = get_post( $post_ID ); - if ( empty($post->ID) || !in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', array( 'post', 'page' ) ) ) ) + $post_types = array( 'post', 'page' ); + /** + * Filter the array of post types to cache oEmbed results for. + * + * @since 2.9.0 + * + * @param array $post_types Array of post types to cache oEmbed results for. Default 'post', 'page'. + */ + if ( empty($post->ID) || !in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', $post_types ) ) ) return; // Trigger a caching @@ -271,6 +308,15 @@ class WP_Embed { */ function maybe_make_link( $url ) { $output = ( $this->linkifunknown ) ? '' . esc_html($url) . '' : $url; + + /** + * Filter the returned, maybe-linked embed URL. + * + * @since 2.9.0 + * + * @param string $output The linked or original URL. + * @param string $url The original URL. + */ return apply_filters( 'embed_maybe_make_link', $output, $url ); } }