diff --git a/src/wp-includes/widgets/class-wp-widget-media-gallery.php b/src/wp-includes/widgets/class-wp-widget-media-gallery.php index 9f76bc87106f1..f7167792740f5 100644 --- a/src/wp-includes/widgets/class-wp-widget-media-gallery.php +++ b/src/wp-includes/widgets/class-wp-widget-media-gallery.php @@ -245,17 +245,17 @@ public function render_control_template_scripts() { * @return bool Whether widget has content. */ protected function has_content( $instance ) { - if ( ! empty( $instance['ids'] ) ) { - $attachments = wp_parse_id_list( $instance['ids'] ); - // Prime attachment post caches. - _prime_post_caches( $attachments, false, false ); - foreach ( $attachments as $attachment ) { - if ( 'attachment' !== get_post_type( $attachment ) ) { - return false; - } - } - return true; + if ( empty( $instance['ids'] ) ) { + return false; } - return false; + + $attachments = wp_parse_id_list( $instance['ids'] ); + // Prime attachment post caches. + _prime_post_caches( $attachments, false, false ); + + return array_all( + $attachments, + fn( $attachment ) => 'attachment' === get_post_type( $attachment ) + ); } }