Пример #1
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        $query_args['posts_per_page'] = $instance['number_of_article'];
        $tab_args = array();
        if ($instance['popular_title']) {
            $tab_args[] = array('label' => $instance['popular_title'], 'orderby' => 'most_comment');
        }
        if ($instance['latest_title']) {
            $tab_args[] = array('label' => $instance['latest_title'], 'orderby' => 'latest');
        }
        if ($instance['comment_title']) {
            $tab_args[] = array('label' => $instance['comment_title'], 'orderby' => 'most_comment');
        }
        ?>

        <ul class="nav nav-tabs kopa-tabs-1">
            <?php 
        foreach ($tab_args as $k => $tab_arg) {
            ?>
                <li class="<?php 
            if (0 === $k) {
                echo 'active';
            }
            ?>
"><a data-toggle="tab" href="#tab1-<?php 
            echo $this->number . $k;
            ?>
"><?php 
            echo $tab_arg['label'];
            ?>
</a></li>
            <?php 
        }
        ?>
        </ul> <!-- nav-tabs -->

        <div class="tab-content">
            <?php 
        foreach ($tab_args as $k1 => $tab_arg) {
            $query_args['orderby'] = $tab_arg['orderby'];
            if (isset($instance['kopa_timestamp'])) {
                $query_args['date_query'] = $instance['kopa_timestamp'];
            }
            $posts = news_maxx_lite_widget_posttype_build_query($query_args);
            ?>
            <div id="tab1-<?php 
            echo $this->number . $k1;
            ?>
" class="tab-pane<?php 
            if (0 === $k1) {
                echo ' active';
            }
            ?>
">
                <ul class="clearfix">
                    <?php 
            while ($posts->have_posts()) {
                $posts->the_post();
                ?>
                    <li>
                        <article class="entry-item clearfix">
                            <?php 
                if (has_post_thumbnail()) {
                    ?>
                                <div class="entry-thumb">
                                    <a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
">
                                        <?php 
                    the_post_thumbnail('news-maxx-lite-topnew', array('class' => 'img-responsive'));
                    ?>
                                    </a>
                                </div>
                            <?php 
                }
                ?>
                            <div class="entry-content">
                                <header>
                                    <?php 
                if (news_maxx_lite_check_title_null(get_the_ID())) {
                    ?>
                                            <span class="entry-date pull-left"><i class="fa <?php 
                    echo news_maxx_lite_get_post_format_icon(get_the_ID());
                    ?>
"></i><?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
                                        <?php 
                } else {
                    ?>
                                            <span class="entry-date pull-left"><i class="fa <?php 
                    echo news_maxx_lite_get_post_format_icon(get_the_ID());
                    ?>
"></i><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><?php 
                    the_time(get_option('date_format'));
                    ?>
</a></span>
                                        <?php 
                }
                ?>

                                    <span class="entry-meta">&nbsp;/&nbsp;</span>
                                    <span class="entry-author"><?php 
                _e('By', 'news-maxx-lite');
                ?>
 <?php 
                the_author_posts_link();
                ?>
</span>
                                </header>
                                <h6 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
"><?php 
                the_title();
                ?>
</a></h6>
                            </div>
                        </article>
                    </li>
                    <?php 
            }
            ?>
                </ul>
            </div>
            <?php 
        }
        ?>
        </div><!-- tab-content -->

    <?php 
        echo $after_widget;
        wp_reset_postdata();
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('List Articles', 'news-maxx-lite') : $instance['title'], $instance, $this->id_base);
        $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'];
        if (isset($instance['kopa_timestamp'])) {
            $query_args['date_query'] = $instance['kopa_timestamp'];
        }
        $query_args['orderby'] = $instance['orderby'];
        $limit = $instance['limit'];
        $type = $instance['display_type'];
        $posts = news_maxx_lite_widget_posttype_build_query($query_args);
        ?>

