Created
June 22, 2018 17:33
-
-
Save marcelo2605/853c499b01a9084d9ce94d8f788e5357 to your computer and use it in GitHub Desktop.
Add an audio description with the audio player.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wp_audio_shortcode', function ($html, $atts, $audio, $post_id, $library) { | |
$media_id = attachment_url_to_postid($atts['mp3']); | |
if (0 !== $media_id) { | |
$content = get_post_field('post_content', $media_id); | |
$content = apply_filters('the_content', $content); | |
if (!empty($content)) { | |
$html = $html.'<div class="audio-description">'.$content.'</div>'; | |
} | |
} | |
return $html; | |
}, 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment