Compare commits

..

No commits in common. "d89708381d48f394b6f3c9a1fe2a58060de0cf0a" and "5b2d677d173c125a7712aad131e47a03cadb4403" have entirely different histories.

1 changed files with 11 additions and 27 deletions

View File

@ -24,19 +24,13 @@ if ($wordpress_endpoint) {
foreach ($response_data as $menu_item) { foreach ($response_data as $menu_item) {
$lowered_title = strtolower($menu_item->title); $lowered_title = strtolower($menu_item->title);
$item_url = $menu_item->url; $item_url = $menu_item->url;
if ($lowered_title == 'login') { if ($lowered_title == 'login') { // manipulate login url
// manipulate login url
$item_url = "/login"; $item_url = "/login";
} }
$item_title = $menu_item->title; $item_title = $menu_item->title;
if ($lowered_title == 'collections') { if ($lowered_title == 'collections') { // change Collections item
if ($wordpress_site) {
// change Collections item
$item_title = "Project"; $item_title = "Project";
$item_url = $wordpress_site; $item_url = $wordpress_site;
} else {
continue; // do not render the Collections item
}
} }
$item = [ $item = [
"id" => $menu_item->ID, "id" => $menu_item->ID,
@ -57,37 +51,27 @@ if (count($items[0]) == 0) {
// let's create a default menu // let's create a default menu
if ($wordpress_site) { if ($wordpress_site) {
$project_item = [ $project_item = [
"id" => 1, "id" => 2,
"title" => "Project", "title" => "Project",
"url" => $wordpress_site "url" => $wordpress_site
]; ];
$items[0][1] = $project_item; $items[0][2] = $project_item;
} }
$login_item = [ $login_item = [
"id" => 2, "id" => 1,
"title" => "Login", "title" => "Login",
"url" => "/login" "url" => "/login"
]; ];
$items[0][2] = $login_item; $items[0][1] = $login_item;
} }
//print_r($items); //print_r($items);
if (!function_exists('render_menu')) { if (!function_exists('render_menu')) {
function render_menu($items, $level_id) { function render_menu($items, $level_id) {
if ($level_id == 0) { echo '<ul>' . PHP_EOL;
echo '<ul id="" class="dropdown menu" data-dropdown-menu="dropdown-menu" role="menubar">'.
PHP_EOL;
} else {
echo '<ul class="dropdown menu vertical submenu is-dropdown-submenu first-sub" data-toggle="" data-submenu="" role="">'.
PHP_EOL;
}
foreach ($items[$level_id] as $menu_item) { foreach ($items[$level_id] as $menu_item) {
if ($level_id == 0) { echo '<li>' . PHP_EOL;
echo '<li id="" class="" role="">'.PHP_EOL; echo '<a href="'.$menu_item['url'].'">'.$menu_item['title'].'</a>' . PHP_EOL;
} else {
echo '<li id="" class="is-submenu-item is-dropdown-submenu-item" role="">'.PHP_EOL;
}
echo '<a role="" href="'.$menu_item['url'].'">'.$menu_item['title'].'</a>'.PHP_EOL;
if (array_key_exists($menu_item['id'], $items)) { if (array_key_exists($menu_item['id'], $items)) {
render_menu($items, $menu_item['id']); // render sub menu render_menu($items, $menu_item['id']); // render sub menu
} }