Example #1
0
" <?php 
        post_class('clear');
        ?>
>
                    <a href="<?php 
        the_permalink();
        ?>
" class="post-thumb"><?php 
        if (has_post_thumbnail()) {
            the_post_thumbnail('general');
        }
        ?>
</a>
                    <div class="post-meta"><?php 
        if (function_exists('unspoken_posted_on')) {
            unspoken_posted_on($postedon_data);
        }
        ?>
</div>
                    <h2><a href="<?php 
        the_permalink();
        ?>
" rel="bookmark"><?php 
        the_title();
        ?>
</a></h2>
                    <p><?php 
        the_excerpt();
        ?>
</p>
                </div>
    function widget($args, $instance)
    {
        extract($args);
        $type = $instance['type'];
        $slider_title = empty($instance['slider_title']) ? '' : $instance['slider_title'];
        $choice_title = empty($instance['choice_title']) ? '' : $instance['choice_title'];
        $video_title = empty($instance['video_title']) ? '' : $instance['video_title'];
        $category = $instance['category'];
        $category_perpage = $instance['category_perpage'];
        $categories1 = $instance['categories1'];
        $categories2 = $instance['categories2'];
        $categories3 = $instance['categories3'];
        $categories4 = $instance['categories4'];
        $categories_perpage = $instance['categories_perpage'];
        $video_qty = $instance['video_qty'];
        $latest_perpage = $instance['latest_perpage'];
        $postedon_data = array('date' => get_option('unspoken_postedon_date'), 'category' => get_option('unspoken_postedon_cat'), 'comment' => get_option('unspoken_postedon_comm'), 'author' => get_option('unspoken_postedon_author'));
        global $exl_posts;
        echo $before_widget;
        if ($type == 'latest') {
            ?>

            <div class="latest clear">
                <div class="slider">
                    <div class="block-title2"><?php 
            echo $slider_title;
            ?>
<a href="javascript:void(0);" class="prev"></a><a href="javascript:void(0);" class="next"></a></div>
                    <div class="slider-inn">
                        <ul>
                            <?php 
            $args = array('posts_per_page' => -1, 'meta_key' => 'usn_highlight', 'meta_value' => 'on', 'post__not_in' => get_option('sticky_posts'));
            query_posts($args);
            while (have_posts()) {
                the_post();
                if (get_option('unspoken_slider_excl')) {
                    $exl_posts[] = get_the_ID();
                }
                ?>
                            <li>
                                <div class="slider-item">
                                    <div class="slider-photo">
                                        <a href="<?php 
                the_permalink();
                ?>
"><?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('slide-home', array('alt' => trim(strip_tags(get_the_title())), 'title' => trim(strip_tags(get_the_title()))));
                }
                ?>
</a>
                                    </div>
                                    <div class="slider-item-meta"><?php 
                if (function_exists('unspoken_posted_on')) {
                    unspoken_posted_on($postedon_data);
                }
                ?>
</div>
                                    <h2><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h2>
                                    <?php 
                the_excerpt();
                ?>
                                </div>
                            </li>
                            <?php 
            }
            wp_reset_query();
            ?>
                        </ul>
                    </div>
                </div>
                <script type="text/javascript">
                    jQuery(document).ready(function() {
                        jQuery('.slider-inn').jCarouselLite({
                            btnNext: ".slider .next", btnPrev: ".slider .prev", visible: 1, scroll: 1 <?php 
            if (get_option('unspoken_slider_auto') && get_option('unspoken_slider_delay') > 0) {
                echo ', auto: ' . get_option('unspoken_slider_delay');
            }
            ?>
                        });
                    });
                </script>
                <div class="latest-news">
                    <div class="block-title"><?php 
            _e('Latest Entries', 'unspoken');
            ?>
</div>
                    <ul>
                    <?php 
            $args = array('posts_per_page' => $latest_perpage, 'post__not_in' => get_option('sticky_posts'), 'post__not_in' => $exl_posts);
            query_posts($args);
            while (have_posts()) {
                the_post();
                ?>
                        <li>
                            <p class="latest-news-meta"><?php 
                if (function_exists('unspoken_posted_on')) {
                    unspoken_posted_on($postedon_data);
                }
                ?>
</p>
                            <p class="latest-news-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></p>
                        </li>
                    <?php 
            }
            wp_reset_query();
            ?>
                    </ul>
                </div>
            </div>

        <?php 
        }
        if ($type == 'slider') {
            $args = array('posts_per_page' => -1, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes');
            query_posts($args);
            if (true or have_posts()) {
                ?>
        <div id="mainposts">
            <ul>
                <?php 
                while (have_posts()) {
                    the_post();
                    ?>
                <li>
                    <div class="mainpost">
                        <a href="<?php 
                    the_permalink();
                    ?>
">
                        <?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('slide-magazine');
                    }
                    ?>
                        </a>
                        <div class="mainpost-container">
                            <div class="bg"></div>
                            <div class="mainpost-data">
                                <div class="mainpost-meta" style="display:none"><?php 
                    echo get_the_date();
                    ?>
 &middot; <?php 
                    comments_popup_link(__('0 Comments', 'unspoken'), __('1 Comment', 'unspoken'), __('% Comments', 'unspoken'), '', __('Comments off', 'unspoken'));
                    ?>
 &middot; <?php 
                    the_category(', ');
                    ?>
</div>
                                <h2><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h2>
                                <?php 
                    the_content();
                    ?>
                            </div>
                        </div>
                    </div>
                </li>
                <?php 
                }
                wp_reset_query();
                ?>
            </ul>
            <a href="javascript: void(0);" class="prev"></a>
            <a href="javascript: void(0);" class="next"></a>
        </div>
		<script type="text/javascript">
                    jQuery(document).ready(function() {
                        jQuery('#mainposts').jCarouselLite({
                            btnNext: "#mainposts .next", btnPrev: "#mainposts .prev", visible: 1, scroll: 1 <?php 
                if (get_option('unspoken_mag_auto') && get_option('unspoken_mag_delay') > 0) {
                    echo ', auto: ' . get_option('unspoken_mag_delay');
                }
                ?>
                        });
                    });
                </script>	
        <?php 
            }
            ?>

        <?php 
        }
        if ($type == 'category' && $category) {
            ?>

            <div class="category">
                <div class="block-title"><a href="<?php 
            echo get_category_link($category);
            ?>
"><?php 
            echo get_cat_name($category);
            ?>
</a></div>
                <div class="category-inn clear">
                    <?php 
            $args = array('cat' => $category, 'posts_per_page' => 1, 'post__not_in' => get_option('sticky_posts'), 'post__not_in' => $exl_posts);
            query_posts($args);
            while (have_posts()) {
                the_post();
                ?>
                        <div class="category-item">
                            <div class="category-item-photo">
                                <a href="<?php 
                the_permalink();
                ?>
"><?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('general', array('alt' => trim(strip_tags(get_the_title())), 'title' => trim(strip_tags(get_the_title()))));
                }
                ?>
</a>
                            </div>
                            <div class="category-item-meta"><?php 
                if (function_exists('unspoken_posted_on')) {
                    unspoken_posted_on($postedon_data);
                }
                ?>
</div>
                            <h2><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h2>
                            <?php 
                the_excerpt();
                ?>
                        </div>
                    <?php 
            }
            wp_reset_query();
            ?>
                    <div class="category-list">
                        <ul>
                            <?php 
            $args = array('cat' => $category, 'posts_per_page' => $category_perpage, 'offset' => 1, 'post__not_in' => get_option('sticky_posts'), 'post__not_in' => $exl_posts);
            query_posts($args);
            while (have_posts()) {
                the_post();
                ?>
                            <li>
                                <p class="category-list-meta"><?php 
                if (function_exists('unspoken_posted_on')) {
                    unspoken_posted_on($postedon_data);
                }
                ?>
</p>
                                <p class="category-list-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></p>
                            </li>
                            <?php 
            }
            wp_reset_query();
            ?>
                        </ul>
                    </div>
                </div>
            </div>

        <?php 
        }
        if ($type == 'categories' && ($categories1 || $categories2 || $categories3 || $categories4)) {
            ?>

            <div class="categories">
                <div class="categories-inn clear">
                    <?php 
            $catlist = array($categories1, $categories2, $categories3, $categories4);
            foreach ($catlist as $cat) {
                if (!empty($cat)) {
                    ?>

                                <div class="catlist">
                                    <div class="block-title"><a href="<?php 
                    echo get_category_link($cat);
                    ?>
"><?php 
                    echo get_cat_name($cat);
                    ?>
</a></div>
                                    <ul>

                            <?php 
                    $args = array('cat' => $cat, 'posts_per_page' => $categories_perpage, 'post__not_in' => get_option('sticky_posts'), 'post__not_in' => $exl_posts);
                    query_posts($args);
                    $i = 0;
                    while (have_posts()) {
                        the_post();
                        $i++;
                        if ($i == 1) {
                            ?>
                                    <li class="catlist-item first">
                                        <a href="<?php 
                            the_permalink();
                            ?>
" class="catlist-item-photo"><?php 
                            if (has_post_thumbnail()) {
                                the_post_thumbnail('mini', array('alt' => trim(strip_tags(get_the_title())), 'title' => trim(strip_tags(get_the_title()))));
                            }
                            ?>
</a>
                                        <div class="catlist-item-date"><?php 
                            echo get_the_date();
                            ?>
</div>
                                        <h2><a href="<?php 
                            the_permalink();
                            ?>
"><?php 
                            the_title();
                            ?>
</a></h2>
                                    </li>

                                    <?php 
                        } else {
                            ?>
                                            
                                    <li class="catlist-item">
                                        <div class="catlist-item-date"><?php 
                            echo get_the_date();
                            ?>
</div>
                                        <p><a href="<?php 
                            the_permalink();
                            ?>
"><?php 
                            the_title();
                            ?>
</a></p>
                                    </li>

                        <?php 
                        }
                    }
                    wp_reset_query();
                    ?>
                                    </ul>
                                </div>
                    <?php 
                }
            }
            ?>
                </div>
            </div>

        <?php 
        }
        if ($type == 'choice') {
            ?>

            <div class="choice">
                <div class="block-title2"><?php 
            echo __("Editor's Choice", 'unspoken');
            ?>
<a href="javascript:void(0);" class="prev"></a><a href="javascript:void(0);" class="next"></a></div>
                <div class="choice-inn">
                    <ul>
                        <?php 
            $args = array('posts_per_page' => -1, 'meta_key' => 'usn_ec', 'meta_value' => 'on', 'post__not_in' => get_option('sticky_posts'), 'post__not_in' => $exl_posts);
            query_posts($args);
            while (have_posts()) {
                the_post();
                ?>

                        <li class="choice-item">
                            <a href="<?php 
                the_permalink();
                ?>
" class="choice-photo"><?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('mini-ec', array('alt' => trim(strip_tags(get_the_title())), 'title' => trim(strip_tags(get_the_title()))));
                }
                ?>
</a>
                            <div class="choice-cat"><?php 
                the_category(', ');
                ?>
</div>
                            <h2><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h2>
                        </li>

                        <?php 
            }
            wp_reset_query();
            ?>
                    </ul>
                </div>
            </div>

        <?php 
        }
        if ($type == 'video') {
            ?>

            <div class="video clear">
                <div class="block-title"><?php 
            echo __("Video", 'unspoken');
            ?>
</div>
                <div class="video-item-container">
                <?php 
            $args = array('posts_per_page' => -1, 'meta_key' => 'usn_show_in_video', 'meta_value' => 'on', 'post__not_in' => get_option('sticky_posts'), 'post__not_in' => $exl_posts);
            query_posts($args);
            $i = 0;
            while (have_posts()) {
                the_post();
                $active = '';
                $i++;
                if ($i == 1) {
                    $active = 'active';
                }
                ?>
                <div class="video-item <?php 
                echo 'item' . $i;
                ?>
 <?php 
                echo $active;
                ?>
">
                    <?php 
                $videourl = get_post_meta(get_the_ID(), 'usn_videolink', true);
                if (!$videourl) {
                    ?>
                        <a href="<?php 
                    the_permalink();
                    ?>
" class="video-item-photo"><?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('video', array('alt' => trim(strip_tags(get_the_title())), 'title' => trim(strip_tags(get_the_title()))));
                    }
                    ?>
</a>
                    <?php 
                } else {
                    ?>
<div class="video-item-photo"><?php 
                    $AE = new AutoEmbed();
                    // loading the AutoEmbed PHP Class
                    if ($videourl && $AE->parseUrl($videourl)) {
                        $AE->setParam('wmode', 'transparent');
                        $AE->setParam('autoplay', 'false');
                        $AE->setHeight(260);
                        $AE->setWidth(460);
                        echo $AE->getEmbedCode();
                    }
                    ?>
</div><?php 
                }
                ?>
                    <div class="video-item-meta"><?php 
                if (function_exists('unspoken_posted_on')) {
                    unspoken_posted_on($postedon_data);
                }
                ?>
</div>
                    <h2><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h2>
                    <?php 
                the_excerpt();
                ?>
                </div>
                <?php 
            }
            wp_reset_query();
            ?>
                </div>
                <div class="videolist">
                    <a href="javascript:void(0);" class="prev"></a>
                    <div class="videolist-inn">
                        <ul>
                            <?php 
            $args = array('meta_key' => 'usn_show_in_video', 'meta_value' => 'on', 'posts_per_page' => $video_qty, 'post__not_in' => get_option('sticky_posts'), 'post__not_in' => $exl_posts);
            query_posts($args);
            $i = 0;
            while (have_posts()) {
                the_post();
                $i++;
                ?>
                                    <li class="videolist-item">
                                        <div class="videolist-thumb">
                                            <?php 
                the_post_thumbnail('video-mini', array('alt' => trim(strip_tags(get_the_title())), 'title' => trim(strip_tags(get_the_title()))));
                ?>
                                            <a class="videolist-play <?php 
                echo $i == 1 ? 'active' : '';
                ?>
" href="javascript:void(0);" title="<?php 
                the_title();
                ?>
"></a>
                                        </div>
                                    </li>
                            <?php 
            }
            wp_reset_query();
            ?>
                        </ul>
                    </div>
                    <a href="javascript:void(0);" class="next"></a>
                </div>
            </div>

        <?php 
        }
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $number = is_numeric($instance['number']) && $instance['number'] > 0 ? $instance['number'] : 5;
        $hide_thumb = $instance['hide_thumb'];
        $postedon_data = array('date' => get_option('unspoken_postedon_date'), 'category' => get_option('unspoken_postedon_cat'), 'tag' => get_option('unspoken_postedon_tag'), 'comment' => get_option('unspoken_postedon_comm'), 'author' => get_option('unspoken_postedon_author'));
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        global $post;
        $posts = get_posts('numberposts=' . $number);
        echo '<ul>';
        foreach ($posts as $post) {
            setup_postdata($post);
            $offset = '';
            if (has_post_thumbnail() && !$hide_thumb) {
                $offset = 'offset';
            }
            ?>

            <li class="hentry-thumb clear">
                <span class="hentry-thumb-image"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            if (has_post_thumbnail() && !$hide_thumb) {
                the_post_thumbnail('micro', array('alt' => trim(strip_tags(get_the_title())), 'title' => trim(strip_tags(get_the_title()))));
            }
            ?>
</a></span>
                <span class="hentry-thumb-meta <?php 
            echo $offset;
            ?>
"><?php 
            if (function_exists('unspoken_posted_on')) {
                unspoken_posted_on($postedon_data);
            }
            ?>
</span>
                <span class="hentry-thumb-title <?php 
            echo $offset;
            ?>
"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a></span>
             </li>

        <?php 
        }
        echo '</ul>';
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', __('Popular Posts', 'unspoken'));
        $number = is_numeric($instance['number']) && $instance['number'] > 0 ? $instance['number'] : 5;
        $period = is_numeric($instance['period']) && $instance['period'] > 0 ? $instance['period'] : 30;
        $hide_thumb = $instance['hide_thumb'];
        $postedon_data = array('date' => get_option('unspoken_postedon_date'), 'category' => get_option('unspoken_postedon_cat'), 'tag' => get_option('unspoken_postedon_tag'), 'comment' => get_option('unspoken_postedon_comm'), 'author' => get_option('unspoken_postedon_author'));
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        global $wpdb, $post;
        $lang = constant("ICL_LANGUAGE_CODE");
        $interval = date('Y-m-d', strtotime('-' . $period . ' days'));
        $posts = $wpdb->get_results("SELECT P.* FROM {$wpdb->posts} P LEFT JOIN wp_icl_translations T ON P.id = T.element_id WHERE P.post_type = 'post' AND P.post_status = 'publish' AND T.language_code = '{$lang}' AND P.post_date > '{$interval}' ORDER BY P.comment_count DESC LIMIT 0 , {$number}");
        echo '<ul>';
        foreach ($posts as $post) {
            setup_postdata($post);
            $offset = '';
            if (has_post_thumbnail() && !$hide_thumb) {
                $offset = 'offset';
            }
            ?>

            <li class="hentry-thumb clear">
                <span class="hentry-thumb-image"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            if (has_post_thumbnail() && !$hide_thumb) {
                the_post_thumbnail('micro', array('alt' => trim(strip_tags(get_the_title())), 'title' => trim(strip_tags(get_the_title()))));
            }
            ?>
</a></span>
                <span class="hentry-thumb-meta <?php 
            echo $offset;
            ?>
"><?php 
            if (function_exists('unspoken_posted_on')) {
                unspoken_posted_on($postedon_data);
            }
            ?>
</span>
                <span class="hentry-thumb-title <?php 
            echo $offset;
            ?>
"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a></span>
             </li>

        <?php 
        }
        echo '</ul>';
        echo $after_widget;
    }