Changeset 63579
- Timestamp:
- 09/10/2026 10:48:20 AM (23 hours ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/class-wp-scripts.php (modified) (1 diff)
-
tests/phpunit/tests/dependencies/scripts.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-scripts.php
r63440 r63579 528 528 } 529 529 530 $script = (array) $this->get_data( $handle, $position ); 530 $script = $this->get_data( $handle, $position ); 531 $script = false === $script ? array() : (array) $script; 531 532 $script[] = $data; 532 533 -
trunk/tests/phpunit/tests/dependencies/scripts.php
r62957 r63579 228 228 'defer' => array( 'defer' ), 229 229 'async' => array( 'async' ), 230 ); 231 } 232 233 /** 234 * Tests that inline scripts do not include a false entry when no data exists yet. 235 * 236 * @ticket 52320 237 * @dataProvider data_inline_script_positions 238 * 239 * @param string $position Inline script position. 240 */ 241 public function test_add_inline_script_does_not_store_false_for_empty_existing_data( $position ): void { 242 $handle = 'test-inline-script-' . $position; 243 244 wp_register_script( $handle, '/test.js', array(), null ); 245 wp_add_inline_script( $handle, 'console.log( "test" );', $position ); 246 247 $this->assertSame( 248 array( 'console.log( "test" );' ), 249 wp_scripts()->get_data( $handle, $position ) 250 ); 251 } 252 253 /** 254 * Data provider for inline script positions. 255 * 256 * @return array<string, array{0: string}> Inline script positions. 257 */ 258 public function data_inline_script_positions(): array { 259 return array( 260 'before' => array( 'before' ), 261 'after' => array( 'after' ), 230 262 ); 231 263 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)