WP_Navigation_Block_Renderer::render()public staticWP 6.5.0

Renders the navigation block.

Method of the class: WP_Navigation_Block_Renderer{}

No Hooks.

Return

String. Returns the navigation block markup.

Usage

$result = WP_Navigation_Block_Renderer::render( $attributes, $content, $block );
$attributes(array) (required)
The block attributes.
$content(string) (required)
The saved content.
$block(WP_Block) (required)
The parsed block.

Changelog

Since 6.5.0 Introduced.

WP_Navigation_Block_Renderer::render() code WP 6.7.1

public static function render( $attributes, $content, $block ) {
	/**
	 * Deprecated:
	 * The rgbTextColor and rgbBackgroundColor attributes
	 * have been deprecated in favor of
	 * customTextColor and customBackgroundColor ones.
	 * Move the values from old attrs to the new ones.
	 */
	if ( isset( $attributes['rgbTextColor'] ) && empty( $attributes['textColor'] ) ) {
		$attributes['customTextColor'] = $attributes['rgbTextColor'];
	}

	if ( isset( $attributes['rgbBackgroundColor'] ) && empty( $attributes['backgroundColor'] ) ) {
		$attributes['customBackgroundColor'] = $attributes['rgbBackgroundColor'];
	}

	unset( $attributes['rgbTextColor'], $attributes['rgbBackgroundColor'] );

	$inner_blocks = static::get_inner_blocks( $attributes, $block );
	// Prevent navigation blocks referencing themselves from rendering.
	if ( block_core_navigation_block_contains_core_navigation( $inner_blocks ) ) {
		return '';
	}

	static::handle_view_script_module_loading( $attributes, $block, $inner_blocks );

	return sprintf(
		'<nav %1$s>%2$s</nav>',
		static::get_nav_wrapper_attributes( $attributes, $inner_blocks ),
		static::get_wrapper_markup( $attributes, $inner_blocks )
	);
}