Ticket #26675: 26675.patch
File 26675.patch, 2.0 KB (added by , 11 years ago) |
---|
-
wp-includes/media.php
1977 1977 } 1978 1978 1979 1979 /** 1980 * Check the content blob for an < audio>, <video> <object>, <embed>, or <iframe>1980 * Check the content blob for an <img>, <audio>, <video> <object>, <embed>, or <iframe> 1981 1981 * 1982 1982 * @since 3.6.0 1983 1983 * 1984 1984 * @param string $content A string which might contain media data. 1985 * @param array $types array of media types: 'audio', 'video', 'object', 'embed', or 'iframe' 1985 * @param array $types array of media types: 'img', 'audio', 'video', 'object', 'embed', or 'iframe' 1986 * @param string $sortby A string which defines how to sort the results. 1986 1987 * @return array A list of found HTML media embeds 1987 1988 */ 1988 function get_media_embedded_in_content( $content, $types = null ) {1989 function get_media_embedded_in_content( $content, $types = null, $sortby = 'type' ) { 1989 1990 $html = array(); 1990 $allowed_media_types = array( 'audio', 'video', 'object', 'embed', 'iframe' ); 1991 1992 $allowed_media_types = array( 'audio', 'video', 'object', 'embed', 'iframe', 'img' ); 1991 1993 if ( ! empty( $types ) ) { 1992 if ( ! is_array( $types ) ) 1994 if ( ! is_array( $types ) ) { 1993 1995 $types = array( $types ); 1996 } 1994 1997 $allowed_media_types = array_intersect( $allowed_media_types, $types ); 1995 1998 } 1996 1999 1997 foreach ( $allowed_media_types as $tag ) { 1998 if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) { 1999 $html[] = $matches[0]; 2000 if ( 'source' == $sortby ) { 2001 $tags = implode( '|', $allowed_media_types ); 2002 2003 if ( preg_match_all( '#<(?P<tag>' . $tags . ')[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)#', $content, $matches ) ) { 2004 foreach ( $matches[0] as $match ) { 2005 $html[] = $match; 2006 } 2007 } 2008 } else { 2009 foreach ( $allowed_media_types as $tag ) { 2010 if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) { 2011 foreach ( $matches[0] as $match ) { 2012 $html[] = $match; 2013 } 2014 } 2000 2015 } 2001 2016 } 2002 2017