<div class="short-description" itemprop="description">
			<?php 
    the_excerpt();
    ?>
		</div>
		<?php 
}
?>

		<div class="entry-meta">

			<div class="author-date">
				<?php 
$milkit_date_vis_var = get_option('milkit_opt_single_post_show_date') == 'false' ? true : false;
$milkit_author_vis_var = get_option('milkit_opt_single_post_show_author') == 'false' ? true : false;
milkit_post_date($milkit_date_vis_var);
milkit_post_author($milkit_author_vis_var);
?>
			</div><!-- .author-date -->

			<div class="comments-views">
				<?php 
if (!(get_option('milkit_opt_blog_post_comments_icon') == 'false')) {
    milkit_post_comments_count();
}
if (get_option('milkit_opt_check_post_counter') == 'true' && get_option('milkit_opt_blog_post_views_icon') == 'true') {
    do_action('milkit_display_post_views', get_the_ID());
}
?>
			</div><!-- .comments-views -->
the_title('<h1 class="entry-title">', '</h1>');
?>
	</header><!-- .entry-header -->

	<?php 
if (get_option('milkit_opt_single_page_layout') == 'no-sidebar') {
    milkit_post_thumbnail('milkit_1330x590');
} else {
    milkit_post_thumbnail('milkit_886x590');
}
?>

	<div class="entry-content">
		<?php 
the_content();
?>
		<?php 
wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'milkit'), 'after' => '</div>'));
?>
	</div><!-- .entry-content -->

	<footer class="entry-footer">
		<?php 
echo milkit_post_author(true);
?>
		<?php 
echo milkit_post_date(true);
?>
	</footer><!-- .entry-footer -->
