diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php
index 0f34aac1df..f6e6764343 100644
a
|
b
|
function register_block_script_handle( $metadata, $field_name ) { |
106 | 106 | $wpinc_path_norm = wp_normalize_path( ABSPATH . WPINC ); |
107 | 107 | $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ); |
108 | 108 | $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); |
| 109 | $is_plugin_block = isset( $metadata['file'] ) && strpos( $metadata['file'], 'wp-content/plugins' ); |
| 110 | $is_theme_block = isset( $metadata['file'] ) && strpos( $metadata['file'], 'wp-content/themes' ); |
| 111 | $script_uri = false; |
| 112 | |
| 113 | if ( false !== $is_plugin_block ) { |
| 114 | $script_uri = plugins_url( $script_path, $metadata['file'] ); |
| 115 | } |
| 116 | |
| 117 | if ( false !== $is_theme_block ) { |
| 118 | $theme_pos = strpos( $metadata['file'], '/themes' ); |
| 119 | $theme_block_path = substr( $metadata['file'], $theme_pos ); |
| 120 | $theme_script_path = dirname( $theme_block_path ) . '/' . $script_path; |
| 121 | $script_uri = content_url( $theme_script_path ); |
| 122 | } |
| 123 | |
| 124 | if ( $is_core_block ) { |
| 125 | $script_uri = includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) ); |
| 126 | } |
109 | 127 | |
110 | | $script_uri = $is_core_block ? |
111 | | includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) ) : |
112 | | plugins_url( $script_path, $metadata['file'] ); |
113 | 128 | $script_asset = require $script_asset_path; |
114 | 129 | $script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array(); |
115 | 130 | $result = wp_register_script( |
… |
… |
function register_block_style_handle( $metadata, $field_name ) { |
147 | 162 | } |
148 | 163 | $wpinc_path_norm = wp_normalize_path( ABSPATH . WPINC ); |
149 | 164 | $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); |
| 165 | $is_plugin_block = isset( $metadata['file'] ) && strpos( $metadata['file'], 'wp-content/plugins' ); |
| 166 | $is_theme_block = isset( $metadata['file'] ) && strpos( $metadata['file'], 'wp-content/themes' ); |
| 167 | $style_uri = false; |
| 168 | |
150 | 169 | if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { |
151 | 170 | return false; |
152 | 171 | } |
… |
… |
function register_block_style_handle( $metadata, $field_name ) { |
161 | 180 | return $style_handle; |
162 | 181 | } |
163 | 182 | |
164 | | $style_uri = plugins_url( $style_path, $metadata['file'] ); |
| 183 | if ( false !== $is_plugin_block ) { |
| 184 | $style_uri = plugins_url( $style_path, $metadata['file'] ); |
| 185 | } |
| 186 | |
| 187 | if ( false !== $is_theme_block ) { |
| 188 | $theme_pos = strpos( $metadata['file'], '/themes' ); |
| 189 | $theme_block_path = substr( $metadata['file'], $theme_pos ); |
| 190 | $theme_style_path = dirname( $theme_block_path ) . '/' . $style_path; |
| 191 | $style_uri = content_url( $theme_style_path ); |
| 192 | } |
| 193 | |
165 | 194 | if ( $is_core_block ) { |
166 | 195 | $style_path = "style$suffix.css"; |
167 | 196 | $style_uri = includes_url( 'blocks/' . str_replace( 'core/', '', $metadata['name'] ) . "/style$suffix.css" ); |