Exemplo n.º 1
0
    public function widget($args, $instance)
    {
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $select_week = isset($instance['select_week']) ? $instance['select_week'] : true;
        $select_month = isset($instance['select_month']) ? $instance['select_month'] : true;
        $select_year = isset($instance['select_year']) ? $instance['select_year'] : true;
        $number = !empty($instance['number']) ? absint($instance['number']) : 5;
        if (!$number) {
            $number = 5;
        }
        $show_thumbnail = isset($instance['show_thumbnail']) ? $instance['show_thumbnail'] : true;
        echo $args['before_widget'];
        if ($title) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        if ($select_week || $select_month || $select_year) {
            $rand = rand();
            $tabs = array();
            if ($select_week) {
                $tabs[] = 'week';
            }
            if ($select_month) {
                $tabs[] = 'month';
            }
            if ($select_year) {
                $tabs[] = 'year';
            }
            ?>
            <div class="kt_widget_tabs">
                <ul class="clearfix kt-tabs-nav">
                    <?php 
            if ($select_week) {
                ?>
<li><a href="#kt_tab_week<?php 
                echo $rand;
                ?>
"><?php 
                esc_html_e('1 Week', 'adroit');
                ?>
</a></li><?php 
            }
            ?>
                    <?php 
            if ($select_month) {
                ?>
<li><a href="#kt_tab_month<?php 
                echo $rand;
                ?>
"><?php 
                esc_html_e('1 Month', 'adroit');
                ?>
</a></li><?php 
            }
            ?>
                    <?php 
            if ($select_year) {
                ?>
<li><a href="#kt_tab_year<?php 
                echo $rand;
                ?>
"><?php 
                esc_html_e('1 year', 'adroit');
                ?>
</a></li><?php 
            }
            ?>
                </ul>
                <div class="tabs-container">
                    <?php 
            if (count($tabs)) {
                $argsp = array('posts_per_page' => $number, 'ignore_sticky_posts' => true, 'post_status' => 'publish', 'orderby' => 'meta_value_num', 'meta_key' => 'kt_post_views_count');
                foreach ($tabs as $tab) {
                    $argsn = $argsp;
                    if ($tab == 'week') {
                        $argsn['date_query'] = array(array('year' => date('Y'), 'week' => date('w')));
                    } elseif ($tab == 'month') {
                        $argsn['date_query'] = array(array('after' => array('year' => date('Y'), 'month' => date('m') - 1, 'day' => date('d')), 'before' => array('year' => date('Y'), 'month' => date('m'), 'day' => date('d')), 'inclusive' => true));
                    } elseif ($tab == 'year') {
                        $argsn['date_query'] = array(array('after' => array('year' => date('Y'), 'month' => date('m'), 'day' => date('d')), 'before' => array('year' => date('Y'), 'month' => date('m'), 'day' => date('d')), 'inclusive' => true));
                    }
                    $query = new WP_Query(apply_filters('widget_posts_args', $argsn));
                    ?>
                            <div id="kt_tab_<?php 
                    echo $tab;
                    echo $rand;
                    ?>
" class="kt_tabs_content">
                                <?php 
                    if ($query->have_posts()) {
                        ?>
                                    <ul>
                                        <?php 
                        while ($query->have_posts()) {
                            $query->the_post();
                            ?>
                                            <li <?php 
                            post_class('article-widget clearfix');
                            ?>
>
                                                <?php 
                            if ($show_thumbnail) {
                                kt_post_thumbnail_image('kt_small', 'img-responsive');
                            }
                            ?>
                                                <div class="article-attr">
                                                    <h3 class="title"><a href="<?php 
                            the_permalink();
                            ?>
"><?php 
                            get_the_title() ? the_title() : the_ID();
                            ?>
</a></h3>
                                                    <div class="entry-meta-data">
                                                        <?php 
                            kt_entry_date();
                            kt_get_post_views();
                            ?>
                                                    </div>
                                                </div>
                                            </li>
                                        <?php 
                        }
                        wp_reset_postdata();
                        ?>
                                    </ul>
                                <?php 
                    }
                    ?>
                            </div>
                            <?php 
                }
            }
            ?>
                </div>
            </div>
        <?php 
        }
        echo $args['after_widget'];
    }
