@@ -315,18 +315,32 @@ function wpfc_sermon_media() {
315315 } elseif ( ! get_wpfc_sermon_meta ( 'sermon_video ' ) && ! get_wpfc_sermon_meta ( 'sermon_video_link ' ) && get_wpfc_sermon_meta ( 'sermon_audio ' ) ) {
316316 $ html = '' ;
317317 $ html .= '<div class="wpfc_sermon-audio cf"> ' ;
318- $ mp3_url = get_wpfc_sermon_meta ( 'sermon_audio ' );
319- $ attr = array (
320- 'src ' => $ mp3_url ,
321- 'preload ' => 'none '
322- );
323- $ html .= wp_audio_shortcode ( $ attr );
318+ $ html .= wpfc_render_audio ( get_wpfc_sermon_meta ( 'sermon_audio ' ) );
324319 $ html .= '</div> ' ;
325320
326321 return $ html ;
327322 }
328323}
329324
325+ /**
326+ * Renders the audio player
327+ *
328+ * @param string $url The URL of the audio file
329+ *
330+ * @return string Audio player HTML
331+ */
332+ function wpfc_render_audio ( $ url = '' ) {
333+ if ( ! is_string ( $ url ) || trim ( $ url ) === '' ) {
334+ return '' ;
335+ }
336+
337+ $ output = '<audio controls> ' ;
338+ $ output .= '<source src=" ' . $ url . '"> ' ;
339+ $ output .= '</audio> ' ;
340+
341+ return $ output ;
342+ }
343+
330344// legacy function
331345function wpfc_sermon_files () {
332346 do_action ( 'sermon_media ' );
@@ -336,12 +350,7 @@ function wpfc_sermon_files() {
336350function wpfc_sermon_audio () {
337351 $ html = '' ;
338352 $ html .= '<div class="wpfc_sermon-audio cf"> ' ;
339- $ mp3_url = get_wpfc_sermon_meta ( 'sermon_audio ' );
340- $ attr = array (
341- 'src ' => $ mp3_url ,
342- 'preload ' => 'none '
343- );
344- $ html .= wp_audio_shortcode ( $ attr );
353+ $ html .= wpfc_render_audio ( get_wpfc_sermon_meta ( 'sermon_audio ' ) );
345354 $ html .= '</div> ' ;
346355
347356 return $ html ;
@@ -368,7 +377,7 @@ function wpfc_sermon_attachments() {
368377 }
369378 }
370379 if ( get_wpfc_sermon_meta ( 'sermon_audio ' ) ) {
371- $ html .= '<a href=" ' . get_wpfc_sermon_meta ( 'sermon_audio ' ) . '" class="sermon-attachments"><span class="dashicons dashicons-media-audio"></span> ' . __ ( 'MP3 ' , 'sermon-manager ' ) . '</a> ' ;
380+ $ html .= '<a href=" ' . get_wpfc_sermon_meta ( 'sermon_audio ' ) . '" class="sermon-attachments"><span class="dashicons dashicons-media-audio" download="true" ></span> ' . __ ( 'MP3 ' , 'sermon-manager ' ) . '</a> ' ;
372381 }
373382 if ( get_wpfc_sermon_meta ( 'sermon_notes ' ) ) {
374383 $ html .= '<a href=" ' . get_wpfc_sermon_meta ( 'sermon_notes ' ) . '" class="sermon-attachments"><span class="dashicons dashicons-media-document"></span> ' . __ ( 'Notes ' , 'sermon-manager ' ) . '</a> ' ;
0 commit comments