/** * 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']; }
static function single() { if (empty(self::$single)) { self::$single = new SiteOrigin_Masonry(); } return self::$single; }