Example #1
0
File: menu.php Project: nkeat12/dv
/**
 * Pass nav menu link attributes through attribute parser.
 *
 * Adds nav menu link attributes via the Genesis markup API.
 *
 * @since 2.2.0
 *
 * @param array $atts {
 *		The HTML attributes applied to the menu item's <a>, empty strings are ignored.
 *
 *		@type string $title Title attribute.
 *		@type string $target Target attribute.
 *		@type string $rel The rel attribute.
 *		@type string $href The href attribute.
 * }
 * @param object $item The current menu item.
 * @param array $args An array of wp_nav_menu() arguments.
 *
 * @return array Maybe modified menu attributes array.
 */
function genesis_nav_menu_link_attributes($atts, $item, $args)
{
    if (genesis_html5()) {
        $atts = genesis_parse_attr('nav-link', $atts);
    }
    return $atts;
}
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @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;
     extract($args);
     // Merge with defaults
     $instance = wp_parse_args((array) $instance, $this->defaults);
     echo $before_widget;
     if (!empty($instance['title'])) {
         echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
     }
     $query_args = array('post_type' => 'listing', 'taxonomy' => $instance['taxonomy'], 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order']);
     // Exclude displayed IDs from this loop?
     global $post;
     $wp_query = new WP_Query($query_args);
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             $_genesis_displayed_ids[] = get_the_ID();
             genesis_markup(array('html5' => '<article %s><div class="listing-wrap">', 'xhtml' => sprintf('<div class="%s"><div class="listing-wrap">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             if ($instance['show_image']) {
                 if ($image) {
                     printf('<a href="%s" alt="%s">%s</a>', esc_url(get_permalink()), esc_attr(the_title_attribute('echo=0')), wp_kses_post($image));
                 } else {
                     $fallback = plugins_url('includes/sample-images/simple-listings.png', dirname(__FILE__));
                     printf('<a href="%s"><img src="%s" alt="%s" />', esc_url(get_permalink()), esc_url($fallback), esc_attr(the_title_attribute('echo=0')));
                 }
             }
             if ($instance['show_title']) {
                 echo genesis_html5() ? '<header class="entry-header">' : '';
             }
             if (!empty($instance['show_title'])) {
                 printf('<h2 class="entry-title">%s</h2>', the_title_attribute('echo=0'), get_the_title());
             }
             if (!empty($instance['show_status'])) {
                 echo '<span class="listing-status">' . strip_tags(get_the_term_list($post->ID, 'status', '', ', ', '')) . '</span>';
             }
             if ($instance['show_title']) {
                 echo genesis_html5() ? '</header>' : '';
             }
             if (!empty($instance['show_content'])) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 global $more;
                 $orig_more = $more;
                 $more = 0;
                 the_content(esc_html($instance['more_text']));
                 $more = $orig_more;
                 echo genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</div></article>', 'xhtml' => '</div></div>'));
         }
     }
     if (!empty($instance['archive_link']) && !empty($instance['archive_text'])) {
         printf('<p class="more-from-category"><a href="%1$s">%2$s</a></p>', esc_url(get_post_type_archive_link($instance['post_type'])), esc_html($instance['archive_text']));
     }
     // Restore original query
     wp_reset_query();
     echo $after_widget;
 }
Example #3
0
/**
 * Display the image
 * 
 * We know it's an image since the file is image.php
 */
function genesis_image_do_entry_content()
{
    $img = genesis_get_image(array('format' => 'html', 'size' => genesis_get_option('image_size'), 'context' => 'archive', 'attr' => genesis_parse_attr('entry-image')));
    if (!empty($img)) {
        echo $img;
    } else {
        //echo "Not got it yet";
    }
}
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @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();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-page-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             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'])) {
                 if (genesis_html5()) {
                     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());
                 } else {
                     printf('<h2><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
                 }
             }
             if (!empty($instance['show_content'])) {
                 echo genesis_html5() ? '<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 genesis_html5() ? '</div>' : '';
             }
             if (!empty($instance['custom_text'])) {
                 $text = wp_kses_post($instance['custom_text']);
                 echo '<div class="custom-text">';
                 echo $instance['filter'] ? wpautop($text) : $text;
                 if (!empty($instance['more_text'])) {
                     echo '<span class="more-link"><a href="' . get_permalink($instance['page_id']) . '">' . $instance['more_text'] . '</a></span>';
                 }
                 echo '</div>';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     //* Restore original query
     wp_reset_query();
     echo $after_widget;
 }
 /**
  * Echo the widget content.
  *
  * @since 0.2.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;
     extract($args);
     //* Merge with defaults
     $instance = wp_parse_args((array) $instance, $this->defaults);
     echo $before_widget;
     //* Set up the widget title
     if (!empty($instance['title'])) {
         echo '<h2 class="widget-title widgettitle">' . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . '</h2>';
     }
     $query_args = array('post_type' => 'awp-community', 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order']);
     $wp_query = new WP_Query($query_args);
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-community-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             if ($instance['show_image'] && $image) {
                 printf('<div class="awp-community-image"><a href="%s" title="%s" class="%s">%s</a></div>', get_permalink(), the_title_attribute('echo=0'), 'awp-community-link', $image);
             }
             if ($instance['show_title']) {
                 echo '<header class="entry-header">';
                 printf('<h3 class="entry-title"><a href="%s" title="%s">%s</a></h3>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
                 echo '</header>';
             }
             if (!empty($instance['show_content'])) {
                 echo '<div class="entry-content">';
                 if ('excerpt' == $instance['show_content']) {
                     $current_excerpt = get_the_excerpt();
                     echo $current_excerpt;
                     //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>';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     //* Restore original query
     wp_reset_query();
     echo $after_widget;
 }
/**
 * Add term/default image to blog/archive pages. Use:
 * add_action( 'genesis_entry_content', 'display_featured_image_genesis_add_archive_thumbnails', 5 );
 * @return image If a post doesn't have its own thumbnail, you can use this function to add one to archive pages.
 *
 * @since  2.1.0
 */
