wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



block_core_tabs_provide_context › WordPress Function

Od7.1.0
Przestarzałyn/a
› block_core_tabs_provide_context ( $context, $parsed_block )
Parametry: (2)
  • (array) $context Default block context.
    Wymagane: Tak
  • (array) $parsed_block The block being rendered.
    Wymagane: Tak
Powrót:
  • (array) Modified context.
Zdefiniowane na:
Codex:

Filter to provide tabs list context to core/tabs and core/tab-list blocks.

It is more performant to do this here, once, rather than in the tabs render and tabs context filters. In this way core/tabs is both a provider and a consumer of the core/tabs-list context.


Źródło

function block_core_tabs_provide_context( array $context, array $parsed_block ): array {
	if ( 'core/tabs' === $parsed_block['blockName'] ) {
		// Generate a unique ID for the tabs instance first, so it can be used
		// to derive stable tab IDs.
		$tabs_id                   = $parsed_block['attrs']['anchor'] ?? wp_unique_prefixed_id( 'tabs_' );
		$tabs_list                 = block_core_tabs_generate_tabs_list( $parsed_block['innerBlocks'] ?? array(), $tabs_id );
		$context['core/tabs-list'] = $tabs_list;
		$context['core/tabs-id']   = $tabs_id;
	}

	return $context;
}