Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

block_core_navigation_link_build_css_font_sizes

Function Description:

Build an array with CSS classes and inline styles defining the font sizes which will be applied to the navigation markup in the front-end.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Setting custom font sizes for navigation links in WordPress block editor
add_filter( 'block_core_navigation_link_build_css_font_sizes', function( $font_sizes ) {
    $font_sizes['small'] = '14px';
    $font_sizes['medium'] = '16px';
    $font_sizes['large'] = '18px';
    return $font_sizes;
} );
// Example 2: Adjusting font sizes for navigation links based on screen size in WordPress
add_filter( 'block_core_navigation_link_build_css_font_sizes', function( $font_sizes ) {
    $font_sizes['small'] = '14px';
    $font_sizes['medium'] = '16px';
    $font_sizes['large'] = '18px';
    
    if ( wp_is_mobile() ) {
        $font_sizes['small'] = '12px';
        $font_sizes['medium'] = '14px';
        $font_sizes['large'] = '16px';
    }
    
    return $font_sizes;
} );
// Example 3: Adding custom font sizes for specific navigation link blocks in WordPress
add_filter( 'block_core_navigation_link_build_css_font_sizes', function( $font_sizes ) {
    $font_sizes['small'] = '14px';
    $font_sizes['medium'] = '16px';
    $font_sizes['large'] = '18px';
    
    if ( has_block( 'core/navigation', $post ) ) {
        $font_sizes['small'] = '12px';
        $font_sizes['medium'] = '14px';
        $font_sizes['large'] = '16px';
    }
    
    return $font_sizes;
} );