/** * Echo the widget content. * * @since 0.9.1 * * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget */ function widget($args, $instance) { global $wp_query; extract($args); //* Merge with defaults $instance = wp_parse_args((array) $instance, $this->defaults); echo $before_widget; //* Set up the author bio if (!empty($instance['title'])) { echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title; } $wp_query = new WP_Query(array('page_id' => $instance['page_id'])); if (have_posts()) { while (have_posts()) { the_post(); echo '<article class="' . implode(' ', get_post_class()) . ' entry" itemtype="http://schema.org/CreativeWork" itemscope="itemscope">'; $image = omega_get_image(array('format' => 'html', 'size' => $instance['image_size'])); if ($instance['show_image'] && $image) { printf('<a href="%s" title="%s" class="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $image); } if (!empty($instance['show_title'])) { printf('<header class="entry-header"><h2 class="entry-title"><a href="%s" title="%s">%s</a></h2></header>', get_permalink(), the_title_attribute('echo=0'), get_the_title()); } if (!empty($instance['show_content'])) { echo '<div class="entry-content">'; if (empty($instance['content_limit'])) { global $more; $more = 0; the_content($instance['more_text']); } else { the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text'])); } echo '</div>'; } echo '</article>'; } } //* Restore original query wp_reset_query(); echo $after_widget; }
/** * Echo the widget content. * * @since 0.9.1 * * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget */ function widget($args, $instance) { global $wp_query, $_omega_displayed_ids; //$_omega_displayed_ids[] = get_the_ID(); extract($args); //* Merge with defaults $instance = wp_parse_args((array) $instance, $this->defaults); echo $before_widget; //* Set up the author bio if (!empty($instance['title'])) { echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title; } $query_args = array('post_type' => 'post', 'cat' => $instance['posts_cat'], 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order']); //* Exclude displayed IDs from this loop? if ($instance['exclude_displayed']) { $query_args['post__not_in'] = (array) $_omega_displayed_ids; } $wp_query = new WP_Query($query_args); if (have_posts()) { while (have_posts()) { the_post(); $_omega_displayed_ids[] = get_the_ID(); echo '<article class="' . implode(' ', get_post_class()) . ' entry" itemtype="http://schema.org/BlogPosting" itemscope="itemscope">'; $image = omega_get_image(array('format' => 'html', 'size' => $instance['image_size'])); if ($instance['show_image'] && $image) { printf('<a href="%s" title="%s" class="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $image); } if (!empty($instance['show_gravatar'])) { echo '<span class="' . esc_attr($instance['gravatar_alignment']) . '">'; echo get_avatar(get_the_author_meta('ID'), $instance['gravatar_size']); echo '</span>'; } if ($instance['show_title']) { echo '<header class="entry-header">'; } if (!empty($instance['show_title'])) { printf('<h2 class="entry-title"><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), get_the_title()); } if (!empty($instance['show_byline']) && !empty($instance['post_info'])) { printf('<p class="entry-meta">%s</p>', do_shortcode($instance['post_info'])); } if ($instance['show_title']) { echo '</header>'; } if (!empty($instance['show_content'])) { echo '<div class="entry-content">'; if ('excerpt' == $instance['show_content']) { the_excerpt(); } elseif ('content-limit' == $instance['show_content']) { the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text'])); } else { global $more; $orig_more = $more; $more = 0; the_content(esc_html($instance['more_text'])); $more = $orig_more; } echo '</div>'; } echo '</article>'; } } //* Restore original query wp_reset_query(); //* The EXTRA Posts (list) if (!empty($instance['extra_num'])) { if (!empty($instance['extra_title'])) { echo $before_title . esc_html($instance['extra_title']) . $after_title; } $offset = intval($instance['posts_num']) + intval($instance['posts_offset']); $query_args = array('cat' => $instance['posts_cat'], 'showposts' => $instance['extra_num'], 'offset' => $offset); $wp_query = new WP_Query($query_args); $listitems = ''; if (have_posts()) { while (have_posts()) { the_post(); $_omega_displayed_ids[] = get_the_ID(); $listitems .= sprintf('<li><a href="%s" title="%s">%s</a></li>', get_permalink(), the_title_attribute('echo=0'), get_the_title()); } if (mb_strlen($listitems) > 0) { printf('<ul>%s</ul>', $listitems); } } //* Restore original query wp_reset_query(); } if (!empty($instance['more_from_category']) && !empty($instance['posts_cat'])) { printf('<p class="more-from-category"><a href="%1$s" title="%2$s">%3$s</a></p>', esc_url(get_category_link($instance['posts_cat'])), esc_attr(get_cat_name($instance['posts_cat'])), esc_html($instance['more_from_category_text'])); } echo $after_widget; }
/** * Echoes an image pulled from media gallery. * * Supported $args keys are: * - format - string, default is 'html', may be 'url' * - size - string, default is 'full' * - num - integer, default is 0 * - attr - string, default is '' * * @since 0.1.0 * * @uses omega_get_image() * * @param array|string $args Optional. Image query arguments. Default is empty array * @return false Returns false if URL is empty */ function omega_image($args = array()) { $image = omega_get_image($args); if ($image) { echo $image; } else { return false; } }