/**
  * Echo the widget content.
  *
  * @since 2.0.0
  *
  *
  * @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, $_genesis_displayed_ids;
     // Merge with defaults
     $instance = wp_parse_args((array) $instance, $this->defaults);
     $term_id = $instance['term'];
     $term = get_term_by('id', $term_id, $instance['taxonomy']);
     if (!$term) {
         return;
     }
     $title = displayfeaturedimagegenesis_get_term_meta($term, 'headline');
     if (!$title) {
         $title = $term->name;
     }
     $permalink = get_term_link($term);
     $args['before_widget'] = str_replace('class="widget ', 'class="widget ' . $term->slug . ' ', $args['before_widget']);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title'];
     }
     $image = '';
     $term_image = displayfeaturedimagegenesis_get_term_image($term_id);
     if ($term_image) {
         $image_src = wp_get_attachment_image_src($term_image, $instance['image_size']);
         if ($image_src) {
             $image = '<img src="' . esc_url($image_src[0]) . '" alt="' . esc_html($title) . '" />';
         }
         if ($instance['show_image'] && $image) {
             $role = empty($instance['show_title']) ? '' : 'aria-hidden="true"';
             printf('<a href="%s" title="%s" class="%s" %s>%s</a>', esc_url($permalink), esc_html($title), esc_attr($instance['image_alignment']), $role, wp_kses_post($image));
         }
     }
     if ($instance['show_title']) {
         if (!empty($instance['show_title'])) {
             $title_output = sprintf('<h2><a href="%s">%s</a></h2>', esc_url($permalink), esc_html($title));
             if (genesis_html5()) {
                 $title_output = sprintf('<h2 class="archive-title"><a href="%s">%s</a></h2>', esc_url($permalink), esc_html($title));
             }
             echo wp_kses_post($title_output);
         }
     }
     if ($instance['show_content']) {
         echo genesis_html5() ? '<div class="term-description">' : '';
         $intro_text = displayfeaturedimagegenesis_get_term_meta($term, 'intro_text');
         $intro_text = apply_filters('display_featured_image_genesis_term_description', $intro_text);
         if (!$intro_text) {
             $intro_text = $term->description;
         }
         echo wp_kses_post(wpautop($intro_text));
         echo genesis_html5() ? '</div>' : '';
     }
     echo $args['after_widget'];
 }
 /**
  * Add custom description to category / tag / taxonomy archive pages.
  *
  * If the page is not a category, tag or taxonomy term archive, or we're not on the first page, or there's no term, or
  * no term meta set, then nothing extra is displayed.
  *
  * If there's a description to display, it runs through `wpautop()` before being added to a div.
  *
  * @since 1.3.0
  *
  * @global WP_Query $wp_query Query object.
  *
  * @return null Return early if not the correct archive page, not page one, or no term meta is set.
  */
 public function do_tax_description()
 {
     global $wp_query;
     if (!is_category() && !is_tag() && !is_tax()) {
         return;
     }
     if (get_query_var('paged') >= 2) {
         return;
     }
     $term = is_tax() ? get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')) : $wp_query->get_queried_object();
     if (!$term) {
         return;
     }
     $intro_text = displayfeaturedimagegenesis_get_term_meta($term, 'intro_text');
     $intro_text = apply_filters('display_featured_image_genesis_term_description', $intro_text);
     if ($intro_text) {
         $class = 'archive-description taxonomy-description';
         $this->print_description($intro_text, $class);
     }
 }
 /**
  * @param string $title
  *
  * @return mixed|void
  */
 protected static function set_item_title($title = '')
 {
     $frontpage = get_option('show_on_front');
     // either 'posts' or 'page'
     $postspage = get_option('page_for_posts');
     $a11ycheck = current_theme_supports('genesis-accessibility', array('headings'));
     if (is_singular()) {
         $title = get_the_title();
     } elseif (is_home() && 'page' === $frontpage) {
         $title = get_post($postspage)->post_title;
     } elseif (is_category() || is_tag() || is_tax()) {
         $term = is_tax() ? get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')) : get_queried_object();
         if (!$term) {
             return;
         }
         $title = displayfeaturedimagegenesis_get_term_meta($term, 'headline');
         if (empty($title) && $a11ycheck) {
             $title = $term->name;
         }
     } elseif (is_author()) {
         $title = get_the_author_meta('headline', (int) get_query_var('author'));
         if (empty($title) && $a11ycheck) {
             $title = get_the_author_meta('display_name', (int) get_query_var('author'));
         }
     } elseif (is_post_type_archive() && genesis_has_post_type_archive_support()) {
         $title = genesis_get_cpt_option('headline');
         if (empty($title) && $a11ycheck) {
             $title = post_type_archive_title('', false);
         }
     }
     return apply_filters('display_featured_image_genesis_title_text', $title);
 }