@@ -3468,9 +3468,10 @@ function wp_audio_shortcode( $attr, $content = '' ) {
34683468
34693469 $ primary = false ;
34703470 if ( ! empty ( $ atts ['src ' ] ) ) {
3471- $ type = wp_check_filetype ( $ atts ['src ' ], wp_get_mime_types () );
3471+ $ type = wp_check_filetype ( $ atts ['src ' ], wp_get_mime_types () );
3472+ $ has_extension = (bool ) pathinfo ( wp_parse_url ( $ atts ['src ' ], PHP_URL_PATH ), PATHINFO_EXTENSION );
34723473
3473- if ( ! in_array ( strtolower ( $ type ['ext ' ] ), $ default_types , true ) ) {
3474+ if ( $ has_extension && ! in_array ( strtolower ( $ type ['ext ' ] ), $ default_types , true ) ) {
34743475 return sprintf ( '<a class="wp-embedded-audio" href="%s">%s</a> ' , esc_url ( $ atts ['src ' ] ), esc_html ( $ atts ['src ' ] ) );
34753476 }
34763477
@@ -3567,17 +3568,21 @@ function wp_audio_shortcode( $attr, $content = '' ) {
35673568
35683569 $ html = sprintf ( '<audio %s controls="controls"> ' , implode ( ' ' , $ attr_strings ) );
35693570 $ fileurl = '' ;
3570- $ source = '<source type="%s" src="%s" /> ' ;
35713571
35723572 foreach ( $ default_types as $ fallback ) {
35733573 if ( ! empty ( $ atts [ $ fallback ] ) ) {
35743574 if ( empty ( $ fileurl ) ) {
35753575 $ fileurl = $ atts [ $ fallback ];
35763576 }
35773577
3578- $ type = wp_check_filetype ( $ atts [ $ fallback ], wp_get_mime_types () );
3579- $ url = add_query_arg ( '_ ' , $ instance , $ atts [ $ fallback ] );
3580- $ html .= sprintf ( $ source , $ type ['type ' ], esc_url ( $ url ) );
3578+ $ type = wp_check_filetype ( $ atts [ $ fallback ], wp_get_mime_types () );
3579+ $ url = add_query_arg ( '_ ' , $ instance , $ atts [ $ fallback ] );
3580+
3581+ if ( ! empty ( $ type ['type ' ] ) ) {
3582+ $ html .= sprintf ( '<source type="%s" src="%s" /> ' , $ type ['type ' ], esc_url ( $ url ) );
3583+ } else {
3584+ $ html .= sprintf ( '<source src="%s" /> ' , esc_url ( $ url ) );
3585+ }
35813586 }
35823587 }
35833588
@@ -3723,9 +3728,10 @@ function wp_video_shortcode( $attr, $content = '' ) {
37233728 $ is_youtube = ( preg_match ( $ yt_pattern , $ atts ['src ' ] ) );
37243729
37253730 if ( ! $ is_youtube && ! $ is_vimeo ) {
3726- $ type = wp_check_filetype ( $ atts ['src ' ], wp_get_mime_types () );
3731+ $ type = wp_check_filetype ( $ atts ['src ' ], wp_get_mime_types () );
3732+ $ has_extension = (bool ) pathinfo ( wp_parse_url ( $ atts ['src ' ], PHP_URL_PATH ), PATHINFO_EXTENSION );
37273733
3728- if ( ! in_array ( strtolower ( $ type ['ext ' ] ), $ default_types , true ) ) {
3734+ if ( $ has_extension && ! in_array ( strtolower ( $ type ['ext ' ] ), $ default_types , true ) ) {
37293735 return sprintf ( '<a class="wp-embedded-video" href="%s">%s</a> ' , esc_url ( $ atts ['src ' ] ), esc_html ( $ atts ['src ' ] ) );
37303736 }
37313737 }
@@ -3845,7 +3851,6 @@ function wp_video_shortcode( $attr, $content = '' ) {
38453851
38463852 $ html = sprintf ( '<video %s controls="controls"> ' , implode ( ' ' , $ attr_strings ) );
38473853 $ fileurl = '' ;
3848- $ source = '<source type="%s" src="%s" /> ' ;
38493854
38503855 foreach ( $ default_types as $ fallback ) {
38513856 if ( ! empty ( $ atts [ $ fallback ] ) ) {
@@ -3859,8 +3864,13 @@ function wp_video_shortcode( $attr, $content = '' ) {
38593864 } else {
38603865 $ type = wp_check_filetype ( $ atts [ $ fallback ], wp_get_mime_types () );
38613866 }
3862- $ url = add_query_arg ( '_ ' , $ instance , $ atts [ $ fallback ] );
3863- $ html .= sprintf ( $ source , $ type ['type ' ], esc_url ( $ url ) );
3867+ $ url = add_query_arg ( '_ ' , $ instance , $ atts [ $ fallback ] );
3868+
3869+ if ( ! empty ( $ type ['type ' ] ) ) {
3870+ $ html .= sprintf ( '<source type="%s" src="%s" /> ' , $ type ['type ' ], esc_url ( $ url ) );
3871+ } else {
3872+ $ html .= sprintf ( '<source src="%s" /> ' , esc_url ( $ url ) );
3873+ }
38643874 }
38653875 }
38663876
0 commit comments