WP_Customize_Nav_Menus::render_nav_menu_partial()publicWP 4.3.0

Renders a specific menu via wp_nav_menu() using the supplied arguments.

Method of the class: WP_Customize_Nav_Menus{}

No Hooks.

Return

String|false.

Usage

$WP_Customize_Nav_Menus = new WP_Customize_Nav_Menus();
$WP_Customize_Nav_Menus->render_nav_menu_partial( $partial, $nav_menu_args );
$partial(WP_Customize_Partial) (required)
Partial.
$nav_menu_args(array) (required)
Nav menu args supplied as container context.

Notes

Changelog

Since 4.3.0 Introduced.

WP_Customize_Nav_Menus::render_nav_menu_partial() code WP 6.6.2

public function render_nav_menu_partial( $partial, $nav_menu_args ) {
	unset( $partial );

	if ( ! isset( $nav_menu_args['args_hmac'] ) ) {
		// Error: missing_args_hmac.
		return false;
	}

	$nav_menu_args_hmac = $nav_menu_args['args_hmac'];
	unset( $nav_menu_args['args_hmac'] );

	ksort( $nav_menu_args );
	if ( ! hash_equals( $this->hash_nav_menu_args( $nav_menu_args ), $nav_menu_args_hmac ) ) {
		// Error: args_hmac_mismatch.
		return false;
	}

	ob_start();
	wp_nav_menu( $nav_menu_args );
	$content = ob_get_clean();

	return $content;
}