Skip to content

Commit

Permalink
Pull in module_deps handling from WordPress/wordpress-develop#8024
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Dec 20, 2024
1 parent 736b800 commit 4cf9dd0
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,28 @@ function gutenberg_override_script( $scripts, $handle, $src, $deps = array(), $v

// See: `_WP_Dependency::__construct` .
$script->src = $src;
$script->deps = $deps;
$script->ver = $ver;
$script->args = $in_footer ? 1 : null;

$module_deps = array();
$script_deps = array();
if ( array() !== $deps ) {
foreach ( $deps as $dep ) {
if ( is_string( $dep ) ) {
$script_deps[] = $dep;
} elseif (
isset( $dep['type'], $dep['id'] ) &&
'module' === $dep['type'] &&
is_string( $dep['id'] )
) {
$module_deps[] = $dep['id'];
}
}
}
$script->deps = $script_deps;
if ( array() !== $module_deps ) {
$scripts->add_data( $handle, 'module_deps', $module_deps );
}
} else {
$scripts->add( $handle, $src, $deps, $ver, ( $in_footer ? 1 : null ) );
}
Expand Down

0 comments on commit 4cf9dd0

Please sign in to comment.