<?php 
        if ('grid_2columns_with_featured_style2' === $type) {
            ?>
            <div class="widget kopa-article-list-3-widget">
                <h4 class="widget-title"><?php 
            echo esc_attr($title);
            ?>
</h4>
                <div class="widget-inner clearfix">
                <?php 
            $count = 0;
            $next = true;
            ?>
                <?php 
            while ($posts->have_posts()) {
                $posts->the_post();
                ?>
                <?php 
                if (0 === $count) {
                    ?>
                    <article class="last-item">
                        <?php 
                    //if ( has_post_thumbnail() ) :
                    ?>
                        <div class="entry-thumb">
                            <a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
">
                                <?php 
                    the_post_thumbnail('news-maxx-lite-article-list-cat-2column-feature2', array('class' => 'img-responsive'));
                    ?>
                            </a>
                        </div>
                        <?php 
                    //endif;
                    ?>
<!-- entry-thumb -->
                        <div class="entry-content">
                            <h6 class="entry-title" itemscope="" itemtype="http://schema.org/Event"><a itemprop="name" href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h6>
                        </div>
                        <!-- entry-content -->
                    </article>
                    <!-- last-item -->
                    <?php 
                } else {
                    if ($next) {
                        echo '<ul class="older-post clearfix">';
                        $next = false;
                    }
                    ?>
                    <li>
                        <article class="entry-item clearfix">
                            <?php 
                    if (has_post_thumbnail()) {
                        ?>
                            <div class="entry-thumb">
                                <a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        the_title();
                        ?>
">
                                    <?php 
                        the_post_thumbnail('news-maxx-lite-topnew', array('class' => 'img-responsive'));
                        ?>
                                </a>
                            </div>
                            <?php 
                    }
                    ?>
<!-- entry-thumb -->
                            <div class="entry-content<?php 
                    if (!has_post_thumbnail()) {
                        echo ' no-thumbnail';
                    }
                    ?>
">
                                <header>
                                    <?php 
                    if (news_maxx_lite_check_title_null(get_the_ID())) {
                        ?>
                                        <span class="entry-date"><i class="fa <?php 
                        echo news_maxx_lite_get_post_format_icon(get_the_ID());
                        ?>
"></i><?php 
                        the_time(get_option('date_format'));
                        ?>
</span>
                                        <?php 
                    } else {
                        ?>
                                        <span class="entry-date"><a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        the_title();
                        ?>
"><i class="fa <?php 
                        echo news_maxx_lite_get_post_format_icon(get_the_ID());
                        ?>
"></i><?php 
                        the_time(get_option('date_format'));
                        ?>
</a></span>
                                        <?php 
                    }
                    ?>
                                    <span class="entry-meta">&nbsp;/&nbsp;</span>
                                    <span class="entry-author"><?php 
                    _e('By', 'news-maxx-lite');
                    ?>
 <?php 
                    the_author_posts_link();
                    ?>
</span>
                                </header>
                                <h6 class="entry-title" itemscope="" itemtype="http://schema.org/Event"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
" itemprop="name"><?php 
                    the_title();
                    ?>
</a></h6>
                            </div>
                        </article>
                        <!-- entry-item -->
                    </li>

                    <?php 
                    if ($count === $posts->post_count - 1) {
                        echo '</ul>';
                    }
                }
                ?>
                <?php 
                $count++;
            }
            ?>
                </div>
            </div>
        <?php 
        }
        ?>

    <?php 
        wp_reset_postdata();
    }
Пример #3
0
function news_maxx_lite_related_articles()
{
    if (is_single()) {
        $get_by = 'category';
        if ('hide' != $get_by) {
            $limit = (int) 4;
            if ($limit > 0) {
                global $post;
                $taxs = array();
                if ('category' == $get_by) {
                    $cats = get_the_category($post->ID);
                    if ($cats) {
                        $ids = array();
                        foreach ($cats as $cat) {
                            $ids[] = $cat->term_id;
                        }
                        $taxs[] = array('taxonomy' => 'category', 'field' => 'id', 'terms' => $ids);
                    }
                } else {
                    $tags = get_the_tags($post->ID);
                    if ($tags) {
                        $ids = array();
                        foreach ($tags as $tag) {
                            $ids[] = $tag->term_id;
                        }
                        $taxs[] = array('taxonomy' => 'post_tag', 'field' => 'id', 'terms' => $ids);
                    }
                }
                if ($taxs) {
                    $related_args = array('tax_query' => $taxs, 'post__not_in' => array($post->ID), 'posts_per_page' => $limit);
                    $related_posts = new WP_Query($related_args);
                    if ($related_posts->have_posts()) {
                        ?>

                        <div class="related-post">
                            <h3><span><?php 
                        _e('Post by related', 'news-maxx-lite');
                        ?>
</span><?php 
                        _e('Related post', 'news-maxx-lite');
                        ?>
</h3>
                        </div>
                        <div class="owl-carousel kopa-related-post-carousel">
                            <?php 
                        $i = 0;
                        ?>
                            <?php 
                        while ($related_posts->have_posts()) {
                            $related_posts->the_post();
                            if ($i % 2 == 0) {
                                echo '<div class="item"><ul>';
                            }
                            ?>

                                <li>
                                    <article class="entry-item clearfix">
                                        <?php 
                            if (has_post_thumbnail()) {
                                ?>
                                            <div class="entry-thumb">
                                                <a href="<?php 
                                the_permalink();
                                ?>
" title="<?php 
                                the_title();
                                ?>
">
                                                    <?php 
                                the_post_thumbnail('news-maxx-lite-topnew', array('class' => 'img-responsive'));
                                ?>
                                                </a>
                                            </div>
                                        <?php 
                            }
                            ?>
                                        <div class="entry-content">
                                            <?php 
                            if ('post' === get_post_type()) {
                                ?>
                                                <?php 
                                if (news_maxx_lite_check_title_null(get_the_ID())) {
                                    ?>
                                                        <span class="entry-date"><i class="fa <?php 
                                    echo news_maxx_lite_get_post_format_icon(get_the_ID());
                                    ?>
"></i><?php 
                                    the_time(get_option('date_format'));
                                    ?>
</span>
                                                    <?php 
                                } else {
                                    ?>
                                                        <a href="<?php 
                                    the_permalink();
                                    ?>
" title="<?php 
                                    the_title();
                                    ?>
"><span class="entry-date"><i class="fa <?php 
                                    echo news_maxx_lite_get_post_format_icon(get_the_ID());
                                    ?>
"></i><?php 
                                    the_time(get_option('date_format'));
                                    ?>
</span></a>
                                                    <?php 
                                }
                                ?>


                                            <?php 
                            }
                            ?>
                                            <h6 class="entry-title"><a href="<?php 
                            the_permalink();
                            ?>
" title="<?php 
                            the_title();
                            ?>
"><?php 
                            the_title();
                            ?>
</a></h6>
                                        </div>
                                    </article>
                                </li>

                                <?php 
                            if ($i % 2 == 1) {
                                echo '</ul></div>';
                            }
                            $i++;
                            ?>
                            <?php 
                        }
                        ?>
                            <?php 
                        //Check in case don't have multiple of 3 items
                        if ($i % 2 != 0) {
                            echo '</ul></div>';
                        }
                        ?>
                        </div>
                        <?php 
                    }
                    // endif
                    wp_reset_postdata();
                }
            }
        }
    }
}
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('List Articles', 'news-maxx-lite') : $instance['title'], $instance, $this->id_base);
        $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'];
        if (isset($instance['kopa_timestamp'])) {
            $query_args['date_query'] = $instance['kopa_timestamp'];
        }
        $query_args['orderby'] = $instance['orderby'];
        $limit = $instance['limit'];
        $posts = news_maxx_lite_widget_posttype_build_query($query_args);
        ?>

        <div class="widget kopa-article-list-1-widget clearfix">
            <h4 class="widget-title"><?php 
        echo $title;
        ?>
