Пример #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
    function kopa_load_timeline_posts_fn($month, $year, $paged)
    {
        $args = array('date_query' => array('post_type' => array('post'), 'post_status' => array('publish'), 'ignore_sticky_posts' => true, array('year' => $year, 'month' => $month)));
        if ($paged) {
            $args['paged'] = $paged;
        }
        $posts = new WP_Query($args);
        $exceprt_type = KopaOptions::get_option('exceprt_type', 'limit');
        $excerpt_limit = KopaOptions::get_option('excerpt_limit', 200, 'Int');
        $metadata = array();
        $metadata['date'] = false;
        $metadata['comments'] = KopaOptions::get_option('is_display_comments', true, 'Boolean');
        $metadata['views'] = KopaOptions::get_option('is_display_views', true, 'Boolean');
        $metadata['likes'] = KopaOptions::get_option('is_display_likes', true, 'Boolean');
        $metadata['readmore'] = KopaOptions::get_option('is_display_readmore', true, 'Boolean');
        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 (!is_sticky()) {
                ?>
                <div class="item clearfix">
                    <p class="kopa-timeline-date-small"><?php 
                echo get_the_date();
                ?>
</p>
                    <?php 
                if (has_post_thumbnail()) {
                    $image_full = KopaImage::get_post_image_src($post_id, 'full');
                    $image_croped = KopaImage::get_post_image_src($post_id, 'size_09');
                    ?>
                        <div class="kopa-thumb">
                            <img src="<?php 
                    echo $image_croped;
                    ?>
" alt="<?php 
                    echo $post_title;
                    ?>
"/>
                            <div class="mask"></div>
                            <a href="<?php 
                    echo $post_url;
                    ?>
" class="icon-link fa fa-link fa-flip-horizontal"></a>
                            <span class="icon-zoom-in fa fa-search-plus" onclick="KopaLightbox.open_image('<?php 
                    echo $image_full;
                    ?>
');"></span>
                        </div>
                        <?php 
                }
                ?>

                    <div class="kp-caption">
                        <h4 class="post-title"><a href="<?php 
                echo $post_url;
                ?>
" title="<?php 
                echo $post_title;
                ?>
"><?php 
                echo $post_title;
                ?>
</a></h4>

                        <ul class="kp-meta-post list-inline">       
                            <?php 
                $is_first = true;
                foreach ($metadata as $key => $val) {
                    if ($val) {
                        $class = $is_first ? 'metadata-first' : '';
                        $is_first = false;
                        switch ($key) {
                            case 'date':
                                printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconDatetime(), get_the_date());
                                break;
                            case 'comments':
                                ?>
                                            <li class="<?php 
                                echo $class;
                                ?>
"><?php 
                                echo KopaIcon::getIconComment();
                                ?>
<span><?php 
                                comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                                ?>
</span></li>                                            
                                            <?php 
                                break;
                            case 'views':
                                printf('<li class="%s">%s<span>%s</span></li>', $class, KopaIcon::getIconView(), KopaUtil::get_views($post_id, true));
                                break;
                            case 'likes':
                                printf('<li class="%s">%s</li>', $class, KopaUtil::kopa_get_like_button($post_id, true));
                                break;
                        }
                    }
                }
                ?>
                        </ul>

                        <?php 
                if ('excerpt' == $exceprt_type) {
                    if (has_excerpt()) {
                        printf('<p>%s</p>', get_the_excerpt());
                    } else {
                        global $post;
                        if (strpos($post->post_content, '<!--more-->')) {
                            the_content(' ');
                        } else {
                            printf('<p>%s</p>', get_the_excerpt());
                        }
                    }
                } elseif ('full' == $exceprt_type) {
                    global $more;
                    $more = true;
                    the_content();
                } else {
                    if ($excerpt_limit) {
                        $excerpt = KopaUtil::substr($post->post_content, $excerpt_limit);
                        echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
                    }
                }
                ?>

                        <?php 
                if ($metadata['readmore'] && 'full' != $exceprt_type) {
                    ?>
                            <a href="<?php 
                    echo $post_url;
                    ?>
" class="read-more"><?php 
                    _e('Read more', kopa_get_domain());
                    ?>
</a>
                        <?php 
                }
                ?>

                    </div>
                    <!-- kp-caption -->
                    <div class="more-i">
                        <div class="more-time">
                            <span><?php 
                echo get_the_date('M d');
                ?>
</span> 
                            <i><?php 
                echo get_the_date('Y');
                ?>
</i>
                        </div>
                        <span></span>
                        <?php 
                echo KopaIcon::getIconPostFormat($post_format);
                ?>
                        
                    </div>
                    <!-- more i -->
                </div>
                <?php 
            }
        }
        wp_reset_postdata();
    }
Пример #3
0
    public static function get_html($query, $params, $paged = 1, $orderby = 'date')
    {
        global $post;
        $query['paged'] = (int) $paged;
        $posts = new WP_Query($query);
        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();
            ?>
            <div class="item">
                <?php 
            if (has_post_thumbnail()) {
                $image_croped = KopaImage::get_post_image_src($post_id, 'size_07');
                ?>
                    <figure>
                        <a href="<?php 
                echo $post_url;
                ?>
" class="pull-left">
                            <img src="<?php 
                echo $image_croped;
                ?>
" alt="">                                            
                            <span><?php 
                echo KopaIcon::getIconPostFormat($post_format);
                ?>
</span>
                        </a>                            
                    </figure>
                    <?php 
            }
            ?>

                <div class="item-content">
                    <?php 
            if (!$params['is_hide_title']) {
                ?>
                        <h4 class="post-title"><a href="<?php 
                echo $post_url;
                ?>
"><?php 
                echo $post_title;
                ?>
</a></h4>
                    <?php 
            }
            ?>
                   


                    <?php 
            if (!$params['is_hide_excerpt']) {
                if ((int) $params['excerpt_character_limit'] > 0) {
                    $excerpt = KopaUtil::substr($post->post_content, (int) $params['excerpt_character_limit']);
                    echo $excerpt ? sprintf('<p>%s</p>', $excerpt) : '';
                } else {
                    the_excerpt();
                }
            }
            ?>

                </div>

                <ul class="kp-meta-post bottom list-inline">
                    <li class="metadata-first"><?php 
            echo KopaIcon::getIconDatetime();
            ?>
<span><?php 
            echo get_the_date();
            ?>
</span></li>

                    <?php 
            switch ($orderby) {
                case 'views':
                    printf('<li>%s<span>%s</span></li>', KopaIcon::getIconView(), KopaUtil::get_views($post_id, true));
                    break;
                case 'likes':
                    printf('<li>%s</li>', KopaUtil::kopa_get_like_button($post_id, true));
                    break;
                default:
                    ?>
                            <li><?php 
                    echo KopaIcon::getIconComment();
                    comments_popup_link(__('No Comment', kopa_get_domain()), __('1 Comment', kopa_get_domain()), __('% Comments', kopa_get_domain()), '', __('0 Comment', kopa_get_domain()));
                    ?>
</li>
                            <?php 
                    break;
            }
            ?>
 
                </ul>

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