function tfuse_latest_reviews($atts, $content = null)
{
    extract(shortcode_atts(array('title' => '', 'items' => ''), $atts));
    $query = new WP_Query(array('post_type' => 'review', 'orderby' => 'post_date', 'order ' => 'DESC', 'posts_per_page' => $items));
    $posts = $query->get_posts();
    $return_html = $img = '';
    if (!empty($posts)) {
        $return_html .= '<div class="widget widget_recent_entries">
                            <h3 class="widget-title">Latest Reviews</h3>
                            <ul class="side-postlist">';
        foreach ($posts as $post) {
            $post_image_src = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'post-thumbnails'));
            if (!empty($post_image_src)) {
                $get_image = new TF_GET_IMAGE();
                $img = $get_image->properties(array('class' => '', 'alt' => get_the_title($post->ID)))->width(62)->height(62)->src($post_image_src)->resize(true)->get_img();
            }
            $return_html .= '<li>';
            if (!empty($img)) {
                $return_html .= '<a href="' . get_permalink($post->ID) . '" class="post-thumbnail">
                                                ' . $img . '
                                            </a>';
            }
            $return_html .= '<a href="' . get_permalink($post->ID) . '" class="post-title">' . get_the_title($post->ID) . '</a>
                                        <span class="comments-link"><a href="' . get_permalink($post->ID) . '#comments">' . tfuse_get_comments(true, $post->ID) . '</a></span>
                                    </li>';
        }
        $return_html .= '</ul>
                        </div>';
    }
    return $return_html;
}
Exemple #2
0
 /**
  *  Generate array with: recent/popular/most commented posts
  * @param string $sort Sort type (recent/popular/most commented)
  * @param integer $items Number of items to be extracted
  * @param boolean $image_post Extract or no post image
  * @param integer $image_width Set width of post image
  * @param integer $image_height Set height of post image
  * @param string $image_class Set class of post image
  * @param boolean $date_post Extract or no post date
  * @param string $date_format Set date format
  * @param string $post_type Set post type
  * @param string $category Set category from where posts would be extracted
  * @since Medica 2.0
  */
 function tfuse_shortcode_posts($args = null)
 {
     $defaults = array('sort' => 'recent', 'items' => 5, 'image_post' => true, 'image_width' => 54, 'image_height' => 54, 'image_class' => 'thumbnail', 'date_post' => true, 'date_format' => 'F jS, Y', 'post_type' => 'post', 'category' => '', 'specialites' => '');
     extract(wp_parse_args($args, $defaults));
     global $post;
     $tf_cat_ID = !empty($category) && empty($specialites) ? get_cat_ID($category) : '';
     $specialites = empty($category) && !empty($specialites) ? $specialites : '';
     if ($sort == 'recent') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'post_date', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'Specialites' => $specialites, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } elseif ($sort == 'popular') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'meta_value', 'meta_key' => TF_THEME_PREFIX . '_post_viewed', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } elseif ($sort == 'commented') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'comment_count', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } else {
         return false;
     }
     $tf_post_option = array();
     $count = 0;
     if (!empty($posts)) {
         foreach ($posts as $post_elm) {
             setup_postdata($post_elm);
             $img = '';
             if ($image_post == true) {
                 $post_image_src = tfuse_page_options('thumbnail_image', tfuse_page_options('single_image', null, $post_elm->ID), $post_elm->ID);
                 if (!empty($post_image_src)) {
                     $get_image = new TF_GET_IMAGE();
                     $img = $get_image->properties(array('class' => $image_class, 'alt' => get_the_title($post_elm->ID)))->width($image_width)->height($image_height)->src($post_image_src)->resize(true)->get_img();
                 }
             }
             if (!empty($img)) {
                 $tf_post_option[$count]['post_img'] = $img;
             } else {
                 $tf_post_option[$count]['post_img'] = '';
             }
             if ($date_post) {
                 $time_format = apply_filters('tfuse_widget_time_format', $date_format);
                 $tf_post_option[$count]['post_date_post'] = get_the_time($time_format, $post_elm->ID);
             } else {
                 $tf_post_option[$count]['post_date_post'] = '';
             }
             $tf_post_option[$count]['post_class'] = is_singular() && $post->ID == $post_elm->ID ? 'current-menu-item post_' . $sort : 'post_' . $sort;
             $tf_post_option[$count]['post_title'] = get_the_title($post_elm->ID);
             $tf_post_option[$count]['post_link'] = get_permalink($post_elm->ID);
             $tf_post_option[$count]['post_author_link'] = get_author_posts_url(get_the_author_meta('ID'));
             $tf_post_option[$count]['post_author_name'] = get_the_author();
             $tf_post_option[$count]['post_comnt_numb'] = get_comments_number($post_elm->ID);
             $tf_post_option[$count]['post_comnt_numb_link'] = tfuse_get_comments(true, $post_elm->ID);
             $tf_post_option[$count]['post_loveit_number'] = get_post_meta($post_elm->ID, TF_THEME_PREFIX . '_post_viewed', true);
             $tf_post_option[$count]['post_excerpt'] = apply_filters('get_the_excerpt', $post_elm->post_excerpt);
             $count++;
         }
         wp_reset_postdata();
     }
     return $tf_post_option;
 }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'tfuse') : $instance['title'], $instance, $this->id_base);
        $number = esc_attr($instance['number']);
        $b = $instance['b'] = empty($instance['b']) ? '' : $instance['b'];
        $class = $b ? 'widget-boxed' : '';
        if ($number > 0) {
        } else {
            $number = 8;
        }
        ?>

