Exemple #1
0
    $cb_featured_qry = array('post_type' => $cb_cpt_output, 'cat' => $cb_current_cat, 'offset' => $cb_grid_size, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish', 'cb_offset_loop' => $cb_offset_loop, 'paged' => $cb_paged);
    $cb_qry = new WP_Query($cb_featured_qry);
} else {
    global $wp_query;
    $cb_qry = $wp_query;
}
if (!isset($cb_category_color_style)) {
    $cb_category_color_style = NULL;
}
if ($cb_qry->have_posts()) {
    while ($cb_qry->have_posts()) {
        $cb_qry->the_post();
        $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on');
        $cb_cat_id = get_the_category($post->ID);
        $cb_post_id = $post->ID;
        $cb_post_format_icon = cb_post_format_check($cb_post_id);
        $cb_category_color = cb_get_cat_color($cb_post_id);
        if ($i % 2 == 0) {
            $cb_side = NULL;
            $cb_closer = true;
            echo '<div class="cb-double clearfix">';
        } else {
            $cb_side = ' cb-last';
            $cb_closer = false;
        }
        ?>

<article id="post-<?php 
        the_ID();
        ?>
" class="cb-blog-style-b clearfix<?php 
        function widget($args, $instance)
        {
            $cache = wp_cache_get('widget_recent_posts', '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);
            $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'cubell') : $instance['title'], $instance, $this->id_base);
            $category = apply_filters('widget_category', empty($instance['category']) ? '' : $instance['category'], $instance, $this->id_base);
            $type = apply_filters('widget_type', empty($instance['type']) ? 'cb-small' : $instance['type'], $instance, $this->id_base);
            if (empty($instance['number']) || !($number = absint($instance['number']))) {
                $number = 5;
            }
            if ($category != 'cb-all') {
                $cb_cat_qry = $category;
            } else {
                $cb_cat_qry = NULL;
            }
            $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'category_name' => $cb_cat_qry, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
            if ($r->have_posts()) {
                echo $before_widget;
                if ($title) {
                    echo $before_title . $title . $after_title;
                }
                ?>
    		
    		<ul class="cb-light <?php 
                echo $type;
                ?>
">
    		<?php 
                while ($r->have_posts()) {
                    $r->the_post();
                    global $post;
                    $cb_custom_fields = get_post_custom();
                    $cb_global_color = ot_get_option('cb_base_color', '#eb9812');
                    $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on');
                    $cb_review_checkbox = get_post_meta(get_the_id(), "cb_review_checkbox");
                    if ($type == 'cb-small') {
                        $width = '80';
                        $height = '60';
                        $cb_small_box = true;
                        $cb_class = NULL;
                    }
                    if ($type == 'cb-big') {
                        $width = '360';
                        $height = '240';
                        $cb_small_box = false;
                        $cb_class = ' class="h2"';
                    }
                    $cb_all_categories = get_the_category();
                    $cb_current_cat_id = $cb_all_categories[0]->term_id;
                    $cb_category_color = get_tax_meta($cb_current_cat_id, 'cb_color_field_id');
                    if ($cb_category_color == "#" || $cb_category_color == NULL) {
                        $cb_parent_cat_id = $cb_all_categories[0]->parent;
                        if ($cb_parent_cat_id != '0') {
                            $cb_category_color = get_tax_meta($cb_parent_cat_id, 'cb_color_field_id');
                        }
                        if ($cb_category_color == "#" || $cb_category_color == NULL) {
                            $cb_category_color = $cb_global_color;
                        }
                    }
                    $cb_post_id = $post->ID;
                    $cb_post_format_icon = cb_post_format_check($cb_post_id);
                    ?>
                
                <li class="cb-article clearfix">
                	<div class="cb-mask" style="background-color:<?php 
                    echo $cb_category_color;
                    ?>
;">
                	    <?php 
                    cb_thumbnail($width, $height);
                    echo cb_review_ext_box($cb_post_id, $cb_category_color, $cb_small_box);
                    echo $cb_post_format_icon;
                    ?>
                	</div>
                    <div class="cb-meta">    
                        <h4<?php 
                    echo $cb_class;
                    ?>
><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h4>
                        <?php 
                    echo cb_byline(false, $cb_post_id, true);
                    ?>
                        <?php 
                    if ($type == 'cb-big') {
                        echo '<div class="cb-excerpt">' . cb_clean_excerpt(120) . '</div>';
                    }
                    ?>
                   </div> 
                </li>
    		<?php 
                }
                ?>
    		</ul>
    		<?php 
                echo $after_widget;
                ?>
    <?php 
                // Reset the global $the_post as this query will have stomped on it
                wp_reset_postdata();
            }
            $cache[$args['widget_id']] = ob_get_flush();
            wp_cache_set('widget_recent_posts', $cache, 'widget');
        }