Skip to content

Instantly share code, notes, and snippets.

@farookibrahim
Created May 31, 2016 12:04
Show Gist options
  • Select an option

  • Save farookibrahim/1e28ae778348f1769dbd957c7e07c41d to your computer and use it in GitHub Desktop.

Select an option

Save farookibrahim/1e28ae778348f1769dbd957c7e07c41d to your computer and use it in GitHub Desktop.
Sermons Media Icons
if( ! function_exists( 'sermons_post_format_icons' ) ) {
function sermons_post_format_icons() {
$show_post_icons = apply_filters( 'show_sermons_post_icons', TRUE );
$enable_download = apply_filters( 'enable_sermons_download', TRUE );
$enable_audio = apply_filters( 'enable_sermons_audio', TRUE );
$enable_video = apply_filters( 'enable_sermons_video', TRUE );
if( $show_post_icons ) :
$post_format = get_post_format();
$audio_embed = get_post_meta( get_the_ID(), 'postformat_audio_embedded', TRUE);
$mp3 = get_post_meta( get_the_ID(), 'postformat_audio_mp3', TRUE);
$ogg = get_post_meta( get_the_ID(), 'postformat_audio_ogg', TRUE);
$video_embed = get_post_meta( get_the_ID(), 'postformat_video_embed', true);
$m4v = get_post_meta( get_the_ID(), 'postformat_video_m4v', TRUE);
$ogv = get_post_meta( get_the_ID(), 'postformat_video_ogv', TRUE);
$webm = get_post_meta( get_the_ID(), 'postformat_video_webm', TRUE);
if( empty( $audio_embed ) && empty( $mp3 ) && empty( $ogg ) ) {
$enable_audio = FALSE;
}
if( empty( $video_embed ) && empty( $m4v ) && empty( $ogv ) && empty( $webm ) ) {
$enable_video = FALSE;
}
$download_url = sermons_meta_media_url();
if( empty( $download_url ) ) {
if( ! empty( $mp3 ) ) {
$download_url = $mp3;
} elseif( ! empty( $ogg ) ) {
$download_url = $ogg;
} elseif ( ! empty( $m4v ) ) {
$download_url = $m4v;
} elseif( ! empty( $ogv ) ) {
$download_url = $ogv;
} elseif( ! empty( $webm ) ) {
$download_url = $webm;
}
}
if( empty( $download_url ) ) {
$enable_download = FALSE;
}
if( $enable_video || $enable_audio || $enable_download ) :
?>
<ul class="post-icons">
<?php if( $enable_video ) : ?>
<li>
<a href="#modal-sermon-media" role="button" class="sermon-video" data-modal-content-id="modal-content-video-<?php echo esc_attr( get_the_ID() );?>" data-toggle="modal" data-target="#modal-sermon-media">
<i class="fa fa-play"></i>
<span class="icon-info"><?php _e( 'Watch', 'bethlehem-extension' ); ?></span>
</a>
<div id="modal-content-video-<?php echo esc_attr( get_the_ID() );?>" class="modal-content-media hidden"><?php sermons_post_video(); ?></div>
</li>
<?php endif; ?>
<?php if( $enable_audio ) : ?>
<li>
<a href="#modal-sermon-media" role="button" class="sermon-audio" data-modal-content-id="modal-content-audio-<?php echo esc_attr( get_the_ID() );?>" data-toggle="modal" data-target="#modal-sermon-media">
<i class="fa fa-headphones"></i>
<span class="icon-info"><?php _e( 'Listen', 'bethlehem-extension' ); ?></span>
</a>
<div id="modal-content-audio-<?php echo esc_attr( get_the_ID() );?>" class="modal-content-media hidden"><?php sermons_post_audio();?></div>
</li>
<?php endif; ?>
<?php if( $enable_download ) : ?>
<li>
<a href="<?php echo esc_url( $download_url );?>" class="sermon-save" download><i class="fa fa-arrow-down"></i><span class="icon-info"><?php _e( 'Save as', 'bethlehem-extension' ); ?></span></a>
</li>
<?php endif; ?>
</ul>
<?php
endif;
endif;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment