Skip to content

Commit

Permalink
Issue #55 - set default template part tagName based on template area
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Apr 7, 2021
1 parent 948571c commit 4d7c957
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion includes/template-part.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,24 @@ function fizzie_render_block_core_template_part( $attributes, $content, $block
// Except shortcode processing that is.

$content = do_shortcode($content);
// This code will now require Gutenberg 10.2.0
if ( defined( 'WP_TEMPLATE_PART_AREA_UNCATEGORIZED' )) {
$area=WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
//$html_tag = isset( $attributes['tagName'] ) ? esc_attr($attributes['tagName']) : 'div';
if ( empty( $attributes['tagName'] ) ) {
$area_tags=array(
WP_TEMPLATE_PART_AREA_HEADER =>'header',
WP_TEMPLATE_PART_AREA_FOOTER =>'footer',
WP_TEMPLATE_PART_AREA_UNCATEGORIZED=>'div',
);
$html_tag =null !== $area && isset( $area_tags[ $area ] ) ? $area_tags[ $area ] : $area_tags[ WP_TEMPLATE_PART_AREA_UNCATEGORIZED ];
} else {
$html_tag=esc_attr( $attributes['tagName'] );
}
} else {
$html_tag = isset( $attributes['tagName'] ) ? esc_attr($attributes['tagName']) : 'div';
}

$html_tag = esc_attr($attributes['tagName']);
$wrapper_attributes = get_block_wrapper_attributes();
$html = "<$html_tag $wrapper_attributes>" . str_replace(']]>', ']]&gt;', $content) . "</$html_tag>";
fizzie_clear_processed_content( );
Expand Down

0 comments on commit 4d7c957

Please sign in to comment.