function display_featured_image_genesis_add_archive_thumbnails()
{
    $show_thumbs = genesis_get_option('content_archive_thumbnail');
    if (is_singular() || is_admin() || is_404() || !$show_thumbs) {
        return;
    }
    $args = array('post_mime_type' => 'image', 'post_parent' => get_the_ID(), 'post_type' => 'attachment');
    $attached_images = get_children($args);
    if (has_post_thumbnail() || $attached_images) {
        return;
    }
    $image_id = display_featured_image_genesis_get_term_image_id();
    if (empty($image_id)) {
        $image_id = display_featured_image_genesis_get_cpt_image_id();
        if (empty($image_id)) {
            $image_id = display_featured_image_genesis_get_default_image_id();
        }
    }
    if (empty($image_id)) {
        return;
    }
    $image = genesis_get_image(array('fallback' => apply_filters('display_featured_image_genesis_fallback_archive_thumbnail', $image_id), 'size' => genesis_get_option('image_size'), 'attr' => genesis_parse_attr('entry-image', array('alt' => get_the_title())), 'context' => 'archive'));
    $permalink = get_permalink();
    printf('<a href="%1$s" aria-hidden="true">%2$s</a>', esc_url($permalink), wp_kses_post($image));
}
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @global WP_Query $wp_query Query object.
  * @global integer  $more
  */
 function widget_output()
 {
     global $wp_query, $Genesis_Author_Pro_CPT;
     echo $this->_args['before_widget'];
     //* Set up the author bio
     if (!empty($this->_instance['title'])) {
         echo $this->_args['before_title'] . apply_filters('widget_title', $this->_instance['title'], $this->_instance, $this->_widget_object->id_base) . $this->_args['after_title'];
     }
     $wp_query = new WP_Query(array('post__in' => array($this->_instance['book_id']), 'post_type' => $Genesis_Author_Pro_CPT->post_type));
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $this->_instance['image_size'], 'context' => 'featured-page-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             if ($this->_instance['show_image'] && $image) {
                 $banner = $this->_instance['show_featured_text'] && ($text = genesis_author_pro_get_book_meta('featured_text')) ? sprintf('<div class="book-featured-text-banner">%s</div>', $text) : '';
                 printf('<div class="author-pro-featured-image image-%s"><a class="%s" href="%s" title="%s">%s %s</a></div>', esc_attr($this->_instance['image_alignment']), esc_attr($this->_instance['image_alignment']), get_permalink(), the_title_attribute('echo=0'), $image, $banner);
             }
             if (!empty($this->_instance['show_title']) || !empty($this->_instance['show_author'])) {
                 echo genesis_html5() ? '<header class="entry-header">' : '';
                 if (!empty($this->_instance['show_title'])) {
                     $title = get_the_title() ? get_the_title() : __('(no title)', 'genesis');
                     /**
                      * Filter the featured book title.
                      *
                      *
                      * @param string $title    Featured book title.
                      * @param array  $this->_instance {
                      *     Widget settings for this instance.
                      *
                      *     @type string $title           Widget title.
                      *     @type int    $book_id         ID of the featured page.
                      *     @type bool   $show_image      True if featured image should be shown, false
                      *                                   otherwise.
                      *     @type string $image_alignment Image alignment: alignnone, alignleft,
                      *                                   aligncenter or alignright.
                      *     @type string $image_size      Name of the image size.
                      *     @type bool   $show_title      True if featured page title should be shown,
                      *                                   false otherwise.
                      *     @type bool   $show_content    True if featured page content should be shown,
                      *                                   false otherwise.
                      *     @type int    $content_limit   Amount of content to show, in characters.
                      *     @type int    $more_text       Text to use for More link.
                      * }
                      * @param array  $this->_args     {
                      *     Widget display arguments.
                      *
                      *     @type string $before_widget Markup or content to display before the widget.
                      *     @type string $before_title  Markup or content to display before the widget title.
                      *     @type string $after_title   Markup or content to display after the widget title.
                      *     @type string $after_widget  Markup or content to display after the widget.
                      * }
                      */
                     $title = apply_filters('genesis_author_pro_featured_book_title', $title, $this->_instance, $this->_args);
                     printf('<h2 class="entry-title"><a href="%s">%s</a></h2>', get_permalink(), $title);
                 }
                 //include the author details if selected
                 $this->_instance['show_author'] ? genesis_author_pro_do_by_line() : '';
                 echo genesis_html5() ? '</header>' : '';
             }
             //show the content, content limit, or excerpt as selected
             if (!empty($this->_instance['show_content']) || !empty($this->_instance['show_price']) || !empty($this->_instance['more_text'])) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 if (!empty($this->_instance['show_content'])) {
                     if ('excerpt' == $this->_instance['show_content']) {
                         the_excerpt();
                     } elseif ('content-limit' == $this->_instance['show_content']) {
                         add_filter('get_the_content_limit', array($this, 'content_limit_filter'));
                         the_content_limit((int) $this->_instance['content_limit'], '');
                         remove_filter('get_the_content_limit', array($this, 'content_limit_filter'));
                     } else {
                         global $more;
                         $orig_more = $more;
                         $more = 0;
                         the_content('');
                         $more = $orig_more;
                     }
                 }
                 echo empty($this->_instance['show_price']) ? '' : sprintf('<p>%s</p>', genesis_author_pro_get_price());
                 //show the link to view the single book page if selected
                 echo empty($this->_instance['more_text']) ? '' : sprintf('<p><a href="%s" class="button">%s</a></p>', get_permalink(), $this->_instance['more_text']);
                 echo genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     //* Restore original query
     wp_reset_query();
     echo $this->_args['after_widget'];
 }
/**
 * Pass nav menu link attributes through attribute parser.
 *
 * Adds nav menu link attributes via the Genesis markup API.
 *
 * @since 2.2.0
 *
 * @param array $atts {
 *		The HTML attributes applied to the menu item's <a>, empty strings are ignored.
 *
 *		@type string $title Title attribute.
 *		@type string $target Target attribute.
 *		@type string $rel The rel attribute.
 *		@type string $href The href attribute.
 * }
 * @param object $item The current menu item.
 * @param array $args An array of wp_nav_menu() arguments.
 *
 * @return array Maybe modified menu attributes array.
 */
function genesis_nav_menu_link_attributes($atts, $item, $args)
{
    return genesis_parse_attr('nav-link', $atts);
}
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @global WP_Query $wp_query Query object.
  * @global integer  $more
  *
  * @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;
     //* Merge with defaults
     $instance = wp_parse_args((array) $instance, $this->defaults);
     echo $args['before_widget'];
     //* Set up the author bio
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title'];
     }
     $wp_query = new WP_Query(array('page_id' => $instance['page_id']));
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-page-widget', 'attr' => genesis_parse_attr('entry-image-widget', array('alt' => get_the_title()))));
             if ($instance['show_image'] && $image) {
                 $role = empty($instance['show_title']) ? '' : 'aria-hidden="true"';
                 printf('<a href="%s" class="%s" %s>%s</a>', get_permalink(), esc_attr($instance['image_alignment']), $role, $image);
             }
             if (!empty($instance['show_title'])) {
                 $title = get_the_title() ? get_the_title() : __('(no title)', 'genesis');
                 /**
                  * Filter the featured page widget title.
                  *
                  * @since  2.2.0
                  *
                  * @param string $title    Featured page title.
                  * @param array  $instance {
                  *     Widget settings for this instance.
                  *
                  *     @type string $title           Widget title.
                  *     @type int    $page_id         ID of the featured page.
                  *     @type bool   $show_image      True if featured image should be shown, false
                  *                                   otherwise.
                  *     @type string $image_alignment Image alignment: alignnone, alignleft,
                  *                                   aligncenter or alignright.
                  *     @type string $image_size      Name of the image size.
                  *     @type bool   $show_title      True if featured page title should be shown,
                  *                                   false otherwise.
                  *     @type bool   $show_content    True if featured page content should be shown,
                  *                                   false otherwise.
                  *     @type int    $content_limit   Amount of content to show, in characters.
                  *     @type int    $more_text       Text to use for More link.
                  * }
                  * @param array  $args     {
                  *     Widget display arguments.
                  *
                  *     @type string $before_widget Markup or content to display before the widget.
                  *     @type string $before_title  Markup or content to display before the widget title.
                  *     @type string $after_title   Markup or content to display after the widget title.
                  *     @type string $after_widget  Markup or content to display after the widget.
                  * }
                  */
                 $title = apply_filters('genesis_featured_page_title', $title, $instance, $args);
                 $heading = genesis_a11y('headings') ? 'h4' : 'h2';
                 if (genesis_html5()) {
                     printf('<header class="entry-header"><%s class="entry-title"><a href="%s">%s</a></%s></header>', $heading, get_permalink(), $title, $heading);
                 } else {
                     printf('<%s><a href="%s">%s</a></%s>', $heading, get_permalink(), $title, $heading);
                 }
             }
             if (!empty($instance['show_content'])) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 if (empty($instance['content_limit'])) {
                     global $more;
                     $orig_more = $more;
                     $more = 0;
                     the_content(genesis_a11y_more_link($instance['more_text']));
                     $more = $orig_more;
                 } else {
                     the_content_limit((int) $instance['content_limit'], genesis_a11y_more_link(esc_html($instance['more_text'])));
                 }
                 echo genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     //* Restore original query
     wp_reset_query();
     echo $args['after_widget'];
 }
