Menus: Make use of `wp_resolve_post_date()` when updating menu items.
This allows a menu item `post_date` to be set to particular value, rather than only allowing it to be set to "now". In particular, the WordPress Importer can use this to perform faster, more accurate duplicate checks. Props jmdodd. Fixes #52189. Built from https://develop.svn.wordpress.org/trunk@50013 git-svn-id: http://core.svn.wordpress.org/trunk@49714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ce19f7a630
commit
2660382579
|
@ -436,20 +436,22 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'menu-item-db-id' => $menu_item_db_id,
|
'menu-item-db-id' => $menu_item_db_id,
|
||||||
'menu-item-object-id' => 0,
|
'menu-item-object-id' => 0,
|
||||||
'menu-item-object' => '',
|
'menu-item-object' => '',
|
||||||
'menu-item-parent-id' => 0,
|
'menu-item-parent-id' => 0,
|
||||||
'menu-item-position' => 0,
|
'menu-item-position' => 0,
|
||||||
'menu-item-type' => 'custom',
|
'menu-item-type' => 'custom',
|
||||||
'menu-item-title' => '',
|
'menu-item-title' => '',
|
||||||
'menu-item-url' => '',
|
'menu-item-url' => '',
|
||||||
'menu-item-description' => '',
|
'menu-item-description' => '',
|
||||||
'menu-item-attr-title' => '',
|
'menu-item-attr-title' => '',
|
||||||
'menu-item-target' => '',
|
'menu-item-target' => '',
|
||||||
'menu-item-classes' => '',
|
'menu-item-classes' => '',
|
||||||
'menu-item-xfn' => '',
|
'menu-item-xfn' => '',
|
||||||
'menu-item-status' => '',
|
'menu-item-status' => '',
|
||||||
|
'menu-item-post-date' => '',
|
||||||
|
'menu-item-post-date-gmt' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
$args = wp_parse_args( $menu_item_data, $defaults );
|
$args = wp_parse_args( $menu_item_data, $defaults );
|
||||||
|
@ -513,6 +515,11 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
|
||||||
'post_type' => 'nav_menu_item',
|
'post_type' => 'nav_menu_item',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$post_date = wp_resolve_post_date( $args['menu-item-post-date'], $args['menu-item-post-date-gmt'] );
|
||||||
|
if ( $post_date ) {
|
||||||
|
$post['post_date'] = $post_date;
|
||||||
|
}
|
||||||
|
|
||||||
$update = 0 != $menu_item_db_id;
|
$update = 0 != $menu_item_db_id;
|
||||||
|
|
||||||
// New menu item. Default is draft status.
|
// New menu item. Default is draft status.
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.7-alpha-50012';
|
$wp_version = '5.7-alpha-50013';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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