Exemplo n.º 1
0
function parse_tm_related_post_func($atts, $content)
{
    $title = isset($atts['title']) ? $atts['title'] : '';
    $postformat = isset($atts['postformat']) ? $atts['postformat'] : '';
    $posttypes = isset($atts['posttypes']) ? $atts['posttypes'] : 'post';
    $count = isset($atts['count']) ? $atts['count'] : '';
    $tags = isset($atts['tag']) ? $atts['tag'] : '';
    $orderby = isset($atts['orderby']) ? $atts['orderby'] : '';
    if (function_exists('ot_get_option')) {
        $themes_pur = ot_get_option('theme_purpose');
    }
    if (function_exists('ot_get_option')) {
        $layout_ct_video = ot_get_option('single_layout_ct_video');
        if ($layout_ct_video != 'full') {
            $count = '4';
        } else {
            $count = '6';
        }
    }
    if (class_exists('CT_ContentHelper')) {
        $item_loop_video = new CT_ContentHelper();
        $the_query = $item_loop_video->tm_get_related_posts($posttypes, $tags, $postformat, $count, $orderby, $args = array());
        $thumb = 'thumb_196x126';
        $show_title = 1;
        $show_meta = $show_exceprt = 0;
        $item_video = new CT_ContentHtml();
        if ($the_query->have_posts()) {
            $html = '
			<div class="smart-box smart-box-style-2 is-carousel" >';
            $html .= '<div class="smart-box-head">
			<h2 class="light-title">' . $title . '</h2>
			</div>
			<div class="smart-box-content">
				<div class="smart-item">
					<div class="row">
			';
            while ($the_query->have_posts()) {
                $the_query->the_post();
                if ($layout_ct_video != 'full') {
                    $html .= '
					<div class="col-md-3 col-sm-6 col-xs-6">';
                } else {
                    $html .= '
					<div class="col-md-2 col-sm-6 col-xs-6">';
                }
                $html .= $item_video->get_item_medium_video($thumb, $show_title, $show_exceprt, $show_meta, $themes_pur);
                $html .= '</div>';
            }
            $html .= '</div>
				</div>
			</div>
		</div>
		<div class="clear"></div>
		';
        }
        wp_reset_query();
        return $html;
    }
}
    function widget($args, $instance)
    {
        wp_enqueue_script('jquery-isotope');
        $cache = wp_cache_get('widget_related_videos', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($argsxx['widget_id'])) {
            $argsxx['widget_id'] = $this->id;
        }
        if (isset($cache[$argsxx['widget_id']])) {
            echo $cache[$argsxx['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $tags = empty($instance['tags']) ? '' : $instance['tags'];
        $postformat = empty($instance['postformat']) ? '' : $instance['postformat'];
        $title = empty($instance['title']) ? '' : $instance['title'];
        $title = apply_filters('widget_title', $title);
        $orderby = empty($instance['sortby']) ? '' : $instance['sortby'];
        $count = empty($instance['count']) ? '' : $instance['count'];
        $posttypes = 'post';
        if (function_exists('ot_get_option')) {
            $themes_pur = ot_get_option('theme_purpose');
        }
        if ($themes_pur == '0') {
            $postformat = '';
        }
        if (is_single()) {
            if ($tags == '') {
                $tag = '';
                $posttags = get_the_tags();
                if ($posttags) {
                    foreach ($posttags as $tag) {
                        $tags .= ',' . $tag->slug;
                    }
                    $tags = substr($tags, 1);
                }
            }
        }
        $item_loop_video = new CT_ContentHelper();
        $the_query = $item_loop_video->tm_get_related_posts($posttypes, $tags, $postformat, $count, $orderby, $args = array());
        //$the_query = new WP_Query($args);
        $html = $before_widget;
        if ($title) {
            $html .= $before_title . $title . $after_title;
        }
        if ($the_query->have_posts()) {
            $html .= '
                <div class="widget-content">
				<div class="list-rating-item row">
			';
            $item_video = new CT_ContentHtml();
            $i = 0;
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $i++;
                $html .= $item_video->get_item_related($postformat, $themes_pur);
            }
            $html .= '</div>
			</div>';
        }
        $html .= $after_widget;
        if (is_singular('post') && $tags != '') {
            echo $html;
        }
        wp_reset_postdata();
        $cache[$argsxx['widget_id']] = ob_get_flush();
        wp_cache_set('widget_popular_videos', $cache, 'widget');
    }
    function widget($args, $instance)
    {
        wp_enqueue_script('jquery-isotope');
        $cache = wp_cache_get('widget_popular_videos', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($argsxx['widget_id'])) {
            $argsxx['widget_id'] = $this->id;
        }
        if (isset($cache[$argsxx['widget_id']])) {
            echo $cache[$argsxx['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $conditions = empty($instance['conditions']) ? '' : $instance['conditions'];
        $show_likes = empty($instance['show_likes']) ? '' : $instance['show_likes'];
        $show_com = empty($instance['show_com']) ? '' : $instance['show_com'];
        $show_view = empty($instance['show_view']) ? '' : $instance['show_view'];
        $show_rate = empty($instance['show_rate']) ? '' : $instance['show_rate'];
        $show_excerpt = empty($instance['show_excerpt']) ? '' : $instance['show_excerpt'];
        $num_ex = empty($instance['num_ex']) ? '' : $instance['num_ex'];
        $ids = empty($instance['ids']) ? '' : $instance['ids'];
        $title = empty($instance['title']) ? '' : $instance['title'];
        $title = apply_filters('widget_title', $title);
        $link = empty($instance['link']) ? '' : $instance['link'];
        $sort_by = empty($instance['sort_by']) ? '' : $instance['sort_by'];
        $number = empty($instance['number']) ? '' : $instance['number'];
        $thumb = empty($instance['thumb']) ? '' : $instance['thumb'];
        $thumb_w = empty($instance['thumb_w']) ? '' : $instance['thumb_w'];
        $thumb_h = empty($instance['thumb_h']) ? '' : $instance['thumb_h'];
        $cates = empty($instance['cats']) ? '' : $instance['cats'];
        if ($link != '') {
            $before_title .= '<a href=' . $link . '>';
            $after_title = '</a>' . $after_title;
        }
        if (function_exists('ot_get_option')) {
            $themes_pur = ot_get_option('theme_purpose');
        }
        if ($conditions == 'most_liked' && $ids == '' && class_exists('CT_ContentHelper')) {
            global $wpdb;
            $show_count = 1;
            $time_range = 'all';
            //$show_type = $instance['show_type'];
            $order_by = 'ORDER BY like_count DESC, post_title';
            if ($number > 0) {
                $limit = "LIMIT " . $number;
            }
            $widget_data = $before_widget;
            $widget_data .= $before_title . $title . $after_title;
            $show_excluded_posts = get_option('wti_like_post_show_on_widget');
            $excluded_post_ids = explode(',', get_option('wti_like_post_excluded_posts'));
            if (!$show_excluded_posts && count($excluded_post_ids) > 0) {
                $where = "AND post_id NOT IN (" . get_option('wti_like_post_excluded_posts') . ")";
            }
            //getting the most liked posts
            $query = "SELECT post_id, SUM(value) AS like_count, post_title FROM `{$wpdb->prefix}wti_like_post` L, {$wpdb->prefix}posts P ";
            $query .= "WHERE L.post_id = P.ID AND post_status = 'publish' AND value > -1 {$where} GROUP BY post_id {$order_by} {$limit}";
            $posts = $wpdb->get_results($query);
            $item_loop_video = new CT_ContentHtml();
            $cates_ar = $cates;
            if (count($posts) > 0) {
                $widget_data .= '
			<div class="widget-content">
					<div class="list-rating-item row">';
                foreach ($posts as $post) {
                    $cat_cur = get_the_category($post->post_id);
                    $cat_s = $cat_cur[0]->cat_ID;
                    $p_data = $excerpt = '';
                    $post_title = stripslashes($post->post_title);
                    $permalink = get_permalink($post->post_id);
                    $like_count = $post->like_count;
                    $p_data = get_post($post->post_id);
                    $excerpt = strip_tags($p_data->post_content);
                    $excerpt = wp_trim_words($excerpt, $num_ex, $more = '');
                    if ($cates != '') {
                        foreach ($cates_ar as $categs) {
                            if ($categs == $cat_s) {
                                $widget_data .= $item_loop_video->tm_likes_html($post, $like_count, $themes_pur, $show_likes, $show_com, $show_rate, $show_view, $show_excerpt, $excerpt);
                            }
                        }
                    } else {
                        $widget_data .= $item_loop_video->tm_likes_html($post, $like_count, $themes_pur, $show_likes, $show_com, $show_rate, $show_view, $show_excerpt, $excerpt);
                    }
                }
                //$widget_data .= $show_count == '1' ? ' ('.$like_count.')' : '';
                $widget_data .= '</div>
			</div>';
            }
            $widget_data .= $after_widget;
            echo $widget_data;
            wp_reset_postdata();
            $cache[$argsxx['widget_id']] = ob_get_flush();
            wp_cache_set('widget_trending_videos', $cache, 'widget');
        } else {
            if (class_exists('CT_ContentHelper')) {
                $item_loop_video = new CT_ContentHelper();
                $tag = $categories = '';
                if ($ids == '') {
                    $categories = $cates;
                }
                $the_query = $item_loop_video->tm_get_popular_posts($conditions, $tag, $number, $ids, $sort_by, $categories, $args = array(), $themes_pur);
                //			if(count($cats) > 0){
                //				$args = array('category__in' => $cats, 'showposts' => $number);
                //			}
                $html = $before_widget;
                if ($title) {
                    $html .= $before_title . $title . $after_title;
                }
                if ($the_query->have_posts()) {
                    $html .= '
					<div class="widget-content">
					<div class="list-rating-item row">
				';
                    $i = 0;
                    $item_video = new CT_ContentHtml();
                    while ($the_query->have_posts()) {
                        $the_query->the_post();
                        $i++;
                        $excerpt = get_the_excerpt();
                        $excerpt = wp_trim_words($excerpt, $num_ex, $more = '');
                        $html .= $item_video->get_item_video_trending($conditions, $themes_pur, $show_likes, $show_com, $show_rate, $show_view, $show_excerpt, $excerpt);
                    }
                    $html .= '</div>
				</div>';
                }
                $html .= $after_widget;
                echo $html;
                wp_reset_postdata();
                $cache[$argsxx['widget_id']] = ob_get_flush();
                wp_cache_set('widget_popular_videos', $cache, 'widget');
            }
        }
    }
Exemplo n.º 4
0
function parse_tm_cat_videos_func($atts, $content)
{
    $condition = isset($atts['condition']) ? $atts['condition'] : '';
    $count = isset($atts['count']) ? $atts['count'] : -1;
    $categories = isset($atts['categories']) ? $atts['categories'] : '';
    if ($condition == 'likes' && class_exists('CT_ContentHelper')) {
        $atts = array();
        global $wpdb;
        $show_count = 1;
        $time_range = 'all';
        //$show_type = $instance['show_type'];
        $order_by = 'ORDER BY like_count DESC, post_title';
        if ($count > 0) {
            $limit = "LIMIT " . $count;
        }
        $show_excluded_posts = get_option('wti_like_post_show_on_widget');
        $excluded_post_ids = explode(',', get_option('wti_like_post_excluded_posts'));
        if (!$show_excluded_posts && count($excluded_post_ids) > 0) {
            $where = "AND post_id NOT IN (" . get_option('wti_like_post_excluded_posts') . ")";
        }
        //getting the most liked posts
        $query = "SELECT post_id, SUM(value) AS like_count, post_title FROM `{$wpdb->prefix}wti_like_post` L, {$wpdb->prefix}posts P ";
        $query .= "WHERE L.post_id = P.ID AND post_status = 'publish' AND value > 0 {$where} GROUP BY post_id {$order_by} {$limit}";
        $posts = $wpdb->get_results($query);
        $item_loop_video = new CT_ContentHtml();
        $widget_data = '
				<div id="top-carousel" class="cat-carousel">
					 <div class="container">
						<div class="is-carousel" id="top1">
							<div class="carousel-content">';
        if (count($posts) > 0) {
            foreach ($posts as $post) {
                $post_title = stripslashes($post->post_title);
                $permalink = get_permalink($post->post_id);
                $like_count = $post->like_count;
                $widget_data .= $item_loop_video->tm_likes_cat_html($post, $like_count);
            }
        }
        $widget_data .= '
						</div><!--/carousel-content-->
						<div class="carousel-button">
							<a href="#" class="prev maincolor1 bordercolor1 bgcolor1hover"><i class="fa fa-chevron-left"></i></a>
							<a href="#" class="next maincolor1 bordercolor1 bgcolor1hover"><i class="fa fa-chevron-right"></i></a>
						</div><!--/carousel-button-->
					</div><!--/is-carousel-->
					</div>
			</div>';
        wp_reset_query();
        return $widget_data;
    } else {
        if (class_exists('CT_ContentHelper')) {
            $item_video1 = new CT_ContentHelper();
            $the_query = $item_video1->tm_get_popular_posts($condition, $tags, $count, $ids, $sort_by, $categories, $args = array());
            $num_item = count($the_query->posts);
            $html = '
			<div id="top-carousel" class="cat-carousel">
				 <div class="container">
					<div class="is-carousel" id="top1">
						<div class="carousel-content">';
            if ($the_query->have_posts()) {
                while ($the_query->have_posts()) {
                    $the_query->the_post();
                    $html .= '   
							<div class="video-item">
								<div class="item-thumbnail">
									<a href="' . get_permalink() . '" title="' . get_the_title() . '">';
                    if (has_post_thumbnail()) {
                        $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumb_196x126', true);
                    } else {
                        $thumbnail[0] = function_exists('tm_get_default_image') ? tm_get_default_image() : '';
                    }
                    $html .= '
									<img src="' . $thumbnail[0] . '" alt="' . the_title_attribute('echo=0') . '" title="' . the_title_attribute('echo=0') . '">
										<div class="link-overlay fa fa-play"></div>
									</a>
									' . tm_post_rating(get_the_ID()) . '
									<div class="item-head">
										<h3><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h3>
									</div>
								</div>
							</div>';
                }
            }
            $html .= '
						</div><!--/carousel-content-->
						<div class="carousel-button">
							<a href="#" class="prev maincolor1 bordercolor1 bgcolor1hover"><i class="fa fa-chevron-left"></i></a>
							<a href="#" class="next maincolor1 bordercolor1 bgcolor1hover"><i class="fa fa-chevron-right"></i></a>
						</div><!--/carousel-button-->
					</div><!--/is-carousel-->
					</div>
			</div>';
            wp_reset_query();
            return $html;
        }
    }
}
Exemplo n.º 5
0
function parse_smart_content_func($atts, $content)
{
    $title = isset($atts['title']) ? $atts['title'] : '';
    $ids = isset($atts['ids']) ? $atts['ids'] : '';
    $column = isset($atts['column']) ? $atts['column'] : '';
    $row = isset($atts['row']) ? $atts['row'] : '1';
    $layout = isset($atts['layout']) ? $atts['layout'] : '';
    $condition = isset($atts['condition']) ? $atts['condition'] : '';
    $number = isset($atts['count']) ? $atts['count'] : '1';
    $url_viewall = isset($atts['url_viewall']) ? $atts['url_viewall'] : '';
    $categories = isset($atts['categories']) ? $atts['categories'] : '';
    $sort_by = isset($atts['order']) ? $atts['order'] : 'DESC';
    $tags = isset($atts['tags']) ? $atts['tags'] : '';
    $label = isset($atts['label']) ? $atts['label'] : '';
    $show_title = isset($atts['show_title']) ? $atts['show_title'] : '';
    $show_exceprt = isset($atts['show_exceprt']) ? $atts['show_exceprt'] : '';
    $show_rate = isset($atts['show_rate']) ? $atts['show_rate'] : '';
    $show_dur = isset($atts['show_dur']) ? $atts['show_dur'] : '';
    $show_view = isset($atts['show_view']) ? $atts['show_view'] : '';
    $show_com = isset($atts['show_com']) ? $atts['show_com'] : '';
    $show_like = isset($atts['show_like']) ? $atts['show_like'] : '';
    $show_aut = isset($atts['show_aut']) ? $atts['show_aut'] : '';
    $show_date = isset($atts['show_date']) ? $atts['show_date'] : '';
    $number_excerpt = isset($atts['number_excerpt']) ? $atts['number_excerpt'] : 55;
    $quick_view = isset($atts['quick_view']) ? $atts['quick_view'] : 'def';
    if ($number_excerpt == '') {
        $number_excerpt = apply_filters('excerpt_length', $number_excerpt, 1);
    }
    $num_r = '';
    if (function_exists('ot_get_option')) {
        $themes_pur = ot_get_option('theme_purpose');
    }
    if ($row == '') {
        $row = 1;
    }
    if ($layout == 'grid') {
        if ($column == 2) {
            $count = $number * 1;
        } else {
            if ($column == 4) {
                $count = $number * 5;
            } else {
                if ($column == 6) {
                    $count = $number * 9;
                }
            }
        }
    } else {
        if ($layout == 'small_carousel') {
            $num_r = $row * $column;
            if ($column == 2) {
                $count = $number * 2 * $row;
            } else {
                if ($column == 4) {
                    $count = $number * 4 * $row;
                } else {
                    if ($column == 6) {
                        $count = $number * 6 * $row;
                    }
                }
            }
        } else {
            if ($layout == 'medium_carousel' || $layout == 'medium_carousel_2') {
                if ($column == 2) {
                    $count = $number * 1 * $row;
                    $num_r = $row * 1;
                } else {
                    if ($column == 4) {
                        $count = $number * 2 * $row;
                        $num_r = $row * 2;
                    } else {
                        if ($column == 6) {
                            $count = $number * 3 * $row;
                            $num_r = $row * 3;
                        }
                    }
                }
            } else {
                if ($layout == 'single') {
                    $count = $number * $row;
                }
            }
        }
    }
    //if(){ $count=$number;}
    if (class_exists('Mobile_Detect')) {
        $detect = new Mobile_Detect();
        $_device_ = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'mobile' : 'pc';
        $animation_class = isset($atts['animation']) && $_device_ == 'pc' ? 'wpb_' . $atts['animation'] . ' wpb_animate_when_almost_visible' : '';
    } else {
        $animation_class = isset($atts['animation']) ? 'wpb_' . $atts['animation'] . ' wpb_animate_when_almost_visible' : '';
    }
    if (class_exists('CT_ContentHelper')) {
        $item_video1 = new CT_ContentHelper();
        $the_query = $item_video1->tm_get_popular_posts($condition, $tags, $count, $ids, $sort_by, $categories, $args = array(), $themes_pur);
        $num_item = count($the_query->posts);
        $html = '
			<div class="smart-box ';
        $id = rand();
        if ($layout == 'grid') {
            $html .= 'smart-box-style-1 is-carousel" id="' . $id . '"';
        } else {
            if ($layout == 'small_carousel') {
                $html .= 'smart-box-style-2 is-carousel" id="' . $id . '"';
            } else {
                if ($layout == 'medium_carousel') {
                    $html .= 'smart-box-style-3 is-carousel" id="' . $id . '"';
                } else {
                    if ($layout == 'medium_carousel_2') {
                        $html .= 'smart-box-style-3 smart-box-style-3-2 is-carousel" id="' . $id . '" data-pagi="pagi-' . $id . '"';
                    } else {
                        if ($layout == 'single') {
                            $html .= 'smart-box-style-4 is-carousel" id="' . $id . '"';
                        }
                    }
                }
            }
        }
        $html .= '>';
        $border_h = '';
        $class_cssit = '';
        if ($layout != 'grid') {
            $class_cssit = 'it-row';
        }
        if ($the_query->have_posts()) {
            if ($title == '' && $url_viewall == '' && $number == '1') {
                $border_h = 'style="border:0"';
            }
            if ($layout != 'medium_carousel_2') {
                $html .= '<div class="smart-box-head" ' . $border_h . '>';
                if ($number == 1) {
                    $html .= '<h2 class="light-title title">' . $title . '</h2>';
                } else {
                    if ($url_viewall != '') {
                        $html .= '<h2 class="light-title title"><a class="title-link" href="' . $url_viewall . '">' . $title . '</a></h2>';
                    } else {
                        $html .= '<h2 class="light-title title">' . $title . '</h2>';
                    }
                }
                $html .= '<div class="smart-control pull-right">
					<a class="prev maincolor2 bordercolor2 bgcolor2hover" href="#" style="display: inline-block;"><i class="fa fa-angle-left"></i></a>
					<a class="next maincolor2 bordercolor2 bgcolor2hover" href="#" style="display: inline-block;"><i class="fa fa-angle-right"></i></a>';
                if ($url_viewall != '' && $number == 1 && $label == '') {
                    $html .= '	
					<a href="' . $url_viewall . '" class="bordercolor2 bgcolor2hover">' . __('View all', 'cactusthemes') . '</a>';
                } else {
                    if ($url_viewall != '' && $number == 1 && $label != '') {
                        $html .= '	
					<a href="' . $url_viewall . '" class="bordercolor2 bgcolor2hover">' . $label . '</a>';
                    }
                }
                $html .= '</div>
			</div>';
            }
            $html .= '<div class="smart-box-content">';
            if ($layout != 'medium_carousel_2') {
                $html .= '<div class="smart-item ' . $class_cssit . '">
					<div class="row">';
            }
            $item_video = new CT_ContentHtml();
            $item = 0;
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $item++;
                $html .= $item_video->get_all_item_video($item, $num_item, $column, $layout, $show_title, $show_exceprt, $show_rate, $show_dur, $show_view, $show_com, $show_like, $show_aut, $show_date, $themes_pur, $num_r, $number, $row, $class_cssit, $number_excerpt, $quick_view);
            }
            $html .= '</div>';
            if ($layout == 'medium_carousel_2') {
                $html .= '<div class="carousel-dotted" id="pagi-' . $id . '"></div>
				';
            }
            $html .= '</div>';
            $html .= '<div class="clear"></div>';
        }
        wp_reset_query();
        return $html;
    }
}
Exemplo n.º 6
0
function parse_featured_content_func($atts, $content)
{
    $title = isset($atts['title']) ? $atts['title'] : '';
    $condition = isset($atts['condition']) ? $atts['condition'] : '';
    $count = isset($atts['count']) ? $atts['count'] : '6';
    $categories = isset($atts['categories']) ? $atts['categories'] : '';
    $sort_by = isset($atts['order']) ? $atts['order'] : 'DESC';
    $show_title = isset($atts['show_title']) ? $atts['show_title'] : '';
    $show_exceprt = isset($atts['show_exceprt']) ? $atts['show_exceprt'] : '';
    $show_rate = isset($atts['show_rate']) ? $atts['show_rate'] : '';
    $show_dur = isset($atts['show_dur']) ? $atts['show_dur'] : '';
    $show_view = isset($atts['show_view']) ? $atts['show_view'] : '';
    $show_com = isset($atts['show_com']) ? $atts['show_com'] : '';
    $show_like = isset($atts['show_like']) ? $atts['show_like'] : '';
    $show_aut = isset($atts['show_aut']) ? $atts['show_aut'] : '';
    $show_date = isset($atts['show_date']) ? $atts['show_date'] : '';
    $number_excerpt = isset($atts['number_excerpt']) ? $atts['number_excerpt'] : 55;
    if ($number_excerpt == '') {
        $number_excerpt = apply_filters('excerpt_length', $number_excerpt, 1);
    }
    if (function_exists('ot_get_option')) {
        $themes_pur = ot_get_option('theme_purpose');
    }
    if (class_exists('CT_ContentHelper')) {
        ob_start();
        $contenthelper = new CT_ContentHelper();
        //$num_item = count($featured_query->posts);
        $contenthtml = new CT_ContentHtml();
        $categories_array = explode(',', $categories);
        ?>
        <div class="featured-content-box">
        	<div class="featured-content-box-inner">
            	<div class="featured-box-heading bgcolor2">
                	<h3 class="featured-box-title pull-left"><?php 
        echo $title;
        ?>
</h3>
                	<div class="featured-tabs pull-right hidden-xs">
                    	<ul class="list-inline">
                        <?php 
        $tab_count = 1;
        if ($categories) {
            foreach ($categories_array as $category) {
                // get category name
                $category_name = '';
                if (is_numeric($category)) {
                    $category_name = get_cat_name($category);
                } else {
                    $cat = get_category_by_slug($category);
                    if ($cat) {
                        $category_name = $cat->name;
                    }
                }
                echo '<li class="' . ($tab_count == 1 ? 'active' : '') . '"><a class="featured-tab" href="#' . $category . '" data-toggle="tab">' . $category_name . '</a></li>';
                $tab_count++;
            }
            $categories_array[] = '__allcat_hidden';
        } else {
            $categories_array = array('__allcat');
        }
        ?>
                        </ul>
                    </div>
                    <div class="clearfix"></div>
                </div><!--/featured-box-heading-->
                <div class="tab-content featured-box-content">
                <?php 
        foreach ($categories_array as $category) {
            $category_to_query = $category == '__allcat' ? '' : ($category == '__allcat_hidden' ? $categories : $category);
            $featured_query = $contenthelper->tm_get_popular_posts($condition, $tags, $count, $ids, $sort_by, $category_to_query, $args = array(), $themes_pur);
            $html_carousel = '';
            ?>
                	<div class="tab-pane fade featured-box-tab <?php 
            echo $category == $categories_array[0] ? 'in active' : '';
            echo $category == '__allcat_hidden' ? ' visible-xs in active' : ($category == '__allcat' ? '' : ' hidden-xs');
            ?>
" id="<?php 
            echo $category;
            ?>
">
                  		<div class="featured-box-tab-inner">
                            <div class="row">
                            	<div class="featured-control-col col-md-4 col-sm-4">
                                	<ul class="featured-control" data-id="<?php 
            echo $category;
            ?>
" >
                                        <?php 
            $featured_count = 0;
            while ($featured_query->have_posts()) {
                $featured_query->the_post();
                echo '<li><a class="item-cat-' . $category . ' item-cat-' . $category . '-' . $featured_count . ' ' . ($featured_count == 0 ? 'selected' : '') . '" data-pos=' . $featured_count . ' href="#">' . get_the_title() . '</a></li>';
                $html_carousel .= $contenthtml->get_item_medium_video($thumb = 'thumb_520x293', $show_title, $show_exceprt, $show_rate, $show_dur, $show_view, $show_com, $show_like, $show_aut, $show_date, $themes_pur, $number_excerpt);
                $featured_count++;
            }
            wp_reset_postdata();
            ?>
                                    </ul>
                                </div>
                                <div class="featured-carousel-col col-md-8 col-sm-8">
                                	<div class="featured-box-carousel is-carousel" data-pagi="pagi-<?php 
            echo $category;
            ?>
">
                                    	<div data-id="<?php 
            echo $category;
            ?>
" class="featured-box-carousel-content">
                                    	<?php 
            echo $html_carousel;
            ?>
                                        </div>
                                        <div id="pagi-<?php 
            echo $category;
            ?>
" class="carousel-pagination"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                	</div><!--featured-box-tab-->
                    <?php 
        }
        ?>
                </div>
            </div>
        </div><!--/featured-content-box-->
        <?php 
        $output_string = ob_get_contents();
        ob_end_clean();
        return $output_string;
    }
}
    function widget($args, $instance)
    {
        wp_enqueue_script('jquery-isotope');
        $cache = wp_cache_get('widget_trending_videos', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($argsxx['widget_id'])) {
            $argsxx['widget_id'] = $this->id;
        }
        if (isset($cache[$argsxx['widget_id']])) {
            echo $cache[$argsxx['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $conditions = empty($instance['conditions']) ? '' : $instance['conditions'];
        $title = empty($instance['title']) ? '' : $instance['title'];
        $title = apply_filters('widget_title', $title);
        $number = empty($instance['number']) ? '' : $instance['number'];
        $timerange = empty($instance['timerange']) ? '' : $instance['timerange'];
        $show_likes = empty($instance['show_likes']) ? '' : $instance['show_likes'];
        $show_com = empty($instance['show_com']) ? '' : $instance['show_com'];
        $link = empty($instance['link']) ? '' : $instance['link'];
        $show_view = empty($instance['show_view']) ? '' : $instance['show_view'];
        $show_rate = empty($instance['show_rate']) ? '' : $instance['show_rate'];
        $show_excerpt = empty($instance['show_excerpt']) ? '' : $instance['show_excerpt'];
        $num_ex = empty($instance['num_ex']) ? '' : $instance['num_ex'];
        if (function_exists('ot_get_option')) {
            $themes_pur = ot_get_option('theme_purpose');
        }
        if ($conditions == 'most_liked' && class_exists('CT_ContentHelper')) {
            global $wpdb;
            $show_count = 1;
            if ($timerange == 'day') {
                $time_range = '1';
            } else {
                if ($timerange == 'week') {
                    $time_range = '7';
                } else {
                    if ($timerange == 'month') {
                        $time_range = '1m';
                    } else {
                        if ($timerange == 'year') {
                            $time_range = '1y';
                        }
                    }
                }
            }
            //$time_range = $instance['time_range'];
            //$show_type = $instance['show_type'];
            $order_by = 'ORDER BY like_count DESC, post_title';
            if ($number > 0) {
                $limit = "LIMIT " . $number;
            }
            $widget_data = $before_widget;
            $widget_data .= $before_title . $title . $after_title;
            $show_excluded_posts = get_option('wti_like_post_show_on_widget');
            $excluded_post_ids = explode(',', get_option('wti_like_post_excluded_posts'));
            if (!$show_excluded_posts && count($excluded_post_ids) > 0) {
                $where = "AND post_id NOT IN (" . get_option('wti_like_post_excluded_posts') . ")";
            }
            if ($time_range != 'all') {
                $last_date = GetWtiLastDate($time_range);
                $where .= " AND date_time >= '{$last_date}'";
            }
            //getting the most liked posts
            $query = "SELECT post_id, SUM(value) AS like_count, post_title FROM `{$wpdb->prefix}wti_like_post` L, {$wpdb->prefix}posts P ";
            $query .= "WHERE L.post_id = P.ID AND post_status = 'publish' AND value > 0 {$where} GROUP BY post_id {$order_by} {$limit}";
            $posts = $wpdb->get_results($query);
            if (count($posts) > 0) {
                $item_loop_video = new CT_ContentHtml();
                $widget_data .= '
			<div class="widget-content">
					<div class="list-rating-item row">';
                foreach ($posts as $post) {
                    $p_data = $excerpt = '';
                    $post_title = stripslashes($post->post_title);
                    $permalink = get_permalink($post->post_id);
                    $like_count = $post->like_count;
                    $p_data = get_post($post->post_id);
                    $excerpt = strip_tags($p_data->post_content);
                    $excerpt = wp_trim_words($excerpt, $num_ex, $more = '');
                    $widget_data .= $item_loop_video->tm_likes_html($post, $like_count, $themes_pur, $show_likes, $show_com, $show_rate, $show_view, $show_excerpt, $excerpt);
                }
                $widget_data .= '</div>
			</div>';
            }
            $widget_data .= $after_widget;
            echo $widget_data;
        } else {
            if (class_exists('CT_ContentHelper')) {
                if ($conditions == 'most_viewed' || $conditions == '') {
                    if ($timerange == 'day') {
                        $args = array('post_type' => 'post', 'posts_per_page' => $number, 'meta_key' => '_count-views_day-' . date("Ymd"), 'orderby' => 'meta_value_num', 'order' => 'DESC', 'post_status' => 'publish');
                    } else {
                        if ($timerange == 'week') {
                            $args = array('post_type' => 'post', 'posts_per_page' => $number, 'meta_key' => '_count-views_week-' . date("YW"), 'orderby' => 'meta_value_num', 'order' => '', 'post_status' => 'publish');
                        } else {
                            if ($timerange == 'month') {
                                $args = array('post_type' => 'post', 'posts_per_page' => $number, 'meta_key' => '_count-views_month-' . date("Ym"), 'orderby' => 'meta_value_num', 'order' => '', 'post_status' => 'publish');
                            } else {
                                if ($timerange == 'year') {
                                    $args = array('post_type' => 'post', 'posts_per_page' => $number, 'meta_key' => '_count-views_year-' . date("Y"), 'orderby' => 'meta_value_num', 'order' => '', 'post_status' => 'publish');
                                }
                            }
                        }
                    }
                    if ($themes_pur != '0') {
                        $args['tax_query'] = array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => 'post-format-video'));
                    }
                    $the_query = new WP_Query($args);
                    $html = $before_widget;
                    if ($title) {
                        $html .= $before_title . $title . $after_title;
                    }
                    if ($the_query->have_posts()) {
                        $html .= '
						<div class="widget-content">
						<div class="list-rating-item row">
					';
                        $item_video = new CT_ContentHtml();
                        $i = 0;
                        while ($the_query->have_posts()) {
                            $the_query->the_post();
                            $i++;
                            $excerpt = get_the_excerpt();
                            $excerpt = wp_trim_words($excerpt, $num_ex, $more = '');
                            $html .= $item_video->get_item_video_trending($conditions, $themes_pur, $show_likes, $show_com, $show_rate, $show_view, $show_excerpt, $excerpt);
                        }
                        $html .= '</div>
					</div>';
                    }
                    $html .= $after_widget;
                    echo $html;
                } else {
                    if ($conditions == 'most_comments') {
                        wp_reset_postdata();
                        if ($timerange == 'day') {
                            $some_comments = get_comments(array('date_query' => array(array('after' => '1 day ago'))));
                        } else {
                            if ($timerange == 'week') {
                                $some_comments = get_comments(array('date_query' => array(array('after' => '1 week ago'))));
                            } else {
                                if ($timerange == 'month') {
                                    $some_comments = get_comments(array('date_query' => array(array('after' => '1 month ago'))));
                                } else {
                                    if ($timerange == 'year') {
                                        $some_comments = get_comments(array('date_query' => array(array('after' => '1 year ago'))));
                                    }
                                }
                            }
                        }
                        $html = $before_widget;
                        if ($title) {
                            $html .= $before_title . $title . $after_title;
                        }
                        $arr_id = array();
                        foreach ($some_comments as $comment) {
                            $arr_id[] = $comment->comment_post_ID;
                        }
                        $arr_id = array_unique($arr_id, SORT_REGULAR);
                        //$arr_id = implode(",", $arr_id);
                        $args = array('post_type' => 'post', 'posts_per_page' => $number, 'order' => $sort_by, 'post_status' => 'publish', 'post__in' => $arr_id, 'ignore_sticky_posts' => 1);
                        $query = new WP_Query($args);
                        if ($query->have_posts()) {
                            $html .= '
				<div class="widget-content">
					<div class="list-rating-item row">';
                            while ($query->have_posts()) {
                                $query->the_post();
                                $excerpt = get_the_excerpt();
                                $html .= '
						<div class="col-md-12 col-sm-4">
						  <div class="video-item">
							  <div class="videos-row">
									<div class="item-thumbnail">
										<a href="' . get_permalink(get_the_ID()) . '" title="' . get_the_title(get_the_ID()) . '">';
                                if (has_post_thumbnail(get_the_ID())) {
                                    $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'thumb_139x89', true);
                                } else {
                                    $thumbnail[0] = function_exists('tm_get_default_image') ? tm_get_default_image() : '';
                                }
                                $html .= '<img src="' . $thumbnail[0] . '" alt="' . the_title_attribute('echo=0') . '" title="' . the_title_attribute('echo=0') . '">';
                                //'.get_the_post_thumbnail(get_the_ID(), array(139,89) ).'
                                if ($themes_pur != '0') {
                                    $html .= '<div class="link-overlay fa fa-play "></div>';
                                }
                                $html .= '</a>';
                                if ($show_rate != 'hide_r') {
                                    $html .= tm_post_rating(get_the_ID());
                                }
                                $html .= '</div>
								  <div class="item-info">
									<div class="all-info">
									<h2 class="rt-article-title"> <a href="' . get_permalink(get_the_ID()) . '" title="' . get_the_title(get_the_ID()) . '">' . get_the_title(get_the_ID()) . '</a></h2>
									<div class="item-meta">';
                                if ($show_view != 'hide_v') {
                                    $html .= '<span class="pp-icon"><i class="fa fa-eye"></i> ' . get_post_meta(get_the_ID(), '_count-views_all', true) . '</span><br>';
                                }
                                if ($show_likes != 'hide_l' && function_exists('GetWtiLikeCount')) {
                                    $html .= '<span class="pp-icon iclike"><i class="fa fa-thumbs-up"></i> ' . str_replace('+', '', GetWtiLikeCount(get_the_ID())) . '</span><br>';
                                }
                                if ($show_com != 'hide_c') {
                                    $html .= '<span class="pp-icon"><i class="fa fa-comment"></i> ' . get_comments_number(get_the_ID()) . '</span><br>';
                                }
                                $html .= '
										</div>
										</div>
										</div>';
                                if ($show_excerpt != 'hide_ex') {
                                    $html .= '<div class="pp-exceprt">' . $excerpt . '</div>';
                                }
                                $html .= '
							   </div>
						  </div>
						</div>
						';
                            }
                            $html .= '</div>
				</div>';
                        }
                        $html .= $after_widget;
                        echo $html;
                    }
                }
                wp_reset_postdata();
                $cache[$argsxx['widget_id']] = ob_get_flush();
                wp_cache_set('widget_trending_videos', $cache, 'widget');
            }
        }
    }
Exemplo n.º 8
0
    function getLatestCategoryItems($cat_id, $post_type = 'post')
    {
        $args = array('posts_per_page' => 3, 'category' => $cat_id, 'post_type' => $post_type);
        $posts = get_posts($args);
        $html = '';
        ob_start();
        global $post;
        $tmp_post = $post;
        $options = get_option('mashmenu_options');
        $sizes = $options['thumbnail_size'];
        $width = 520;
        $height = 354;
        if ($sizes != '') {
            $sizes = explode('x', $sizes);
            if (count($sizes) == 2) {
                $width = intval($sizes[0]);
                $height = intval($sizes[1]);
                if ($width == 0) {
                    $width = 200;
                }
                if ($height == 0) {
                    $height = 200;
                }
            }
        }
        $content_helper = new CT_ContentHtml();
        foreach ($posts as $post) {
            setup_postdata($post);
            ?>
		<div class="content-item col-md-4">
			<?php 
            echo $content_helper->get_item_small_video('thumb_260x146', 1, 1, 1, 1, '0');
            ?>
		</div>
		<?php 
        }
        $html = ob_get_contents();
        ob_end_clean();
        $temp_post = '';
        $post = $temp_post;
        return $html;
    }