Code Quality: Fix reported undefined $script_uri variable notice

The code editor reported this issue while mamduka was browsing the blocks.php file. PHP considers variables undefined until a value is assigned (or the global keyword is used).

Follow-up for [53091].
Props mamaduka, peterwilsoncc.
See 55567.



git-svn-id: https://develop.svn.wordpress.org/trunk@53211 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski
2022-04-19 09:56:02 +00:00
parent e8df37e341
commit 87dc304715

View File

@@ -113,13 +113,11 @@ function register_block_script_handle( $metadata, $field_name ) {
$is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );
$is_theme_block = 0 === strpos( $script_path_norm, $theme_path_norm );
$script_uri;
$script_uri = plugins_url( $script_path, $metadata['file'] );
if ( $is_core_block ) {
$script_uri = includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) );
} elseif ( $is_theme_block ) {
$script_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $script_path_norm ) );
} else {
$script_uri = plugins_url( $script_path, $metadata['file'] );
}
$script_asset = require $script_asset_path;