Compare commits

..

2 Commits

Author SHA1 Message Date
buttle f9d2d65931 improves item title comparisons 2022-03-25 11:25:32 +01:00
buttle 27ed8e6db5 does not render empty menu 2022-03-25 11:21:23 +01:00
1 changed files with 6 additions and 3 deletions

View File

@ -17,12 +17,13 @@ if ($wordpress_endpoint) {
if (!$response->isClientError() && $response_data) { if (!$response->isClientError() && $response_data) {
foreach ($response_data as $menu_item) { foreach ($response_data as $menu_item) {
$lowered_title = strtolower($menu_item->title);
$item_url = $menu_item->url; $item_url = $menu_item->url;
if (strtolower($menu_item->title) == 'login') { if ($lowered_title == 'login') { // manipulate login url
$item_url = "/login"; $item_url = "/login";
} }
$item_title = $menu_item->title; $item_title = $menu_item->title;
if (strtolower($menu_item->title) == 'collections') { if ($lowered_title == 'collections') { // change Collections item
$item_title = "Project"; $item_title = "Project";
$item_url = $wordpress_site; $item_url = $wordpress_site;
} }
@ -54,6 +55,8 @@ function render_menu($items, $level_id) {
echo '</ul>' . PHP_EOL; echo '</ul>' . PHP_EOL;
} }
if (count($items[0]) > 0) {
render_menu($items, 0); render_menu($items, 0);
}
?> ?>