Changeset 55703 for trunk/src/wp-includes/blocks.php
- Timestamp:
- 05/02/2023 03:43:03 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r55673 r55703 18 18 function remove_block_asset_path_prefix( $asset_handle_or_path ) { 19 19 $path_prefix = 'file:'; 20 if ( 0 !== strpos( $asset_handle_or_path, $path_prefix ) ) {20 if ( ! str_starts_with( $asset_handle_or_path, $path_prefix ) ) { 21 21 return $asset_handle_or_path; 22 22 } … … 25 25 strlen( $path_prefix ) 26 26 ); 27 if ( str pos( $path, './' ) === 0) {27 if ( str_starts_with( $path, './' ) ) { 28 28 $path = substr( $path, 2 ); 29 29 } … … 45 45 */ 46 46 function generate_block_asset_handle( $block_name, $field_name, $index = 0 ) { 47 if ( 0 === strpos( $block_name, 'core/' ) ) {47 if ( str_starts_with( $block_name, 'core/' ) ) { 48 48 $asset_handle = str_replace( 'core/', 'wp-block-', $block_name ); 49 if ( 0 === strpos( $field_name, 'editor' ) ) {49 if ( str_starts_with( $field_name, 'editor' ) ) { 50 50 $asset_handle .= '-editor'; 51 51 } 52 if ( 0 === strpos( $field_name, 'view' ) ) {52 if ( str_starts_with( $field_name, 'view' ) ) { 53 53 $asset_handle .= '-view'; 54 54 } … … 138 138 $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ); 139 139 140 $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );141 $is_theme_block = 0 === strpos( $script_path_norm, $theme_path_norm );140 $is_core_block = isset( $metadata['file'] ) && str_starts_with( $metadata['file'], $wpinc_path_norm ); 141 $is_theme_block = str_starts_with( $script_path_norm, $theme_path_norm ); 142 142 143 143 $script_uri = plugins_url( $script_path, $metadata['file'] ); … … 192 192 } 193 193 194 $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );194 $is_core_block = isset( $metadata['file'] ) && str_starts_with( $metadata['file'], $wpinc_path_norm ); 195 195 // Skip registering individual styles for each core block when a bundled version provided. 196 196 if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { … … 360 360 361 361 // Add `style` and `editor_style` for core blocks if missing. 362 if ( ! empty( $metadata['name'] ) && 0 === strpos( $metadata['name'], 'core/' ) ) {362 if ( ! empty( $metadata['name'] ) && str_starts_with( $metadata['name'], 'core/' ) ) { 363 363 $block_name = str_replace( 'core/', '', $metadata['name'] ); 364 364 … … 699 699 */ 700 700 function strip_core_block_namespace( $block_name = null ) { 701 if ( is_string( $block_name ) && 0 === strpos( $block_name, 'core/' ) ) {701 if ( is_string( $block_name ) && str_starts_with( $block_name, 'core/' ) ) { 702 702 return substr( $block_name, 5 ); 703 703 }
Note: See TracChangeset
for help on using the changeset viewer.