Changeset 56527
- Timestamp:
- 09/06/2023 09:22:28 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r56455 r56527 151 151 * the parent (template) or child (stylesheet) directory path. 152 152 */ 153 $is_parent_theme_block = str_starts_with( $script_path_norm, $template_path_norm);154 $is_child_theme_block = str_starts_with( $script_path_norm, $stylesheet_path_norm);153 $is_parent_theme_block = str_starts_with( $script_path_norm, trailingslashit( $template_path_norm ) ); 154 $is_child_theme_block = str_starts_with( $script_path_norm, trailingslashit( $stylesheet_path_norm ) ); 155 155 $is_theme_block = ( $is_parent_theme_block || $is_child_theme_block ); 156 156 … … 271 271 // Determine if the block style was registered in a theme, by checking if the script path starts with either 272 272 // the parent (template) or child (stylesheet) directory path. 273 $is_parent_theme_block = str_starts_with( $style_path_norm, $template_path_norm);274 $is_child_theme_block = str_starts_with( $style_path_norm, $stylesheet_path_norm);273 $is_parent_theme_block = str_starts_with( $style_path_norm, trailingslashit( $template_path_norm ) ); 274 $is_child_theme_block = str_starts_with( $style_path_norm, trailingslashit( $stylesheet_path_norm ) ); 275 275 $is_theme_block = ( $is_parent_theme_block || $is_child_theme_block ); 276 276 -
trunk/tests/phpunit/tests/blocks/register.php
r56421 r56527 271 271 272 272 $this->assertSame( 'unit-tests-test-block-script', $result ); 273 274 // Test the behavior directly within the unit test 275 $this->assertFalse( 276 strpos( 277 wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $metadata['script'] ) ), 278 trailingslashit( wp_normalize_path( get_template_directory() ) ) 279 ) === 0 280 ); 281 282 $this->assertFalse( 283 strpos( 284 wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $metadata['script'] ) ), 285 trailingslashit( wp_normalize_path( get_stylesheet_directory() ) ) 286 ) === 0 287 ); 273 288 } 274 289 … … 438 453 wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block.css' ) ), 439 454 wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-style', 'path' ) ) 455 ); 456 457 // Test the behavior directly within the unit test 458 $this->assertFalse( 459 strpos( 460 wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $metadata['style'] ) ), 461 trailingslashit( wp_normalize_path( get_template_directory() ) ) 462 ) === 0 463 ); 464 465 $this->assertFalse( 466 strpos( 467 wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $metadata['style'] ) ), 468 trailingslashit( wp_normalize_path( get_stylesheet_directory() ) ) 469 ) === 0 440 470 ); 441 471 }
Note: See TracChangeset
for help on using the changeset viewer.