Make WordPress Core

Changeset 24684


Ignore:
Timestamp:
07/12/2013 07:51:59 PM (11 years ago)
Author:
nacin
Message:

Add types parameter to get_media_embedded_in_content(). props aaroncampbell. see #24202.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r24682 r24684  
    18711871 * @since 3.6.0
    18721872 *
    1873  * @param string $type Type of media: audio or video
    18741873 * @param string $content A string which might contain media data.
     1874 * @param array $types array of media types: 'audio', 'video', 'object', 'embed', or 'iframe'
    18751875 * @return array A list of found HTML media embeds
    18761876 */
    1877 function get_media_embedded_in_content( $content ) {
     1877function get_media_embedded_in_content( $content, $types = null ) {
    18781878    $html = array();
    1879 
    1880     foreach ( array( 'audio', 'video', 'object', 'embed', 'iframe' ) as $tag ) {
     1879    $allowed_media_types = array( 'audio', 'video', 'object', 'embed', 'iframe' );
     1880    if ( ! empty( $types ) ) {
     1881        if ( ! is_array( $types ) )
     1882            $types = array( $types );
     1883        $allowed_media_types = array_intersect( $allowed_media_types, $types );
     1884    }
     1885
     1886    foreach ( $allowed_media_types as $tag ) {
    18811887        if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) {
    18821888            $html[] = $matches[0];
Note: See TracChangeset for help on using the changeset viewer.