get_nav_menu_item example

$nav_menu_item_id = wp_update_nav_menu_item( $prepared_nav_item['menu-id']$prepared_nav_item['menu-item-db-id']wp_slash( $prepared_nav_item ), false );
        if ( is_wp_error( $nav_menu_item_id ) ) {
            if ( 'db_insert_error' === $nav_menu_item_id->get_error_code() ) {
                $nav_menu_item_id->add_data( array( 'status' => 500 ) );
            } else {
                $nav_menu_item_id->add_data( array( 'status' => 400 ) );
            }

            return $nav_menu_item_id;
        }

        $nav_menu_item = $this->get_nav_menu_item( $nav_menu_item_id );
        if ( is_wp_error( $nav_menu_item ) ) {
            $nav_menu_item->add_data( array( 'status' => 404 ) );

            return $nav_menu_item;
        }

        /** * Fires after a single menu item is created or updated via the REST API. * * @since 5.9.0 * * @param object $nav_menu_item Inserted or updated menu item object. * @param WP_REST_Request $request Request object. * @param bool $creating True when creating a menu item, false when updating. */
Home | Imprint | This part of the site doesn't use cookies.