develop #63
|
@ -2,27 +2,29 @@
|
||||||
|
|
||||||
use Zend\Http\Client;
|
use Zend\Http\Client;
|
||||||
|
|
||||||
$client = New Client;
|
|
||||||
$client = new Client('https://dev.arc-hive.zone/wp-json/menus/v1/menus/4');
|
$client = new Client('https://dev.arc-hive.zone/wp-json/menus/v1/menus/4');
|
||||||
|
$client->setOptions(array("timeout"=>1));
|
||||||
$response = $client->send();
|
$response = $client->send();
|
||||||
$response_items = json_decode($response->getBody());
|
$response_data = json_decode($response->getBody());
|
||||||
$items = new ArrayObject();
|
$items = new ArrayObject;
|
||||||
|
$items[0] = new ArrayObject();
|
||||||
|
|
||||||
foreach ($response_items as $menu_item) {
|
if (!$response->isClientError()&& $response_data) {
|
||||||
$item_url = $menu_item->url;
|
foreach ($response_data as $menu_item) {
|
||||||
if (strtolower($menu_item->title) == 'login') {
|
$item_url = $menu_item->url;
|
||||||
$item_url = "/login";
|
if (strtolower($menu_item->title) == 'login') {
|
||||||
|
$item_url = "/login";
|
||||||
|
}
|
||||||
|
$item = [
|
||||||
|
"ID" => $menu_item->ID,
|
||||||
|
"title" => $menu_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;
|
||||||
}
|
}
|
||||||
$item = [
|
|
||||||
"ID" => $menu_item->ID,
|
|
||||||
"title" => $menu_item->title,
|
|
||||||
"url" => $item_url,
|
|
||||||
"menu_item_parent" => $menu_item->menu_item_parent,
|
|
||||||
];
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//print_r($items);
|
//print_r($items);
|
||||||
|
|
Loading…
Reference in New Issue