Example #10
0
function femme_grid_loop_content()
{
    global $_genesis_loop_args;
    if (in_array('genesis-feature', get_post_class())) {
        // if the post is a feature
        if ($_genesis_loop_args['feature_image_size']) {
            $image = genesis_get_image(array('size' => $_genesis_loop_args['feature_image_size'], 'context' => 'grid-loop-featured', 'attr' => genesis_parse_attr('entry-image-grid-loop', array('class' => $_genesis_loop_args['feature_image_class']))));
            printf('<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), $image);
        }
        if ($_genesis_loop_args['feature_content_limit']) {
            the_content_limit((int) $_genesis_loop_args['feature_content_limit'], esc_html($_genesis_loop_args['more']));
        } else {
            the_content(esc_html($_genesis_loop_args['more']));
        }
    } else {
        // The post is a teaser
        $default_img = '<img class="post-image" itemprop="image" src="' . CUTTZ_CORE_SKINS_URL . '/femme-flora/images/femme-default-img.png" alt="Femme-Flora" />';
        if ($_genesis_loop_args['grid_image_size']) {
            $image = genesis_get_image(array('size' => $_genesis_loop_args['grid_image_size'], 'context' => 'grid-loop', 'attr' => genesis_parse_attr('entry-image-grid-loop', array('class' => $_genesis_loop_args['grid_image_class']))));
            printf('<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), empty($image) ? $default_img : $image);
        }
        if ($_genesis_loop_args['grid_content_limit'] == 'no_content') {
            printf(__('%sClick to read more&hellip;%s', 'cuttz-framework'), '<a href="' . get_permalink() . '" class="more-link"><span class="more-link-content">', '</span></a>');
        } elseif ($_genesis_loop_args['grid_content_limit']) {
            the_content_limit((int) $_genesis_loop_args['grid_content_limit'], esc_html($_genesis_loop_args['more']));
        } else {
            //the_excerpt();
            printf('<a href="%s" class="more-link">%s</a>', get_permalink(), esc_html($_genesis_loop_args['more']));
        }
    }
}
Example #11
0
/**
 * Echo the post image on archive pages.
 *
 * If this an archive page and the option is set to show thumbnail, then it gets the image size as per the theme
 * setting, wraps it in the post permalink and echoes it.
 *
 * @since 1.1.0
 *
 * @uses genesis_get_option() Get theme setting value.
 * @uses genesis_get_image()  Return an image pulled from the media library.
 * @uses genesis_parse_attr() Return contextual attributes.
 */
function genesis_do_post_image()
{
    if (!is_singular() && genesis_get_option('content_archive_thumbnail')) {
        $img = genesis_get_image(array('format' => 'html', 'size' => genesis_get_option('image_size'), 'context' => 'archive', 'attr' => genesis_parse_attr('entry-image', array('alt' => get_the_title()))));
        if (!empty($img)) {
            genesis_markup(array('html5' => '<a %s>', 'xhtml' => '<a href="' . get_permalink() . '" class="entry-image-link" aria-hidden="true">', 'context' => 'entry-image-link'));
            echo $img . '</a>';
        }
    }
}
Example #12
0
/**
 * Output specially formatted content, based on the grid loop args.
 *
 * @since 1.5.0
 *
 * @uses genesis_get_image()  Return an image pulled from the media gallery.
 * @uses the_content_limit()  Echo the limited content.
 * @uses genesis_parse_attr() Return contextual attributes for an element.
 *
 * @global array $_genesis_loop_args Associative array for grid loop configuration.
 */
function genesis_grid_loop_content()
{
    global $_genesis_loop_args;
    if (in_array('genesis-feature', get_post_class())) {
        if ($_genesis_loop_args['feature_image_size']) {
            $image = genesis_get_image(array('size' => $_genesis_loop_args['feature_image_size'], 'context' => 'grid-loop-featured', 'attr' => genesis_parse_attr('entry-image-grid-loop', array('class' => $_genesis_loop_args['feature_image_class']))));
            printf('<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), $image);
        }
        if ($_genesis_loop_args['feature_content_limit']) {
            the_content_limit((int) $_genesis_loop_args['feature_content_limit'], esc_html($_genesis_loop_args['more']));
        } else {
            the_content(esc_html($_genesis_loop_args['more']));
        }
    } else {
        if ($_genesis_loop_args['grid_image_size']) {
            $image = genesis_get_image(array('size' => $_genesis_loop_args['grid_image_size'], 'context' => 'grid-loop', 'attr' => genesis_parse_attr('entry-image-grid-loop', array('class' => $_genesis_loop_args['grid_image_class']))));
            printf('<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), $image);
        }
        if ($_genesis_loop_args['grid_content_limit']) {
            the_content_limit((int) $_genesis_loop_args['grid_content_limit'], esc_html($_genesis_loop_args['more']));
        } else {
            the_excerpt();
            printf('<a href="%s" class="more-link">%s</a>', get_permalink(), esc_html($_genesis_loop_args['more']));
        }
    }
}
Example #13
0
 /**
  * Echo the post image on archive pages.
  *
  * If this an archive page and the option is set to show thumbnail, then it gets the image size as per the theme
  * setting, wraps it in the post permalink and echoes it.
  *
  * @since 1.0.0
  *
  * @uses genesis_get_option() Get theme setting value.
  * @uses genesis_get_image()  Return an image pulled from the media library.
  * @uses genesis_parse_attr() Return contextual attributes.
  */
 public function do_post_image()
 {
     if (genesis_get_option('content_archive_thumbnail')) {
         $img = genesis_get_image(array('format' => 'html', 'size' => $this->config->post_image_size, 'context' => 'archive', 'attr' => genesis_parse_attr('entry-image')));
         if (!empty($img)) {
             $this->load_view('post_image', compact('img'));
         }
     }
 }
Example #14
0
 /**
  * Echo the widget content on the frontend.
  *
  * @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;
     //* Display widget title above image
     if ($instance['widget_title_below'] != 1) {
         if ($instance['feature_type'] == 'page' && !empty($instance['title']) && $instance['enable_title_link'] == 1) {
             echo $before_title;
             printf('<a href="%s" title="%s">%s</a>', get_permalink($instance['page_id']), get_the_title($instance['page_id']), apply_filters('widget_title', $instance['title'], $instance, $this->id_base));
             echo $after_title;
         } elseif ($instance['feature_type'] == 'custom' && !empty($instance['title']) && $instance['enable_title_link'] == 1) {
             echo $before_title;
             printf('<a href="%s" title="%s">%s</a>', esc_url($instance['custom_link']), esc_attr($instance['title']), apply_filters('widget_title', $instance['title'], $instance, $this->id_base));
             echo $after_title;
         } elseif (!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();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-page-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             //* Display page title above image (Hide if using Custom Link)
             if ($instance['feature_type'] == 'page' && $instance['page_title_above'] == 1) {
                 if (!empty($instance['show_title']) && $instance['enable_page_title_link'] == 1) {
                     if (genesis_html5()) {
                         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());
                     } else {
                         printf('<h2><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
                     }
                 } elseif (!empty($instance['show_title'])) {
                     if (genesis_html5()) {
                         printf('<header class="entry-header"><h2 class="entry-title">%s</h2></header>', get_the_title());
                     } else {
                         printf('<h2>%s</h2>', get_the_title());
                     }
                 }
             }
             //* Display featured image (Hide if using Custom Link)
             if ($instance['feature_type'] == 'page' && $instance['show_image'] == 2 && $image) {
                 if ($instance['enable_image_link'] == 1) {
                     printf('<a href="%s" title="%s" class="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $image);
                 } else {
                     //* The <span> replaces the <a> so the image alignment feature still works
                     printf('<span class="%s">%s</span>', esc_attr($instance['image_alignment']), $image);
                 }
             }
             //* Display custom image
             if ($instance['show_image'] == 3) {
                 if ($instance['feature_type'] == 'page' && $instance['enable_image_link'] == 1) {
                     printf('<a href="%s" title="%s" class="%s"><img src="%s"/></a>', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $instance['custom_image']);
                 } elseif ($instance['feature_type'] == 'custom' && $instance['enable_image_link'] == 1) {
                     printf('<a href="%s" title="%s" class="%s"><img src="%s"/></a>', esc_url($instance['custom_link']), esc_attr($instance['title']), esc_attr($instance['image_alignment']), $instance['custom_image']);
                 } else {
                     //* The <span> replaces the <a> so the image alignment feature still works
                     printf('<span class="%s"><img src="%s"/></span>', esc_attr($instance['image_alignment']), $instance['custom_image']);
                 }
             }
             //* Display widget title below image
             if ($instance['widget_title_below'] == 1) {
                 if ($instance['feature_type'] == 'page' && !empty($instance['title']) && $instance['enable_title_link'] == 1) {
                     echo $before_title;
                     printf('<a href="%s" title="%s">%s</a>', get_permalink($instance['page_id']), get_the_title($instance['page_id']), apply_filters('widget_title', $instance['title'], $instance, $this->id_base));
                     echo $after_title;
                 } elseif ($instance['feature_type'] == 'custom' && !empty($instance['title']) && $instance['enable_title_link'] == 1) {
                     echo $before_title;
                     printf('<a href="%s" title="%s">%s</a>', esc_url($instance['custom_link']), esc_attr($instance['title']), apply_filters('widget_title', $instance['title'], $instance, $this->id_base));
                     echo $after_title;
                 } elseif (!empty($instance['title'])) {
                     echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
                 }
             }
             //* Display page title below image (Hide if using Custom Link)
             if ($instance['feature_type'] == 'page' && $instance['page_title_above'] != 1) {
                 if (!empty($instance['show_title']) && $instance['enable_page_title_link'] == 1) {
                     if (genesis_html5()) {
                         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());
                     } else {
                         printf('<h2><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
                     }
                 } elseif (!empty($instance['show_title'])) {
                     if (genesis_html5()) {
                         printf('<header class="entry-header"><h2 class="entry-title">%s</h2></header>', get_the_title());
                     } else {
                         printf('<h2>%s</h2>', get_the_title());
                     }
                 }
             }
             //* Display page content (Hide if using Custom Link)
             if ($instance['feature_type'] == 'page' && !empty($instance['show_content'])) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 if (empty($instance['content_limit'])) {
                     the_content($instance['more_text']);
                 } else {
                     the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
                 }
                 echo genesis_html5() ? '</div>' : '';
             }
             //* Display page excerpt (Hide if using Custom Link)
             if ($instance['feature_type'] == 'page' && !empty($instance['show_excerpt'])) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 echo '<p>' . get_the_excerpt() . ' ';
                 if (!empty($instance['more_text'])) {
                     printf('<a href="%s" class="more-link">%s</a>', get_permalink(), esc_attr($instance['more_text']));
                 }
                 echo '</p>';
                 echo genesis_html5() ? '</div>' : '';
             }
             //* Display custom content
             if ($instance['show_custom_content'] == 1 && !empty($instance['custom_content'])) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 echo '<p>' . wp_kses_post($instance['custom_content']) . ' ';
                 if ($instance['feature_type'] == 'page' && !empty($instance['more_text'])) {
                     printf('<a href="%s" class="more-link">%s</a>', get_permalink(), esc_attr($instance['more_text']));
                 } elseif ($instance['feature_type'] == 'custom' && !empty($instance['more_text'])) {
                     printf('<a href="%s" class="more-link">%s</a>', esc_url($instance['custom_link']), esc_attr($instance['more_text']));
                 }
                 echo '</p>';
                 echo genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     //* Restore original query
     wp_reset_query();
     echo $after_widget;
 }
Example #15
0
 function widget($args, $instance)
 {
     $args = $this->override_args($args, $instance);
     extract($args);
     $term_args = array();
     $terms = array();
     $term = $this->get_current_term();
     if ('page' != $instance['post_type']) {
         switch ($instance['source_type']) {
             case "parent":
                 $term = $this->get_top_term($term);
                 break;
             case "current":
                 break;
             default:
                 $term = $this->get_instance_term($instance['posts_term']);
         }
         if ($term) {
             $term_args['tax_query'] = array(array('taxonomy' => $term->taxonomy, 'field' => 'id', 'terms' => count($terms) > 0 ? $terms : $term->term_id));
             if ($instance['exclude_terms']) {
                 $exclude_terms = explode(',', str_replace(' ', '', $instance['exclude_terms']));
                 $term_args[$term->taxonomy . '__not_in'] = $exclude_terms;
             }
         }
     }
     if ($instance['post_id']) {
         $IDs = explode(',', str_replace(' ', '', $instance['post_id']));
         if ('include' == $instance['include_exclude']) {
             $term_args['post__in'] = $IDs;
         } else {
             $term_args['post__not_in'] = $IDs;
         }
     }
     if ($instance['posts_offset']) {
         $myOffset = $instance['posts_offset'];
         $term_args['offset'] = $myOffset;
     }
     $query_args = array_merge($term_args, array('post_type' => $instance['post_type'], 'posts_per_page' => $instance['posts_num'], 'orderby' => $instance['orderby']));
     $wrap = $instance['show_excerpt'];
     echo $before_widget;
     $posts = array();
     $posts = new WP_Query($query_args);
     while ($posts->have_posts()) {
         $posts->the_post();
         $permalink = get_permalink();
         $title = get_the_title();
         $post_title = $instance['show_title'] ? sprintf('<a rel="bookmark" href="%1$s">%2$s</a>', $permalink, esc_html($title)) : '';
         if ($instance['show_image'] && ($image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget'))))) {
             $post_image = sprintf('<a href="%s" title="%s" class="%s">%s</a>', $permalink, the_title_attribute('echo=0'), esc_attr($instance['image_align']), $image);
         } else {
             $post_image = '';
         }
         if ($instance['show_excerpt']) {
             if ($instance['show_content']) {
                 if ($instance['show_limit']) {
                     $post_excerpt = get_the_content_limit((int) $instance['show_limit']);
                 } else {
                     $post_excerpt = get_the_content($instance['show_more'] ? null : '');
                 }
             } else {
                 $post_excerpt = get_the_excerpt();
             }
         } else {
             $post_excerpt = '';
         }
         if ($wrap) {
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
         }
         if (!empty($post_title) || !empty($post_image)) {
             printf(genesis_html5() ? '<header class="entry-header"><h2 class="entry-title">%1$s%2$s</h2></header>' : '<h2>%1$s%2$s</h2>', $post_image, $post_title);
         }
         if (!empty($post_excerpt)) {
             printf(genesis_html5() ? '<div class="entry-content">%1$s</div>' : '%1$s', $post_excerpt);
         }
         if ($wrap) {
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     echo $after_widget;
     wp_reset_query();
 }
Example #16
0
/**
 * Echo the post image on archive pages.
 *
 * If this an archive page and the option is set to show thumbnail, then it gets the image size as per the theme
 * setting, wraps it in the post permalink and echoes it.
 *
 * @since 1.1.0
 */
function genesis_do_post_image()
{
    if (!is_singular() && genesis_get_option('content_archive_thumbnail')) {
        $img = genesis_get_image(array('format' => 'html', 'size' => genesis_get_option('image_size'), 'context' => 'archive', 'attr' => genesis_parse_attr('entry-image', array('alt' => get_the_title()))));
        if (!empty($img)) {
            genesis_markup(array('open' => '<a %s>', 'close' => '</a>', 'content' => wp_make_content_images_responsive($img), 'context' => 'entry-image-link'));
        }
    }
}
Example #17
0
/**
 * Build list of attributes into a string and apply contextual filter on string.
 *
 * The contextual filter is of the form `genesis_attr_{context}_output`.
 *
 * @since 2.0.0
 *
 * @param string $context    The context, to build filter name.
 * @param array  $attributes Optional. Extra attributes to merge with defaults.
 * @return string String of HTML attributes and values.
 */
function genesis_attr($context, $attributes = array())
{
    $attributes = genesis_parse_attr($context, $attributes);
    $output = '';
    // Cycle through attributes, build tag attribute string.
    foreach ($attributes as $key => $value) {
        if (!$value) {
            continue;
        }
        if (true === $value) {
            $output .= esc_html($key) . ' ';
        } else {
            $output .= sprintf('%s="%s" ', esc_html($key), esc_attr($value));
        }
    }
    $output = apply_filters("genesis_attr_{$context}_output", $output, $attributes, $context);
    return trim($output);
}
Example #18
0
/**
 * Echo the post image on archive pages.
 *
 * If this an archive page and the option is set to show thumbnail, then it gets the image size as per the theme
 * setting, wraps it in the post permalink and echoes it.
 *
 * @since 1.1.0
 *
 * @uses genesis_get_option() Get theme setting value.
 * @uses genesis_get_image()  Return an image pulled from the media library.
 * @uses genesis_parse_attr() Return contextual attributes.
 */
function sk_do_post_image()
{
    if (!is_singular() && genesis_get_option('content_archive_thumbnail')) {
        $img = genesis_get_image(array('format' => 'html', 'size' => genesis_get_option('image_size'), 'context' => 'archive', 'attr' => genesis_parse_attr('entry-image')));
        if (!empty($img)) {
            printf('<div class="archive-pages-image"><a href="%s" title="%s">%s</a></div>', get_permalink(), the_title_attribute('echo=0'), $img);
        }
    }
}
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @global WP_Query $wp_query               Query object.
  * @global array    $_genesis_displayed_ids Array of displayed post IDs.
  * @global $integer $more
  *
  * @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);
     echo $args['before_widget'];
     //* Set up the author bio
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['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) $_genesis_displayed_ids;
     }
     $coldata = badabing_get_colclass($instance['num_cols']);
     $wp_query = new WP_Query($query_args);
     echo '<div class="masonry">';
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             $is_first = $article_num % $coldata['cols'] == 0 ? " first" : "";
             echo "<div class='" . $coldata['class'] . $is_first . " '>";
             $article_num++;
             $_genesis_displayed_ids[] = get_the_ID();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             /* get the title for this post */
             if (!empty($instance['show_title'])) {
                 $title = get_the_title() ? get_the_title() : __('(no title)', 'genesis');
                 $thetitle = genesis_html5() ? sprintf('<h2 class="entry-title"><a href="%s">%s</a></h2>', get_permalink(), esc_html($title)) : sprintf('<h2><a href="%s">%s</a></h2>', get_permalink(), esc_html($title));
             }
             /* get the entrymeta data */
             if (!empty($instance['show_byline']) && !empty($instance['post_info'])) {
                 $entrymeta = sprintf(genesis_html5() ? '<p class="entry-meta">%s</p>' : '<p class="byline post-info">%s</p>', do_shortcode($instance['post_info']));
             }
             /* get the gravatar */
             if (!empty($instance['show_gravatar'])) {
                 $gravatar = '<span class="' . esc_attr($instance['gravatar_alignment']) . '">';
                 $gravatar .= get_avatar(get_the_author_meta('ID'), $instance['gravatar_size']);
                 $gravatar .= '</span>';
             }
             /* get the content */
             if (!empty($instance['show_content'])) {
                 switch ($instance['show_content']) {
                     case 'excerpt':
                         $content = (int) $instance['content_limit'] > 0 ? substr(get_the_excerpt(), 0, (int) $instance['content_limit']) . '...' : get_the_excerpt();
                         break;
                     case 'content-limit':
                         $content = get_the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
                         break;
                     case 'content':
                     case '':
                     default:
                         $content = apply_filters('the_content', get_the_content($instance['more_text']));
                         break;
                 }
             }
             /* get the permalink button */
             if (!empty($instance['permalink_button']) && $instance['permalink_button']) {
                 switch ($instance['permalink_button_style']) {
                     case 'flbuilder':
                     default:
                         $permalink_button = sprintf('<div class="fl-button-wrap fl-button-width-auto fl-button-right"><a href="%s" target="_self" class="fl-button" role="button"><span class="fl-button-text">%s</span></a></div>', get_permalink(), $instance['more_text']);
                         break;
                     case 'themed':
                         $permalink_button = sprintf('<div class="btn-align-%s"><a href="%s" class="badbtn btn-%s">%s</a></a>', $instance['permalink_button_align'], get_permalink(), $instance['permalink_button_class'], $instance['more_text']);
                         break;
                 }
             }
             switch ($instance['layout_style']) {
                 case 'style1':
                 default:
                     if ($instance['show_image'] && $image) {
                         printf('<div class="bb-feat-style1">%s<a href="%s" title="%s" class="%s img-link"><i class="fa fa-3x fa-arrow-circle-right"></i></a></div>%s %s', $image, get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $thetitle, $entrymeta);
                     }
                     echo $gravatar;
                     echo $content;
                     echo $permalink_button;
                     break;
                 case 'style2':
                     if ($instance['show_image'] && $image) {
                         printf('<div class="bb-feat-style2"><a href="%s" title="%s" class="%s">%s</a></div>%s %s', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $image, $thetitle, $entrymeta);
                     }
                     echo $gravatar;
                     echo $content;
                     echo $permalink_button;
                     break;
                 case 'style3':
                     if ($instance['show_image'] && $image) {
                         printf('<div class="bb-feat-style3"><a href="%s" class="bb-feat3-link %s"><div class="bb-feat3-overlay"><span>+</span></div><div class="bb-feat3-image">%s</div><h3>%s</h3></a></div>', get_permalink(), the_title_attribute('echo=0'), $image, $title);
                     }
                     echo $gravatar;
                     echo $content;
                     echo $permalink_button;
                     break;
                 case 'style4':
                     if ($instance['show_image'] && $image) {
                         printf('<div class="bb-feat-style4"><a href="%s" class="bb-feat4-link %s"><div class="bb-feat4-overlay"><span>+</span></div><div class="bb-feat4-image">%s</div><h3>%s</h3></a>', get_permalink(), the_title_attribute('echo=0'), $image, $title);
                     }
                     echo !empty($instance['show_byline']) && !empty($instance['post_info']) ? '<div class="bb-feat4-meta">' . $entrymeta . '</div>' : '';
                     printf('</div>');
                     echo $gravatar;
                     echo $content;
                     echo $permalink_button;
                     break;
                 case 'style5':
                     printf('<a href="%s" class="bb-feat-style5"><div class="image">%s<h4 class="posted-date">%s</div>' . '<div class="the-excerpt">' . '<h3>%s</h3>' . '%s<br>' . '<span>%s</span>' . '</div></a>', get_permalink(), $image, $entrymeta, $title, $content, $instance['more_text']);
                     break;
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
             echo "</div>";
         }
         while ($article_num % $coldata['cols'] != 0) {
             echo "<div class='" . $coldata['class'] . "'></div>";
             $article_num++;
         }
     }
     echo '</div>';
     // end .masonry class
     //* Restore original query
     wp_reset_query();
     //* The EXTRA Posts (list)
     if (!empty($instance['extra_num'])) {
         if (!empty($instance['extra_title'])) {
             echo $args['before_title'] . esc_html($instance['extra_title']) . $args['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();
                 $_genesis_displayed_ids[] = get_the_ID();
                 $listitems .= sprintf('<li><a href="%s">%s</a></li>', get_permalink(), 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 $args['after_widget'];
 }
 /**
  * Echo the widget content on the frontend.
  *
  * @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;
     $wp_query = new WP_Query(array('page_id' => $instance['page_id']));
     if (!defined('NO_BG')) {
         define('NO_BG', '1');
     }
     if (!defined('FEATURED_BG')) {
         define('FEATURED_BG', '2');
     }
     if (!defined('CUSTOM_BG')) {
         define('CUSTOM_BG', '3');
     }
     if (!defined('COLOR_BG')) {
         define('COLOR_BG', '4');
     }
     $image = genesis_get_image(array('format' => 'url', 'size' => $instance['image_size'], 'context' => 'featured-page-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             if ($instance['feature_type'] == 'page' && $instance['show_image'] == FEATURED_BG && $instance['background_fixed'] && $image) {
                 genesis_markup(array('html5' => '<article class="image-section fixed" style="background-image:url(' . $image . ')"><div class="hook-img-fix">', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             } elseif ($instance['feature_type'] == 'page' && $instance['show_image'] == FEATURED_BG && !$instance['background_fixed'] && $image) {
                 genesis_markup(array('html5' => '<article class="image-section non-fixed" style="background-image:url(' . $image . ')"><div class="hook-img">', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             } elseif ($instance['show_image'] == CUSTOM_BG && $instance['background_fixed']) {
                 genesis_markup(array('html5' => '<article class="image-section fixed" style="background-image:url(' . $instance['custom_image'] . ')"><div class="hook-img-fix">', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             } elseif ($instance['show_image'] == CUSTOM_BG && !$instance['background_fixed']) {
                 genesis_markup(array('html5' => '<article class="image-section non-fixed" style="background-image:url(' . $instance['custom_image'] . ')"><div class="hook-img">', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             } elseif ($instance['show_image'] == COLOR_BG) {
                 genesis_markup(array('html5' => '<article class="image-section bg_color" style="background-color:' . $instance['background_color'] . '"><div class="hook-color">', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             } else {
                 genesis_markup(array('html5' => '<article class="image-section"><div class="hook-blank">', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             }
             //* Display page content
             if ($instance['feature_type'] == 'page' && !empty($instance['show_content'])) {
                 echo genesis_html5() ? '<div class="wrap">' : '';
                 echo $instance['title'];
                 if (!empty($instance['show_title'])) {
                     if (genesis_html5()) {
                         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());
                     } else {
                         printf('<h2><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
                     }
                 }
                 if (empty($instance['content_limit'])) {
                     the_content($instance['more_text']);
                 } else {
                     the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
                 }
                 echo genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</div></article>', 'xhtml' => '</div></div>'));
         }
     }
     //* Restore original query
     wp_reset_query();
     echo $after_widget;
 }
 /**
  * Echo the widget content.
  *
  * @since  1.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
  *
  * @global mixed $wp_query
  */
 function widget($args, $instance)
 {
     /** Extract arguments */
     extract($args);
     /** Merge with defaults */
     $instance = wp_parse_args((array) $instance, $this->defaults);
     /** Check SPECIFIC display option for this widget and optionally disable it from displaying */
     if ($instance['not_in_public'] && !is_user_logged_in()) {
         return;
     }
     /** Check GENERAL display option for this widget and optionally disable it from displaying */
     if ('single_posts' === $instance['widget_display'] && !is_singular('post') || 'single_pages' === $instance['widget_display'] && !is_singular('page') || 'single_posts_pages' === $instance['widget_display'] && !is_singular(array('post', 'page'))) {
         return;
     }
     // end-if widget display checks
     /** Get global $wp_query object */
     global $wp_query;
     /** Widget title URL helpers */
     $title_url_custom = !empty($instance['title_url']) && !$instance['title_url_page'] ? $instance['title_url'] : '';
     $title_url = $instance['title_url_page'] ? get_permalink($instance['page_id']) : $title_url_custom;
     /** Optional title URL target */
     $title_url_target = $instance['title_url_target'] ? ' target="_blank"' : '';
     /** Typical WordPress Widget title filter */
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     /** GFPE Widget title filter */
     $title = apply_filters('gfpe_filter_widget_title', $instance['title'], $instance, $this->id_base);
     /** Prepare the title display string */
     $title_display = sprintf('%1$s%2$s%3$s', $instance['title_url_page'] || !empty($instance['title_url']) ? '<a href="' . esc_url($title_url) . '"' . $title_url_target . '>' : '', esc_attr($instance['title']), $instance['title_url_page'] || !empty($instance['title_url']) ? '</a>' : '');
     /** Output the widget wrapper and title */
     echo $before_widget;
     /** Set up the complete title display */
     if (empty($instance['title_hide']) && !empty($instance['title'])) {
         echo $before_title . $title_display . $after_title;
     }
     // end if
     /** Action hook 'gfpe_before_search_widget' */
     do_action('gfpe_before_page_widget', $instance, $this->id_base);
     /** Display widget intro text if it exists */
     if (!empty($instance['intro_text'])) {
         printf('<div class="textwidget"><p class="%s-intro-text gfpe-intro-text">%s</p></div>', $this->id, $instance['intro_text']);
     }
     // end-if optional intro
     /** Set new WP_Query instance */
     $wp_query = new WP_Query(array('page_id' => $instance['page_id']));
     /** Loop through pages */
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             /** Genesis markup: open */
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             /**
              * Image center alignment helper - needs to go before actual
              *    image if/else statement!
              */
             if ('aligncenter' === $instance['image_alignment']) {
                 $img_centered = ' centered';
                 add_filter('genesis_attr_entry-image-widget', 'ddw_gfpe_entry_image_widget_class');
             } else {
                 $img_centered = '';
             }
             // end if
             /** a) Featured image support */
             if (!empty($instance['image_show']) && empty($instance['image_url'])) {
                 /** Retrieve featured image */
                 $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-page-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
                 /** Output featured image */
                 if ($image) {
                     printf('<%1$s %2$s title="%3$s" class="%4$s%5$s">%6$s</%1$s>', $instance['image_link'] ? 'a' : 'span', $instance['image_link'] ? 'href="' . get_permalink() . '"' : '', the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $img_centered, $image);
                 }
                 // end if
             } elseif (!empty($instance['image_url'])) {
                 $img_sizes = genesis_get_image_sizes();
                 // all image sizes available
                 $size_wh = $instance['image_size'];
                 // needed size (set in widget)
                 $custom_image = '<img width="' . absint($img_sizes[$size_wh]['width']) . '" height="' . absint($img_sizes[$size_wh]['height']) . '" src="' . esc_url($instance['image_url']) . '" class="attachment-' . $size_wh . $img_centered . '" alt="' . the_title_attribute('echo=0') . '" />';
                 printf('<%1$s %2$s title="%3$s" class="%4$s%5$s">%6$s</%1$s>', $instance['image_link'] ? 'a' : 'span', $instance['image_link'] ? 'href="' . esc_url(get_permalink()) . '"' : '', the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $img_centered, $custom_image);
             }
             // end if
             /** Page title support */
             if (!empty($instance['page_title_show'])) {
                 if (!empty($instance['page_title_limit'])) {
                     $page_title = genesis_truncate_phrase(the_title_attribute('echo=0'), $instance['page_title_limit']) . $instance['page_title_cutoff'];
                 } else {
                     $page_title = get_the_title();
                 }
                 // end if
                 $page_link = sprintf('<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), $page_title);
                 /** Genesis 2.0+ / HTML5 way: */
                 if (genesis_html5()) {
                     printf('<header class="entry-header"><h2 class="entry-title">%s</h2></header>', !$instance['page_title_link'] ? $page_title : $page_link);
                 } else {
                     printf('<h2>%s</h2>', !$instance['page_title_link'] ? $page_title : $page_link);
                 }
                 // end if
             }
             // end if
             /** Page Byline support */
             if (!empty($instance['byline_show']) && !empty($instance['page_post_info'])) {
                 printf(genesis_html5() ? '<p class="entry-meta">%s</p>' : '<p class="byline post-info">%s</p>', do_shortcode($instance['page_post_info']));
             }
             // end if
             /** Set optional "autark" custom 'More Link' */
             $more_link_target = 'none' != $instance['more_link_target'] ? ' target="' . esc_html($instance['more_link_target']) . '"' : '';
             $autark_more_link = sprintf('<div class="gfpe-more-link"><a class="more-link%s" href="%s"%s title="%s">%s</a></div>', !empty($instance['more_link_class']) ? ' ' . esc_attr($instance['more_link_class']) : '', empty($instance['more_link_url']) ? get_permalink($instance['page_id']) : esc_url($instance['more_link_url']), $more_link_target, esc_html($instance['more_link_text']), $instance['more_link_text']);
             /**
              * 1) Content Type: Original Page Content (optional with wpautop!)
              */
             if ('page_content' === $instance['content_type']) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 /** a) No content limit is set: */
                 if (empty($instance['content_limit'])) {
                     global $more;
                     $more = 0;
                     printf('%s', $instance['page_keep_wpautop'] ? wpautop(the_content()) . $autark_more_link : get_the_content() . $autark_more_link);
                 } else {
                     printf('%s', empty($instance['more_link_url']) ? the_content_limit((int) $instance['content_limit'], esc_html($instance['more_link_text'])) : the_content_limit((int) $instance['content_limit'], '') . $autark_more_link);
                 }
                 // end if
                 echo genesis_html5() ? '</div>' : '';
             }
             // end if
             /**
              * 2) Content Type: Original Page Excerpt
              */
             if ('page_excerpt' === $instance['content_type']) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 printf(the_excerpt() . '%s', empty($instance['more_link_show']) ? '' : $autark_more_link);
                 echo genesis_html5() ? '</div>' : '';
             }
             // end if
             /**
              * 3) Content Type: Custom Text by user
              */
             if ('custom_user_content' === $instance['content_type']) {
                 echo '<div class="entry-content custom-content">';
                 $content = apply_filters('widget_text', empty($instance['custom_content']) ? '' : $instance['custom_content'], $instance);
                 echo $instance['custom_wpautop'] ? wpautop($content) : $content;
                 echo '</div>';
                 if (!empty($instance['more_link_text'])) {
                     echo $autark_more_link;
                 }
                 // end if
             }
             // end if
             /**
              * 4) Content Type: no content at all
              */
             if ('no_content' === $instance['content_type']) {
                 if ($instance['more_link_text']) {
                     echo $autark_more_link;
                 }
                 // end if
             }
             // end if
             /** Genesis markup: close */
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div><!--end post_class()-->' . "\n\n"));
         }
         // end while (when pages exist)
     }
     // end if loop check
     /** Display widget outro text if it exists */
     if (!empty($instance['outro_text'])) {
         printf('<div class="textwidget"><p class="%s-outro_text gfpe-outro-text">%s</p></div>', $this->id, $instance['outro_text']);
     }
     // end-if optional outro
     /** Action hook 'gfpe_after_search_widget' */
     do_action('gfpe_after_search_widget', $instance, $this->id_base);
     /** Output the closing widget wrapper */
     echo $after_widget;
     /** Reset our custom $wp_query object */
     wp_reset_query();
 }
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @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;
     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) $_genesis_displayed_ids;
     }
     $wp_query = new WP_Query($query_args);
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             $_genesis_displayed_ids[] = get_the_ID();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             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 genesis_html5() ? '<header class="entry-header">' : '';
             }
             if (!empty($instance['show_title'])) {
                 if (genesis_html5()) {
                     printf('<h2 class="entry-title"><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
                 } else {
                     printf('<h2><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(genesis_html5() ? '<p class="entry-meta">%s</p>' : '<p class="byline post-info">%s</p>', do_shortcode($instance['post_info']));
             }
             if ($instance['show_title']) {
                 echo genesis_html5() ? '</header>' : '';
             }
             if (!empty($instance['show_content'])) {
                 echo genesis_html5() ? '<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 genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     //* 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();
                 $_genesis_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;
 }
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @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;
     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' => $instance['post_type'], 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order']);
     // Extract the custom tax term, if provided
     if ('any' !== $instance['tax_term']) {
         list($post_tax, $post_term) = explode('/', $instance['tax_term'], 2);
         $query_args['tax_query'] = array(array('taxonomy' => $post_tax, 'field' => 'slug', 'terms' => $post_term));
     }
     //* Exclude displayed IDs from this loop?
     if ($instance['exclude_displayed']) {
         $query_args['post__not_in'] = (array) $_genesis_displayed_ids;
     }
     if ('full' !== $instance['columns']) {
         add_filter('post_class', array($this, 'add_post_class_' . $instance['columns']));
     }
     $wp_query = new WP_Query($query_args);
     echo '<div class="featured-wrap">';
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             $_genesis_displayed_ids[] = get_the_ID();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             // Enable the image to diplay under the title
             if ($instance['image_position']) {
                 if ($instance['show_title']) {
                     echo genesis_html5() ? '<header class="entry-header">' : '';
                 }
                 if (!empty($instance['show_title'])) {
                     if (genesis_html5()) {
                         printf('<h2 class="entry-title"><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
                     } else {
                         printf('<h2><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(genesis_html5() ? '<p class="entry-meta">%s</p>' : '<p class="byline post-info">%s</p>', do_shortcode($instance['post_info']));
                 }
                 if ($instance['show_title']) {
                     echo genesis_html5() ? '</header>' : '';
                 }
                 $size = $instance['image_size'];
                 $image = apply_filters('featured_custom_post_type_image', genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget'))), $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>';
                 }
             } else {
                 $size = $instance['image_size'];
                 $image = apply_filters('featured_custom_post_type_image', genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget'))), $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 genesis_html5() ? '<header class="entry-header">' : '';
                 }
                 if (!empty($instance['show_title'])) {
                     if (genesis_html5()) {
                         printf('<h2 class="entry-title"><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
                     } else {
                         printf('<h2><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(genesis_html5() ? '<p class="entry-meta">%s</p>' : '<p class="byline post-info">%s</p>', do_shortcode($instance['post_info']));
                 }
                 if ($instance['show_title']) {
                     echo genesis_html5() ? '</header>' : '';
                 }
             }
             if (!empty($instance['show_content'])) {
                 echo genesis_html5() ? '<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 genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     echo '</div>';
     if ('full' !== $instance['columns']) {
         remove_filter('post_class', array($this, 'add_post_class_' . $instance['columns']));
     }
     //* 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('post_type' => $instance['post_type'], 'showposts' => $instance['extra_num'], 'offset' => $offset);
         // Extract the custom tax term, if provided
         if ('any' != $instance['tax_term']) {
             list($post_tax, $post_term) = explode('/', $instance['tax_term'], 2);
             $query_args['tax_query'] = array(array('taxonomy' => $post_tax, 'field' => 'slug', 'terms' => $post_term));
         }
         $wp_query = new WP_Query($query_args);
         $listitems = '';
         if (have_posts()) {
             while (have_posts()) {
                 the_post();
                 $_genesis_displayed_ids[] = get_the_ID();
                 $extra_title = sprintf('<a href="%s">%s</a>', get_permalink(), get_the_title());
                 $listitems .= '<li>';
                 $listitems .= apply_filters('featured_custom_post_type_extra_title', $extra_title);
                 $listitems .= '</li>';
             }
             if (mb_strlen($listitems) > 0) {
                 printf('<ul>%s</ul>', $listitems);
             }
         }
         //* Restore original query
         wp_reset_query();
     }
     if (!empty($instance['more_from_category']) && !empty($instance['more_from_category_text']) && 'any' !== $instance['tax_term']) {
         list($post_tax, $post_term) = explode('/', $instance['tax_term'], 2);
         printf('<p class="more-from-category"><a href="%1$s">%2$s</a></p>', esc_url(get_term_link($post_term, $post_tax)), esc_html($instance['more_from_category_text']));
     }
     if (!empty($instance['archive_link']) && !empty($instance['archive_text'])) {
         $archive_url = get_post_type_archive_link($instance['post_type']);
         if ('post' === $instance['post_type']) {
             $postspage = get_option('page_for_posts');
             $archive_url = get_permalink(get_post($postspage)->ID);
             $frontpage = get_option('show_on_front');
             if ('posts' === $frontpage) {
                 $archive_url = get_home_url();
             }
         }
         printf('<p class="more-from-category"><a href="%1$s">%2$s</a></p>', esc_url($archive_url), esc_html($instance['archive_text']));
     }
     echo $after_widget;
 }
 /**
  * Inserts Post Image
  *
  * @param array $instance The settings for the particular instance of the widget.
  */
 public static function do_post_image($instance)
 {
     //* Bail if empty show param
     if (empty($instance['show_image'])) {
         return;
     }
     $align = $instance['image_alignment'] ? esc_attr($instance['image_alignment']) : 'alignnone';
     $link = $instance['link_image_field'] ? $instance['link_image_field'] : get_permalink();
     $link = '' !== genesis_get_custom_field('gsfc_link_image_field') ? genesis_get_custom_field('gsfc_link_image_field') : $link;
     $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('gsfc-entry-image-widget', array('align' => $align))));
     $image = $instance['link_image'] == 1 ? sprintf('<a href="%s" title="%s" class="%s">%s</a>', $link, the_title_attribute('echo=0'), $align, $image) : $image;
     GS_Featured_Content::maybe_echo($instance, 'gsfc_before_post_content', 'image_position', 'before-title', $image);
     GS_Featured_Content::maybe_echo($instance, 'gsfc_post_content', 'image_position', 'after-title', $image);
     GS_Featured_Content::maybe_echo($instance, 'gsfc_after_post_content', 'image_position', 'after-content', $image);
 }
Example #25
0
File: post.php Project: nkeat12/dv
/**
 * Echo the post image on archive pages.
 *
 * If this an archive page and the option is set to show thumbnail, then it gets the image size as per the theme
 * setting, wraps it in the post permalink and echoes it.
 *
 * @since 1.1.0
 *
 * @uses genesis_get_option() Get theme setting value.
 * @uses genesis_get_image()  Return an image pulled from the media library.
 * @uses genesis_parse_attr() Return contextual attributes.
 */
function genesis_do_post_image()
{
    if (!is_singular() && genesis_get_option('content_archive_thumbnail')) {
        $img = genesis_get_image(array('format' => 'html', 'size' => genesis_get_option('image_size'), 'context' => 'archive', 'attr' => genesis_parse_attr('entry-image', array('alt' => get_the_title()))));
        if (!empty($img)) {
            printf('<a href="%s" aria-hidden="true">%s</a>', get_permalink(), $img);
        }
    }
}
Example #26
0
/**
 * Build list of attributes into a string and apply contextual filter on string.
 *
 * The contextual filter is of the form `genesis_attr_{context}_output`.
 *
 * @since 2.0.0
 *
 * @uses genesis_parse_attr() Merge array of attributes with defaults, and apply contextual filter on array.
 *
 * @param  string $context    The context, to build filter name.
 * @param  array  $attributes Optional. Extra attributes to merge with defaults.
 *
 * @return string String of HTML attributes and values.
 */
function genesis_attr($context, $attributes = array())
{
    $attributes = genesis_parse_attr($context, $attributes);
    $output = '';
    //* Cycle through attributes, build tag attribute string
    foreach ($attributes as $key => $value) {
        if (!$value) {
            continue;
        }
        $output .= sprintf('%s="%s" ', esc_html($key), esc_attr($value));
    }
    $output = apply_filters('genesis_attr_' . $context . '_output', $output, $attributes, $context);
    return trim($output);
}
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @global WP_Query $wp_query               Query object.
  * @global array    $_genesis_displayed_ids Array of displayed post IDs.
  * @global $integer $more
  *
  * @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);
     echo $args['before_widget'];
     //* Set up the author bio
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['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'], 'ignore_sticky_posts' => $instance['exclude_sticky']);
     //* Exclude displayed IDs from this loop?
     if ($instance['exclude_displayed']) {
         $query_args['post__not_in'] = (array) $_genesis_displayed_ids;
     }
     $wp_query = new WP_Query($query_args);
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             $_genesis_displayed_ids[] = get_the_ID();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget', array('alt' => get_the_title()))));
             if ($instance['show_image'] && $image) {
                 $role = empty($instance['show_title']) ? '' : 'aria-hidden="true"';
                 printf('<a href="%s" class="%s" %s>%s</a>', get_permalink(), esc_attr($instance['image_alignment']), $role, $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 genesis_html5() ? '<header class="entry-header">' : '';
             }
             if (!empty($instance['show_title'])) {
                 $title = get_the_title() ? get_the_title() : __('(no title)', 'genesis');
                 /**
                  * Filter the featured post widget title.
                  *
                  * @since  2.2.0
                  *
                  * @param string $title    Featured post title.
                  * @param array  $instance {
                  *     Widget settings for this instance.
                  *
                  *     @type string $title                   Widget title.
                  *     @type int    $posts_cat               ID of the post category.
                  *     @type int    $posts_num               Number of posts to show.
                  *     @type int    $posts_offset            Number of posts to skip when
                  *                                           retrieving.
                  *     @type string $orderby                 Field to order posts by.
                  *     @type string $order                   ASC fr ascending order, DESC for
                  *                                           descending order of posts.
                  *     @type bool   $exclude_displayed       True if posts shown in main output
                  *                                           should be excluded from this widget
                  *                                           output.
                  *     @type bool   $show_image              True if featured image should be
                  *                                           shown, false otherwise.
                  *     @type string $image_alignment         Image alignment: alignnone,
                  *                                           alignleft, aligncenter or alignright.
                  *     @type string $image_size              Name of the image size.
                  *     @type bool   $show_gravatar           True if author avatar should be
                  *                                           shown, false otherwise.
                  *     @type string $gravatar_alignment      Author avatar alignment: alignnone,
                  *                                           alignleft or aligncenter.
                  *     @type int    $gravatar_size           Dimension of the author avatar.
                  *     @type bool   $show_title              True if featured page title should
                  *                                           be shown, false otherwise.
                  *     @type bool   $show_byline             True if post info should be shown,
                  *                                           false otherwise.
                  *     @type string $post_info               Post info contents to show.
                  *     @type bool   $show_content            True if featured page content
                  *                                           should be shown, false otherwise.
                  *     @type int    $content_limit           Amount of content to show, in
                  *                                           characters.
                  *     @type int    $more_text               Text to use for More link.
                  *     @type int    $extra_num               Number of extra post titles to show.
                  *     @type string $extra_title             Heading for extra posts.
                  *     @type bool   $more_from_category      True if showing category archive
                  *                                           link, false otherwise.
                  *     @type string $more_from_category_text Category archive link text.
                  * }
                  * @param array  $args     {
                  *     Widget display arguments.
                  *
                  *     @type string $before_widget Markup or content to display before the widget.
                  *     @type string $before_title  Markup or content to display before the widget title.
                  *     @type string $after_title   Markup or content to display after the widget title.
                  *     @type string $after_widget  Markup or content to display after the widget.
                  * }
                  */
                 $title = apply_filters('genesis_featured_post_title', $title, $instance, $args);
                 $heading = genesis_a11y('headings') ? 'h4' : 'h2';
                 if (genesis_html5()) {
                     printf('<%s class="entry-title"><a href="%s">%s</a></%s>', $heading, get_permalink(), $title, $heading);
                 } else {
                     printf('<%s><a href="%s">%s</a></%s>', $heading, get_permalink(), $title, $heading);
                 }
             }
             if (!empty($instance['show_byline']) && !empty($instance['post_info'])) {
                 printf(genesis_html5() ? '<p class="entry-meta">%s</p>' : '<p class="byline post-info">%s</p>', do_shortcode($instance['post_info']));
             }
             if ($instance['show_title']) {
                 echo genesis_html5() ? '</header>' : '';
             }
             if (!empty($instance['show_content'])) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 if ('excerpt' == $instance['show_content']) {
                     the_excerpt();
                 } elseif ('content-limit' == $instance['show_content']) {
                     the_content_limit((int) $instance['content_limit'], genesis_a11y_more_link(esc_html($instance['more_text'])));
                 } else {
                     global $more;
                     $orig_more = $more;
                     $more = 0;
                     the_content(genesis_a11y_more_link(esc_html($instance['more_text'])));
                     $more = $orig_more;
                 }
                 echo genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     //* Restore original query
     wp_reset_query();
     //* The EXTRA Posts (list)
     if (!empty($instance['extra_num'])) {
         if (!empty($instance['extra_title'])) {
             echo $args['before_title'] . esc_html($instance['extra_title']) . $args['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();
                 $_genesis_displayed_ids[] = get_the_ID();
                 $listitems .= sprintf('<li><a href="%s">%s</a></li>', get_permalink(), 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 $args['after_widget'];
 }
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @global WP_Query $wp_query Query object.
  * @global integer  $more
  *
  * @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;
     //* Merge with defaults
     $instance = wp_parse_args((array) $instance, $this->defaults);
     echo $args['before_widget'];
     //* Set up the author bio
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title'];
     }
     $wp_query = new WP_Query(array('page_id' => $instance['page_id'], 'posts_per_page' => 1, 'post__not_in' => get_option('sticky_posts')));
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $post_id = null;
             // default for genesis_get_image
             if ($instance['page_id'] === $instance['postspage']) {
                 $post_id = $instance['postspage'];
                 // override for blog page
             }
             $image = genesis_get_image(array('post_id' => $post_id, 'format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-page-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             if ($instance['show_image'] && $image) {
                 $image_link = get_permalink();
                 $image_title = the_title_attribute('echo=0');
                 if ($instance['page_id'] === $instance['postspage']) {
                     $image_link = $instance['postspagelink'];
                     $image_title = the_title_attribute(array('echo' => 0, 'post' => $instance['postspage']));
                 }
                 printf('<a href="%s" title="%s" class="%s">%s</a>', $image_link, $image_title, esc_attr($instance['image_alignment']), $image);
             }
             $postspagecontent = get_post(get_option('page_for_posts'))->post_content;
             if (!empty($instance['show_title'])) {
                 $title = get_the_title() ? get_the_title() : __('(no title)', 'genesis-featured-page-static-widget');
                 $post_link = get_permalink();
                 if ($instance['page_id'] === $instance['postspage'] && !empty($postspagecontent)) {
                     $title = get_the_title($instance['postspage']) ? get_the_title($instance['postspage']) : __('(no title)', 'genesis-featured-page-static-widget');
                     $post_link = $instance['postspagelink'];
                 }
                 if (genesis_html5()) {
                     printf('<header class="entry-header"><h2 class="entry-title"><a href="%s">%s</a></h2></header>', esc_url($post_link), esc_html($title));
                 } else {
                     printf('<h2><a href="%s">%s</a></h2>', esc_url($post_link), esc_html($title));
                 }
             }
             if (!empty($instance['show_content'])) {
                 echo genesis_html5() ? '<div class="entry-content">' : '';
                 if (empty($instance['content_limit'])) {
                     global $more;
                     $orig_more = $more;
                     $more = 0;
                     if ($instance['page_id'] === $instance['postspage'] && !empty($postspagecontent)) {
                         echo $postspagecontent;
                     } else {
                         the_content($instance['more_text']);
                     }
                     $more = $orig_more;
                 } else {
                     if ($instance['page_id'] === $instance['postspage'] && !empty($postspagecontent)) {
                         $this->get_the_home_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
                     } else {
                         the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
                     }
                 }
                 echo genesis_html5() ? '</div>' : '';
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     //* Restore original query
     wp_reset_query();
     echo $args['after_widget'];
 }