| 959 | /** |
| 960 | * @ticket 48011 |
| 961 | */ |
| 962 | function test_wp_update_nav_menu_item_with_special_character_in_categories() { |
| 963 | // When inserting a category as a nav item, the `$args['menu-item-title']` should |
| 964 | // always be empty as it should get the title from the category object itself. |
| 965 | add_action( 'wp_update_nav_menu_item', [ $this, 'wp_update_nav_menu_item_48011' ], 10, 3 ); |
| 966 | |
| 967 | $category_name = 'Test Cat & >'; |
| 968 | |
| 969 | $cat = self::factory()->category->create_and_get( array( |
| 970 | 'name' => $category_name, |
| 971 | ) ); |
| 972 | |
| 973 | wp_update_nav_menu_item( |
| 974 | $this->menu_id, |
| 975 | 0, |
| 976 | array( |
| 977 | 'menu-item-type' => 'taxonomy', |
| 978 | 'menu-item-object' => 'category', |
| 979 | 'menu-item-object-id' => $cat->term_id, |
| 980 | 'menu-item-status' => 'publish', |
| 981 | 'menu-item-title' => $category_name, // Interesting enough, if we use `$cat->name` we won't be able to |
| 982 | // replicate the bug because it's in htmlentities form. |
| 983 | ) |
| 984 | ); |
| 985 | } |
| 986 | |
| 987 | function wp_update_nav_menu_item_48011( $menu_id, $menu_item_db_id, $args ) { |
| 988 | $this->assertEmpty( $args['menu-item-title'] ); |
| 989 | } |