</h4>
            <?php 
        if ($posts->have_posts()) {
            $index = 0;
            while ($posts->have_posts()) {
                $posts->the_post();
                $index++;
                $li_common = '<li>';
                $li_common .= '<article class="entry-item clearfix">';
                $li_common .= '<div class="entry-content">';
                $li_common .= '<header>';
                if (news_maxx_lite_check_title_null(get_the_ID())) {
                    $li_common .= '<span class="entry-date"><i class="fa ' . news_maxx_lite_get_post_format_icon(get_the_ID()) . '"></i>' . get_the_time(get_option('date_format')) . '</span>';
                } else {
                    $li_common .= '<span class="entry-date"><i class="fa ' . news_maxx_lite_get_post_format_icon(get_the_ID()) . '"></i><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_time(get_option('date_format')) . '</a></span>';
                }
                $li_common .= '<span class="entry-meta">&nbsp;/&nbsp;</span>';
                $li_common .= '<span class="entry-author">' . __("By ", 'news-maxx-lite') . '<a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a></span>';
                $li_common .= '</header>';
                $li_common .= '<h6 class="entry-title"><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h6>';
                $li_common .= '</div>';
                $li_common .= '</article>';
                $li_common .= '</li>';
                if (1 === $index) {
                    ?>
                           <article class="last-item clearfix">
                               <?php 
                    if (has_post_thumbnail()) {
                        ?>
                                   <div class="entry-thumb">
                                       <a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        the_title();
                        ?>
">
                                           <?php 
                        the_post_thumbnail('news-maxx-lite-article-list', array('class' => 'img-responsive'));
                        ?>
                                       </a>
                                   </div>
                               <?php 
                    }
                    ?>
<!-- entry-thumb -->
                               <div class="entry-content">
                                   <header>
                                       <span class="entry-date pull-left"><i class="fa <?php 
                    echo news_maxx_lite_get_post_format_icon(get_the_ID());
                    ?>
"></i><?php 
                    the_time(get_option('date_format'));
                    ?>
</span>
                                   </header>
                                   <h6 class="entry-title"><a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h6>
                                   <?php 
                    global $post;
                    ?>
                                   <p><?php 
                    echo news_maxx_lite_get_the_excerpt_for_widget($post->post_excerpt, $post->post_content, $limit);
                    ?>
</p>
                                   <a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
" class="more-link"><span><?php 
                    _e('Read more', 'news-maxx-lite');
                    ?>
</span></a>
                               </div>
                               <!-- entry-content -->
                           </article>
                           <!-- last-item -->
                       <?php 
                } elseif (2 === $index) {
                    ?>
                           <ul class="older-post clearfix">
                               <?php 
                    echo $li_common;
                    ?>
                       <?php 
                } elseif ($index === $posts->post_count) {
                    ?>
                                <?php 
                    echo $li_common;
                    ?>
                           </ul>
                       <?php 
                } else {
                    ?>
                        <?php 
                    echo $li_common;
                    ?>
                       <?php 
                }
            }
        }
        ?>
        </div>



    <?php 
        wp_reset_postdata();
    }