Skip to content
Merged
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
10 changes: 10 additions & 0 deletions packages/wp-build/templates/module-registration.php.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
* Register all script modules.
*/
function {{PREFIX}}_register_script_modules() {
// Ensure this only runs once. wp_default_scripts can fire multiple times,
// and each wp_deregister_script_module() call also dequeues the module.
// If a module was enqueued between calls, repeated deregister/register
// cycles would lose the enqueue state.
static $already_registered = false;
if ( $already_registered ) {
return;
}
$already_registered = true;

// Load build constants
$build_constants = require __DIR__ . '/constants.php';
$modules_dir = __DIR__ . '/modules';
Expand Down
Loading