Skip to content

Commit

Permalink
Override navigation-submenu using same logic as navigation-link #14
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Feb 24, 2022
1 parent cba8375 commit ae6d3d5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions includes/block-overrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
//require_once __DIR__ . '/template-part.php';
//require_once __DIR__ . '/navigation.php';
require_once __DIR__ . '/navigation-link.php';
require_once __DIR__ . '/navigation-submenu.php';
//require_once __DIR__ . '/post-hierarchical-terms.php';
//require_once __DIR__ . '/block.php';

Expand All @@ -47,6 +48,7 @@ function written_register_block_type_args( $args ) {
//$args = written_maybe_override_block( $args,'core/template-part', 'render_block_core_template_part' );
//$args = written_maybe_override_block( $args,'core/navigation', 'render_block_core_navigation' );
$args = written_maybe_override_block( $args,'core/navigation-link', 'render_block_core_navigation_link' );
$args = written_maybe_override_block( $args,'core/navigation-submenu', 'render_block_core_navigation_submenu' );
//$args = written_maybe_override_block( $args,'core/post-hierarchical-terms', 'render_block_core_post_hierarchical_terms' );
//$args = written_maybe_override_block( $args,'core/block', 'render_block_core_block' );
return $args;
Expand Down
15 changes: 15 additions & 0 deletions includes/navigation-submenu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Overrides the `core/navigation-submenu` block.
*
* @param array $attributes The block attributes.
* @param array $content The saved content.
* @param array $block The parsed block.
*
* @return string Returns the post content with the legacy widget added.
*/
function written_render_block_core_navigation_submenu( $attributes, $content, $block ) {
$attributes = written_fiddle_nav_atts($attributes);
$html = gutenberg_render_block_core_navigation_submenu($attributes, $content, $block);
return $html;
}
2 changes: 1 addition & 1 deletion parts/footer-widgets.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3 id="follow-me" style="font-size:18px">Follow me</h3>
<!-- wp:template-part {"slug":"social-links","theme":"written"} /-->

<!-- wp:navigation {"overlayMenu":"never","layout":{"type":"flex","orientation":"horizontal"}} -->
<!-- wp:navigation-link {"label":"Home","type":"custom","url":"http://herbmiller.me/","kind":"custom","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Home","type":"custom","url":"https://herbmiller.me/","kind":"custom","isTopLevelLink":true} /-->

<!-- wp:navigation-link {"label":"About","type":"page","url":"https://s.b/hm/about/","kind":"post-type","isTopLevelLink":true} /-->

Expand Down
2 changes: 1 addition & 1 deletion parts/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- wp:column {"style":{"spacing":{"padding":{"top":"20px"}},"color":{"background":"#23282d"}}} -->
<div class="wp-block-column has-background" style="background-color:#23282d;padding-top:20px"><!-- wp:navigation {"textColor":"white","backgroundColor":"dark-grey","showSubmenuIcon":false,"layout":{"type":"flex","orientation":"horizontal"},"fontSize":"extra-small"} -->
<!-- wp:navigation-link {"label":"Home","type":"custom","url":"http://herbmiller.me/","kind":"custom","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Home","type":"custom","url":"https://herbmiller.me/","kind":"custom","isTopLevelLink":true} /-->

<!-- wp:navigation-submenu {"label":"About","type":"page","url":"https://s.b/hm/about","kind":"post-type","isTopLevelItem":true} -->
<!-- wp:navigation-link {"label":"Online CV","type":"page","url":"https://s.b/hm/about/online-cv/","kind":"post-type","isTopLevelLink":false} /-->
Expand Down

0 comments on commit ae6d3d5

Please sign in to comment.