From 75ab12808b1d6577f7eb430e73b7e4557fd0d975 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 12 Jul 2013 19:51:59 +0000 Subject: [PATCH] Add types parameter to get_media_embedded_in_content(). props aaroncampbell. see #24202. git-svn-id: http://core.svn.wordpress.org/trunk@24684 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index ecbedbacb1..4efded06e6 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1870,14 +1870,20 @@ function get_attached_media( $type, $post = 0 ) { * * @since 3.6.0 * - * @param string $type Type of media: audio or video * @param string $content A string which might contain media data. + * @param array $types array of media types: 'audio', 'video', 'object', 'embed', or 'iframe' * @return array A list of found HTML media embeds */ -function get_media_embedded_in_content( $content ) { +function get_media_embedded_in_content( $content, $types = null ) { $html = array(); + $allowed_media_types = array( 'audio', 'video', 'object', 'embed', 'iframe' ); + if ( ! empty( $types ) ) { + if ( ! is_array( $types ) ) + $types = array( $types ); + $allowed_media_types = array_intersect( $allowed_media_types, $types ); + } - foreach ( array( 'audio', 'video', 'object', 'embed', 'iframe' ) as $tag ) { + foreach ( $allowed_media_types as $tag ) { if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) { $html[] = $matches[0]; }