Example #1
0
    function widget($args, $instance)
    {
        global $wpdb;
        extract($args);
        $pop_posts = (int) strip_tags($instance['posts_number']);
        if (empty($pop_posts) || $pop_posts < 1) {
            $pop_posts = 3;
        }
        $now = gmdate("Y-m-d H:i:s", time());
        $lastmonth = gmdate("Y-m-d H:i:s", gmmktime(date("H"), date("i"), date("s"), date("m") - 12, date("d"), date("Y")));
        $popularposts = "SELECT ID, post_title,post_type,  post_date, COUNT({$wpdb->comments}.comment_post_ID) AS\n\t\t\t\t\t'stammy' FROM {$wpdb->posts}, {$wpdb->comments} WHERE comment_approved = '1' AND post_type='post'\n\t\t\t\t\tAND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID AND post_status = 'publish'  \n\t\t\t\t\tAND comment_status = 'open' GROUP BY {$wpdb->comments}.comment_post_ID ORDER BY stammy DESC LIMIT " . $pop_posts;
        $posts = $wpdb->get_results($popularposts);
        $popular = '';
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Popular Posts', 'highthemes') : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        if ($posts) {
            ?>
		<ul class="thumb-list">
		<?php 
            $post_format = '';
            foreach ($posts as $post) {
                $post_title = stripslashes($post->post_title);
                $post_date = $post->post_date;
                $post_date = mysql2date('F j, Y', $post_date, false);
                $permalink = get_permalink($post->ID);
                if (post_type_supports($post->post_type, 'post-formats')) {
                    $_format = get_the_terms($post->ID, 'post_format');
                    if (!empty($_format)) {
                        $format = array_shift($_format);
                        $post_format = str_replace('post-format-', '', $format->slug);
                    }
                }
                $thumb_url = '';
                if (has_post_thumbnail($post->ID)) {
                    $image_details = ht_get_featured_image_url($post->ID, '', 'small-thumb');
                    $thumb_url = $image_details['url'];
                    $image_id = $image_details['id'];
                }
                if (!$thumb_url) {
                    $thumb_url = get_template_directory_uri() . '/images/empty_thumb.png';
                }
                switch ($post_format) {
                    case 'video':
                        $thumb_url = get_template_directory_uri() . '/images/video_thumb.png';
                        break;
                    case 'link':
                        $thumb_url = get_template_directory_uri() . '/images/link_thumb.png';
                        break;
                    case 'quote':
                        $thumb_url = get_template_directory_uri() . '/images/quote_thumb.png';
                        break;
                    case 'audio':
                        $thumb_url = get_template_directory_uri() . '/images/audio_thumb.png';
                        break;
                }
                ?>
            <li>
                <a class="fl" href="<?php 
                echo $permalink;
                ?>
" title="<?php 
                echo $post_title;
                ?>
">
                    <img class="frame" src="<?php 
                echo $thumb_url;
                ?>
" alt="<?php 
                echo $post_title;
                ?>
" />
                </a>
                <div class="thumb-details">
                    <a class="thumb-title" href="<?php 
                echo $permalink;
                ?>
" rel="bookmark"><?php 
                echo $post_title;
                ?>
</a>
                    <span class="date"><?php 
                echo $post_date;
                ?>
</span>
                </div>
            </li>
                <?php 
                $post_format = '';
            }
            ?>
		</ul>
		<?php 
        }
        echo $after_widget;
        //end
    }
Example #2
0
<?php

global $data;
$video_link = get_post_meta(get_the_ID(), '_video_link', true);
$disable_post_image = get_post_meta(get_the_ID(), '_disable_post_image', true);
if (empty($disable_post_image) && $data['disable_post_image'] == '1') {
    $disable_post_image = 'false';
}
if (has_post_thumbnail() && $data['disable_post_image'] != '1') {
    $image_url = ht_get_featured_image_url(get_the_ID(), '', 'full');
    // width: 560
    // height: 250
    $thumb_details = ht_get_featured_image_url(get_the_ID(), '', 'large');
    $thumb_url = $thumb_details['url'];
    if (!empty($video_link)) {
        $video_status = 'video';
        $image_url['url'] = $video_link;
    } else {
        $video_status = 'zoom';
    }
    $lightbox_status = '';
    if ($data['blog_lightbox']) {
        $lightbox_status = 'href="' . get_permalink() . '"';
    } else {
        $lightbox_status = 'rel="prettyPhoto" href="' . $image_url['url'] . '"';
    }
}
/**
 *  search content
 */
if (get_post_type() == 'page') {
if ($wp_query->have_posts()) {
    ?>
    <div id="related-folio" class="projects clearfix">
        <div class="section-title"><h2><?php 
    _e("Related Projects", "highthemes");
    ?>
</h2></div>

        <ul>
            <?php 
    $i = 1;
    while ($wp_query->have_posts()) {
        $wp_query->the_post();
        $video_link = get_post_meta($post->ID, '_video_link', true);
        $thumb_details = ht_get_featured_image_url(get_the_ID(), '', 'ht-folio1');
        $post_large_image = ht_get_featured_image_url(get_the_ID(), '', 'full');
        $thumb_url = $thumb_details['url'];
        $image_url = $post_large_image['url'];
        if (!empty($video_link)) {
            $video_status = 'video';
            $image_url = $video_link;
        } else {
            $video_status = 'zoom';
        }
        ?>
                <li <?php 
        $i % 4 == 0 && $i != 0 ? post_class("one_fourth last folio-box") : post_class("one_fourth folio-box");
        ?>
>
                    <div class="frame">
                        <a title="<?php 
     $orderby = 'date';
 }
 // building the query
 if (!isset($ht_slideshow_category) || $ht_slideshow_category == '') {
     $slideshow_args = array('post_type' => 'slideshow', 'post_status' => 'publish', 'orderby' => $orderby, 'posts_per_page' => -1);
 } else {
     $slideshow_args = array('posts_per_page' => -1, 'post_type' => 'slideshow', 'orderby' => $orderby, 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => 'slideshow-category', 'field' => 'slug', 'terms' => $ht_slideshow_category)));
 }
 $my_query = null;
 $my_query = new WP_Query($slideshow_args);
 if ($my_query->have_posts()) {
     $j = 0;
     $slides = '';
     while ($my_query->have_posts()) {
         $my_query->the_post();
         $image_url = ht_get_featured_image_url($post->ID, '', 'full');
         $image_url = $image_url['url'];
         if (trim(get_the_content()) != '') {
             $excerpt = addslashes(do_shortcode(get_the_content()));
             $excerpt = nl2br($excerpt);
             $excerpt = str_replace(array("\r\n", "\r", "\n"), '\\n', $excerpt);
             $description = '<div class="slideshow-caption-wrap clearfix">' . $excerpt . '</div>';
         } else {
             $description = '';
         }
         $disable_slider_caption = get_post_meta($post->ID, '_slider_disable_caption', true);
         $disable_slider_caption_title = get_post_meta($post->ID, '_slider_disable_caption_title', true);
         if ($disable_slider_caption) {
             $slides .= "{image : '" . $image_url . "',  thumb : '" . $image_url . "', url : ''} ,\n\t";
         } else {
             if ($disable_slider_caption_title) {