close
Skip to content

Add aria role etc support for apply_block_supports / provide addtl HTML5-compliant tagnames or attributes to block/post-content #62246

@albanyacademy

Description

@albanyacademy

What problem does this address?

<div class="entry-content">... gets flagged by some SEO & accessibility tools as lacking its specific HTML5 tag (like <main>) and/or missing aria-label / role attribute tags.

Not going to argue whether or not the flag is valid, but wordpress doesn't provide a way to easily address this either.

function get_block_wrapper_attributes( $extra_attributes = array() ) {
	$new_attributes = WP_Block_Supports::get_instance()->apply_block_supports();

	if ( empty( $new_attributes ) && empty( $extra_attributes ) ) {
		return '';
	}

	// This is hardcoded on purpose.
	// We only support a fixed list of attributes.
	$attributes_to_merge = array( 'style', 'class', 'id' );
	$attributes          = array();
	...
	

there's opportunity to hook into get_block_wrapper_attributes and apply these additional attributes through a custom block supports, but this hardcoded list of attributes in class-wp-block-type-registry.php prevents this.

What is your proposed solution?

Either:

  • add the additional html element attribute present on template blocks to core/post-content
  • allow developers to add additional attributes via a hook
    • forcing aria-role="contentinfo" through a block supports is cumbersome unless its intended to be configurable by the end user, so maybe just add another apply_filter to get_block_wrapper_attributes?
  • just change the tagname and add the standard tags to the post content block itself, because why not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions