Skip to content

Commit

Permalink
Add tag name configurability to global footer block (#620)
Browse files Browse the repository at this point in the history
* Add tag name configurability to global footer block

* Validate the tagName
  • Loading branch information
adamwoodnz authored Jun 5, 2024
1 parent 7dfa6b2 commit 308c936
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion mu-plugins/blocks/global-header-footer/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,16 @@ function render_global_footer( $attributes, $content, $block ) {
$wrapper_attributes = get_block_wrapper_attributes(
array( 'class' => 'global-footer wp-block-group' )
);

$tag_name = $attributes['tagName'];
$allowed_tag_names = array( 'footer', 'div', 'section' );
if ( ! $tag_name || ! in_array( $tag_name, $allowed_tag_names, true ) ) {
$tag_name = 'footer';
}

return sprintf(
'<footer %1$s>%2$s</footer>%3$s',
'<%1$s %2$s>%3$s</%1$s>%4$s',
$tag_name,
$wrapper_attributes,
$markup,
$footer_markup,
Expand Down
7 changes: 6 additions & 1 deletion mu-plugins/blocks/global-header-footer/src/footer/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
"width": true
}
},
"attributes": {},
"attributes": {
"tagName": {
"type": "string",
"default": "footer"
}
},
"textdomain": "wporg",
"style": "wporg-global-header-footer",
"editorStyle": "wporg-global-header-footer",
Expand Down

0 comments on commit 308c936

Please sign in to comment.