diff --git a/projects/plugins/jetpack/changelog/fix-carousel-lightbox-disable b/projects/plugins/jetpack/changelog/fix-carousel-lightbox-disable new file mode 100644 index 0000000000000..c874fe587656a --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-carousel-lightbox-disable @@ -0,0 +1,4 @@ +Significance: patch +Type: compat + +Carousel: disable WordPress' lightbox option when Jetpack's Carousel feature is activated. diff --git a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php index b486d3e99f19b..cac86b3a6d466 100644 --- a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php +++ b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php @@ -83,6 +83,9 @@ public function init() { $this->single_image_gallery_enabled = ! $this->maybe_disable_jp_carousel_single_images(); $this->single_image_gallery_enabled_media_file = $this->maybe_enable_jp_carousel_single_images_media_file(); + // Disable core lightbox when Carousel is enabled. + add_action( 'wp_theme_json_data_theme', array( $this, 'disable_core_lightbox' ) ); + if ( is_admin() ) { // Register the Carousel-related related settings. add_action( 'admin_init', array( $this, 'register_settings' ), 5 ); @@ -206,6 +209,32 @@ public function maybe_enable_jp_carousel_single_images_media_file() { return apply_filters( 'jp_carousel_load_for_images_linked_to_file', false ); } + /** + * Disable the "Lightbox" option offered in WordPress core + * whenever Jetpack's Carousel feature is enabled. + * + * @since $$next-version$$ + * + * @param WP_Theme_JSON_Data $theme_json Class to access and update theme.json data. + */ + public function disable_core_lightbox( $theme_json ) { + return $theme_json->update_with( + array( + 'version' => 2, + 'settings' => array( + 'blocks' => array( + 'core/image' => array( + 'lightbox' => array( + 'allowEditing' => false, + 'enabled' => false, + ), + ), + ), + ), + ) + ); + } + /** * Returns the value of the applied jp_carousel_asset_version filter *