bobbingwide / fizzie

Fizzie theme - a Full Site Editing theme using Gutenberg blocks
9 stars 1 forks source link

Warning: Undefined array key "tagName" in includes\template-part.php on line 58 #55

Closed bobbingwide closed 1 year ago

bobbingwide commented 3 years ago

After updating to Gutenberg 10.2.1 I got a load of Warnings and also unexpected HTML output. There was no problem with Gutenberg 10.1.1 I can't see from the change log what caused this. Time to investigate my code.

As an aside, I also had broken images... but this was down to not having an https connection in my local server. Normally I'd see Kaspersky having a moan about insecure connections.

bobbingwide commented 3 years ago

I can't see from the change log what caused this.

The change was part of Add category panel to template part block

The Category panel is now called Area panel. The title of the PR was misleading.

Anyway. Upshot is that the tagName attribute may not be set. The default logic in template-part.php is to guess it based on the area. Pragmatic fix is to use the same code. By doing so, Fizzie becomes dependent upon Gutenberg 10.2.0 or above..

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'] );
    }
bobbingwide commented 1 year ago

delivered in v0.5.0