From 0fcc70b853bfb119871220ce27a46ef8f7f86f93 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Fri, 2 Oct 2015 06:45:32 +0000 Subject: [PATCH] Introduce the `wp_add_nav_menu_item` action, fired immediately after a new nav menu item has been added. This hook can be leveraged both for the legacy menus interface and the menus integration in the Customizer, as both use the containing function, `wp_update_nav_menu_item()`. Props MikeHansenMe, tyxla. Fixes #30983. git-svn-id: https://develop.svn.wordpress.org/trunk@34769 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/nav-menu.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index 90d0cbfd76..9cce24fbff 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -433,6 +433,19 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item $menu_item_db_id = wp_insert_post( $post ); if ( ! $menu_item_db_id || is_wp_error( $menu_item_db_id ) ) return $menu_item_db_id; + + /** + * Fires immediately after a new navigation menu item has been added. + * + * @since 4.4.0 + * + * @see wp_update_nav_menu_item() + * + * @param int $menu_id ID of the updated menu. + * @param int $menu_item_db_id ID of the new menu item. + * @param array $args An array of arguments used to update/add the menu item. + */ + do_action( 'wp_add_nav_menu_item', $menu_id, $menu_item_db_id, $args ); } // Associate the menu item with the menu term