function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $kopa_query_args['categories'] = $instance['categories'];
        $kopa_query_args['posts_per_page'] = (int) $instance['number_of_article'];
        $kopa_query_args['orderby'] = $instance['orderby'];
        if (isset($instance['kopa_timestamp'])) {
            $kopa_query_args['date_query'] = $instance['kopa_timestamp'];
        }
        if (!empty($instance['categories'])) {
            echo $before_widget;
            if (!empty($title)) {
                echo '<span class="kp-headline-title"> ' . $title . '</span>';
            }
            ?>

        <?php 
            $kopa_slider = kopa_widget_posttype_build_query($kopa_query_args);
            if ($kopa_slider->have_posts()) {
                ?>
            <div class="kp-headline clearfix">                        
                        <dl class="ticker-1 clearfix">
                            <?php 
                while ($kopa_slider->have_posts()) {
                    $kopa_slider->the_post();
                    ?>
                            <dd><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></dd>
                            <?php 
                }
                ?>
                            
                            
                        </dl>
                        <!--ticker-1-->
                    </div>

        <?php 
            }
            wp_reset_postdata();
            echo $after_widget;
        }
    }
Example #2
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $query_args = array();
        $query_args['categories'] = empty($instance['categories']) ? array() : $instance['categories'];
        $query_args['relation'] = isset($instance['relation']) ? $instance['relation'] : 'OR';
        $query_args['tags'] = empty($instance['tags']) ? array() : $instance['tags'];
        $query_args['posts_per_page'] = isset($instance['number_of_article']) ? $instance['number_of_article'] : -1;
        $query_args['orderby'] = isset($instance['orderby']) ? $instance['orderby'] : 'latest';
        if (isset($instance['kopa_timestamp'])) {
            $query_args['date_query'] = $instance['kopa_timestamp'];
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $posts = kopa_widget_posttype_build_query($query_args);
        if ($posts->have_posts()) {
            ?>
            
            <?php 
            while ($posts->have_posts()) {
                $posts->the_post();
                ?>

                <div class="widget kp-article-list-widget clearfix">
                    <article class="entry-item clearfix">
                        <?php 
                if (has_post_thumbnail()) {
                    ?>
                        <div class="entry-thumb">
                            <a href="<?php 
                    the_permalink();
                    ?>
"><img src="<?php 
                    echo kopa_get_image_src(get_the_ID(), 'article-list-image-size');
                    ?>
" alt="<?php 
                    echo get_the_title();
                    ?>
"></a>
                        </div>
                        <?php 
                }
                ?>
                        <div class="entry-content">
                            <h4 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h4>
                            <span class="entry-date">&mdash; <?php 
                the_time(get_option('date_format'));
                ?>
</span>
                            <?php 
                the_excerpt();
                ?>
                        </div>
                    </article>
                </div>

            <?php 
            }
            // endwhile
            ?>

        <?php 
        }
        // endif
        ?>

        <?php 
        wp_reset_postdata();
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $animation = $instance['animation'];
        $direction = $instance['direction'];
        $slideshowSpeed = $instance['slideshowSpeed'];
        $animationSpeed = $instance['animationSpeed'];
        $numpost = (int) $instance['number_of_article'];
        $is_Autoplay = $instance['isAutoplay'];
        if ($numpost > 4) {
            $smallpost = 4;
            $bigpost = $numpost - $smallpost;
        } else {
            $bigpost = 1;
            $smallpost = $numpost - $bigpost;
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
        <?php 
        $kopa_big_query_args['categories'] = $instance['categories'];
        $kopa_big_query_args['relation'] = $instance['relation'];
        $kopa_big_query_args['tags'] = $instance['tags'];
        $kopa_big_query_args['posts_per_page'] = $bigpost;
        $kopa_big_query_args['orderby'] = $instance['orderby'];
        if (isset($instance['kopa_timestamp'])) {
            $kopa_big_query_args['date_query'] = $instance['kopa_timestamp'];
        }
        $kopa_big_post = kopa_widget_posttype_build_query($kopa_big_query_args);
        $not_in_small = array();
        foreach ($kopa_big_post->posts as $key => $value) {
            $not_in_small[] = $value->ID;
        }
        if ($kopa_big_post->have_posts()) {
            ?>
            <article class="last-item clearfix">
                <div class="flexslider kp-featured-slider loading" data-animation = "<?php 
            echo $animation;
            ?>
" data-direction = "<?php 
            echo $direction;
            ?>
" data-slideshow-speed = "<?php 
            echo $slideshowSpeed;
            ?>
" data-animation-speed = "<?php 
            echo $animationSpeed;
            ?>
" data-autoplay = "<?php 
            echo $is_Autoplay;
            ?>
">
                    <ul class="slides">
                        <?php 
            while ($kopa_big_post->have_posts()) {
                $kopa_big_post->the_post();
                $post_format = get_post_format(get_the_ID());
                if ($post_format == '') {
                    $post_format = 'standard';
                }
                ?>
                            <li class="<?php 
                echo $post_format;
                ?>
-post">
                                <?php 
                if (has_post_thumbnail()) {
                    ?>
                                    <div class="entry-thumb">
                                        <a href="<?php 
                    the_permalink();
                    ?>
">
                                            <?php 
                    the_post_thumbnail('kopa-image-size-0');
                    ?>
    
                                        </a>
                                    </div>
                                <?php 
                }
                ?>
                                <!-- entry-thumb -->
                                <div class="entry-content">
                                    <span class="h-line"></span>
                                    <header class="clearfix">
                                        <span class="entry-icon pull-left text-center"><span class="fa fa-camera-retro"></span></span>
                                        <div class="header-content">
                                            <h6 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a><span class="bottom-line"></span></h6>
                                            <?php 
                if (get_the_category()) {
                    ?>
                                                <span class="entry-categories"><?php 
                    echo __('Posted in:', kopa_get_domain());
                    ?>
 <?php 
                    the_category(', ');
                    ?>
</span>
                                            <?php 
                }
                // endif
                ?>
                                            <?php 
                if (get_the_tags()) {
                    ?>
                                                <span class="entry-tags"><span class="entry-bullet"></span><?php 
                    echo __('Tags:', kopa_get_domain());
                    ?>
 <?php 
                    the_tags('', ', ', '');
                    ?>
</span>
                                            <?php 
                }
                // endif
                ?>
                                        </div>
                                        <!-- header-content -->
                                    </header>
                                    <?php 
                the_excerpt();
                ?>
                                </div>
                                <!-- entry-content -->
                            </li>


                            <?php 
            }
            ?>
                    </ul>
                    <!-- slides -->
                </div>
                <!-- kp-blogpost-slider -->
            </article>

            <?php 
        }
        wp_reset_postdata();
        ?>
        <?php 
        $kopa_query_args_small['categories'] = $instance['categories'];
        $kopa_query_args_small['relation'] = $instance['relation'];
        $kopa_query_args_small['tags'] = $instance['tags'];
        $kopa_query_args_small['posts_per_page'] = $smallpost;
        $kopa_query_args_small['orderby'] = $instance['orderby'];
        $kopa_query_args_small['post__not_in'] = $not_in_small;
        if (isset($instance['kopa_timestamp'])) {
            $kopa_query_args_small['date_query'] = $instance['kopa_timestamp'];
        }
        $kopa_small_post = kopa_widget_posttype_build_query($kopa_query_args_small);
        if ($kopa_small_post->have_posts()) {
            ?>
            <div class="masonry-wrapper">
                <div class="v-line"></div>
                <ul class="older-post masonry-container transitions-enabled centered clearfix masonry">
                    <?php 
            while ($kopa_small_post->have_posts()) {
                $kopa_small_post->the_post();
                ?>

                        <li class="masonry-box">
                            <article class="entry-item clearfix">

                                <?php 
                if (has_post_thumbnail()) {
                    ?>
                                    <div class="entry-thumb">
                                        <a href="<?php 
                    the_permalink();
                    ?>
">
                                            <?php 
                    the_post_thumbnail('kopa-image-size-1');
                    ?>
                                        </a>
                                    </div>
                                <?php 
                }
                ?>
                                <!-- entry-thumb -->
                                <div class="entry-content">
                                    <header>
                                        <h6 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h6>
                                        <?php 
                if (get_the_category()) {
                    ?>
                                            <span class="entry-categories"><?php 
                    echo __('Posted in:', kopa_get_domain());
                    ?>
 <?php 
                    the_category(', ');
                    ?>
</span>
                                        <?php 
                }
                // endif
                ?>
                                        <?php 
                if (get_the_tags()) {
                    ?>
                                            <span class="entry-tags"><span class="entry-bullet"></span><?php 
                    echo __('Tags:', kopa_get_domain());
                    ?>
 <?php 
                    the_tags('', ', ', '');
                    ?>
</span>
                                        <?php 
                }
                // endif
                ?>
                                    </header>
                                </div>
                                <!-- entry-content -->
                            </article>
                            <!-- entry-item -->
                        </li>

                    <?php 
            }
            ?>

                </ul>
                <!-- older-post -->
            </div>
            <?php 
        }
        wp_reset_postdata();
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        echo $before_widget;
        $kopa_tab_args = array();
        if ($instance['title1']) {
            $kopa_tab_args[] = array('label' => $instance['title1'], 'orderby' => 'date', 'post_per_page' => $instance['num1']);
        }
        if ($instance['title2']) {
            $kopa_tab_args[] = array('label' => $instance['title2'], 'orderby' => 'popular', 'post_per_page' => $instance['num2']);
        }
        if ($instance['title3']) {
            $kopa_tab_args[] = array('label' => $instance['title3'], 'orderby' => 'most_comment', 'post_per_page' => $instance['num3']);
        }
        if ($instance['title4']) {
            $kopa_tab_args[] = array('label' => $instance['title4'], 'orderby' => 'random', 'post_per_page' => $instance['num4']);
        }
        ?>
        <div class="acc-wrapper">
            <?php 
        foreach ($kopa_tab_args as $kopa_tab_arg) {
            ?>
                <?php 
            $kopa_query['posts_per_page'] = $kopa_tab_arg['post_per_page'];
            $kopa_query['orderby'] = $kopa_tab_arg['orderby'];
            if (isset($instance['kopa_timestamp'])) {
                $kopa_query['date_query'] = $instance['kopa_timestamp'];
            }
            $kopa_my_query = kopa_widget_posttype_build_query($kopa_query);
            ?>
                <div class="accordion-title">
                    <h3><a href="#"><?php 
            echo $kopa_tab_arg['label'];
            ?>
</a></h3>
                    <span>+</span>
                </div>
                <div class="accordion-container">
                    <ul>
                        <?php 
            if ($kopa_my_query->have_posts()) {
                while ($kopa_my_query->have_posts()) {
                    $kopa_my_query->the_post();
                    ?>
                                <li>
                                    <article class="entry-item clearfix">
                                        <?php 
                    if (has_post_thumbnail()) {
                        ?>
                                            <div class="entry-thumb">
                                                <a href="<?php 
                        the_permalink();
                        ?>
">
                                                    <?php 
                        the_post_thumbnail('kopa-image-size-1');
                        ?>
  
                                                </a>
                                            </div>
                                        <?php 
                    }
                    ?>
                                        <div class="entry-content">
                                            <header>
                                                <h6 class="entry-title"><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h6>
                                                <?php 
                    if (get_the_category()) {
                        ?>
                                                    <span class="entry-categories"><?php 
                        echo __('Posted in:', kopa_get_domain());
                        ?>
 <?php 
                        the_category(', ');
                        ?>
</span>
                                                <?php 
                    }
                    // endif
                    ?>
                                                <?php 
                    if (comments_open()) {
                        ?>
                                                <span class="entry-comments"><span class="entry-bullet"></span><?php 
                        echo __('Comments', kopa_get_domain());
                        ?>
: <?php 
                        comments_popup_link(__('0', kopa_get_domain()), __('1', kopa_get_domain()), __('%', kopa_get_domain()));
                        ?>
  </span>
                                                <?php 
                    }
                    ?>
                                            </header>
                                        </div>
                                    </article>
                                </li>
                                <?php 
                }
            }
            wp_reset_postdata();
            ?>

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

        </div>

        <?php 
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $categories = array();
        $categories = $instance['categories'];
        $animation = $instance['animation'];
        $direction = $instance['direction'];
        if (!empty($categories)) {
            echo $before_widget;
            if (!empty($title)) {
                echo $before_title . $title . $after_title;
            }
            ?>
        
        <div class="flexslider kp-topping-slider loading" data-animation = "<?php 
            echo $animation;
            ?>
" data-direction = "<?php 
            echo $direction;
            ?>
">
            <ul class="slides">
                <?php 
            foreach ($categories as $cate) {
                $cat = (int) $cate;
                $kopa_query_args['categories'] = $cate;
                $kopa_query_args['posts_per_page'] = (int) $instance['number_of_article'];
                $kopa_query_args['orderby'] = $instance['orderby'];
                if (isset($instance['kopa_timestamp'])) {
                    $kopa_query_args['date_query'] = $instance['kopa_timestamp'];
                }
                $kopa_slider = kopa_widget_posttype_build_query($kopa_query_args);
                ?>
                    <li>
                        <ul>
                            <?php 
                if ($kopa_slider->have_posts()) {
                    ?>

                                <?php 
                    while ($kopa_slider->have_posts()) {
                        $kopa_slider->the_post();
                        ?>
                                    <li>
                                        <article class="entry-item clearfix">
                                            <?php 
                        if (has_post_thumbnail()) {
                            ?>
                                                <div class="entry-thumb">
                                                    <a href="<?php 
                            the_permalink();
                            ?>
">
                                                        <?php 
                            the_post_thumbnail('kopa-image-size-1');
                            ?>
                                                    </a>
                                                </div>
                                            <?php 
                        }
                        ?>
                                            <div class="entry-content">
                                                <header>
                                                    <h6 class="entry-title"><a href="<?php 
                        the_permalink();
                        ?>
"><?php 
                        the_title();
                        ?>
</a></h6>

                                                    <?php 
                        if (get_the_category()) {
                            ?>
                                                        <span class="entry-categories"><?php 
                            echo __('Posted in:', kopa_get_domain());
                            ?>
 <?php 
                            the_category(', ');
                            ?>
</span>
                                                    <?php 
                        }
                        // endif
                        ?>
                                                   <?php 
                        if (comments_open()) {
                            ?>
                                                <span class="entry-comments"><span class="entry-bullet"></span><?php 
                            echo __('Comments', kopa_get_domain());
                            ?>
: <?php 
                            comments_popup_link(__('0', kopa_get_domain()), __('1', kopa_get_domain()), __('%', kopa_get_domain()));
                            ?>
  </span>
                                                <?php 
                        }
                        ?>
                                                </header>
                                            </div>
                                        </article>
                                    </li>
                                    <?php 
                    }
                }
                wp_reset_postdata();
                ?>
                        </ul>
                    </li>
                    <?php 
            }
            ?>
  
            </ul>
        </div>
        <?php 
            echo $after_widget;
        }
    }
    function widget($args, $instance)
    {
        extract($args);
        $animation = $instance['animation'];
        $direction = $instance['direction'];
        $slideshowSpeed = $instance['slideshowSpeed'];
        $animationSpeed = $instance['animationSpeed'];
        $isAutoplay = $instance['isAutoplay'];
        $kopa_query_args['categories'] = $instance['categories'];
        $kopa_query_args['relation'] = $instance['relation'];
        $kopa_query_args['tags'] = $instance['tags'];
        $kopa_query_args['posts_per_page'] = (int) $instance['number_of_article'];
        $kopa_query_args['orderby'] = $instance['orderby'];
        if (isset($instance['kopa_timestamp'])) {
            $kopa_query_args['date_query'] = $instance['kopa_timestamp'];
        }
        $kopa_slider = kopa_widget_posttype_build_query($kopa_query_args);
        if ($kopa_slider->have_posts()) {
            ?>
            <div class="flexslider kp-blogpost-thumb-slider loading" data-animation = "<?php 
            echo $animation;
            ?>
" data-direction = "<?php 
            echo $direction;
            ?>
" data-slideshow-speed = "<?php 
            echo $slideshowSpeed;
            ?>
" data-animation-speed = "<?php 
            echo $animationSpeed;
            ?>
" data-autoplay = "<?php 
            echo $isAutoplay;
            ?>
" >
                <ul class="slides">
                    <?php 
            while ($kopa_slider->have_posts()) {
                $kopa_slider->the_post();
                if (has_post_thumbnail()) {
                    $image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'kopa-image-size-0');
                    ?>
                            <li data-thumb="<?php 
                    echo $image_url[0];
                    ?>
">
                                <a href="<?php 
                    the_permalink();
                    ?>
">
                                    <?php 
                    the_post_thumbnail('kopa-image-size-0');
                    ?>
                                </a>
                                <div class="flex-caption">
                                    <h2><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h2>
                                    <?php 
                    if (get_the_category()) {
                        ?>
                                        <span class="entry-categories"><?php 
                        echo __('Posted in:', kopa_get_domain());
                        ?>
 <?php 
                        the_category(', ');
                        ?>
</span>
                                    <?php 
                    }
                    // endif
                    ?>
                                    <?php 
                    if (get_the_tags()) {
                        ?>
                                        <span class="entry-tags"><span class="entry-bullet"></span><?php 
                        echo __('Tags:', kopa_get_domain());
                        ?>
 <?php 
                        the_tags('', ', ', '');
                        ?>
</span>
                                    <?php 
                    }
                    // endif
                    ?>
                                </div>
                            </li>
                            <?php 
                }
            }
            ?>
 
                </ul>
            </div>
            <?php 
        }
        wp_reset_postdata();
    }
Example #7
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $query_args['post_type'] = 'post';
        $query_args['cat_name'] = 'category';
        $query_args['tag_name'] = 'post_tag';
        $query_args['categories'] = $instance['categories'];
        $query_args['relation'] = esc_attr($instance['relation']);
        $query_args['tags'] = $instance['tags'];
        $query_args['posts_per_page'] = (int) $instance['posts_per_page'];
        $query_args['orderby'] = $instance['orderby'];
        $posts = kopa_widget_posttype_build_query($query_args);
        if ($posts->post_count == 0) {
            return;
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . '<span data-icon="&#xf03e;"></span>' . $title . $after_title;
        }
        ?>

            <a class="prev" href="#"></a>
            <a class="next" href="#"></a>
            
            <div class="sequence-slider">
            
                <div id="sequence" class="kopa-sequence-slider">
                    <ul>
                    <?php 
        if ($posts->have_posts()) {
            while ($posts->have_posts()) {
                $posts->the_post();
                $slider_background_image = '';
                if (get_post_meta(get_the_ID(), 'slider_background_image', true)) {
                    $slider_background_image = get_post_meta(get_the_ID(), 'slider_background_image', true);
                }
                ?>
                        <li id="<?php 
                echo $this->get_field_id('sequence_slider-item') . '-' . get_the_ID();
                ?>
" style="background: url(<?php 
                echo $slider_background_image;
                ?>
);">
                            <div class="title-2"><h2><?php 
                the_title();
                ?>
</h2></div>
                            <div class="subtitle-2 animate-in">
                                <?php 
                the_excerpt();
                ?>
                            </div>
                            <div class="model-2-1">
                                <div class="video-wrapper">
                                    <a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_post_thumbnail('kopa-image-size-11');
                ?>
</a>
                                </div>
                            </div>
                        </li>
                    <?php 
            }
        }
        ?>
                    </ul>
                </div><!--sequence-->
                                
            </div><!--sequence-slider-->
        
        <?php 
        wp_reset_postdata();
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $animation = $instance['animation'];
        $direction = $instance['direction'];
        $slideshowSpeed = $instance['slideshowSpeed'];
        $animationSpeed = $instance['animationSpeed'];
        $is_Autoplay = $instance['isAutoplay'];
        $kopa_query_args['categories'] = $instance['categories'];
        $kopa_query_args['relation'] = $instance['relation'];
        $kopa_query_args['tags'] = $instance['tags'];
        $kopa_query_args['posts_per_page'] = intval($instance['number_of_article']);
        $kopa_query_args['orderby'] = $instance['orderby'];
        if (isset($instance['kopa_timestamp'])) {
            $kopa_query_args['date_query'] = $instance['kopa_timestamp'];
        }
        $kopa_slider = kopa_widget_posttype_build_query($kopa_query_args);
        if ($kopa_slider->have_posts()) {
            ?>
            <div class="flexslider kp-blogpost-slider loading" data-animation = "<?php 
            echo $animation;
            ?>
" data-direction = "<?php 
            echo $direction;
            ?>
" data-slideshow-speed = "<?php 
            echo $slideshowSpeed;
            ?>
" data-animation-speed = "<?php 
            echo $animationSpeed;
            ?>
" data-autoplay = "<?php 
            echo $is_Autoplay;
            ?>
" >
                <ul class="slides">
                    <?php 
            while ($kopa_slider->have_posts()) {
                $kopa_slider->the_post();
                $post_format = get_post_format(get_the_ID());
                if ($post_format == '') {
                    $post_format = 'standard';
                }
                ?>
                        <li class="<?php 
                echo $post_format;
                ?>
-post">
                            <?php 
                if (has_post_thumbnail()) {
                    ?>
                                <div class="entry-thumb">
                                    <a href="<?php 
                    the_permalink();
                    ?>
">
                                        <?php 
                    the_post_thumbnail('kopa-image-size-0');
                    ?>
                                    </a>
                                </div>
                                <!-- entry-thumb -->
                            <?php 
                }
                ?>
                            <div class="entry-content">
                                <span class="h-line"></span>
                                <header class="clearfix">
                                    <span class="entry-icon pull-right text-center"><span class="fa fa-camera-retro"></span></span>
                                    <div class="header-content">
                                        <h6 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a><span class="bottom-line"></span></h6>
                                        <?php 
                if (get_the_category()) {
                    ?>
                                            <span class="entry-categories"> <?php 
                    the_category(', ');
                    ?>
</span>
                                        <?php 
                }
                // endif
                ?>
                                    </div>
                                    <!-- header-content -->
                                </header>
                            </div>
                            <!-- entry-content -->
                        </li>
                        <?php 
            }
            ?>
                </ul>
            </div>
            <?php 
        }
        wp_reset_postdata();
    }
