Changeset 58854
- Timestamp:
- 08/05/2024 06:58:49 PM (6 weeks ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/nav-menu.php
r58119 r58854 492 492 493 493 $original_title = ''; 494 494 495 if ( 'taxonomy' === $args['menu-item-type'] ) { 495 $original_parent = get_term_field( 'parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' ); 496 $original_title = get_term_field( 'name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' ); 496 $original_object = get_term( $args['menu-item-object-id'], $args['menu-item-object'] ); 497 498 if ( $original_object instanceof WP_Term ) { 499 $original_parent = get_term_field( 'parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' ); 500 $original_title = get_term_field( 'name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' ); 501 } 497 502 } elseif ( 'post_type' === $args['menu-item-type'] ) { 498 499 503 $original_object = get_post( $args['menu-item-object-id'] ); 500 $original_parent = (int) $original_object->post_parent; 501 $original_title = $original_object->post_title; 504 505 if ( $original_object instanceof WP_Post ) { 506 $original_parent = (int) $original_object->post_parent; 507 $original_title = $original_object->post_title; 508 } 502 509 } elseif ( 'post_type_archive' === $args['menu-item-type'] ) { 503 510 $original_object = get_post_type_object( $args['menu-item-object'] ); 504 if ( $original_object ) { 511 512 if ( $original_object instanceof WP_Post_Type ) { 505 513 $original_title = $original_object->labels->archives; 506 514 } -
trunk/tests/phpunit/tests/post/nav-menu.php
r57987 r58854 1210 1210 1211 1211 /** 1212 * Tests `wp_update_nav_menu_item()` with a non-existing taxonomy. 1213 * 1214 * When inserting a term from a non-existing taxonomy as a nav item, 1215 * the `post_title` property should be empty, and the function 1216 * should not throw a fatal error for `wp_specialchars_decode()`. 1217 * 1218 * @ticket 61799 1219 */ 1220 public function test_wp_update_nav_menu_item_with_invalid_taxonomy() { 1221 register_taxonomy( 'invalid', 'post' ); 1222 $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'invalid' ) ); 1223 unregister_taxonomy( 'invalid' ); 1224 1225 $menu_item_id = wp_update_nav_menu_item( 1226 $this->menu_id, 1227 0, 1228 array( 1229 'menu-item-type' => 'taxonomy', 1230 'menu-item-object' => 'invalid', 1231 'menu-item-object-id' => $term->term_id, 1232 'menu-item-status' => 'publish', 1233 ) 1234 ); 1235 1236 $menu_item = get_post( $menu_item_id ); 1237 $this->assertEmpty( $menu_item->post_title ); 1238 } 1239 1240 /** 1212 1241 * Test passed post_date/post_date_gmt. 1213 1242 *
Note: See TracChangeset
for help on using the changeset viewer.