wp/wp-includes/blocks/navigation-submenu.php
author ymh <ymh.work@gmail.com>
Fri, 05 Sep 2025 18:52:52 +0200
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
permissions -rw-r--r--
Update WordPress to latest version (6.7) - Sync WordPress core files from latest release - Updated admin interface, blocks, and core functionality - Enhanced block editor features and performance - Security updates and bug fixes - Preserved custom wp-content directory and configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Server-side rendering of the `core/navigation-submenu` block.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
     9
 * Build an array with CSS classes and inline styles defining the font sizes
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * which will be applied to the navigation markup in the front-end.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    12
 * @since 5.9.0
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * @param  array $context Navigation block context.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 * @return array Font size CSS classes and inline styles.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
function block_core_navigation_submenu_build_css_font_sizes( $context ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
	// CSS classes.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	$font_sizes = array(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
		'css_classes'   => array(),
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
		'inline_styles' => '',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	);
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	$has_named_font_size  = array_key_exists( 'fontSize', $context );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	$has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	if ( $has_named_font_size ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
		// Add the font size class.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
		$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
	} elseif ( $has_custom_font_size ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
		// Add the custom font size inline style.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    32
		$font_sizes['inline_styles'] = sprintf(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    33
			'font-size: %s;',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    34
			wp_get_typography_font_size_value(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    35
				array(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    36
					'size' => $context['style']['typography']['fontSize'],
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    37
				)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    38
			)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    39
		);
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	return $font_sizes;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
/**
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
 * Returns the top-level submenu SVG chevron icon.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    48
 * @since 5.9.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    49
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
 * @return string
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
function block_core_navigation_submenu_render_submenu_icon() {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
	return '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
/**
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
 * Renders the `core/navigation-submenu` block.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    59
 * @since 5.9.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    60
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
 * @param array    $attributes The block attributes.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
 * @param string   $content    The saved content.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
 * @param WP_Block $block      The parsed block.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
 * @return string Returns the post content with the legacy widget added.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
function render_block_core_navigation_submenu( $attributes, $content, $block ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
	$navigation_link_has_id = isset( $attributes['id'] ) && is_numeric( $attributes['id'] );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	$is_post_type           = isset( $attributes['kind'] ) && 'post-type' === $attributes['kind'];
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	$is_post_type           = $is_post_type || isset( $attributes['type'] ) && ( 'post' === $attributes['type'] || 'page' === $attributes['type'] );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	// Don't render the block's subtree if it is a draft.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
	if ( $is_post_type && $navigation_link_has_id && 'publish' !== get_post_status( $attributes['id'] ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
		return '';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
	// Don't render the block's subtree if it has no label.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
	if ( empty( $attributes['label'] ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		return '';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
	$font_sizes      = block_core_navigation_submenu_build_css_font_sizes( $block->context );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    83
	$style_attribute = $font_sizes['inline_styles'];
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    84
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    85
	$has_submenu = count( $block->inner_blocks ) > 0;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    86
	$kind        = empty( $attributes['kind'] ) ? 'post_type' : str_replace( '-', '_', $attributes['kind'] );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    87
	$is_active   = ! empty( $attributes['id'] ) && get_queried_object_id() === (int) $attributes['id'] && ! empty( get_queried_object()->$kind );
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    89
	if ( is_post_type_archive() ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    90
		$queried_archive_link = get_post_type_archive_link( get_queried_object()->name );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    91
		if ( $attributes['url'] === $queried_archive_link ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    92
			$is_active = true;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    93
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    94
	}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
	$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
	$open_on_click           = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	$open_on_hover_and_click = isset( $block->context['openSubmenusOnClick'] ) && ! $block->context['openSubmenusOnClick'] &&
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
		$show_submenu_indicators;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   101
	$classes = array(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   102
		'wp-block-navigation-item',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   103
	);
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   104
	$classes = array_merge(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   105
		$classes,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   106
		$font_sizes['css_classes']
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   107
	);
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   108
	if ( $has_submenu ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   109
		$classes[] = 'has-child';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   110
	}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   111
	if ( $open_on_click ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   112
		$classes[] = 'open-on-click';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   113
	}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   114
	if ( $open_on_hover_and_click ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   115
		$classes[] = 'open-on-hover-click';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   116
	}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   117
	if ( $is_active ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   118
		$classes[] = 'current-menu-item';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   119
	}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   120
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
	$wrapper_attributes = get_block_wrapper_attributes(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		array(
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   123
			'class' => implode( ' ', $classes ),
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
			'style' => $style_attribute,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
		)
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
	);
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
	$label = '';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
	if ( isset( $attributes['label'] ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
		$label .= wp_kses_post( $attributes['label'] );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
	$aria_label = sprintf(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
		/* translators: Accessibility text. %s: Parent page title. */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
		__( '%s submenu' ),
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
		wp_strip_all_tags( $label )
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
	);
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
	$html = '<li ' . $wrapper_attributes . '>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
	// If Submenus open on hover, we render an anchor tag with attributes.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
	// If submenu icons are set to show, we also render a submenu button, so the submenu can be opened on click.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
	if ( ! $open_on_click ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
		$item_url = isset( $attributes['url'] ) ? $attributes['url'] : '';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
		// Start appending HTML attributes to anchor tag.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   147
		$html .= '<a class="wp-block-navigation-item__content"';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   148
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   149
		// The href attribute on a and area elements is not required;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   150
		// when those elements do not have href attributes they do not create hyperlinks.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   151
		// But also The href attribute must have a value that is a valid URL potentially
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   152
		// surrounded by spaces.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   153
		// see: https://html.spec.whatwg.org/multipage/links.html#links-created-by-a-and-area-elements.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   154
		if ( ! empty( $item_url ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   155
			$html .= ' href="' . esc_url( $item_url ) . '"';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   156
		}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
		if ( $is_active ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
			$html .= ' aria-current="page"';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
		if ( isset( $attributes['opensInNewTab'] ) && true === $attributes['opensInNewTab'] ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
			$html .= ' target="_blank"  ';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
		if ( isset( $attributes['rel'] ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
			$html .= ' rel="' . esc_attr( $attributes['rel'] ) . '"';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
		} elseif ( isset( $attributes['nofollow'] ) && $attributes['nofollow'] ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
			$html .= ' rel="nofollow"';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
		if ( isset( $attributes['title'] ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
			$html .= ' title="' . esc_attr( $attributes['title'] ) . '"';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
		$html .= '>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
		// End appending HTML attributes to anchor tag.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   179
		$html .= '<span class="wp-block-navigation-item__label">';
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
		$html .= $label;
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   181
		$html .= '</span>';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   182
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   183
		// Add description if available.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   184
		if ( ! empty( $attributes['description'] ) ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   185
			$html .= '<span class="wp-block-navigation-item__description">';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   186
			$html .= wp_kses_post( $attributes['description'] );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   187
			$html .= '</span>';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   188
		}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
		$html .= '</a>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
		// End anchor tag content.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
		if ( $show_submenu_indicators ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
			// The submenu icon is rendered in a button here
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
			// so that there's a clickable element to open the submenu.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
			$html .= '<button aria-label="' . esc_attr( $aria_label ) . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">' . block_core_navigation_submenu_render_submenu_icon() . '</button>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	} else {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
		// If menus open on click, we render the parent as a button.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
		$html .= '<button aria-label="' . esc_attr( $aria_label ) . '" class="wp-block-navigation-item__content wp-block-navigation-submenu__toggle" aria-expanded="false">';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
		// Wrap title with span to isolate it from submenu icon.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
		$html .= '<span class="wp-block-navigation-item__label">';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
		$html .= $label;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
		$html .= '</span>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   209
		// Add description if available.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   210
		if ( ! empty( $attributes['description'] ) ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   211
			$html .= '<span class="wp-block-navigation-item__description">';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   212
			$html .= wp_kses_post( $attributes['description'] );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   213
			$html .= '</span>';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   214
		}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   215
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
		$html .= '</button>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
		$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_submenu_render_submenu_icon() . '</span>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
	if ( $has_submenu ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   223
		// Copy some attributes from the parent block to this one.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   224
		// Ideally this would happen in the client when the block is created.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   225
		if ( array_key_exists( 'overlayTextColor', $block->context ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   226
			$attributes['textColor'] = $block->context['overlayTextColor'];
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   227
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   228
		if ( array_key_exists( 'overlayBackgroundColor', $block->context ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   229
			$attributes['backgroundColor'] = $block->context['overlayBackgroundColor'];
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   230
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   231
		if ( array_key_exists( 'customOverlayTextColor', $block->context ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   232
			$attributes['style']['color']['text'] = $block->context['customOverlayTextColor'];
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   233
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   234
		if ( array_key_exists( 'customOverlayBackgroundColor', $block->context ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   235
			$attributes['style']['color']['background'] = $block->context['customOverlayBackgroundColor'];
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   236
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   237
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   238
		// This allows us to be able to get a response from wp_apply_colors_support.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   239
		$block->block_type->supports['color'] = true;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   240
		$colors_supports                      = wp_apply_colors_support( $block->block_type, $attributes );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   241
		$css_classes                          = 'wp-block-navigation__submenu-container';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   242
		if ( array_key_exists( 'class', $colors_supports ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   243
			$css_classes .= ' ' . $colors_supports['class'];
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   244
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   245
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   246
		$style_attribute = '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   247
		if ( array_key_exists( 'style', $colors_supports ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   248
			$style_attribute = $colors_supports['style'];
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   249
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   250
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
		$inner_blocks_html = '';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
		foreach ( $block->inner_blocks as $inner_block ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
			$inner_blocks_html .= $inner_block->render();
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   256
		if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   257
			$tag_processor = new WP_HTML_Tag_Processor( $html );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   258
			while ( $tag_processor->next_tag( array( 'class_name' => 'wp-block-navigation-item' ) ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   259
				$tag_processor->add_class( 'current-menu-ancestor' );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   260
			}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   261
			$html = $tag_processor->get_updated_html();
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   262
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   263
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   264
		$wrapper_attributes = get_block_wrapper_attributes(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   265
			array(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   266
				'class' => $css_classes,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   267
				'style' => $style_attribute,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   268
			)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   269
		);
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   270
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
		$html .= sprintf(
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   272
			'<ul %s>%s</ul>',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   273
			$wrapper_attributes,
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
			$inner_blocks_html
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
		);
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   276
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	$html .= '</li>';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
	return $html;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
/**
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
 * Register the navigation submenu block.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   287
 * @since 5.9.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   288
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
 * @uses render_block_core_navigation_submenu()
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
 * @throws WP_Error An WP_Error exception parsing the block definition.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
function register_block_core_navigation_submenu() {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
	register_block_type_from_metadata(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
		__DIR__ . '/navigation-submenu',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
		array(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
			'render_callback' => 'render_block_core_navigation_submenu',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
		)
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
	);
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
add_action( 'init', 'register_block_core_navigation_submenu' );