Example #9
0
    function show_entry_list_style_1($query_args)
    {
        $posts = kopa_widget_posttype_build_query($query_args);
        if ($posts->have_posts()) {
            $post_index = 1;
            while ($posts->have_posts()) {
                $posts->the_post();
                if ($post_index == 1) {
                    // show the thumbnail of the first post
                    ?>
                    <article class="entry-item">
                        <div class="entry-thumb">
                            <?php 
                    if (get_post_format() == 'gallery') {
                        ?>

                                <div class="entry-thumb-slider flexslider">
                                    <ul class="slides">
                                        <?php 
                        if (has_post_thumbnail()) {
                            ?>
                                            <li><img src="<?php 
                            echo kopa_get_image_src(get_the_ID(), 'kopa-image-size-4');
                            ?>
" alt="<?php 
                            echo get_the_title();
                            ?>
"></li>
                                        <?php 
                        }
                        $gallery = kopa_content_get_gallery(get_the_content());
                        if (isset($gallery[0])) {
                            $gallery = $gallery[0];
                        } else {
                            $gallery = '';
                        }
                        if (isset($gallery['shortcode'])) {
                            $shortcode = $gallery['shortcode'];
                        } else {
                            $shortcode = '';
                        }
                        // get gallery string ids
                        preg_match_all('/ids=\\"(?:\\d+,*)+\\"/', $shortcode, $gallery_string_ids);
                        if (isset($gallery_string_ids[0][0])) {
                            $gallery_string_ids = $gallery_string_ids[0][0];
                        } else {
                            $gallery_string_ids = '';
                        }
                        // get array of image id
                        preg_match_all('/\\d+/', $gallery_string_ids, $gallery_ids);
                        if (isset($gallery_ids[0])) {
                            $gallery_ids = $gallery_ids[0];
                        } else {
                            $gallery_ids = '';
                        }
                        if (!empty($gallery_ids)) {
                            foreach ($gallery_ids as $gallery_id) {
                                if (wp_attachment_is_image($gallery_id)) {
                                    echo '<li>' . wp_get_attachment_image($gallery_id, 'kopa-image-size-4') . '</li>';
                                }
                            }
                        }
                        ?>
                                    </ul><!--slides-->
                                </div><!--entry-thumb-slider-->

                            <?php 
                    } elseif (get_post_format() == 'video') {
                        $video = kopa_content_get_video(get_the_content());
                        if (isset($video[0])) {
                            $video = $video[0];
                            if (isset($video['url']) && !empty($video['url'])) {
                                ?>
                                            <a class="play-icon" href="<?php 
                                echo esc_url($video['url']);
                                ?>
" rel="prettyPhoto[<?php 
                                echo $this->get_field_id('video');
                                ?>
]"></a>
                            <?php 
                            }
                            // endif isset( $video['url']
                        }
                        // endif isset( $video[0] )
                        ?>
                                    <a href="<?php 
                        the_permalink();
                        ?>
"><?php 
                        if (has_post_thumbnail()) {
                            ?>
                                        <img src="<?php 
                            echo kopa_get_image_src(get_the_ID(), 'kopa-image-size-4');
                            // 53x53
                            ?>
" alt="<?php 
                            echo get_the_title();
                            ?>
">
                                    <?php 
                        } elseif (isset($video['url']) && isset($video['type'])) {
                            echo '<img src="' . kopa_get_video_thumbnails_url($video['type'], $video['url']) . '">';
                        }
                        ?>
</a>
                            <?php 
                    } else {
                        ?>
                                <?php 
                        if (has_post_thumbnail()) {
                            ?>
 
                                    <a href="<?php 
                            the_permalink();
                            ?>
">
                                        <img src="<?php 
                            echo kopa_get_image_src(get_the_ID(), 'kopa-image-size-4');
                            // 53x53
                            ?>
" alt="<?php 
                            echo get_the_title();
                            ?>
">
                                    </a>
                                <?php 
                        }
                        ?>
                            <?php 
                    }
                    ?>
                        </div>
                        <div class="entry-content">
                            <header>
                                <h4 class="entry-title"><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    echo get_the_title();
                    ?>
</a></h4>
                                <span class="entry-date"><span class="kopa-minus"></span><?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
                            </header>
                            <?php 
                    the_excerpt();
                    ?>
                        </div>
                    </article><!--entry-item-->

        <?php 
                    echo $posts->post_count > 1 ? '<ul class="older-post">' : '';
                } else {
                    // $post_index != 1 ( the rest posts )
                    ?>
                    <li>
                        <a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    echo get_the_title();
                    ?>
</a>
                        <?php 
                    the_excerpt();
                    ?>
                    </li>
        <?php 
                }
                // endif $post_index == 1
                $post_index++;
                // increase post index by 1
            }
            // endwhile $posts->have_posts()
            echo $posts->post_count > 1 ? '</ul><!-- .older-post -->' : '';
        } else {
            // if ! $posts->have_posts()
            _e('No Posts Found', kopa_get_domain());
        }
        wp_reset_postdata();
    }
