Changeset 42732
- Timestamp:
- 02/24/2018 01:43:07 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/nav-menu-template.php
r42343 r42732 442 442 $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' ); 443 443 } 444 444 445 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current ); 445 446 $raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; … … 447 448 $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) ); 448 449 449 if ( $raw_item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) { 450 $matches = array( 451 $current_url, urldecode( $current_url ), 452 $_indexless_current, urldecode( $_indexless_current ), 453 $_root_relative_current, urldecode( $_root_relative_current ), 454 ); 455 456 if ( $raw_item_url && in_array( $item_url, $matches ) ) { 450 457 $classes[] = 'current-menu-item'; 451 458 $menu_items[ $key ]->current = true; -
trunk/tests/phpunit/tests/post/nav-menu.php
r42636 r42732 763 763 } 764 764 765 /** 766 * Provides IRI matching data for _wp_menu_item_classes_by_context() test. 767 */ 768 function get_iri_current_menu_items() { 769 return array( 770 array( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) ), 771 array( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82' ) ), 772 array( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ), 773 array( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82' ), 774 array( '/привет/' ), 775 array( '/привет' ), 776 ); 777 } 778 779 /** 780 * @ticket 43401 781 * @dataProvider get_iri_current_menu_items 782 */ 783 function test_iri_current_menu_item( $custom_link, $current = true ) { 784 wp_update_nav_menu_item( 785 $this->menu_id, 0, array( 786 'menu-item-status' => 'publish', 787 'menu-item-type' => 'custom', 788 'menu-item-url' => $custom_link, 789 ) 790 ); 791 792 $this->go_to( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) ); 793 794 $menu_items = wp_get_nav_menu_items( $this->menu_id ); 795 _wp_menu_item_classes_by_context( $menu_items ); 796 797 $classes = $menu_items[0]->classes; 798 799 if ( $current ) { 800 $this->assertContains( 'current-menu-item', $classes ); 801 } else { 802 $this->assertNotContains( 'current-menu-item', $classes ); 803 } 804 } 805 765 806 }
Note: See TracChangeset
for help on using the changeset viewer.