Skip to content

Commit

Permalink
Issue #25 - refactor navigation overrides into navigation.php
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Nov 14, 2020
1 parent 5fa7808 commit 2ec757c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
23 changes: 2 additions & 21 deletions includes/block-overrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require_once __DIR__ . '/post-excerpt.php';
require_once __DIR__ . '/post-content.php';
require_once __DIR__ . '/template-part.php';
require_once __DIR__ . '/navigation.php';


/**
Expand All @@ -29,15 +30,9 @@ function fizzie_register_block_type_args( $args ) {
$args = fizzie_maybe_override_block( $args,'core/post-excerpt', 'render_block_core_post_excerpt' );
$args = fizzie_maybe_override_block( $args,'core/post-content', 'render_block_core_post_content' );
$args = fizzie_maybe_override_block( $args,'core/template-part', 'render_block_core_template_part' );
$args = fizzie_maybe_override_block( $args,'core/navigation', 'render_block_core_navigation' );



if ( 'core/navigation' == $args['name'] ) {
if ( 'gutenberg_render_block_core_navigation' == $args['render_callback'] ) {
$args['render_callback'] = 'fizzie_render_block_core_navigation';
}
}

if ( 'core/navigation-link' == $args['name'] ) {
if ( 'gutenberg_render_block_core_navigation_link' == $args['render_callback'] ) {
$args['render_callback'] = 'fizzie_render_block_core_navigation_link';
Expand All @@ -60,20 +55,6 @@ function fizzie_register_block_type_args( $args ) {
}









function fizzie_render_block_core_navigation( $attributes, $content, $block ) {
//bw_trace2();
$html = gutenberg_render_block_core_navigation( $attributes, $content, $block );
bw_trace2( $html, "html");
return $html;
}

function fizzie_render_block_core_navigation_link( $attributes, $content, $block ) {
$attributes = fizzie_fiddle_nav_atts( $attributes );
$html = gutenberg_render_block_core_navigation_link($attributes, $content, $block);
Expand Down
19 changes: 19 additions & 0 deletions includes/navigation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* Overrides core/navigation
*
* @TODO - process inner blocks to set the className for the current-menu-item
* then set the ancestors on the way back up.
*
* @param $attributes
* @param $content
* @param $block
* @return string
*/
function fizzie_render_block_core_navigation( $attributes, $content, $block ) {
//bw_trace2();
$html = gutenberg_render_block_core_navigation( $attributes, $content, $block );
bw_trace2( $html, "html");
return $html;
}

0 comments on commit 2ec757c

Please sign in to comment.