Changeset 60062
- Timestamp:
- 03/21/2025 01:54:38 PM (4 weeks ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r59966 r60062 1119 1119 ); 1120 1120 } else { 1121 $aria_current = is_front_page() && ! is_paged() ? ' aria-current="page"' : '';1121 $aria_current = ! is_paged() && ( is_front_page() || is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) ? ' aria-current="page"' : ''; 1122 1122 1123 1123 $html = sprintf( -
trunk/tests/phpunit/tests/general/template.php
r56635 r60062 18 18 public $custom_logo_id; 19 19 public $custom_logo_url; 20 21 /** 22 * Blog page used by aria tests. 23 * 24 * @var int 25 */ 26 public static $blog_page_id; 27 28 /** 29 * Home page used by aria tests. 30 * 31 * @var int 32 */ 33 public static $home_page_id; 20 34 21 35 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { … … 34 48 */ 35 49 add_theme_support( 'custom-logo' ); 50 51 self::$blog_page_id = self::factory()->post->create( 52 array( 53 'post_type' => 'page', 54 'post_title' => 'Blog', 55 'page_name' => 'blog', 56 ) 57 ); 58 59 self::$home_page_id = self::factory()->post->create( 60 array( 61 'post_type' => 'page', 62 'post_title' => 'Home', 63 'page_name' => 'home', 64 ) 65 ); 36 66 } 37 67 … … 524 554 525 555 /** 556 * Test the aria attribute for the custom logo on the front page set to the blog. 557 * 558 * @ticket 62879 559 * 560 * @covers ::get_custom_logo 561 * 562 * @dataProvider data_get_custom_logo_aria_current_attribute_blog_front_page 563 * 564 * @param string $url The URL to visit. 565 * @param bool $attribute_expected Whether the aria-current attribute is expected. 566 */ 567 public function test_get_custom_logo_aria_current_attribute_blog_front_page( $url, $attribute_expected ) { 568 // Set the custom logo. 569 $this->set_custom_logo(); 570 $this->go_to( $url ); 571 572 $this->assertNotEmpty( get_custom_logo(), 'Custom logo is expected to be set' ); 573 574 if ( $attribute_expected ) { 575 $this->assertStringContainsString( 'aria-current="page"', get_custom_logo(), 'Custom logo is expected to contain aria-current attribute' ); 576 } else { 577 $this->assertStringNotContainsString( 'aria-current="page"', get_custom_logo(), 'Custom logo is expected to contain aria-current attribute' ); 578 } 579 } 580 581 /** 582 * Data provider for the test_get_custom_logo_aria_current_attribute_blog_front_page. 583 * 584 * @return array[] 585 */ 586 public function data_get_custom_logo_aria_current_attribute_blog_front_page() { 587 return array( 588 'Front page' => array( home_url(), true ), 589 'Blog post' => array( home_url( '/?p=1' ), false ), 590 'Sample page' => array( home_url( '/?page_id=2' ), false ), 591 ); 592 } 593 594 /** 595 * Test the aria attribute for the custom logo on the front page set to the blog. 596 * 597 * @ticket 62879 598 * 599 * @covers ::get_custom_logo 600 * 601 * @dataProvider data_get_custom_logo_aria_current_attribute_blog_set_to_page_without_front_page_defined 602 * @param string $url The URL to visit. 603 * @param bool $attribute_expected Whether the aria-current attribute is expected. 604 */ 605 public function test_get_custom_logo_aria_current_attribute_blog_set_to_page_without_front_page_defined( $url, $attribute_expected ) { 606 // Set up pretty permalinks. 607 update_option( 'permalink_structure', '/%postname%/' ); 608 609 // Set posts to show on a static page. 610 update_option( 'show_on_front', 'page' ); 611 update_option( 'page_for_posts', self::$blog_page_id ); 612 613 // Set the custom logo. 614 $this->set_custom_logo(); 615 $this->go_to( $url ); 616 617 $this->assertNotEmpty( get_custom_logo(), 'Custom logo is expected to be set' ); 618 619 if ( $attribute_expected ) { 620 $this->assertStringContainsString( 'aria-current="page"', get_custom_logo(), 'Custom logo is expected to contain aria-current attribute' ); 621 } else { 622 $this->assertStringNotContainsString( 'aria-current="page"', get_custom_logo(), 'Custom logo is expected to contain aria-current attribute' ); 623 } 624 } 625 626 /** 627 * Data provider for the test_get_custom_logo_aria_current_attribute_blog_set_to_page_without_front_page_defined. 628 * 629 * @return array[] 630 */ 631 public function data_get_custom_logo_aria_current_attribute_blog_set_to_page_without_front_page_defined() { 632 return array( 633 'Front page' => array( home_url(), true ), 634 'Blog index' => array( home_url( '/blog/' ), true ), 635 'Blog post' => array( home_url( '/?p=1' ), false ), 636 'Sample page' => array( home_url( '/?page_id=2' ), false ), 637 ); 638 } 639 640 /** 641 * Test the aria attribute for the custom logo on the front page set to the blog. 642 * 643 * @ticket 62879 644 * 645 * @covers ::get_custom_logo 646 * 647 * @dataProvider data_get_custom_logo_aria_current_attribute_blog_set_to_page_with_front_page_defined 648 * 649 * @param string $url The URL to visit. 650 * @param bool $attribute_expected Whether the aria-current attribute is expected. 651 */ 652 public function test_get_custom_logo_aria_current_attribute_blog_set_to_page_with_front_page_defined( $url, $attribute_expected ) { 653 // Set up pretty permalinks. 654 update_option( 'permalink_structure', '/%postname%/' ); 655 656 // Set posts to show on a static page, show static page on front. 657 update_option( 'show_on_front', 'page' ); 658 update_option( 'page_for_posts', self::$blog_page_id ); 659 update_option( 'page_on_front', self::$home_page_id ); 660 661 // Set the custom logo. 662 $this->set_custom_logo(); 663 $this->go_to( $url ); 664 665 $this->assertNotEmpty( get_custom_logo(), 'Custom logo is expected to be set' ); 666 667 if ( $attribute_expected ) { 668 $this->assertStringContainsString( 'aria-current="page"', get_custom_logo(), 'Custom logo is expected to contain aria-current attribute' ); 669 } else { 670 $this->assertStringNotContainsString( 'aria-current="page"', get_custom_logo(), 'Custom logo is expected to contain aria-current attribute' ); 671 } 672 } 673 674 /** 675 * Data provider for the test_get_custom_logo_aria_current_attribute_blog_set_to_page_with_front_page_defined. 676 * 677 * @return array[] 678 */ 679 public function data_get_custom_logo_aria_current_attribute_blog_set_to_page_with_front_page_defined() { 680 return array( 681 'Front page' => array( home_url(), true ), 682 'Blog index' => array( home_url( '/blog/' ), true ), 683 'Blog post' => array( home_url( '/?p=1' ), false ), 684 'Sample page' => array( home_url( '/?page_id=2' ), false ), 685 ); 686 } 687 688 /** 526 689 * @ticket 40969 527 690 *
Note: See TracChangeset
for help on using the changeset viewer.