wp-includes/blocks/accordion-item.php:13$attributesarray$contentstringfunction block_core_accordion_item_render( array $attributes, string $content ): string { if ( '' === $content ) { return $content; } $p = new WP_HTML_Tag_Processor( $content ); $unique_id = wp_unique_id( 'accordion-item-' ); // Initialize the state of the item on the server using a closure, // since we need to get derived state based on the current context. wp_interactivity_state( 'core/accordion', array( 'isOpen' => function () { $context = wp_interactivity_get_context(); return $context['openByDefault']; }, ) ); if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-item' ) ) ) { $open_by_default = $attributes['openByDefault'] ? 'true' : 'false'; $p->set_attribute( 'data-wp-context', '{ "id": "' . $unique_id . '", "openByDefault": ' . $open_by_default . ' }' ); $p->set_attribute( 'data-wp-class--is-open', 'state.isOpen' ); $p->set_attribute( 'data-wp-init', 'callbacks.initAccordionItems' ); $p->set_attribute( 'data-wp-on-window--hashchange', 'callbacks.hashChange' ); if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-heading__toggle' ) ) ) { $p->set_attribute( 'data-wp-on--click', 'actions.toggle' ); $p->set_attribute( 'id', $unique_id ); $p->set_attribute( 'aria-controls', $unique_id . '-panel' ); $p->set_attribute( 'data-wp-bind--aria-expanded', 'state.isOpen' ); if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-panel' ) ) ) { $p->set_attribute( 'id', $unique_id . '-panel' ); $p->set_attribute( 'aria-labelledby', $unique_id ); $p->set_attribute( 'data-wp-bind--hidden', 'state.isHidden' ); $p->set_attribute( 'data-wp-on--beforematch', 'actions.handleBeforeMatch' ); // Only modify content if all directives have been set. $content = $p->get_updated_html(); } } } /* * If an Accordion Item is collapsed by default, ensure any contained IMG has fetchpriority=low to deprioritize it * from contending with resources in the critical rendering path. In contrast, remove the loading attribute to * prevent the image from not being available when the item is expanded. */ if ( ! $attributes['openByDefault'] ) { $processor = new WP_HTML_Tag_Processor( $content ); while ( $processor->next_tag( 'IMG' ) ) { $processor->set_attribute( 'fetchpriority', 'low' ); } $content = $processor->get_updated_html(); } return $content;}2 changes between 6.9.7 and 7.1.0.
Signature, return type and hooks compared across 3 parsed releases.
$attributes retyped from untyped to array.verified against source$content retyped from untyped to string.verified against sourcesrc/wp-includes/blocks/accordion-item.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.