Add types parameter to get_media_embedded_in_content(). props aaroncampbell. see #24202.
git-svn-id: https://develop.svn.wordpress.org/trunk@24684 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3a408ff249
commit
09658b5a03
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue