Example #1
0
function imic_sermon($atts, $content = null)
{
    extract(shortcode_atts(array("number" => "", "title" => "", "category" => "", "column" => ""), $atts));
    $output = '';
    query_posts(array('post_type' => 'sermons', 'sermons-category' => $category, 'posts_per_page' => $number, 'orderby' => 'ID', 'order' => 'DESC'));
    if (have_posts()) {
        $output .= '<div class="col-md-' . $column . ' sermon-archive">';
        if (!empty($title)) {
            $output .= '<h2>' . $title . '</h2>';
        }
        ?>
        <!-- Sermons Listing -->
        <?php 
        while (have_posts()) {
            the_post();
            if ('' != get_the_post_thumbnail()) {
                $class = "col-md-8";
            } else {
                $class = "col-md-12";
            }
            $custom = get_post_custom(get_the_ID());
            $output .= '<article class="post sermon">
                        <header class="post-title">';
            $output .= '<div class="row">
      					<div class="col-md-9 col-sm-9">
            				<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
            $output .= '<span class="meta-data"><i class="fa fa-calendar"></i>' . __('Posted on ', 'framework') . get_the_time(get_option('date_format'));
            $output .= get_the_term_list(get_the_ID(), 'sermons-speakers', ' | Pastor: ', ', ', '');
            $output .= '</span>
                                         </div>';
            $output .= '<div class="col-md-3 col-sm-3 sermon-actions">';
            if (!empty($custom['imic_sermons_url'][0])) {
                $output .= '<a href="' . get_permalink() . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Video', 'framework') . '" rel="tooltip"><i class="fa fa-video-camera"></i></a>';
            }
            $attach_full_audio = imic_sermon_attach_full_audio(get_the_ID());
            if (!empty($attach_full_audio)) {
                $output .= '<a href="' . get_permalink() . '/#play-audio" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Audio', 'framework') . '" rel="tooltip"><i class="fa fa-headphones"></i></a>';
            }
            $output .= '<a href="' . get_permalink() . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Read online', 'framework') . '" rel="tooltip"><i class="fa fa-file-text-o"></i></a>';
            $attach_pdf = imic_sermon_attach_full_pdf(get_the_ID());
            if (!empty($attach_pdf)) {
                $output .= '<a href="' . get_template_directory_uri() . '/download/download.php?file=' . $attach_pdf . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Download PDF', 'framework') . '" rel="tooltip"><i class="fa fa-book"></i></a>';
            }
            $output .= '</div>
                 	</div>';
            $output .= '</header>
                        <div class="post-content">
                            <div class="row">';
            if (has_post_thumbnail()) {
                $output .= '<div class="col-md-4">
                                    <a href="' . get_permalink(get_the_ID()) . '" class="media-box">';
                $output .= get_the_post_thumbnail(get_the_ID(), 'full', array('class' => "img-thumbnail"));
                $output .= '</a></div>';
            }
            $output .= '<div class="' . $class . '">';
            $description = imic_excerpt(100);
            if (!empty($description)) {
                $output .= $description;
            }
            $output .= '<p><a href="' . get_permalink() . '" class="btn btn-primary">' . __('Continue reading ', 'framework') . '<i class="fa fa-long-arrow-right"></i></a></p>';
            $output .= '</div>
                            </div>
                        </div>
                    </article>';
        }
        $output .= '</div>';
    }
    wp_reset_query();
    return $output;
}
        $posts = get_posts(array('post_type' => 'sermons', 'sermons-category' => $sermons_cat, 'post_status' => 'publish', 'suppress_filters' => false, 'posts_per_page' => 1));
        if (!empty($posts[0]->ID)) {
            ?>
        <div class="notice-bar latest-sermon">
            <div class="container">
                <div class="row">
                    <div class="col-md-3 col-sm-4 hidden-xs">
                        <h3><i class="fa fa-microphone"></i> <?php 
            _e('Latest Sermon', 'framework');
            ?>
</h3>
                    </div>
                    <?php 
            foreach ($posts as $post) {
                $custom = get_post_custom(get_the_ID());
                $attach_full_audio = imic_sermon_attach_full_audio($post->ID);
                if (!empty($attach_full_audio)) {
                    echo '<div class="col-md-7 col-sm-8 col-xs-12">';
                    echo '<h5><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h5>, <span class="meta-data">' . get_the_time(get_option('date_format')) . '</span>';
                    echo '<audio class="audio-player" src="' . $attach_full_audio . '" type="audio/mp3" controls></audio>';
                    echo '</div>';
                } elseif (empty($attach_full_audio) && !empty($custom['imic_sermons_url'][0])) {
                    echo '<div class="col-md-7 col-sm-8 col-xs-12">';
                    echo '<a href="' . $custom['imic_sermons_url'][0] . '" data-rel="prettyPhoto" class="latest-sermon-play"><i class="fa fa-play-circle-o"></i></a>';
                    echo '<h3><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h3>';
                    echo '</div>';
                } else {
                    echo '<div class="col-md-7 col-sm-8 col-xs-12">';
                    echo '<h3><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h3>';
                    echo '</div>';
                }
function imic_podcast_add_item()
{
    global $post;
    $attach_full_audio = imic_sermon_attach_full_audio(get_the_ID());
    $audio = $attach_full_audio;
    $speaker = strip_tags(get_the_term_list($post->ID, 'sermons-speakers', '', ' &amp; ', ''));
    $series = strip_tags(get_the_term_list($post->ID, 'sermons-category', '', ', ', ''));
    // Sermon Topics
    $topics = wp_get_post_terms(get_the_ID(), 'sermons-tag');
    $topics = false;
    if ($topic_list && count($topic_list) > 0) {
        $c = 0;
        foreach ($topic_list as $t) {
            if ($c == 0) {
                $topics = esc_html($t->name);
                ++$c;
            } else {
                $topics .= ', ' . esc_html($t->name);
            }
        }
    }
    $post_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
    $post_image = $post_image ? $post_image['0'] : null;
    $audio_duration = get_post_meta($post->ID, 'imic_sermon_duration', 'true');
    if ($audio_duration == '') {
        $audio_duration = '0:00';
    }
    //zero if undefined
    $podcast_desc = get_post_meta($post->ID, 'imic_sermons_podcast_description', 'true');
    ?>
    
	<itunes:author><?php 
    echo esc_html($speaker);
    ?>
</itunes:author>
	<itunes:subtitle><?php 
    echo esc_html($series);
    ?>
</itunes:subtitle>
	<itunes:summary><?php 
    echo esc_html($podcast_desc);
    ?>
</itunes:summary>
	<?php 
    if ($post_image) {
        ?>
	<itunes:image href="<?php 
        echo $post_image;
        ?>
" />
	<?php 
    }
    ?>
	<?php 
    if ($enclosure == '') {
        ?>
		<enclosure url="<?php 
        echo $audio;
        ?>
" length="0" type="audio/mpeg"/>
	<?php 
    }
    ?>
	<itunes:duration><?php 
    echo esc_html($audio_duration);
    ?>
</itunes:duration>
	<?php 
    if ($topics) {
        ?>
		<itunes:keywords><?php 
        echo esc_html($topics);
        ?>
</itunes:keywords><?php 
    }
}
    $TotalPages = $TotalPages + 1;
}
if (!empty($sermonterms)) {
    foreach ($sermonterms as $sermonterms_data) {
        if ($count == $paginate && $catValue <= $perPage) {
            $paginate++;
            $catValue++;
            query_posts(array('post_type' => 'sermons', 'sermons-category' => $sermonterms_data->slug, 'posts_per_page' => -1));
            $imic_sermon_attach_full_audio_array = $imic_sermons_url_array = array();
            while (have_posts()) {
                the_post();
                $imic_sermons_url = get_post_meta(get_the_ID(), 'imic_sermons_url', true);
                if (!empty($imic_sermons_url)) {
                    array_push($imic_sermons_url_array, $imic_sermons_url);
                }
                $imic_sermon_attach_full_audio = imic_sermon_attach_full_audio(get_the_ID());
                if (!empty($imic_sermon_attach_full_audio)) {
                    array_push($imic_sermon_attach_full_audio_array, $imic_sermon_attach_full_audio);
                }
            }
            $term_link = get_term_link($sermonterms_data->slug, 'sermons-category');
            $t_id = $sermonterms_data->term_id;
            // Get the ID of the term we're editing
            $term_meta = get_option($sermonterms_data->taxonomy . $t_id . "_image_term_id");
            // Do the check
            echo '<div class="post">
<div class="row">
<div class="col-md-4 col-sm-4">';
            echo '<a href="' . $term_link . '" class="album-cover">
<span class="album-image"><img src="' . $term_meta . '" alt=""></span>
</a>';
    function widget($args, $instance)
    {
        global $wp_query;
        $temp_wp_query = clone $wp_query;
        extract($args);
        // these are the widget options
        $post_title = apply_filters('widget_title', $instance['title']);
        $number = apply_filters('widget_number', $instance['number']);
        $category = apply_filters('widget-category', empty($instance['category']) ? '' : $instance['category'], $instance, $this->id_base);
        $autoplay = isset($instance['autoplay']) ? $instance['autoplay'] : 0;
        $numberPost = !empty($number) ? $number : 3;
        echo $args['before_widget'];
        echo '<div class="listing sermons-listing">';
        if (!empty($instance['title'])) {
            echo '<header class="listing-header">';
            echo $args['before_title'];
            echo apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
            echo $args['after_title'];
            echo '</header>';
        }
        $posts = query_posts(array('order' => 'DESC', 'post_type' => 'sermons', 'sermons-category' => $category, 'posts_per_page' => $numberPost, 'post_status' => 'publish'));
        if (!empty($posts)) {
            echo '<section class="listing-cont">
					<ul>';
            $liFirst = $liOthers = '';
            $flag = 0;
            foreach ($posts as $post) {
                /* check if content has sortcode video */
                if (has_shortcode($post->post_content, 'fullscreenvideo')) {
                    apply_filters('the_content', $post->post_content);
                    $post->post_content = do_shortcode($post->post_content);
                } else {
                    $post->post_content = wp_trim_words($post->post_content, 30);
                }
                /* end check if content has sortcode video */
                $custom = get_post_custom($post->ID);
                if (!empty($custom['imic_sermons_url'][0]) && $flag == 0) {
                    $liFirst .= '<li class="item sermon featured-sermon">
                                    <span class="date">' . get_the_time(get_option('date_format'), $post->ID) . '</span>
                                    <h4><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h4>
                                    <div class="featured-sermon-video">' . imic_video_embed($custom['imic_sermons_url'][0], '200', '150', $autoplay) . '</div><p>' . $post->post_content . '</p><div class="sermon-actions">';
                    if (!empty($custom['imic_sermons_url'][0])) {
                        $liFirst .= '<a href="' . get_permalink($post->ID) . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Video', 'imic-framework-admin') . '"><i class="fa fa-video-camera"></i></a>';
                    }
                    $attach_full_audio = imic_sermon_attach_full_audio($post->ID);
                    if (!empty($attach_full_audio)) {
                        $liFirst .= '<a href="' . get_permalink($post->ID) . '#play-audio" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Audio', 'imic-framework-admin') . '"><i class="fa fa-headphones"></i></a>';
                    }
                    if (!empty($attach_full_audio)) {
                        $liFirst .= '<a href="' . get_template_directory_uri() . '/download/download.php?file=' . $attach_full_audio . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Download Audio', 'imic-framework-admin') . '"><i class="fa fa-download"></i></a>';
                    }
                    $attach_pdf = imic_sermon_attach_full_pdf($post->ID);
                    if (!empty($attach_pdf)) {
                        $liFirst .= '<a href="' . get_template_directory_uri() . '/download/download.php?file=' . $attach_pdf . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Download PDF', 'imic-framework-admin') . '"><i class="fa fa-book"></i></a>';
                    }
                    $liFirst .= '</div>
                                </li>';
                } else {
                    if (!empty($custom['imic_sermons_video_mp4'][0]) && $flag == 0) {
                        $liFirst .= '<li class="item sermon featured-sermon">
								<span class="date">' . get_the_time(get_option('date_format'), $post->ID) . '</span>
								<h4><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h4><div class="featured-sermon-video">';
                        $poster = '';
                        if (isset($custom['imic_sermons_video_poster'][0]) && !empty($custom['imic_sermons_video_poster'][0])) {
                            $poster = $custom['imic_sermons_video_poster'][0];
                        }
                        $liFirst .= '<div class="video-container">';
                        $liFirst .= '<video width="320" height="240" poster="' . $poster . '" controls preload="none" class="custom-video">';
                        if (isset($custom['imic_sermons_video_mp4'][0]) && !empty($custom['imic_sermons_video_mp4'][0])) {
                            $liFirst .= '<source type="video/mp4" src="' . $custom['imic_sermons_video_mp4'][0] . '" />';
                        }
                        if (isset($custom['imic_sermons_video_webm'][0]) && !empty($custom['imic_sermons_video_webm'][0])) {
                            $liFirst .= '<source type="video/webm" src="' . $custom['imic_sermons_video_webm'][0] . '" />';
                        }
                        if (isset($custom['imic_sermons_video_ogv'][0]) && !empty($custom['imic_sermons_video_ogv'][0])) {
                            $liFirst .= '<source type="video/ogg" src="' . $custom['imic_sermons_video_ogv'][0] . '" />';
                        }
                        $liFirst .= '<object width="320" height="240" type="application/x-shockwave-flash" data="flashmediaelement.swf">';
                        $liFirst .= '<param name="movie" value="' . get_template_directory_uri() . '/plugins/mediaelementflashmediaelement.swf" />';
                        if (isset($custom['imic_sermons_video_poster'][0]) && !empty($custom['imic_sermons_video_mp4'][0])) {
                            $liFirst .= '<param name="flashvars" value="controls=true&file=' . $custom['imic_sermons_video_mp4'][0] . '" />';
                        }
                        $liFirst .= '</object>';
                        $liFirst .= '</video>';
                        $liFirst .= '</div>' . '</div><p>' . $post->post_content . '</p><div class="sermon-actions">';
                        if (isset($custom['imic_sermons_url'][0]) && !empty($custom['imic_sermons_url'][0])) {
                            $liFirst .= '<a href="' . get_permalink($post->ID) . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Video', 'imic-framework-admin') . '"><i class="fa fa-video-camera"></i></a>';
                        }
                        $attach_full_audio = imic_sermon_attach_full_audio($post->ID);
                        if (!$attach_full_audio) {
                            $liFirst .= '<a href="' . get_permalink($post->ID) . '#play-audio" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Audio', 'imic-framework-admin') . '"><i class="fa fa-headphones"></i></a>';
                        }
                        if (!empty($attach_full_audio)) {
                            $liFirst .= '<a href="' . get_template_directory_uri() . '/download/download.php?file=' . $attach_full_audio . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Download Audio', 'imic-framework-admin') . '"><i class="fa fa-download"></i></a>';
                        }
                        $attach_pdf = imic_sermon_attach_full_pdf($post->ID);
                        if (!empty($attach_pdf)) {
                            $liFirst .= '<a href="' . get_template_directory_uri() . '/download/download.php?file=' . $attach_pdf . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Download PDF', 'imic-framework-admin') . '"><i class="fa fa-book"></i></a>';
                        }
                        $liFirst .= '</div>
									</li>';
                    } else {
                        if (has_post_thumbnail($post->ID) && $flag == 0) {
                            //get the featured image
                            $featured_image_url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
                            //end
                            $liFirst .= '<li class="item sermon featured-sermon">
								<span class="date">' . get_the_time(get_option('date_format'), $post->ID) . '</span>
								<h4><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h4>
								<div class="featured-sermon-video format-standard">' . '<a href="' . get_permalink($post->ID) . '" class="media-box"><img src="' . $featured_image_url . '" />' . '</a></div><p>' . $post->post_content . '</p><div class="sermon-actions">';
                            if (!empty($custom['imic_sermons_url'][0])) {
                                $liFirst .= '<a href="' . get_permalink($post->ID) . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Video', 'imic-framework-admin') . '"><i class="fa fa-video-camera"></i></a>';
                            }
                            $attach_full_audio = imic_sermon_attach_full_audio($post->ID);
                            if (!empty($attach_full_audio)) {
                                $liFirst .= '<a href="' . get_permalink($post->ID) . '#play-audio" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Audio', 'imic-framework-admin') . '"><i class="fa fa-headphones"></i></a>';
                            }
                            if (!empty($attach_full_audio)) {
                                $liFirst .= '<a href="' . get_template_directory_uri() . '/download/download.php?file=' . $attach_full_audio . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Download Audio', 'imic-framework-admin') . '"><i class="fa fa-download"></i></a>';
                            }
                            $attach_pdf = imic_sermon_attach_full_pdf($post->ID);
                            if (!empty($attach_pdf)) {
                                $liFirst .= '<a href="' . get_template_directory_uri() . '/download/download.php?file=' . $attach_pdf . '" data-placement="top" data-toggle="tooltip" data-original-title="' . __('Download PDF', 'imic-framework-admin') . '"><i class="fa fa-book"></i></a>';
                            }
                            $liFirst .= '</div>
									</li>';
                        } else {
                            $liOthers .= '<li class="item sermon">
                                    <h2 class="sermon-title"><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></h2>
                                    <span class="meta-data"><i class="fa fa-calendar"></i>' . __(' on ', 'imic-framework-admin') . get_the_time(get_option('date_format'), $post->ID) . '</span>
                                </li>';
                        }
                    }
                }
                $flag++;
            }
            echo $liFirst . $liOthers;
            echo '</ul></section>';
        } else {
            _e('No Sermon Found', 'imic-framework-admin');
        }
        echo '</div>';
        echo $args['after_widget'];
        $wp_query = clone $temp_wp_query;
    }