STYLE Refactor menu item button function: rename function to 'dynamiques_wrap_parent_menu_item_buttons', update theme location check from 'renovateur' to 'primary', and remove unused code for improved clarity and functionality.
This commit is contained in:
parent
18e5f76288
commit
1a3d61eb8a
|
|
@ -4,9 +4,8 @@
|
||||||
Walker to ReWrap li submenu parent with button instead of
|
Walker to ReWrap li submenu parent with button instead of
|
||||||
-----------------------------------------------------------*/
|
-----------------------------------------------------------*/
|
||||||
|
|
||||||
function wrap_parent_menu_item_buttons($output, $item, $depth, $args)
|
function dynamiques_wrap_parent_menu_item_buttons($output, $item, $depth, $args)
|
||||||
{
|
{
|
||||||
// write_log($item);
|
|
||||||
|
|
||||||
// $item->classes = array_merge($item->classes, array('menu-item-' . $item->ID));
|
// $item->classes = array_merge($item->classes, array('menu-item-' . $item->ID));
|
||||||
|
|
||||||
|
|
@ -22,34 +21,21 @@ function wrap_parent_menu_item_buttons($output, $item, $depth, $args)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($args->theme_location === "renovateur") {
|
if ($args->theme_location === "primary") {
|
||||||
$page_icon = get_field('page_icon', $item->object_id);
|
$page_icon = get_field('page_icon', $item->object_id);
|
||||||
|
|
||||||
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>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// #### ICONE DE PAGE FOR TOP LEVEL MENU ITEMS
|
|
||||||
if (isset($page_icon)) {
|
if (isset($page_icon)) {
|
||||||
$icon = '<img class="page_icon" src="' . $page_icon['url'] . '" alt=""/>';
|
$icon = '<img class="page_icon" src="' . $page_icon['url'] . '" alt=""/>';
|
||||||
$link = $output;
|
$link = $output;
|
||||||
$output = $icon . $link;
|
$output = $icon . $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_log($output);
|
|
||||||
|
|
||||||
// #### TAXONOMY : GET ICON & INFOS ABOUT TAX
|
// #### TAXONOMY : GET ICON & INFOS ABOUT TAX
|
||||||
|
|
||||||
if ($item->type === "taxonomy") {
|
|
||||||
$term = get_term_by('id', $item->object_id, 'thematiques');
|
|
||||||
$cover = get_field('taxonomy_pictures', "thematiques_" . $item->object_id);
|
|
||||||
|
|
||||||
$output = '<a class="lol" href="' . $item->url . '">';
|
|
||||||
$output .= '<img class="thematique-icon" src="' . $cover['icon']['url'] . '"/>';
|
|
||||||
$output .= '<h6>' . $item->title . "</h6>";
|
|
||||||
$output .= '<p>' . $term->description . "</p>";
|
|
||||||
$output .= "</a>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($args->theme_location === "footer" && in_array('menu-item-has-children', $item->classes, true)) {
|
if ($args->theme_location === "footer" && in_array('menu-item-has-children', $item->classes, true)) {
|
||||||
|
|
@ -57,7 +43,7 @@ function wrap_parent_menu_item_buttons($output, $item, $depth, $args)
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
add_filter('walker_nav_menu_start_el', 'wrap_parent_menu_item_buttons', 10, 4);
|
add_filter('walker_nav_menu_start_el', 'dynamiques_wrap_parent_menu_item_buttons', 10, 4);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user