setOptions(array("timeout"=>1)); $response = $client->send(); } catch (exception $e) { $response = null; } if ($response) { $response_data = json_decode($response->getBody()); if (!$response->isClientError() && $response_data) { foreach ($response_data as $menu_item) { $lowered_title = strtolower($menu_item->title); $item_url = $menu_item->url; if ($lowered_title == 'login') { // manipulate login url $item_url = "/login"; } $item_title = $menu_item->title; if ($lowered_title == 'collections') { if ($wordpress_site) { // change Collections item $item_title = "Project"; $item_url = $wordpress_site; } else { continue; // do not render the Collections item } } $item = [ "id" => $menu_item->ID, "title" => $item_title, "url" => $item_url ]; if (!array_key_exists($menu_item->menu_item_parent, $items)) { $items[$menu_item->menu_item_parent] = new ArrayObject(); } $items[$menu_item->menu_item_parent][$menu_item->ID] =$item; } } } } if (count($items[0]) == 0) { // we did not retrieve a menu from the wordpress site // let's create a default menu if ($wordpress_site) { $project_item = [ "id" => 1, "title" => "Project", "url" => $wordpress_site ]; $items[0][1] = $project_item; } $login_item = [ "id" => 2, "title" => "Login", "url" => "/login" ]; $items[0][2] = $login_item; } //print_r($items); if (!function_exists('render_menu')) { function render_menu($items, $level_id) { echo '