WordPress.org

Make WordPress Core

Ticket #26675: 26675-2014.02.19.patch

File 26675-2014.02.19.patch, 1.1 KB (added by Kopepasah, 6 years ago)
  • wp-includes/media.php

     
    21332133 */
    21342134function get_media_embedded_in_content( $content, $types = null ) {
    21352135        $html = array();
    2136         $allowed_media_types = array( 'audio', 'video', 'object', 'embed', 'iframe' );
     2136
     2137        $allowed_media_types = apply_filters( 'get_media_embedded_in_content_allowed', array( 'audio', 'video', 'object', 'embed', 'iframe' ) );
     2138
    21372139        if ( ! empty( $types ) ) {
    2138                 if ( ! is_array( $types ) )
     2140                if ( ! is_array( $types ) ) {
    21392141                        $types = array( $types );
     2142                }
     2143
    21402144                $allowed_media_types = array_intersect( $allowed_media_types, $types );
    21412145        }
    21422146
    2143         foreach ( $allowed_media_types as $tag ) {
    2144                 if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) {
    2145                         $html[] = $matches[0];
     2147        $tags = implode( '|', $allowed_media_types );
     2148
     2149        if ( preg_match_all( '#<(?P<tag>' . $tags . ')[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)#', $content, $matches ) ) {
     2150                foreach ( $matches[0] as $match ) {
     2151                        $html[] = $match;
    21462152                }
    21472153        }