Editor: Fix loading of assets in blocks in child themes where the directory name starts with the parent theme's directory name. Example: twentyseventeen and twentyseventeen-child.

Props: lgladdy, masteradhoc, audrasjb, rajinsharwar, azaozz.
Fixes: #59018.



git-svn-id: https://develop.svn.wordpress.org/trunk@56527 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2023-09-06 21:22:28 +00:00
parent d67d8d6e94
commit 476db82c2f
2 changed files with 34 additions and 4 deletions

View File

@@ -270,6 +270,21 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
$result = register_block_script_handle( $metadata, 'script' );
$this->assertSame( 'unit-tests-test-block-script', $result );
// Test the behavior directly within the unit test
$this->assertFalse(
strpos(
wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $metadata['script'] ) ),
trailingslashit( wp_normalize_path( get_template_directory() ) )
) === 0
);
$this->assertFalse(
strpos(
wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $metadata['script'] ) ),
trailingslashit( wp_normalize_path( get_stylesheet_directory() ) )
) === 0
);
}
/**
@@ -438,6 +453,21 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block.css' ) ),
wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-style', 'path' ) )
);
// Test the behavior directly within the unit test
$this->assertFalse(
strpos(
wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $metadata['style'] ) ),
trailingslashit( wp_normalize_path( get_template_directory() ) )
) === 0
);
$this->assertFalse(
strpos(
wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $metadata['style'] ) ),
trailingslashit( wp_normalize_path( get_stylesheet_directory() ) )
) === 0
);
}
/**