mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-02 22:48:12 +01:00
Menus: Check if taxonomy term exists in wp_update_nav_menu_item()
.
When inserting a term from a non-existing taxonomy as a nav item, the `post_title` property should be empty, and the function should not throw a fatal error for `wp_specialchars_decode()`. Includes bringing some consistency to similar checks for post types and post type archives in the same code fragment. Follow-up to [14283], [14450], [35382], [36095]. Props dd32, narenin, mukesh27, SergeyBiryukov. Fixes #61799. Built from https://develop.svn.wordpress.org/trunk@58854 git-svn-id: http://core.svn.wordpress.org/trunk@58250 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ae993cf8e2
commit
1a2b5794da
@ -491,17 +491,25 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
|
|||||||
$args['menu-item-url'] = '';
|
$args['menu-item-url'] = '';
|
||||||
|
|
||||||
$original_title = '';
|
$original_title = '';
|
||||||
if ( 'taxonomy' === $args['menu-item-type'] ) {
|
|
||||||
$original_parent = get_term_field( 'parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' );
|
|
||||||
$original_title = get_term_field( 'name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' );
|
|
||||||
} elseif ( 'post_type' === $args['menu-item-type'] ) {
|
|
||||||
|
|
||||||
|
if ( 'taxonomy' === $args['menu-item-type'] ) {
|
||||||
|
$original_object = get_term( $args['menu-item-object-id'], $args['menu-item-object'] );
|
||||||
|
|
||||||
|
if ( $original_object instanceof WP_Term ) {
|
||||||
|
$original_parent = get_term_field( 'parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' );
|
||||||
|
$original_title = get_term_field( 'name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' );
|
||||||
|
}
|
||||||
|
} elseif ( 'post_type' === $args['menu-item-type'] ) {
|
||||||
$original_object = get_post( $args['menu-item-object-id'] );
|
$original_object = get_post( $args['menu-item-object-id'] );
|
||||||
$original_parent = (int) $original_object->post_parent;
|
|
||||||
$original_title = $original_object->post_title;
|
if ( $original_object instanceof WP_Post ) {
|
||||||
|
$original_parent = (int) $original_object->post_parent;
|
||||||
|
$original_title = $original_object->post_title;
|
||||||
|
}
|
||||||
} elseif ( 'post_type_archive' === $args['menu-item-type'] ) {
|
} elseif ( 'post_type_archive' === $args['menu-item-type'] ) {
|
||||||
$original_object = get_post_type_object( $args['menu-item-object'] );
|
$original_object = get_post_type_object( $args['menu-item-object'] );
|
||||||
if ( $original_object ) {
|
|
||||||
|
if ( $original_object instanceof WP_Post_Type ) {
|
||||||
$original_title = $original_object->labels->archives;
|
$original_title = $original_object->labels->archives;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.7-alpha-58853';
|
$wp_version = '6.7-alpha-58854';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user