File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -631,6 +631,24 @@ 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+ return "<?php wp_nav_menu( $ expression); ?> " ;
643+ },
644+
645+ 'hasmenu ' => function ($ expression ) {
646+ return "<?php if (has_nav_menu( $ expression)) : ?> " ;
647+ },
648+
649+ 'endhasmenu ' => function () {
650+ return '<?php endif; ?> ' ;
651+ },
634652 ];
635653 }
636654}
Original file line number Diff line number Diff line change 845845 expect ($ compiled )->toBe ("<?php echo get_theme_mod('mod', 'default'); ?> " );
846846 });
847847});
848+
849+ describe ('@menu ' , function () {
850+ it ('compiles correctly ' , function () {
851+ $ directive = "@menu(['theme_location' => 'primary_navigation']) " ;
852+
853+ $ compiled = $ this ->compile ($ directive );
854+
855+ expect ($ compiled )->toBe ("<?php wp_nav_menu(['theme_location' => 'primary_navigation']); ?> " );
856+ });
857+ });
858+
859+ describe ('@hasmenu ' , function () {
860+ it ('compiles correctly ' , function () {
861+ $ directive = "@hasmenu('primary_navigation') " ;
862+
863+ $ compiled = $ this ->compile ($ directive );
864+
865+ expect ($ compiled )->toBe ("<?php if (has_nav_menu('primary_navigation')) : ?> " );
866+ });
867+ });
868+
869+ describe ('@endhasmenu ' , function () {
870+ it ('compiles correctly ' , function () {
871+ $ directive = '@endhasmenu ' ;
872+
873+ $ compiled = $ this ->compile ($ directive );
874+
875+ expect ($ compiled )->toBe ('<?php endif; ?> ' );
876+ });
877+ });
You can’t perform that action at this time.
0 commit comments