You appear to be a bot. Output may be restricted
Description
Echo the widget content.
Usage
Genesis_Featured_Post::widget( $args, $instance );
Parameters
- $args
- ( array ) required – Display arguments including `before_title`, `after_title`, `before_widget`, and `after_widget`.
- $instance
- ( array ) required – The settings for the particular instance of the widget.
Returns
void
Source
File name: genesis/lib/widgets/featured-post-widget.php
Lines:
1 to 100 of 296
public function widget( $args, $instance ) { global $wp_query, $_genesis_displayed_ids; // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $args['before_widget']; if ( ! empty( $instance['title'] ) ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title']; } $query_args = [ '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 ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Reset later. if ( have_posts() ) { while ( have_posts() ) { the_post(); $_genesis_displayed_ids[] = get_the_ID(); genesis_markup( [ 'open' => '<article %s>', 'context' => 'entry', 'params' => [ 'is_widget' => true, ], ] ); $image = genesis_get_image( [ 'format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr( 'entry-image-widget', [] ), ] ); if ( $image && $instance['show_image'] ) { $role = empty( $instance['show_title'] ) ? '' : ' aria-hidden="true" tabindex="-1"'; printf( '<a href="%s" class="%s"%s>%s</a>', esc_url( get_permalink() ), esc_attr( $instance['image_alignment'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping breaks output here $role, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping breaks output here $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'] || $instance['show_byline'] ) { $header = ''; if ( ! empty( $instance['show_title'] ) ) { $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.