/** * Get a short-form mime type for an audio file to display as a class attribute. * * @param int ID of an attachment * @return string A short representation of the file's mime type. */ function pinktouch_post_classes($classes) { if (has_post_format('audio')) { $audio = pinktouch_audio_grabber(get_the_ID()); if (!empty($audio) && is_object($audio)) { $mime = str_replace('audio/', '', get_post_mime_type($audio->ID)); if (in_array($mime, array('mp3', 'ogg', 'wav'))) { $classes[] = $mime; } } } return $classes; }
<?php /** * @package WordPress * @subpackage Pink Touch 2 */ $audio_file = pinktouch_audio_grabber( $post->ID ); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="date"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'pinktouch' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"> <?php if ( ! is_singular() && is_sticky() ) : ?> <p><?php _e( 'Featured', 'pinktouch' ); ?></p> <?php else : ?> <p><span class="day"><?php the_time( 'd' ); ?></span><?php the_time( 'M / Y' ); ?></p> <?php endif; ?> </a> </div> <div class="content"> <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'pinktouch' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1> <div class="entry-content"> <?php if ( ! empty( $audio_file ) ) : ?> <div class="player"> <audio controls autobuffer id="audio-player-<?php echo $post->ID; ?>" src="<?php echo $audio_file; ?>"> <source src="<?php echo $audio_file; ?>" type="audio/mp3" /> </audio> <script type="text/javascript"> var audioTag = document.createElement( 'audio' );