@@ -43,7 +43,7 @@ function block_core_gallery_data_id_backcompatibility( $parsed_block ) {
4343 * @param string $content Content of the block being rendered.
4444 * @return string The content of the block being rendered.
4545 */
46- function block_core_gallery_render ( $ attributes , $ content, $ block ) {
46+ function block_core_gallery_render ( $ attributes , $ content ) {
4747 // Adds a style tag for the --wp--style--unstable-gallery-gap var.
4848 // The Gallery block needs to recalculate Image block width based on
4949 // the current gap setting in order to maintain the number of flex columns
@@ -121,34 +121,8 @@ function block_core_gallery_render( $attributes, $content, $block ) {
121121 )
122122 );
123123
124- $ lightbox_settings = block_core_image_get_lightbox_settings ( $ block ->parsed_block );
125-
126- if (
127- isset ( $ lightbox_settings ) &&
128- // 'none' === $link_destination &&
129- isset ( $ lightbox_settings ['enabled ' ] ) &&
130- true === $ lightbox_settings ['enabled ' ]
131- ) {
132- $ processed_content ->set_attribute ( 'data-wp-interactive ' , 'core/gallery ' );
133- $ processed_content ->set_attribute ( 'data-wp-context ' , '{"lightbox": true, "images": []} ' );
134- $ processed_content ->set_attribute ( 'data-wp-init ' , 'callbacks.init ' );
135- $ processed_content ->set_attribute ( 'data-wp-on-async--load ' , 'callbacks.init ' );
136-
137- $ suffix = wp_scripts_get_suffix ();
138- if ( defined ( 'IS_GUTENBERG_PLUGIN ' ) && IS_GUTENBERG_PLUGIN ) {
139- $ module_url = gutenberg_url ( '/build/interactivity/gallery.min.js ' );
140- }
141-
142- wp_register_script_module (
143- '@wordpress/block-library/gallery ' ,
144- isset ( $ module_url ) ? $ module_url : includes_url ( "blocks/gallery/view {$ suffix }.js " ),
145- array ( '@wordpress/interactivity ' ),
146- defined ( 'GUTENBERG_VERSION ' ) ? GUTENBERG_VERSION : get_bloginfo ( 'version ' )
147- );
148-
149- wp_enqueue_script_module ( '@wordpress/block-library/gallery ' );
150-
151- }
124+ $ processed_content ->set_attribute ( 'data-wp-interactive ' , 'core/gallery ' );
125+ $ processed_content ->set_attribute ( 'data-wp-context ' , '{"lightbox": true, "images": []} ' );
152126
153127 // The WP_HTML_Tag_Processor class calls get_updated_html() internally
154128 // when the instance is treated as a string, but here we explicitly
@@ -196,32 +170,6 @@ static function () use ( $image_blocks, &$i ) {
196170 return $ content ;
197171}
198172
199- // NOTE: this setting isn't required for the gallery block.
200- // since lightbox implementation is done in the image block, it can totally be removed.
201- function block_core_gallery_get_lightbox_settings ( $ block ) {
202- // Gets the lightbox setting from the block attributes.
203- if ( isset ( $ block ['attrs ' ]['lightbox ' ] ) ) {
204- $ lightbox_settings = $ block ['attrs ' ]['lightbox ' ];
205- }
206-
207- if ( ! isset ( $ lightbox_settings ) ) {
208- // TODO: change it to gallery block name.
209- $ lightbox_settings = wp_get_global_settings ( array ( 'lightbox ' ), array ( 'block_name ' => 'core/image ' ) );
210-
211- // If not present in global settings, check the top-level global settings.
212- //
213- // NOTE: If no block-level settings are found, the previous call to
214- // `wp_get_global_settings` will return the whole `theme.json` structure in
215- // which case we can check if the "lightbox" key is present at the top-level
216- // of the global settings and use its value.
217- if ( isset ( $ lightbox_settings ['lightbox ' ] ) ) {
218- $ lightbox_settings = wp_get_global_settings ( array ( 'lightbox ' ) );
219- }
220- }
221-
222- return $ lightbox_settings ?? null ;
223- }
224-
225173/**
226174 * Registers the `core/gallery` block on server.
227175 *
0 commit comments