wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



render_block_core_accordion › WordPress Function

Seit6.9.0
Veraltetn/v
render_block_core_accordion ( $attributes, $content )
Parameter: (2)
  • (array) $attributes The block attributes.
    Erforderlich: Ja
  • (string) $content The block content.
    Erforderlich: Ja
Gibt zurück:
  • (string) Returns the updated markup.
Definiert in:
Codex:

Server-side rendering of the `core/accordion` block.



Quellcode

function render_block_core_accordion( $attributes, $content ) {
	if ( ! $content ) {
		return $content;
	}

	$p         = new WP_HTML_Tag_Processor( $content );
	$autoclose = $attributes['autoclose'] ? 'true' : 'false';

	if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion' ) ) ) {
		$p->set_attribute( 'data-wp-interactive', 'core/accordion' );
		$p->set_attribute( 'data-wp-context', '{ "autoclose": ' . $autoclose . ', "accordionItems": [] }' );

		// Only modify content if directives have been set.
		$content = $p->get_updated_html();
	}

	return $content;
}