Make WordPress Core


Ignore:
Timestamp:
03/16/2013 05:25:44 AM (13 years ago)
Author:
markjaquith
Message:

Introduce [audio] and [video] shortcodes, and use MediaElement.js to play them.

props wonderboymusic. see #23282.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-formats.php

    r23655 r23729  
    309309    $format_output = '';
    310310    $meta = get_post_format_meta( $post->ID );
     311    // passed by ref in preg_match()
     312    $matches = array();
    311313
    312314    switch ( $format ) {
     
    366368
    367369        case 'gallery':
    368             preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches );
    369             if ( ! empty( $matches ) && isset( $matches[2] ) ) {
    370                 foreach ( (array) $matches[2] as $match ) {
    371                     if ( 'gallery' === $match )
    372                         break 2; // foreach + case
    373                 }
    374             }
    375 
    376             if ( ! empty( $meta['gallery'] ) ) {
     370            if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta['gallery'] ) )
    377371                $format_output .= $meta['gallery'];
    378             }
    379372            break;
    380373
    381374        case 'video':
    382375        case 'audio':
    383             $shortcode_regex = '/' . get_shortcode_regex() . '/s';
    384             $matches = preg_match( $shortcode_regex, $content );
    385             if ( ! $matches || $format !== $matches[2] ) {
    386                 if ( ! empty( $meta['media'] ) ) {
    387                     // the metadata is a shortcode or an embed code
    388                     if ( preg_match( $shortcode_regex, $meta['media'] ) || preg_match( '#<[^>]+>#', $meta['media'] ) ) {
    389                         $format_output .= $meta['media'];
    390                     } elseif ( ! stristr( $content, $meta['media'] ) ) {
    391                         // attempt to embed the URL
    392                         $format_output .= sprintf( '[embed]%s[/embed]', $meta['media'] );
    393                     }
     376            if ( ! has_shortcode( $post->post_content, $format ) && ! empty( $meta['media'] ) ) {
     377                // the metadata is a shortcode or an embed code
     378                if ( preg_match( '/' . get_shortcode_regex() . '/s', $meta['media'] ) || preg_match( '#<[^>]+>#', $meta['media'] ) ) {
     379                    $format_output .= $meta['media'];
     380                } elseif ( ! stristr( $content, $meta['media'] ) ) {
     381                    // attempt to embed the URL
     382                    $format_output .= sprintf( '[embed]%s[/embed]', $meta['media'] );
    394383                }
    395384            }
Note: See TracChangeset for help on using the changeset viewer.