Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carousel: disable WordPress Core' Lightbox option #36565

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

Carousel: disable WordPress' lightbox option when Jetpack's Carousel feature is activated.
29 changes: 29 additions & 0 deletions projects/plugins/jetpack/modules/carousel/jetpack-carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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
*
Expand Down
Loading