Example #10
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $query_args['posts_per_page'] = $instance['number_of_article'];
        $orderbys = array('lastest', 'popular', 'most_comment');
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>

        <div class="list-container-2">
            <ul class="tabs-2 clearfix">
                <li class="active"><a href="#<?php 
        echo $this->get_field_id('tab') . '-lastest';
        ?>
"><?php 
        _e('Latest', kopa_get_domain());
        ?>
</a></li>
                <li><a href="#<?php 
        echo $this->get_field_id('tab') . '-popular';
        ?>
"><?php 
        _e('Popular', kopa_get_domain());
        ?>
</a></li>
                <li><a href="#<?php 
        echo $this->get_field_id('tab') . '-most_comment';
        ?>
"><?php 
        _e('Comments', kopa_get_domain());
        ?>
</a></li>
            </ul><!--tabs-2-->
        </div>

        <div class="tab-container-2">

        <?php 
        foreach ($orderbys as $orderby) {
            $query_args['orderby'] = $orderby;
            $posts = kopa_widget_posttype_build_query($query_args);
            ?>

            <div class="tab-content-2" id="<?php 
            echo $this->get_field_id('tab') . '-' . $orderby;
            ?>
">                        
                <ul>
                <?php 
            if ($posts->have_posts()) {
                while ($posts->have_posts()) {
                    $posts->the_post();
                    ?>

                        <li>
                            <article class="entry-item clearfix">
                                <div class="entry-thumb">
                                    <?php 
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('kopa-image-size-4');
                        // 81 x 81
                    } elseif ('video' == get_post_format()) {
                        $video = kopa_content_get_video(get_the_content());
                        if (isset($video[0])) {
                            $video = $video[0];
                        } else {
                            $video = '';
                        }
                        if (isset($video['type']) && isset($video['url'])) {
                            $video_thumbnail_url = kopa_get_video_thumbnails_url($video['type'], $video['url']);
                            echo '<img src="' . esc_url($video_thumbnail_url) . '" alt="' . get_the_title() . '">';
                        }
                    } elseif ('gallery' == get_post_format()) {
                        $gallery_ids = kopa_content_get_gallery_attachment_ids(get_the_content());
                        if (!empty($gallery_ids)) {
                            foreach ($gallery_ids as $id) {
                                if (wp_attachment_is_image($id)) {
                                    echo wp_get_attachment_image($id, 'kopa-image-size-4');
                                    // 81 x 81
                                    break;
                                }
                            }
                        }
                    }
                    // endif has_post_thumbnail
                    ?>
                                </div>
                                <div class="entry-content">
                                    <h4 class="entry-title"><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h4>
                                    <div class="meta-box">
                                        <span class="entry-date"><?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
                                        <span class="entry-author"><?php 
                    _e('By', kopa_get_domain());
                    ?>
 <?php 
                    the_author_posts_link();
                    ?>
</span>
                                    </div>
                                </div>
                            </article>
                        </li>

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

            <?php 
            wp_reset_postdata();
        }
        // endforeach
        ?>

        </div>

        <?php 
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $big_query_args['categories'] = $instance['categories'];
        $big_query_args['relation'] = $instance['relation'];
        $big_query_args['tags'] = $instance['tags'];
        $big_query_args['posts_per_page'] = 1;
        $big_query_args['orderby'] = $instance['orderby'];
        if (isset($instance['kopa_timestamp'])) {
            $big_query_args['date_query'] = $instance['kopa_timestamp'];
        }
        $big_post = kopa_widget_posttype_build_query($big_query_args);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        ?>
        
        <?php 
        if ($big_post->have_posts()) {
            while ($big_post->have_posts()) {
                $big_post->the_post();
                ?>
                <article class="entry-item last-item clearfix">

                    <?php 
                if (has_post_thumbnail()) {
                    ?>
                        <div class="entry-thumb">
                            <a href="<?php 
                    the_permalink();
                    ?>
">
                                <?php 
                    the_post_thumbnail('kopa-image-size-2');
                    ?>
                            </a>
                        </div>
                    <?php 
                }
                ?>
                    <!-- entry-thumb -->
                    <div class="entry-content">
                        <header>
                            <h6 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h6>
                            <?php 
                $category = get_the_category(get_the_ID());
                ?>
                            <?php 
                if (get_the_category()) {
                    ?>
                                <span class="entry-categories"><?php 
                    echo __('Posted in:', kopa_get_domain());
                    ?>
 <?php 
                    the_category(', ');
                    ?>
</span>
                            <?php 
                }
                // endif
                ?>
                            <?php 
                if (get_the_tags()) {
                    ?>
                                <span class="entry-tags"><span class="entry-bullet"></span><?php 
                    echo __('Tags:', kopa_get_domain());
                    ?>
 <?php 
                    the_tags('', ', ', '');
                    ?>
</span>
                            <?php 
                }
                // endif
                ?>

                        </header>
                        <?php 
                the_excerpt();
                ?>
                        <a href="<?php 
                the_permalink();
                ?>
" class="more-link kp-button"><span><?php 
                echo __('Read More', kopa_get_domain());
                ?>
</span></a>
                    </div>
                    <!-- entry-content -->
                </article>

                <?php 
            }
        }
        wp_reset_postdata();
        ?>

        <?php 
        if ($instance['number_of_article'] > 1) {
            $small_query_args['categories'] = $instance['categories'];
            $small_query_args['relation'] = $instance['relation'];
            $small_query_args['tags'] = $instance['tags'];
            $small_query_args['posts_per_page'] = (int) $instance['number_of_article'] - 1;
            $small_query_args['orderby'] = $instance['orderby'];
            $small_query_args['ignore_sticky_posts'] = 1;
            if (isset($instance['kopa_timestamp'])) {
                $small_query_args['date_query'] = $instance['kopa_timestamp'];
            }
            if ($big_post->have_posts()) {
                $small_query_args['post__not_in'] = array($big_post->post->ID);
            }
            $small_post = kopa_widget_posttype_build_query($small_query_args);
            if ($small_post->have_posts()) {
                ?>
            <ul class="older-post">
            <?php 
                while ($small_post->have_posts()) {
                    $small_post->the_post();
                    ?>
                    <li>
                        <article class="entry-item clearfix">
                <?php 
                    if (has_post_thumbnail()) {
                        ?>
                                <div class="entry-thumb">
                                    <a href="<?php 
                        the_permalink();
                        ?>
"><?php 
                        the_post_thumbnail('kopa-image-size-1');
                        ?>
</a>
                                </div>
                <?php 
                    }
                    ?>
                            <!-- entry-thumb -->
                            <div class="entry-content">
                                <header>
                                    <h6 class="entry-title"><a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h6>
                                    <?php 
                    if (get_the_category()) {
                        ?>
                                        <span class="entry-categories"><?php 
                        echo __('Posted in:', kopa_get_domain());
                        ?>
 <?php 
                        the_category(', ');
                        ?>
</span>
                                    <?php 
                    }
                    // endif
                    ?>
                                    <?php 
                    if (get_the_tags()) {
                        ?>
                                        <span class="entry-tags"><span class="entry-bullet"></span><?php 
                        echo __('Tags:', kopa_get_domain());
                        ?>
 <?php 
                        the_tags('', ', ', '');
                        ?>
</span>
                <?php 
                    }
                    // endif
                    ?>
                                </header>
                            </div>
                            <!-- entry-content -->
                        </article>
                        <!-- entry-item -->
                    </li>


                    <?php 
                }
                ?>
            </ul>
            <?php 
            }
            wp_reset_postdata();
        }
        ?>

        <div class="clear"></div>    
        <?php 
        echo $after_widget;
    }