Пример #1
0
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $instance['posts_per_page'] = 4;
        $query = $this->build_query($instance);
        $posts = new WP_Query($query);
        if ($posts->have_posts()) {
            ?>
    
            <div class="widget-content container clearfix">
                <div class="owl-slider-col-left pull-left">
                    <?php 
            $is_first = true;
            $loop_index = 0;
            while ($posts->have_posts()) {
                $posts->the_post();
                if (has_post_thumbnail()) {
                    $classes = array('owl-slider-navigation-post-title');
                    if ($is_first) {
                        $classes[] = 'active';
                        $classes[] = 'first';
                        $is_first = false;
                    }
                    ?>
                            <p class="<?php 
                    echo implode(' ', $classes);
                    ?>
" data-index="<?php 
                    echo $loop_index;
                    ?>
">
                                <?php 
                    echo get_the_title();
                    ?>
                            </p>
                            <?php 
                    $loop_index++;
                }
            }
            ?>
                
                </div>

                <div class="owl-slider-col-center pull-left">
                    <div class="owl-carousel" data-transition="<?php 
            echo $instance['transition_type'];
            ?>
">
                        <?php 
            $is_first = true;
            global $post;
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                $post_format = get_post_format();
                if (has_post_thumbnail()) {
                    $classes = array('owl-slider-single-slide');
                    if ($is_first) {
                        $classes[] = 'active';
                        $classes[] = 'first';
                        $classes[] = 'synced';
                        $is_first = false;
                    }
                    $image_croped = KopaImage::get_post_image_src($post_id, 'size_11');
                    ?>
                                <div class="<?php 
                    echo implode(' ', $classes);
                    ?>
">
                                    <?php 
                    if ('video' == $post_format) {
                        $video = KopaUtil::get_video($post->post_content, array('youtube', 'vimeo'));
                        if ($video) {
                            $url = '';
                            if ('youtube' == $video['type']) {
                                $url = 'http://www.youtube.com/watch?v=' . $video['id'];
                            } else {
                                if ('vimeo' == $video['type']) {
                                    $url = 'https://vimeo.com/' . $video['id'];
                                }
                            }
                            printf('<a class="kss-icon kss-icon-play" href="%s"><span class="fa fa-play"></span></a>', $url);
                        }
                    }
                    ?>
         

                                    <img src="<?php 
                    echo $image_croped;
                    ?>
" alt="<?php 
                    echo $post_title;
                    ?>
">
                                    <a href="<?php 
                    echo $post_url;
                    ?>
" title="<?php 
                    echo $post_title;
                    ?>
"><?php 
                    echo $post_title;
                    ?>
</a>                                                                       
                                </div>
                                <?php 
                }
            }
            ?>
                    </div>
                </div>

                <div class="owl-slider-col-right pull-left">
                    <div class="owl-carousel">
                        <?php 
            $is_first = true;
            while ($posts->have_posts()) {
                $posts->the_post();
                $post_id = get_the_ID();
                $post_title = get_the_title();
                $post_url = get_permalink();
                $post_format = get_post_format();
                if (has_post_thumbnail()) {
                    $classes = array('owl-slider-single-slide-detail');
                    if ($is_first) {
                        $classes[] = 'first';
                        $classes[] = 'synced';
                        $is_first = false;
                    }
                    ?>
                                <div class="<?php 
                    echo implode(' ', $classes);
                    ?>
">

                                    <span class="kopa-icon-post-format"><?php 
                    echo KopaIcon::getIconPostFormat($post_format, 'span');
                    ?>
</span>

                                    <?php 
                    if ('true' != $instance['is_hide_created_date']) {
                        ?>
                                        <span class="kopa-date"><?php 
                        echo get_the_date('M, j');
                        ?>
<br/><?php 
                        echo get_the_date('Y');
                        ?>
</span>                                                    
                                    <?php 
                    }
                    ?>


                                    <?php 
                    if ('true' != $instance['is_hide_views'] || 'true' != $instance['is_hide_comments'] || 'true' != $instance['is_hide_views']) {
                        ?>
                                        <ul class="kopa-metadata">                                               
                                            <?php 
                        if ('true' != $instance['is_hide_comments']) {
                            ?>
                                                <li class="metadata-first"><i class="fa fa-comment"></i><span><?php 
                            echo KopaUtil::get_comments($post_id, true);
                            ?>
</span></li>                                            
                                            <?php 
                        }
                        ?>

                                            <?php 
                        if ('true' != $instance['is_hide_views']) {
                            ?>
                                                <li><?php 
                            echo KopaIcon::getIconView();
                            ?>
<span><?php 
                            echo KopaUtil::get_views($post_id, false);
                            ?>
</span></li>
                                            <?php 
                        }
                        ?>

                                            <?php 
                        if ('true' != $instance['is_hide_likes']) {
                            ?>
                                                <li class="metadata-last"><?php 
                            echo KopaIcon::getIconLike();
                            ?>
<span><?php 
                            echo KopaUtil::get_likes($post_id, false);
                            ?>
</span></li>
                                                    <?php 
                        }
                        ?>
                                        </ul>      
                                    <?php 
                    }
                    ?>

                                </div>
                                <?php 
                }
            }
            ?>
                    </div>
                </div>
            </div>
            <?php 
        }
        wp_reset_postdata();
        echo $after_widget;
    }
Пример #2
0
 /**
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0         
  */
 public static function kopa_get_like_button($post_id, $include_text = false)
 {
     $class = '';
     if (self::is_liked($post_id)) {
         $class = 'kopa-button-likes-disable';
     } else {
         $class = 'kopa-button-likes-enable';
     }
     $onclick = sprintf('onclick="KopaFrontend.click_likes_button(event, jQuery(this), %s, \'%s\')"', $post_id, $include_text);
     $out = sprintf('<span class="%s" %s>%s<span>%s</span></span>', $class, $onclick, KopaIcon::getIconLike(), KopaUtil::get_likes($post_id, $include_text));
     return apply_filters('kopa_get_like_button', $out, $post_id);
 }
