Skip to content

Commit

Permalink
Modules API: Fix Interactivity not working on Classic Themes. (#57396)
Browse files Browse the repository at this point in the history
* Move modules scripts to footer on classic themes

* Move only required modules

* Move also the module preloads

* Make preload only for block themes at head

* Revert "Make preload only for block themes at head"

This reverts commit 3edb69f.
  • Loading branch information
cbravobernal committed Dec 27, 2023
1 parent ea2a22e commit 1129dcf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/experimental/modules/class-gutenberg-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,15 @@ function gutenberg_dequeue_module( $module_identifier ) {
Gutenberg_Modules::dequeue( $module_identifier );
}

// Prints the import map in the head tag.
add_action( 'wp_head', array( 'Gutenberg_Modules', 'print_import_map' ) );
$modules_position = wp_is_block_theme() ? 'wp_head' : 'wp_footer';
// Prints the import map in the head tag in block themes. Otherwise in the footer.
add_action( $modules_position, array( 'Gutenberg_Modules', 'print_import_map' ) );

// Prints the enqueued modules in the head tag.
add_action( 'wp_head', array( 'Gutenberg_Modules', 'print_enqueued_modules' ) );
// Prints the enqueued modules in the head tag in block themes. Otherwise in the footer.
add_action( $modules_position, array( 'Gutenberg_Modules', 'print_enqueued_modules' ) );

// Prints the preloaded modules in the head tag.
add_action( 'wp_head', array( 'Gutenberg_Modules', 'print_module_preloads' ) );
// Prints the preloaded modules in the head tag in block themes. Otherwise in the footer.
add_action( $modules_position, array( 'Gutenberg_Modules', 'print_module_preloads' ) );

// Prints the script that loads the import map polyfill in the footer.
add_action( 'wp_footer', array( 'Gutenberg_Modules', 'print_import_map_polyfill' ), 11 );

1 comment on commit 1129dcf

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 1129dcf.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7339213182
📝 Reported issues:

Please sign in to comment.