35 lines
1.5 KiB
PHP
35 lines
1.5 KiB
PHP
<?php
|
|
|
|
/* -----------------------------------------------------------
|
|
Walker to ReWrap li submenu parent with button instead of
|
|
-----------------------------------------------------------*/
|
|
|
|
function wrap_parent_menu_item_buttons($output, $item, $depth, $args)
|
|
{
|
|
|
|
|
|
if ($args->theme_location === "homegrade" && $args->menu_class === "menu-homegrade-header" && in_array('menu-item-has-children', $item->classes, true)) {
|
|
$output = '<button type="button" class="menu-item-submenu-toggle" aria-expanded="false" aria-controls="sub-menu-' . $item->ID . '">' . $item->title . '</button>';
|
|
}
|
|
if ($args->theme_location === "renovateur") {
|
|
$page_icon = get_field('page_icon', $item->object_id);
|
|
|
|
// write_log($item);
|
|
if (in_array('menu-item-has-children', $item->classes, true)) {
|
|
$output = '<button type="button" class="menu-item-submenu-toggle" aria-expanded="false" aria-controls="sub-menu-' . $item->ID . '">' . $item->title . '</button>';
|
|
}
|
|
|
|
if ($page_icon['url']) {
|
|
write_log($page_icon['url']);
|
|
$icon = '<img class="page_icon" src="' . $page_icon['url'] . '" alt=""/>';
|
|
$link = $output;
|
|
$output = $icon . $link;
|
|
}
|
|
}
|
|
|
|
if ($args->theme_location === "footer" && in_array('menu-item-has-children', $item->classes, true)) {
|
|
$output = $item->title;
|
|
}
|
|
return $output;
|
|
}
|
|
add_filter('walker_nav_menu_start_el', 'wrap_parent_menu_item_buttons', 10, 4); |