From 87dc30471586c163117c4697e59b0eea27612778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=83=C2=B3=C3=85=E2=80=9Akowski?= Date: Tue, 19 Apr 2022 09:56:02 +0000 Subject: [PATCH] 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 --- src/wp-includes/blocks.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 9d41509cc0..b59e76bcc6 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -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;