| @@ -8,9 +8,9 @@ | ||
| 8 | 8 | /** |
| 9 | 9 | * Returns the submenu visibility value with backward compatibility |
| 10 | 10 | * for the deprecated openSubmenusOnClick attribute. |
| 11 | 11 | * |
| 12 | - * @since 7.0.0 | |
| 12 | + * @since 6.9.0 | |
| 13 | 13 | * |
| 14 | 14 | * @param array $context Block context from parent Navigation block. |
| 15 | 15 | * @return string The visibility mode: 'hover', 'click', or 'always'. |
| 16 | 16 | */ |
| @@ -122,9 +122,47 @@ | ||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return $colors; |
| 125 | 125 | } |
| 126 | + | |
| 126 | 127 | /** |
| 128 | + * Build an array with CSS classes and inline styles defining the font sizes | |
| 129 | + * which will be applied to the pages markup in the front-end when it is a descendant of navigation. | |
| 130 | + * | |
| 131 | + * @since 5.8.0 | |
| 132 | + * | |
| 133 | + * @param array $context Navigation block context. | |
| 134 | + * @return array Font size CSS classes and inline styles. | |
| 135 | + */ | |
| 136 | +function gutenberg_block_core_page_list_build_css_font_sizes( $context ) { | |
| 137 | + // CSS classes. | |
| 138 | + $font_sizes = array( | |
| 139 | + 'css_classes' => array(), | |
| 140 | + 'inline_styles' => '', | |
| 141 | + ); | |
| 142 | + | |
| 143 | + $has_named_font_size = array_key_exists( 'fontSize', $context ); | |
| 144 | + $has_custom_font_size = isset( $context['style']['typography']['fontSize'] ); | |
| 145 | + | |
| 146 | + if ( $has_named_font_size ) { | |
| 147 | + // Add the font size class. | |
| 148 | + $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] ); | |
| 149 | + } elseif ( $has_custom_font_size ) { | |
| 150 | + // Add the custom font size inline style. | |
| 151 | + $font_sizes['inline_styles'] = sprintf( | |
| 152 | + 'font-size: %s;', | |
| 153 | + gutenberg_get_typography_font_size_value( | |
| 154 | + array( | |
| 155 | + 'size' => $context['style']['typography']['fontSize'], | |
| 156 | + ) | |
| 157 | + ) | |
| 158 | + ); | |
| 159 | + } | |
| 160 | + | |
| 161 | + return $font_sizes; | |
| 162 | +} | |
| 163 | + | |
| 164 | +/** | |
| 127 | 165 | * Outputs Page list markup from an array of pages with nested children. |
| 128 | 166 | * |
| 129 | 167 | * @since 5.8.0 |
| 130 | 168 | * |
| @@ -258,9 +296,9 @@ | ||
| 258 | 296 | static $block_id = 0; |
| 259 | 297 | ++$block_id; |
| 260 | 298 | |
| 261 | 299 | $parent_page_id = $attributes['parentPageID']; |
| 262 | - $is_nested = ! empty( $block->context['core/isInsideSubmenu'] ); | |
| 300 | + $is_nested = $attributes['isNested']; | |
| 263 | 301 | |
| 264 | 302 | $all_pages = get_pages( |
| 265 | 303 | array( |
| 266 | 304 | 'sort_column' => 'menu_order,post_title', |
| @@ -303,14 +341,15 @@ | ||
| 303 | 341 | |
| 304 | 342 | } |
| 305 | 343 | } |
| 306 | 344 | |
| 307 | - $colors = gutenberg_block_core_page_list_build_css_colors( $attributes, $block->context ); | |
| 308 | - $classes = array_merge( | |
| 309 | - $colors['css_classes'] | |
| 345 | + $colors = gutenberg_block_core_page_list_build_css_colors( $attributes, $block->context ); | |
| 346 | + $font_sizes = gutenberg_block_core_page_list_build_css_font_sizes( $block->context ); | |
| 347 | + $classes = array_merge( | |
| 348 | + $colors['css_classes'], | |
| 349 | + $font_sizes['css_classes'] | |
| 310 | 350 | ); |
| 311 | - | |
| 312 | - $style_attribute = $colors['inline_styles']; | |
| 351 | + $style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] ); | |
| 313 | 352 | $css_classes = trim( implode( ' ', $classes ) ); |
| 314 | 353 | |
| 315 | 354 | $nested_pages = gutenberg_block_core_page_list_nest_pages( $top_level_pages, $pages_with_children ); |
| 316 | 355 | |