diff --git a/modules/blocks.php b/modules/blocks.php index 2d1932733e7e8..df3dddcd556df 100644 --- a/modules/blocks.php +++ b/modules/blocks.php @@ -15,6 +15,38 @@ jetpack_register_block( 'vr' ); +/** + * Tiled Gallery block. Depends on the Photon module. + * + * @since 6.9.0 +*/ +if ( class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) { + jetpack_register_block( + 'tiled-gallery', + array( + 'render_callback' => 'jetpack_tiled_gallery_load_block_assets', + ) + ); + + /** + * Tiled gallery block registration/dependency declaration. + * + * @param array $attr - Array containing the block attributes. + * @param string $content - String containing the block content. + * + * @return string + */ + function jetpack_tiled_gallery_load_block_assets( $attr, $content ) { + $dependencies = array( + 'lodash', + 'wp-i18n', + 'wp-token-list', + ); + Jetpack_Gutenberg::load_assets_as_required( 'tiled-gallery', $dependencies ); + return $content; + } +} + /** * Map block registration/dependency declaration. * diff --git a/modules/tiled-gallery/tiled-gallery.php b/modules/tiled-gallery/tiled-gallery.php index b93854addca02..479eadc26ee95 100644 --- a/modules/tiled-gallery/tiled-gallery.php +++ b/modules/tiled-gallery/tiled-gallery.php @@ -16,31 +16,6 @@ public function __construct() { add_action( 'admin_init', array( $this, 'settings_api_init' ) ); add_filter( 'jetpack_gallery_types', array( $this, 'jetpack_gallery_types' ), 9 ); add_filter( 'jetpack_default_gallery_type', array( $this, 'jetpack_default_gallery_type' ) ); - - jetpack_register_block( - 'tiled-gallery', - array( - 'render_callback' => array( $this, 'load_block_assets' ), - ) - ); - } - - /** - * Tiled gallery block registration/dependency declaration. - * - * @param array $attr - Array containing the block attributes. - * @param string $content - String containing the block content. - * - * @return string - */ - public function load_block_assets( $attr, $content ) { - $dependencies = array( - 'lodash', - 'wp-i18n', - 'wp-token-list', - ); - Jetpack_Gutenberg::load_assets_as_required( 'tiled-gallery', $dependencies ); - return $content; } public function tiles_enabled() {