'widget_recent_galleries', 'description' => _x( 'Your site’s most recent galleries.', 'Description of the recent galleries widget', 'bornholm' ) ); parent::__construct( 'recent-galleries', _x( 'Recent Galleries', 'Name of the recent galleries widget', 'bornholm' ), $widget_ops ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 2; if ( ! $number ) { $number = 2; } /** * Filter the arguments for the Recent Galleries widget * * @see WP_Query::get_posts() * * @param array $args An array of arguments used to retrieve the recent posts. */ $result = new WP_Query( apply_filters( 'widget_galleries_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => 'post-format-gallery' ) ) ) ) ); if ( $result->have_posts() ) { echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } while ( $result->have_posts() ) { $result->the_post(); $post = get_post( get_the_ID() ); $images = bornholm_get_gallery_images( $post->ID ); if ( $images ) { $hide_gallery_titles_on_recent_galleries_widget = get_theme_mod( 'hide_gallery_titles_on_recent_galleries_widget' ); ?>