Esempio 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');
    }