Changeset 52338
- Timestamp:
- 12/07/2021 05:44:46 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class.wp-dependencies.php
r51851 r52338 94 94 */ 95 95 private $all_queued_deps; 96 97 /** 98 * List of assets enqueued before details were registered. 99 * 100 * @since 5.9.0 101 * 102 * @var array 103 */ 104 private $queued_before_register = array(); 96 105 97 106 /** … … 249 258 } 250 259 $this->registered[ $handle ] = new _WP_Dependency( $handle, $src, $deps, $ver, $args ); 260 261 // If the item was enqueued before the details were registered, enqueue it now. 262 if ( array_key_exists( $handle, $this->queued_before_register ) ) { 263 if ( ! is_null( $this->queued_before_register[ $handle ] ) ) { 264 $this->enqueue( $handle . '?' . $this->queued_before_register[ $handle ] ); 265 } else { 266 $this->enqueue( $handle ); 267 } 268 269 unset( $this->queued_before_register[ $handle ] ); 270 } 271 251 272 return true; 252 273 } … … 335 356 $this->args[ $handle[0] ] = $handle[1]; 336 357 } 358 } else if ( ! isset( $this->registered[ $handle[0] ] ) ) { 359 $this->queued_before_register[ $handle[0] ] = null; // $args 360 361 if ( isset( $handle[1] ) ) { 362 $this->queued_before_register[ $handle[0] ] = $handle[1]; 363 } 337 364 } 338 365 } … … 361 388 unset( $this->queue[ $key ] ); 362 389 unset( $this->args[ $handle[0] ] ); 390 } else if ( array_key_exists( $handle[0], $this->queued_before_register ) ) { 391 unset( $this->queued_before_register[ $handle[0] ] ); 363 392 } 364 393 } -
trunk/tests/phpunit/tests/dependencies.php
r52010 r52338 137 137 138 138 } 139 140 function test_enqueue_before_register() { 141 $dep = new WP_Dependencies; 142 143 $this->assertArrayNotHasKey( 'one', $dep->registered ); 144 145 $dep->enqueue( 'one' ); 146 147 $this->assertNotContains( 'one', $dep->queue ); 148 149 $this->assertTrue( $dep->add( 'one', '' ) ); 150 151 $this->assertContains( 'one', $dep->queue ); 152 } 139 153 }
Note: See TracChangeset
for help on using the changeset viewer.