Exemple #1
0
 /**
  * Output the masonry HTML
  *
  * @param array $args
  * @param array $instance
  */
 function widget($args, $instance)
 {
     // Enqueue all the front end scripts for the masonry
     SiteOrigin_Masonry::single()->enqueue();
     $instance = wp_parse_args($instance, array('sticky' => false, 'additional' => '', 'responsive' => true));
     $query_args = $instance;
     unset($query_args['additional']);
     unset($query_args['sticky']);
     $query_args = wp_parse_args($instance['additional'], $query_args);
     global $wp_query;
     $query_args['paged'] = $wp_query->get('paged');
     switch ($instance['sticky']) {
         case 'ignore':
             $query_args['ignore_sticky_posts'] = 1;
             break;
         case 'only':
             $query_args['post__in'] = get_option('sticky_posts');
             break;
         case 'exclude':
             $query_args['post__not_in'] = get_option('sticky_posts');
             break;
     }
     if (!empty($instance['title'])) {
         echo $args['before_title'] . esc_html($instance['title']) . $args['after_title'];
     }
     $posts = new WP_Query($query_args);
     echo $args['before_widget'];
     include plugin_dir_path(__FILE__) . '../tpl/masonry.php';
     echo $args['after_widget'];
 }
Exemple #2
0
 static function single()
 {
     if (empty(self::$single)) {
         self::$single = new SiteOrigin_Masonry();
     }
     return self::$single;
 }
Exemple #3
0
<div class="so-masonry-container <?php 
if (!empty($instance['responsive'])) {
    echo 'responsive';
}
?>
">
	<?php 
while ($posts->have_posts()) {
    $posts->the_post();
    $settings = SiteOrigin_Masonry::get_settings(get_the_ID());
    ?>
		<div class="masonry-brick <?php 
    echo esc_attr('size-' . $settings['size'] . ' ' . (!has_post_thumbnail() ? 'no-thumbnail' : ''));
    ?>
">
			<div class="post-information">
				<h2><a href="<?php 
    the_permalink();
    ?>
"><?php 
    the_title();
    ?>
</h2></a>
				<div class="entry-meta">
					<?php 
    printf(__('Posted on <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="byline"> by <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'so-masonry'), esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'so-masonry'), get_the_author())), get_the_author());
    ?>
				</div><!-- .entry-meta -->
			</div>