Skip to content

Commit 307c3b9

Browse files
authored
Add @menu, @hasmenu and @endhasmenu
1 parent c6b5ed9 commit 307c3b9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Directives/WordPress.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,25 @@ public function directives(): array
631631

632632
return "<?php echo get_theme_mod({$mod}); ?>";
633633
},
634+
635+
/*
636+
|---------------------------------------------------------------------
637+
| @menu / @hasmenu / @endhasmenu
638+
|---------------------------------------------------------------------
639+
*/
640+
641+
'menu' => function ($expression) {
642+
$expression = $this->parse($expression);
643+
return "<?php wp_nav_menu({$expression->get(0)}); ?>";
644+
},
645+
646+
'hasmenu' => function ($expression) {
647+
return "<?php if (has_nav_menu($expression)) : ?>";
648+
},
649+
650+
'endhasmenu' => function () {
651+
return '<?php endif; ?>';
652+
},
634653
];
635654
}
636655
}

0 commit comments

Comments
 (0)