wordpress-menu #56
|
@ -2,13 +2,15 @@
|
||||||
|
|
||||||
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) {
|
||||||
|
foreach ($response_data as $menu_item) {
|
||||||
$item_url = $menu_item->url;
|
$item_url = $menu_item->url;
|
||||||
if (strtolower($menu_item->title) == 'login') {
|
if (strtolower($menu_item->title) == 'login') {
|
||||||
$item_url = "/login";
|
$item_url = "/login";
|
||||||
|
@ -16,13 +18,13 @@ foreach ($response_items as $menu_item) {
|
||||||
$item = [
|
$item = [
|
||||||
"ID" => $menu_item->ID,
|
"ID" => $menu_item->ID,
|
||||||
"title" => $menu_item->title,
|
"title" => $menu_item->title,
|
||||||
"url" => $item_url,
|
"url" => $item_url
|
||||||
"menu_item_parent" => $menu_item->menu_item_parent,
|
|
||||||
];
|
];
|
||||||
if (!array_key_exists($menu_item->menu_item_parent, $items)) {
|
if (!array_key_exists($menu_item->menu_item_parent, $items)) {
|
||||||
$items[$menu_item->menu_item_parent] = new ArrayObject();
|
$items[$menu_item->menu_item_parent] = new ArrayObject();
|
||||||
}
|
}
|
||||||
$items[$menu_item->menu_item_parent][$menu_item->ID] =$item;
|
$items[$menu_item->menu_item_parent][$menu_item->ID] =$item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//print_r($items);
|
//print_r($items);
|
||||||
|
|
Loading…
Reference in New Issue