/** * Displays the output * * @param array $args * @param array $instance * @since Achievements (3.3) */ public function widget($args, $instance) { $settings = $this->parse_settings($instance); $settings['post_id'] = absint(apply_filters('dpa_featured_achievement_post_id', $settings['post_id'], $instance, $this->id_base)); // Get the specified achievement $achievement = get_posts(array('no_found_rows' => true, 'numberposts' => 1, 'p' => $settings['post_id'], 'post_status' => 'publish', 'post_type' => dpa_get_achievement_post_type(), 'suppress_filters' => false)); // Bail if it doesn't exist if (empty($achievement)) { return; } $achievement = array_shift($achievement); $title = dpa_get_achievement_title($achievement->ID); echo $args['before_widget']; echo $args['before_title'] . $title . $args['after_title']; if (has_post_thumbnail($achievement->ID)) { ?> <a href="<?php dpa_achievement_permalink($achievement->ID); ?> "><?php echo get_the_post_thumbnail($achievement->ID, 'thumbnail', array('alt' => $title)); ?> </a> <?php } dpa_achievement_excerpt($settings['post_id']); echo $args['after_widget']; }
/** * Displays the output * * @param array $args * @param array $instance * @since Achievements (2.0) */ public function widget($args, $instance) { $settings = $this->parse_settings($instance); // Use these filters $settings['limit'] = absint(apply_filters('dpa_available_achievements_limit', $settings['limit'], $instance, $this->id_base)); $settings['title'] = apply_filters('dpa_available_achievements_title', $settings['title'], $instance, $this->id_base); // WordPress filters widget_title through esc_html. $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base); echo $args['before_widget']; if (!empty($settings['title'])) { echo $args['before_title'] . $settings['title'] . $args['after_title']; } // Get the posts $achievements = get_posts(array('ignore_sticky_posts' => true, 'no_found_rows' => true, 'numberposts' => $settings['limit'], 'post_status' => 'publish', 'post_type' => dpa_get_achievement_post_type(), 'suppress_filters' => false)); // Bail if no posts if (empty($achievements)) { return; } echo '<ul>'; foreach ($achievements as $post) { if (has_post_thumbnail($post->ID)) { ?> <li> <a href="<?php dpa_achievement_permalink($post->ID); ?> "><?php echo get_the_post_thumbnail($post->ID, 'dpa-thumb', array('alt' => dpa_get_achievement_title($post->ID))); ?> </a> </li> <?php } } echo '</ul>'; echo $args['after_widget']; }
?> " id="dpa-achievement-<?php dpa_achievement_id(); ?> " <?php dpa_achievement_class(); ?> > <?php do_action('dpa_template_in_achievements_loop_early'); ?> <a href="<?php dpa_achievement_permalink(); ?> "> <?php if (has_post_thumbnail(dpa_get_the_achievement_id())) { ?> <?php do_action('dpa_template_before_achievement_image'); ?> <?php echo the_post_thumbnail('post-thumbnail', array('class' => 'dpa-archive-achievements-image', 'alt' => dpa_get_achievement_title())); ?> <?php