<div class="widget widget_recent_entries <?php 
        echo $class;
        ?>
">
        <h3 class="widget-title"><?php 
        echo tfuse_qtranslate($title);
        ?>
</h3>
        <ul class="side-postlist">
            <?php 
        $pop_posts = tfuse_shortcode_posts(array('sort' => 'recent', 'items' => $number, 'image_post' => true, 'image_width' => 62, 'image_height' => 62, 'image_class' => 'post-thumbnail'));
        foreach ($pop_posts as $post_val) {
            ?>
                <li>
                    <a href="<?php 
            echo $post_val['post_link'];
            ?>
"><?php 
            echo $post_val['post_img'];
            ?>
</a>
                    <a href="<?php 
            echo $post_val['post_link'];
            ?>
" class="post-title"><?php 
            echo $post_val['post_title'];
            ?>
</a>
                    <span class="comments-link"><a href="<?php 
            echo $post_val['post_link'];
            ?>
#comments"><?php 
            echo tfuse_get_comments(false, $post_val['post_id']);
            ?>
</a></span>
                </li>

            <?php 
        }
        ?>
        </ul>
    </div>

    <?php 
    }
function tfuse_recent_posts($atts, $content = null)
{
    $return_html = '';
    extract(shortcode_atts(array('items' => 5), $atts));
    $latest_posts = tfuse_shortcode_posts(array('sort' => 'recent', 'items' => $items, 'image_post' => false, 'date_format' => 'F jS,Y', 'date_post' => true));
    $return_html .= '
    <div class="widget recent-posts">
            <ul>';
    foreach ($latest_posts as $post_val) {
        $return_html .= '<li>';
        $return_html .= '
            <a href="' . $post_val['post_link'] . '" class="entry-title">' . $post_val['post_title'] . '</a>';
        $return_html .= '<div class="entry-meta">
                            <time class="entry-date" datetime="">' . $post_val['post_date_post'] . '</time>
                            <a href="' . $post_val['post_link'] . '#comments" class="comments-link"><span>' . tfuse_get_comments(true, $post_val['post_id']) . '</span></a>
                        </div>';
        $return_html .= '</li>';
    }
    $return_html .= '</ul></div> ';
    return $return_html;
}
?>
            </div>
        </header>
        <div class="entry-content">
            <?php 
if (tfuse_options('post_content') == 'content') {
    the_content('');
} else {
    the_excerpt();
}
?>
        </div>
        <footer class="entry-meta clearfix">
            <a href="<?php 
the_permalink();
?>
" class="btn btn-yellow btn-read-more"><span><?php 
_e('Read More', 'tfuse');
?>
</span></a>
            <a href="<?php 
the_permalink();
?>
#comments" class="btn btn-transparent link-comment"><span><?php 
echo tfuse_get_comments(TRUE, $post->ID);
?>
</span></a>
        </footer>
    </div>
</article>