diff --git a/includes/embeds/class-amp-gallery-embed.php b/includes/embeds/class-amp-gallery-embed.php index c4b72ccef1a..86ae86909ef 100644 --- a/includes/embeds/class-amp-gallery-embed.php +++ b/includes/embeds/class-amp-gallery-embed.php @@ -171,14 +171,20 @@ public function maybe_override_gallery( $html, $attributes ) { return $attr; }; + $set_link_attribute = static function ( $attributes ) { + $attributes['link'] = 'none'; + return $attributes; + }; + remove_filter( 'post_gallery', [ $this, 'maybe_override_gallery' ], 10 ); add_filter( 'wp_get_attachment_image_attributes', $add_lightbox_attribute ); + add_filter( 'shortcode_atts_gallery', $set_link_attribute, PHP_INT_MAX ); - $attributes['link'] = 'none'; - $html = gallery_shortcode( $attributes ); + $html = gallery_shortcode( $attributes ); remove_filter( 'wp_get_attachment_image_attributes', $add_lightbox_attribute ); add_filter( 'post_gallery', [ $this, 'maybe_override_gallery' ], 10, 2 ); + remove_filter( 'shortcode_atts_gallery', $set_link_attribute, PHP_INT_MAX ); } return $html;