Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bobbingwide opened this issue Mar 19, 2021 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request Gutenberg A bug / enhancement to Gutenberg

Comments

@bobbingwide
Copy link
Owner

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 bobbingwide self-assigned this Mar 19, 2021
@bobbingwide bobbingwide added Gutenberg A bug / enhancement to Gutenberg bug Something isn't working enhancement New feature or request labels Mar 19, 2021
@bobbingwide
Copy link
Owner Author

bobbingwide commented Mar 19, 2021

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
Copy link
Owner Author

delivered in v0.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request Gutenberg A bug / enhancement to Gutenberg
Projects
None yet
Development

No branches or pull requests

1 participant