[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/blocks/navigation-link/shared/ -> build-css-font-sizes.php (source)

   1  <?php
   2  /**
   3   * Shared helper function for building CSS font sizes in navigation blocks.
   4   *
   5   * @package WordPress
   6   */
   7  
   8  /**
   9   * Build an array with CSS classes and inline styles defining the font sizes
  10   * which will be applied to the navigation markup in the front-end.
  11   *
  12   * @since 7.1.0
  13   *
  14   * @param  array $context Navigation block context.
  15   * @return array Font size CSS classes and inline styles.
  16   */
  17  function block_core_shared_navigation_build_css_font_sizes( $context ) {
  18      // CSS classes.
  19      $font_sizes = array(
  20          'css_classes'   => array(),
  21          'inline_styles' => '',
  22      );
  23  
  24      $has_named_font_size  = array_key_exists( 'fontSize', $context );
  25      $has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
  26  
  27      if ( $has_named_font_size ) {
  28          // Add the font size class.
  29          $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
  30      } elseif ( $has_custom_font_size ) {
  31          // Add the custom font size inline style.
  32          $font_sizes['inline_styles'] = sprintf(
  33              'font-size: %s;',
  34              wp_get_typography_font_size_value(
  35                  array(
  36                      'size' => $context['style']['typography']['fontSize'],
  37                  )
  38              )
  39          );
  40      }
  41  
  42      return $font_sizes;
  43  }


Generated : Sat Jul 4 08:20:12 2026 Cross-referenced by PHPXref