Exemplo n.º 2
0
 /**
  * Prints HTML with meta information for the categories, tags.
  *
  * Create your own kt_entry_meta() function to override in a child theme.
  *
  */
 function kt_entry_meta($share = false)
 {
     echo '<div class="post-item-meta">';
     echo '<div class="post-item-metaleft pull-left">';
     kt_entry_meta_author();
     kt_entry_date();
     echo '</div><!-- .post-item-metaleft -->';
     echo '<div class="post-item-metaright pull-right">';
     if ($share) {
         kt_share_box();
     }
     kt_get_post_views();
     kt_entry_meta_comments();
     echo '</div><!-- .post-item-metaright -->';
     echo '<div class="clearfix"></div></div><!-- .post-item-meta -->';
 }
Exemplo n.º 3
0
<article id="post-<?php 
the_ID();
?>
" <?php 
post_class('blog-post');
?>
 itemscope="" itemtype="http://schema.org/BlogPosting">
    <?php 
kt_post_thumbnail_image('kt_list');
?>
    <?php 
kt_entry_date();
?>
    <div class="blog-post-content">
        <div class="blog-post-inner">
            <?php 
the_title(sprintf('<h2 class="entry-title" itemprop="name headline"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>');
?>
            <?php 
kt_entry_excerpt();
?>
            <?php 
kt_entry_meta();
?>
            <p class="entry-more">
                <?php 
printf('<a href="%1$s" class="%2$s">%3$s</a>', esc_url(get_permalink(get_the_ID())), 'btn btn-default', sprintf(esc_html__('Read more %s', 'mondova'), '<span class="screen-reader-text">' . get_the_title(get_the_ID()) . '</span>'));
?>
            </p>
        </div>
    </div>
Exemplo n.º 4
0
    public function widget($args, $instance)
    {
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $number = !empty($instance['number']) ? absint($instance['number']) : 5;
        $just_featured = isset($instance['just_featured']) ? $instance['just_featured'] : false;
        if (!$number) {
            $number = 5;
        }
        $args_article = array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'order' => $instance['order'], 'orderby' => $instance['orderby']);
        if (is_array($instance['category'])) {
            $args_article['category__in'] = $instance['category'];
        }
        if ($just_featured == true) {
            $args_article['meta_key'] = '_kt_post_featured';
            $args_article['meta_value'] = 'yes';
        }
        $r = new WP_Query(apply_filters('widget_posts_args', $args_article));
        if ($r->have_posts()) {
            $layout = !empty($instance['layout']) ? absint($instance['layout']) : 1;
            if (!$layout) {
                $layout = 1;
            }
            echo $args['before_widget'];
            if ($title) {
                echo $args['before_title'] . $title . $args['after_title'];
            }
            ?>
            <ul class="kt_posts_widget kt-artilce-<?php 
            echo esc_attr($layout);
            ?>
">
                <?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>
                    <li <?php 
                post_class('article-widget clearfix');
                ?>
>
                        <?php 
                if ($layout == 2) {
                    kt_post_thumbnail_image('kt_recent_posts', 'img-responsive');
                } else {
                    kt_post_thumbnail_image('kt_widget_article', 'img-responsive');
                }
                ?>
                        <div class="article-attr">
                            <h3 class="title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                get_the_title() ? the_title() : the_ID();
                ?>
</a></h3>
                            <?php 
                $layout == 2 ? kt_entry_meta() : kt_entry_date();
                ?>
                        </div>
                    </li>
                <?php 
            }
            ?>
            </ul>
            <?php 
            echo $args['after_widget'];
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
    }