Skip to content

Commit

Permalink
Slideshows: don't attempt to use the block when not available (#38744)
Browse files Browse the repository at this point in the history
* Slideshows: don't attempt to use the block when not available

Fixes #38742

* Load the slideshow block manually if needed.
  • Loading branch information
jeherve authored Aug 19, 2024
1 parent d0fe557 commit 1806b17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

AMP: avoid errors when using Jetpack's classic slideshows on a site where Jetpack blocks are disabled.
13 changes: 12 additions & 1 deletion projects/plugins/jetpack/modules/shortcodes/slideshow.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ public function shortcode_callback( $attr ) {
);
}

if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
) {
// Load the styles and use the rendering method from the Slideshow block.
Jetpack_Gutenberg::load_styles_as_required( 'slideshow' );

Expand All @@ -195,6 +198,14 @@ public function shortcode_callback( $attr ) {
$amp_args['autoplay'] = true;
}

/*
* Blocks can be disabled in Jetpack Settings.
* If that's the case, we need to include the slideshow block manually.
*/
if ( ! class_exists( 'Automattic\Jetpack\Extensions\Slideshow' ) ) {
require_once JETPACK__PLUGIN_DIR . 'extensions/blocks/slideshow/slideshow.php';
}

return Slideshow\render_amp( $amp_args );
}

Expand Down

0 comments on commit 1806b17

Please sign in to comment.