PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/scripts/block-library/tab.php +4 -21 23.0.122.7.0 View file →
@@ -10,36 +10,19 @@
10 10 *
11 11 * @since 7.0.0
12 12 *
13 13 * @param array $attributes Block attributes.
14 -* @param array $attributes Block attributes.
15 -* @param string $content Block content.
16 -* @param \WP_Block $block Block instance.
14 + * @param string $content Block content.
17 15 *
18 16 * @return string Updated HTML.
19 17 */
20 -function gutenberg_block_core_tab_render( array $attributes, string $content, \WP_Block $block ): string {
21 - $tabs_id = $block->context['core/tabs-id'] ?? '';
22 -
23 - static $tab_counters = array();
24 -
25 - if ( ! isset( $tab_counters[ $tabs_id ] ) ) {
26 - $tab_counters[ $tabs_id ] = 0;
27 - }
28 -
29 - $tab_index = $tab_counters[ $tabs_id ];
30 - ++$tab_counters[ $tabs_id ];
31 -
18 +function gutenberg_block_core_tab_render( array $attributes, string $content ): string {
32 19 $tag_processor = new WP_HTML_Tag_Processor( $content );
33 20 $tag_processor->next_tag( array( 'class_name' => 'wp-block-tab' ) );
34 -
35 - // Use the user's custom anchor if present, otherwise fall back to
36 - // the generated position-based ID.
37 21 $tab_id = (string) $tag_processor->get_attribute( 'id' );
22 + // If no id, generate a unique one
38 23 if ( empty( $tab_id ) ) {
39 - $tab_id = ! empty( $tabs_id )
40 - ? $tabs_id . '-tab-' . $tab_index
41 - : 'tab-' . $tab_index;
24 + $tab_id = sanitize_title( $attributes['label'] );
42 25 $tag_processor->set_attribute( 'id', $tab_id );
43 26 }
44 27
45 28 /**