Changeset 64681
- Timestamp:
- 10/22/2026 08:29:24 PM (4 hours ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/widgets.php (modified) (1 diff)
-
tests/phpunit/tests/widgets.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/widgets.php
r64163 r64681 703 703 } else { 704 704 $index = sanitize_title( $index ); 705 foreach ( (array) $wp_registered_sidebars as $key => $value ) { 706 if ( sanitize_title( $value['name'] ) === $index ) { 707 $index = $key; 708 break; 705 706 if ( empty( $wp_registered_sidebars[ $index ] ) ) { 707 foreach ( (array) $wp_registered_sidebars as $key => $value ) { 708 if ( sanitize_title( $value['name'] ) === $index ) { 709 $index = $key; 710 break; 711 } 709 712 } 710 713 } -
trunk/tests/phpunit/tests/widgets.php
r64038 r64681 407 407 408 408 $this->assertSame( $sidebar_id, $this->sidebar_index ); 409 } 410 411 /** 412 * @group sidebar 413 * @ticket 22116 414 */ 415 public function test_dynamic_sidebar_id_takes_priority_over_sanitized_name() { 416 // Register a sidebar with the name 'Widget Area 121' (sanitizes to 'widget-area-121'). 417 register_sidebar( 418 array( 419 'id' => 'widget-area-127', 420 'name' => 'Widget Area 121', 421 ) 422 ); 423 424 /* 425 * Register a second sidebar whose ID is 'widget-area-121' — 426 * the same as the sanitized name of the first sidebar. 427 */ 428 register_sidebar( 429 array( 430 'id' => 'widget-area-121', 431 'name' => 'Widget Area 121', 432 ) 433 ); 434 435 add_action( 'dynamic_sidebar_before', array( $this, 'retrieve_sidebar_id' ), 10, 2 ); 436 437 /* 438 * Passing 'widget-area-121' as an exact ID should resolve to that sidebar directly, 439 * not to 'widget-area-127' whose sanitized name also equals 'widget-area-121'. 440 */ 441 dynamic_sidebar( 'widget-area-121' ); 442 443 $this->assertSame( 'widget-area-121', $this->sidebar_index ); 409 444 } 410 445
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)