render-navigation-block.php 649 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. if ( ! function_exists( 'render_navigation_block' ) ) :
  3. function render_navigation_block( $menu_location ) {
  4. if ( ! has_nav_menu( $menu_location ) ) {
  5. return;
  6. }
  7. $block_attributes = array();
  8. $block_attributes['isResponsive'] = true;
  9. $nav_items = wp_nav_menu(
  10. array(
  11. 'echo' => false,
  12. 'block_attributes' => $block_attributes,
  13. 'theme_location' => $menu_location,
  14. 'container' => '',
  15. 'items_wrap' => '%3$s',
  16. 'fallback_cb' => false,
  17. )
  18. );
  19. if ( ! $nav_items ) {
  20. return;
  21. }
  22. return '<!-- wp:html -->' . $nav_items . '<!-- /wp:html -->';
  23. }
  24. endif;