-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dynamic navigation block and hierarchy attributes
- Loading branch information
1 parent
174c098
commit 4f13e08
Showing
8 changed files
with
119 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
InnerBlocks, | ||
} from '@wordpress/block-editor'; | ||
|
||
export default function save( { attributes } ) { | ||
return ( | ||
<a | ||
href={ attributes.destination } | ||
rel={ attributes.nofollow && 'nofollow' } | ||
title={ attributes.title } | ||
target={ attributes.opensInNewTab && '_blank' } | ||
> | ||
{ attributes.label } | ||
</a> | ||
<> | ||
<a | ||
href={ attributes.destination } | ||
rel={ attributes.nofollow && 'nofollow' } | ||
title={ attributes.title } | ||
target={ attributes.opensInNewTab && '_blank' } | ||
> | ||
{ attributes.label } | ||
</a> | ||
<InnerBlocks.Content /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ | |
"automaticallyAdd": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"hierarchy": { | ||
"type": "array", | ||
"default": [] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Server-side rendering of the `core/navigation-menu` block. | ||
* | ||
* @package WordPress | ||
*/ | ||
|
||
/** | ||
* Renders the `core/navigation-menu` block on server. | ||
* | ||
* @see WP_Widget | ||
* | ||
* @param array $attributes The block attributes. | ||
* | ||
* @return string Returns the post content with the legacy widget added. | ||
*/ | ||
function render_block_navigation_menu( $attributes, $content ) { | ||
return "Content"; | ||
} | ||
|
||
/** | ||
* Register legacy widget block. | ||
*/ | ||
function register_block_core_navigation_menu() { | ||
register_block_type( | ||
'core/navigation-menu', | ||
array( | ||
'category' => 'layout', | ||
'attributes' => array( | ||
'automaticallyAdd' => array( | ||
'type' => 'boolean', | ||
'default' => 'false', | ||
), | ||
'hierarchy' => array( | ||
'type' => 'array', | ||
'default' => array(), | ||
'items' => array( | ||
'type' => 'object', | ||
), | ||
), | ||
), | ||
'render_callback' => 'render_block_navigation_menu', | ||
) | ||
); | ||
} | ||
|
||
add_action( 'init', 'register_block_core_navigation_menu' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { InnerBlocks } from '@wordpress/block-editor'; | ||
|
||
export default function save() { | ||
return ( | ||
<nav> | ||
<InnerBlocks.Content /> | ||
</nav> | ||
); | ||
return null; | ||
} |