Пример #3
0
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $query = $this->build_query($instance);
        echo $before_widget;
        $unique_id = wp_generate_password(4, false, false);
        $latest_id = "latest-{$unique_id}";
        $most_comment_id = "most-comment-{$unique_id}";
        $most_view_id = "most-view-{$unique_id}";
        $most_like_id = "most-like-{$unique_id}";
        $params = array('is_hide_title' => 'true' == $instance['is_hide_title'] ? true : false, 'is_hide_views' => 'true' == $instance['is_hide_views'] ? true : false, 'is_hide_created_date' => 'true' == $instance['is_hide_created_date'] ? true : false, 'is_hide_comments' => 'true' == $instance['is_hide_comments'] ? true : false, 'is_hide_likes' => 'true' == $instance['is_hide_likes'] ? true : false, 'is_hide_excerpt' => 'true' == $instance['is_hide_excerpt'] ? true : false, 'excerpt_character_limit' => (int) $instance['excerpt_character_limit']);
        ?>
        

        <header>
            <?php 
        echo empty($title) ? '' : $before_title . $title . $after_title;
        ?>
            <?php 
        if (!$params['is_hide_created_date'] || !$params['is_hide_comments'] || !$params['is_hide_views'] || !$params['is_hide_likes']) {
            $is_first = true;
            $class = '';
            ?>
                <ul class="filter-isotope list-unstyled">
                    <?php 
            if (!$params['is_hide_created_date']) {
                if ($is_first) {
                    $class = 'active';
                    $is_first = false;
                } else {
                    $class = '';
                }
                ?>
                        <li class="<?php 
                echo $class;
                ?>
"><a class="kplaf_filter_name" href="#<?php 
                echo $latest_id;
                ?>
"><?php 
                echo KopaIcon::getIconDatetime();
                ?>
</a></li>
                    <?php 
            }
            ?>

                    <?php 
            if (!$params['is_hide_comments']) {
                if ($is_first) {
                    $class = 'active';
                    $is_first = false;
                } else {
                    $class = '';
                }
                ?>
                        <li class="<?php 
                echo $class;
                ?>
"><a class="kplaf_filter_name" href="#<?php 
                echo $most_comment_id;
                ?>
"><?php 
                echo KopaIcon::getIconComment();
                ?>
</a></li>
                    <?php 
            }
            ?>

                    <?php 
            if (!$params['is_hide_views']) {
                if ($is_first) {
                    $class = 'active';
                    $is_first = false;
                } else {
                    $class = '';
                }
                ?>
                        <li class="<?php 
                echo $class;
                ?>
"><a class="kplaf_filter_name" href="#<?php 
                echo $most_view_id;
                ?>
"><?php 
                echo KopaIcon::getIconView();
                ?>
</a></li>
                    <?php 
            }
            ?>

                    <?php 
            if (!$params['is_hide_likes']) {
                if ($is_first) {
                    $class = 'active';
                    $is_first = false;
                } else {
                    $class = '';
                }
                ?>
                        <li class="<?php 
                echo $class;
                ?>
"><a class="kplaf_filter_name" href="#<?php 
                echo $most_like_id;
                ?>
"><?php 
                echo KopaIcon::getIconLike();
                ?>
</a></li>
                    <?php 
            }
            ?>
                                    
                </ul>
            <?php 
        }
        ?>
                                                
        </header>

        <div class="widget-content">
            <?php 
        $sections = array('latest' => array('id' => $latest_id, 'title' => __('Latest', kopa_get_domain())), 'most-comment' => array('id' => $most_comment_id, 'title' => __('Most comment', kopa_get_domain())), 'most-view' => array('id' => $most_view_id, 'title' => __('Most view', kopa_get_domain())), 'most-like' => array('id' => $most_like_id, 'title' => __('Most like', kopa_get_domain())));
        if ($params['is_hide_created_date']) {
            unset($sections['latest']);
        }
        if ($params['is_hide_comments']) {
            unset($sections['most-comment']);
        }
        if ($params['is_hide_views']) {
            unset($sections['most-view']);
        }
        if ($params['is_hide_likes']) {
            unset($sections['most-like']);
        }
        if ($sections) {
            $is_first = true;
            foreach ($sections as $key => $section) {
                if ($is_first) {
                    $section_display = 'block';
                    $is_first = false;
                } else {
                    $section_display = 'none';
                }
                ?>
                    <div id="<?php 
                echo $section['id'];
                ?>
" class="section-content" style="display: <?php 
                echo $section_display;
                ?>
"  data-type="<?php 
                echo $key;
                ?>
" data-paged="1">
                        <div class="kp-isotope">
                            <?php 
                switch ($key) {
                    case 'latest':
                        self::get_latest($query, $params);
                        break;
                    case 'most-comment':
                        self::get_most_comment($query, $params);
                        break;
                    case 'most-view':
                        self::get_most_view($query, $params);
                        break;
                    case 'most-like':
                        self::get_most_like($query, $params);
                        break;
                }
                ?>
                        </div>                    
                    </div>
                    <?php 
            }
        }
        ?>
     
            
            <?php 
        if ('true' != $instance['is_hide_loadmore']) {
            ?>
                <p class="kplaf_load_more load-more"><span><?php 
            echo KopaIcon::getIcon('fa fa-spinner', 'i');
            ?>
&nbsp;<?php 
            _e('load more', kopa_get_domain());
            ?>
</span></p>
            <?php 
        }
        ?>
        </div>

        <?php 
        echo $after_widget;
    }