</article><!-- #post-## -->
    public function widget($args, $instance)
    {
        $cache = array();
        if (!$this->is_preview()) {
            $cache = wp_cache_get('milkit_widget_module_random', 'widget');
        }
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        $title = !empty($instance['title']) ? $instance['title'] : '';
        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
        $number = !empty($instance['number']) ? absint($instance['number']) : 4;
        if (!$number) {
            $number = 4;
        }
        $exclude = !empty($instance['exclude']) ? $instance['exclude'] : false;
        if (!$exclude) {
            $exclude = false;
        }
        $columns = !empty($instance['columns']) ? absint($instance['columns']) : 4;
        if (!$columns) {
            $columns = 4;
        }
        $show_thumb = isset($instance['show_thumb']) ? $instance['show_thumb'] : false;
        if (!$show_thumb) {
            $show_thumb = false;
        }
        $show_excerpt = isset($instance['show_excerpt']) ? $instance['show_excerpt'] : false;
        if (!$show_excerpt) {
            $show_excerpt = false;
        }
        $show_cat = isset($instance['show_cat']) ? $instance['show_cat'] : false;
        if (!$show_cat) {
            $show_cat = false;
        }
        $show_author = isset($instance['show_author']) ? $instance['show_author'] : false;
        if (!$show_author) {
            $show_author = false;
        }
        $show_date = isset($instance['show_date']) ? $instance['show_date'] : false;
        if (!$show_date) {
            $show_date = false;
        }
        $show_comments = isset($instance['show_comments']) ? $instance['show_comments'] : false;
        if (!$show_comments) {
            $show_comments = false;
        }
        $show_views = isset($instance['show_views']) ? $instance['show_views'] : false;
        if (!$show_views) {
            $show_views = false;
        }
        $show_review = isset($instance['show_review']) ? $instance['show_review'] : false;
        if (!$show_review) {
            $show_review = false;
        }
        $alignment = !empty($instance['alignment']) ? $instance['alignment'] : 'vertical';
        if (!$alignment) {
            $alignment = 'vertical';
        }
        $show_border = isset($instance['show_border']) ? $instance['show_border'] : false;
        if (!$show_border) {
            $show_border = false;
        }
        $highlight = isset($instance['highlight']) ? $instance['highlight'] : false;
        if (!$highlight) {
            $highlight = false;
        }
        $show_more = isset($instance['show_more']) ? $instance['show_more'] : false;
        if (!$show_more) {
            $show_more = false;
        }
        $more_label = !empty($instance['more_label']) ? $instance['more_label'] : 'All news';
        if (!$more_label) {
            $more_label = 'All news';
        }
        $more_url = !empty($instance['more_url']) ? $instance['more_url'] : false;
        if (!$more_url) {
            $more_url = false;
        }
        $r_args = array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'orderby' => 'rand', 'ignore_sticky_posts' => true);
        $r = new WP_Query($r_args);
        if ($r->have_posts()) {
            $is_full = false;
            $in_sidebar = true;
            switch ($args['id']) {
                case 'milkit-sidebar-home-content':
                    $is_full = get_option('milkit_opt_home_layout') == 'layout1' ? true : false;
                    $in_sidebar = false;
                    break;
                case 'milkit-sidebar-home-top':
                case 'milkit-sidebar-home-bottom':
                    $is_full = true;
                    $in_sidebar = false;
                    break;
            }
            $r_post_thumb_size = 'milkit_440x293';
            if ($columns == 1) {
                if ($is_full) {
                    $r_post_thumb_size = 'milkit_1330x590';
                } else {
                    if ($args['id'] == 'milkit-sidebar-home-content') {
                        $r_post_thumb_size = 'milkit_886x590';
                    }
                }
            }
            if ($columns == 2 && $is_full) {
                $r_post_thumb_size = 'milkit_650x433';
            }
            if ($alignment == 'horizontal') {
                $r_post_thumb_size = 'milkit_248x158';
            }
            if ($in_sidebar) {
                $columns = 1;
            }
            $has_border = $show_border ? 'has-border' : '';
            $has_thumb = !$show_thumb && $alignment == 'horizontal' ? 'no-thumb' : '';
            $r_post_module_classes = array('post-module', 'post-module-' . $columns . 'cols', $alignment, $has_thumb);
            $r_post_module_classes = array_map('esc_attr', $r_post_module_classes);
            ?>

		<?php 
            if ($title) {
                ?>
			<div class="section-title"><h4><?php 
                echo esc_html($title);
                ?>
</h4></div>
		<?php 
            }
            ?>

		<div class="post-modules wdgt <?php 
            echo esc_attr($alignment);
            ?>
 <?php 
            echo esc_attr($has_border);
            ?>
 <?php 
            echo esc_attr($highlight ? 'highlight' : '');
            ?>
">

		<?php 
            if ($highlight) {
                ?>
		<div class="post-modules-highlight">
		<?php 
            }
            ?>

		<?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>

			<article <?php 
                post_class($r_post_module_classes);
                ?>
 itemscope="itemscope" itemtype="http://schema.org/Article">

				<?php 
                if ($show_thumb && (!post_password_required() && has_post_thumbnail())) {
                    ?>

				<a class="post-thumbnail" href="<?php 
                    the_permalink();
                    ?>
">
				<?php 
                    the_post_thumbnail($r_post_thumb_size, array('itemprop' => 'image'));
                    ?>
				</a>

				<?php 
                }
                ?>

				<div class="post-module-content">

					<header class="entry-header">
						<?php 
                /* Display category icon only if enabled */
                ?>
						<?php 
                if ($show_cat) {
                    milkit_entry_cats();
                }
                ?>
						<?php 
                the_title(sprintf('<h2 itemprop="name" class="entry-title"><a itemprop="url" href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>');
                ?>
					</header><!-- .entry-header -->

					<?php 
                if ($alignment != 'horizontal' && $show_excerpt) {
                    ?>
					<div class="entry-summary" itemprop="text">
						<?php 
                    the_excerpt();
                    ?>
					</div><!-- .entry-summary -->
					<?php 
                }
                ?>

					<footer class="entry-footer">
						<meta itemprop="interactionCount" content="UserComments:<?php 
                echo esc_attr(get_comments_number());
                ?>
">
						<div class="author-date">
							<?php 
                $r_date_vis_var = $alignment != 'horizontal' && $show_date ? false : true;
                $r_author_vis_var = $alignment != 'horizontal' && $show_author ? false : true;
                milkit_post_date($r_date_vis_var);
                milkit_post_author($r_author_vis_var);
                ?>
						</div><!-- .author-date -->

						<?php 
                if ($alignment != 'horizontal') {
                    ?>
						<div class="comments-views">
							<?php 
                    if ($show_comments) {
                        milkit_post_comments_count();
                    }
                    if ($show_views && get_option('milkit_opt_blog_post_views_icon') == 'true') {
                        do_action('milkit_display_post_views', get_the_ID());
                    }
                    ?>
						</div><!-- .comments-views -->
						<?php 
                }
                ?>
						<?php 
                if ($show_review) {
                    do_action('milkit_display_post_review_score', get_the_ID());
                }
                ?>
					</footer><!-- .entry-footer -->

				</div><!-- .post-module-content -->

			</article><!-- #post-## -->
		<?php 
            }
            ?>

		<?php 
            if ($highlight) {
                ?>
		</div><!-- .post-modules-highlight -->
		<?php 
            }
            ?>

		<?php 
            if ($show_more) {
                $more_link = $more_url ? $more_url : get_permalink(get_option('page_for_posts'));
                if (!$more_url && get_option('show_on_front') == 'page') {
                    ?>
				<div class="show-site-blog"><a href="<?php 
                    echo esc_url($more_link);
                    ?>
"><?php 
                    echo esc_html($more_label);
                    ?>
</a></div>
			<?php 
                } elseif ($more_url) {
                    ?>
				<div class="show-site-blog"><a href="<?php 
                    echo esc_url($more_link);
                    ?>
"><?php 
                    echo esc_html($more_label);
                    ?>
</a></div>
			<?php 
                }
                ?>
		<?php 
            }
            ?>

		</div><!-- .post-modules -->

		<?php 
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        if (!$this->is_preview()) {
            $cache[$args['widget_id']] = ob_get_flush();
            wp_cache_set('milkit_widget_module_random', $cache, 'widget');
        } else {
            ob_end_flush();
        }
    }
