You are here

function gutenberg_render_block_navigation_menu in Gutenberg 8

Renders the `core/navigation-menu` block on server.

Parameters

array $attributes The block attributes.:

array $content The saved content.:

array $block The parsed block.:

Return value

string Returns the post content with the legacy widget added.

1 string reference to 'gutenberg_render_block_navigation_menu'
gutenberg_register_block_core_navigation_menu in vendor/gutenberg/block-library/blocks/navigation-menu.php
Register the navigation menu block.

File

vendor/gutenberg/block-library/blocks/navigation-menu.php, line 67

Code

function gutenberg_render_block_navigation_menu($attributes, $content, $block) {

  // Inline computed colors.
  $comp_inline_styles = '';
  if (array_key_exists('backgroundColorValue', $attributes)) {
    $comp_inline_styles .= ' background-color: ' . esc_attr($attributes['backgroundColorValue']) . ';';
  }
  if (array_key_exists('textColorValue', $attributes)) {
    $comp_inline_styles .= ' color: ' . esc_attr($attributes['textColorValue']) . ';';
  }
  $comp_inline_styles = !empty($comp_inline_styles) ? ' style="' . esc_attr(trim($comp_inline_styles)) . '"' : '';
  $colors = gutenberg_build_css_colors($attributes);
  return "<nav class='wp-block-navigation-menu' {$comp_inline_styles}>" . gutenberg_build_navigation_menu_html($block, $colors) . '</nav>';
}