<?php
/**
 * The template for displaying Image Posts
 *
 * @package Esquire
 * @since Esquire 1.0
 */

$audio_file = esquire_audio_grabber( $post->ID );
?>

<div <?php post_class(); ?>>
	<?php if ( ! is_page() ) : ?>
	<div class="datebox">
		<p class="day"><?php the_time( 'd' ); ?></p>
		<p class="month"><?php the_time( 'M' ); ?></p>
	</div>
	<?php endif; ?>

	<div class="postbody audio">
		<div class="content">
			<?php if ( has_post_thumbnail() ) :
			$album_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'audio' ); ?>
			<div class="artwork">
				<div class="overlay"></div>
				<img src="<?php echo $album_image[0]; ?>" width="207" height="207" alt="<?php esc_attr_e( 'Album Art', 'esquire' ); ?>" />
			</div>
			<?php endif; ?>

			<?php if ( ! empty( $audio_file ) ) : ?>
			<div class="player">
Example #2
0
    /**
     * Shiv for the_post_format_audio().
     *
     * the_post_format_audio() was introduced to WordPress in version 3.6. To
     * provide backward compatibility with previous versions, we will define our
     * own version of this function.
     *
     * @todo Remove this function when WordPress 3.8 is released.
     *
     * @param string $name The name of the shortcode.
     * @return bool True if shortcode exists; False otherwise.
     */
    function the_post_format_audio()
    {
        $audio = esquire_audio_grabber(get_the_ID());
        if (!empty($audio) && is_object($audio)) {
            $url = wp_get_attachment_url($audio->ID);
            ?>
		<div class="player">
			<audio controls preload="auto" autobuffer id="audio-player-<?php 
            the_ID();
            ?>
" src="<?php 
            echo esc_url($url);
            ?>
">
				<source src="<?php 
            echo esc_url($url);
            ?>
" type="<?php 
            echo esc_attr(get_post_mime_type($audio->ID));
            ?>
" />
			</audio>
			<p class="audio-file-link"><?php 
            printf(__('Download: %1$s', 'esquire'), sprintf('<a href="%1$s">%2$s</a>', esc_url($url), get_the_title($audio->ID)));
            ?>
</p>
		</div>
	<?php 
        }
    }