Sindbad~EG File Manager
<?php
/*** Widget code for Sermon ***/
class adore_core_sermon_list extends WP_Widget {
// constructor
public function __construct() {
$widget_ops = array('description' => __( "Display Sermons.", 'adorechurch-core') );
parent::__construct(false, $name = __('(N) Sermons','adorechurch-core'), $widget_ops);
}
// widget form creation
public function form($instance) {
// Check values
if( $instance) {
$title = esc_attr($instance['title']);
$number = esc_attr($instance['number']);
$category = esc_attr($instance['category']);
} else {
$title = '';
$number = '';
$category='';
}
?>
<p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title', 'adorechurch-core'); ?></label>
<input class="spTitle_<?php echo esc_attr($title); ?>" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('number')); ?>"><?php _e('Number of sermons to show', 'adorechurch-core'); ?></label>
<input class="spNumber_<?php echo esc_attr($number); ?>" id="<?php echo esc_attr($this->get_field_id('number')); ?>" name="<?php echo esc_attr($this->get_field_name('number')); ?>" type="text" value="<?php echo esc_attr($number); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('category')); ?>"><?php _e('Select Category', 'adorechurch-core'); ?></label>
<select class="spType_event_cat" id="<?php echo esc_attr($this->get_field_id('category')); ?>" name="<?php echo esc_attr($this->get_field_name('category')); ?>">
<option value=""><?php _e('All','adorechurch-core'); ?></option>
<?php
$post_terms = get_terms('sermon-category');
if(!empty($post_terms)){
foreach ($post_terms as $term) {
$term_name = $term->name;
$term_id = $term->slug;
$activePost = ($term_id == $category)? 'selected' : '';
echo '<option value="'. $term_id .'" '.$activePost.'>' . $term_name . '</p>';
}
}
?>
</select>
</p>
<?php
}
// update widget
public function update($new_instance, $old_instance) {
$instance = $old_instance;
// Fields
$instance['title'] = strip_tags($new_instance['title']);
$instance['number'] = strip_tags($new_instance['number']);
$instance['category'] = strip_tags($new_instance['category']);
return $instance;
}
// display widget
public function widget($args, $instance) {
$cache = array();
if ( ! $this->is_preview() ) {
$cache = wp_cache_get( 'sermon_list', 'widget' );
}
if ( ! is_array( $cache ) ) {
$cache = array();
}
if ( ! isset( $args['widget_id'] ) ) {
$args['widget_id'] = $this->id;
}
if ( isset( $cache[ $args['widget_id'] ] ) ) {
echo ''.$cache[ $args['widget_id'] ];
return;
}
ob_start();
extract( $args );
// these are the widget options
$post_title = apply_filters('widget_title', $instance['title']);
$number = apply_filters('widget_number', $instance['number']);
$numberEvent = (!empty($number))? $number : 4 ;
$category = apply_filters('widget-category', empty($instance['category']) ?'': $instance['category'], $instance, $this->id_base);
$type = apply_filters('widget-type', empty($instance['type']) ?'': $instance['type'], $instance, $this->id_base);
$EventHeading = (!empty($post_title))? $post_title : __('Recent Sermons','adorechurch-core') ;
$imic_options = get_option('imic_options');
$sermons_sorting = (isset($imic_options['sermons_sorting'])) ? $imic_options['sermons_sorting'] : '0';
echo ''.$args['before_widget'];
if( !empty($instance['title']) ){
echo ''.$args['before_title'];
echo ''.$args['after_title'];
}
$vimeo_video = $url = $video_code = '';
if ($sermons_sorting == 1)
{
$pargs = (array(
'post_type' => 'sermon',
'paged' => get_query_var('paged'),
'posts_per_page'=>$numberEvent,
'sermon-category'=> $category,
'orderby' => 'meta_value',
'meta_key' => 'imic_sermon_date',
'order' => 'DESC',
));
}
else
{
$pargs = (array(
'post_type' => 'sermon',
'paged' => get_query_var('paged'),
'posts_per_page'=>$numberEvent,
'sermon-category'=> $category,
));
}
$first = 1;
$query = new wp_query($pargs);
if ($query->have_posts())
{
echo '<ul>';
while ($query->have_posts())
{
$query->the_post();
$mp4_video = get_post_meta(get_the_ID(),'imic_mp4_video',false);
$webm_video = get_post_meta(get_the_ID(),'imic_webm_video',false);
$ogg_video = get_post_meta(get_the_ID(),'imic_ogg_video',false);
$vimeo_video = get_post_meta(get_the_ID(),'imic_vimeo_video',true);
$youtube_video = get_post_meta(get_the_ID(),'imic_youtube_video',true);
$post_author_id = get_post_meta(get_the_ID(),'imic_sermon_speaker',false);
$self_audio = get_post_meta(get_the_ID(),'imic_self_audio',true);
$download_pdf = get_post_meta(get_the_ID(),'imic_pdf_url',true);
$soundcloud_audio = get_post_meta(get_the_ID(),'imic_soundcloud_audio',true);
$sermon_date = get_post_meta(get_the_ID(),'imic_sermon_date',true);
if (defined('ADORECHURCH_CORE__PLUGIN_URL')) {
$download_directory = ADORECHURCH_CORE__PLUGIN_URL;
}
else
{
$download_directory = '';
}
if ( has_post_thumbnail(get_the_ID()) ) {
$post_thumbnail_id = get_post_thumbnail_id( get_the_ID() );
$url = wp_get_attachment_image_src( $post_thumbnail_id, '600x400' );
}
if($first==1) {
echo '<li class="most-recent-sermon clearfix">
<h3>'.apply_filters('widget_title',$EventHeading, $instance, $this->id_base).'</h3>
<hr class="sm">';
echo '<div class="latest-sermon-video fw-video format-standard">';
if($vimeo_video!=''||$youtube_video!=''||$url!='') {
if($vimeo_video!='') {
$video_code = imic_video_embed($vimeo_video,"500","281"); }
elseif($youtube_video!='') {
$video_code = imic_video_embed($youtube_video,"500","281"); }
else {
$video_code = '<a href="'.get_permalink().'" class="media-box"><img src="'.$url[0].'" alt="Media"></a>'; }
}
echo ''.$video_code.'';
echo '</div>';
echo '<div class="latest-sermon-content">
<h4><a href="'.get_permalink().'">'.get_the_title().'</a></h4>
<div class="meta-data">';
if($post_author_id){
echo __('by ','adorechurch-core');
$count = 1;
foreach($post_author_id as $speaker) {
$sep = ($count<count($post_author_id))?', ':'';
echo '<strong>'.get_the_title($speaker).$sep.'</strong>';
$count++;
}
}
if($sermon_date != ''){
$sermon_date = strtotime($sermon_date);
echo ' '.__('on','adorechurch-core') . ' ' . adorechurch_date_localization(get_option('date_format'),$sermon_date).'';
}
else {
echo ' '.__('on','adorechurch-core') . ' ' . esc_html(get_the_date(get_option('date_format'),get_the_ID())).'';
}
echo '</div>
'.imic_excerpt(8).'
</div>
<div class="sermon-links">
<ul class="action-buttons">';
if(!empty($mp4_video)||!empty($webm_video)||!empty($ogg_video)||!empty($vimeo_video)||!empty($youtube_video)) {
echo '<li><a href="'.get_permalink().'" data-toggle="tooltip" data-placement="right" data-original-title="'.__('Watch Video','adorechurch-core').'"><i class="icon-video-cam"></i></a></li>'; }
if($self_audio!=''||$soundcloud_audio!='') {
echo '<li><a href="'.get_permalink().'" data-toggle="tooltip" data-placement="right" data-original-title="'.__('Listen Audio','adorechurch-core').'"><i class="icon-headphones"></i></a></li>'; }
if($self_audio!='') {
echo '<li><a href="' . esc_attr($download_directory) . 'download/download.php?file='.$self_audio.'" data-toggle="tooltip" data-placement="right" data-original-title="'.__('Download Audio','adorechurch-core').'"><i class="icon-cloud-download"></i></a></li>'; }
if($download_pdf!='') {
echo '<li><a href="' . esc_attr($download_directory) . 'download/download.php?file=' . $download_pdf . '" data-toggle="tooltip" data-placement="right" data-original-title="'.__('Download PDF','adorechurch-core').'"><i class="icon-download-folder"></i></a></li>'; }
echo '</ul>
</div>
</li>'; } else {
echo '<li>
<a href="'.get_permalink().'"><strong class="post-title">'.get_the_title().'</strong></a>
<div class="meta-data">'.__('by ','adorechurch-core');
$count = 1;
foreach($post_author_id as $speaker) {
$sep = ($count<count($post_author_id))?', ':'';
echo '<strong>'.get_the_title($speaker).$sep.'</strong>';
$count++;
}
if($sermon_date != ''){
$sermon_date = strtotime($sermon_date);
echo ' '.__('on','adorechurch-core') . ' ' . adorechurch_date_localization(get_option('date_format'),$sermon_date).'';
}
else {
echo ' '.__('on','adorechurch-core') . ' ' . esc_html(get_the_date(get_option('date_format'),get_the_ID())).'';
}
echo '</div>
</li>'; }
$first++;
} echo '</ul>'; wp_reset_query();
} else {
_e('No Sermons Found','adorechurch-core');
}
echo ''.$args['after_widget'];
if ( ! $this->is_preview() ) {
$cache[ $args['widget_id'] ] = ob_get_flush();
wp_cache_set( 'adore_core_sermon_list', $cache, 'widget' );
} else {
ob_end_flush();
}
}
}
// register widget
add_action( 'widgets_init', function(){
register_widget( 'adore_core_sermon_list' );
});
?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists