<div class="is-carousel" id="control-stage-carousel"> <a class="control-up"><i class="fa fa-angle-up"></i></a> <div class="classy-carousel-content"> <?php $item_count = 0; while ($header_query->have_posts()) { $header_query->the_post(); $item_count++; ?> <div class="video-item"> <div class="item-thumbnail"> <?php if (has_post_thumbnail()) { $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumb_72x72', true); } else { $thumbnail[0] = function_exists('tm_get_default_image') ? tm_get_default_image() : ''; } ?> <img src="<?php echo $thumbnail[0]; ?> " alt="<?php the_title_attribute(); ?> " title="<?php the_title_attribute(); ?> " width="72"> </div> <div class="item-head"> <h3><?php
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; } } }
function get_item_relate_video($thumb, $show_title, $show_exceprt, $show_rate, $show_dur, $show_view, $show_com, $show_like, $show_aut, $show_date, $themes_pur) { $format = get_post_format(get_the_ID()); $html = ''; $html .= ' <div class="video-item"> <div class="item-thumbnail"> <a href="' . get_permalink() . '" title="' . esc_attr(get_the_title()) . '">'; if (has_post_thumbnail()) { $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), $thumb, true); } else { $thumbnail[0] = function_exists('tm_get_default_image') ? tm_get_default_image() : ''; $thumbnail[1] = 520; $thumbnail[2] = 293; } $html .= '<img src="' . $thumbnail[0] . '" width="' . $thumbnail[1] . '" height="' . $thumbnail[2] . '" alt="' . get_the_title('echo=0') . '" title="' . the_title_attribute('echo=0') . '">'; if ($themes_pur != '0') { if ($format == '' || $format == 'standard' || $format == 'gallery') { $html .= '<div class="link-overlay fa fa-search"></div>'; } else { $html .= '<div class="link-overlay fa fa-play "></div>'; } } $html .= '</a>'; if ($show_rate != '0') { $html .= tm_post_rating(get_the_ID()); } if ($show_dur != '0') { if (get_post_meta(get_the_id(), 'time_video', true) != '00:00' && get_post_meta(get_the_id(), 'time_video', true) != '00' && get_post_meta(get_the_id(), 'time_video', true) != '') { $html .= ' <span class="rating-bar bgcolor2 time_dur">' . get_post_meta(get_the_id(), 'time_video', true) . '</span>'; } } $html .= ' </div> <div class="item-head">'; if ($show_title != '0') { $html .= ' <h3><a href="' . get_permalink(get_the_ID()) . '">' . strip_tags(get_the_title(get_the_ID())) . '</a></h3>'; } $html .= ' <div class="item-info">'; if ($show_aut != '0') { $author = get_author_posts_url(get_the_author_meta('ID')); $html .= '<span class="item-author"><a href="' . $author . '" title="' . get_the_author() . '">' . get_the_author() . '</a></span>'; } if ($show_date != '0') { $html .= '<span class="item-date">' . get_the_time(get_option('date_format')) . '</span>'; } $html .= '<div class="item-meta no-bg">'; if ($show_view != '0') { $html .= tm_html_video_meta('view', false, false); } if ($show_com != '0') { $html .= tm_html_video_meta('comment', false, false); } if ($show_like != '0') { $html .= tm_html_video_meta('like', false, false); } $html .= '</div> </div>'; $html .= ' </div>'; if ($show_exceprt != '0') { $html .= ' <div class="item-content">' . get_the_excerpt() . '</div>'; } $html .= ' </div> '; return $html; }
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'); } } }