Beispiel #4
0
    /**
     * Display slider in homepage.
     */
    function milkit_home_slider()
    {
        if (get_option('show_on_front') === 'page' && is_front_page() && get_option('milkit_opt_show_slider') == 'true') {
            $args = array('ignore_sticky_posts' => true, 'meta_key' => 'milkit_meta_home_slider', 'meta_value' => 'yes');
            $query = new WP_Query($args);
            if ($query->have_posts()) {
                ?>

			<div id="homeslider" class="flexslider flex-home">

				<ul class="slides">

				<?php 
                while ($query->have_posts()) {
                    $query->the_post();
                    ?>

					<li><article <?php 
                    post_class();
                    ?>
 itemscope="itemscope" itemtype="http://schema.org/Article">

						<?php 
                    if (!post_password_required() && has_post_thumbnail()) {
                        ?>

						<a class="post-thumbnail" href="<?php 
                        the_permalink();
                        ?>
">
						<?php 
                        the_post_thumbnail('milkit_1330x590', array('itemprop' => 'image'));
                        ?>
						</a>

						<?php 
                    }
                    ?>

						<div class="post-module-content">

							<header class="entry-header">
								<?php 
                    milkit_entry_cats();
                    ?>
								<?php 
                    the_title(sprintf('<h2 itemprop="name" class="entry-title"><a itemprop="url" href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>');
                    ?>
							</header><!-- .entry-header -->

							<div class="entry-summary" itemprop="text">
								<?php 
                    the_excerpt();
                    ?>
							</div><!-- .entry-summary -->

							<a class="more-link" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    echo sprintf(__('Continue reading %s <span class="meta-nav">&rarr;</span>', 'milkit'), the_title('<span class="screen-reader-text">"', '"</span>', false));
                    ?>
</a>

							<footer class="entry-footer">
								<meta itemprop="interactionCount" content="UserComments:<?php 
                    echo esc_attr(get_comments_number());
                    ?>
">
								<div class="author-date">
									<?php 
                    milkit_post_date(true);
                    milkit_post_author(true);
                    ?>
								</div><!-- .author-date -->
							</footer><!-- .entry-footer -->

						</div><!-- .post-module-content -->


					</article></li><!-- #post-## -->

				<?php 
                }
                wp_reset_postdata();
                ?>

				</ul>


			</div>

			<!-- Centered Description -->
			<div class="home-description">
				<?php 
                the_field('site_description_content', 'option');
                ?>
			</div>

		<?php 
            }
        }
    }