Make WordPress Core


Ignore:
Timestamp:
06/08/2021 08:07:15 AM (4 years ago)
Author:
youknowriad
Message:

Block Editor: Package updates for 5.8 beta 1.

This includes the following fixes:

Widgets Editor:

Widget blocks in the customizer:

Global Styles:

Template Editor:

Miscellaneous:

Performance:

Props noisysocks, nosolosw, jorgefilipecosta.
See #52991.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/typography.php

    r50945 r51089  
    2020    }
    2121
    22     $has_font_size_support       = _wp_array_get( $block_type->supports, array( 'fontSize' ), false );
    23     $has_font_style_support      = _wp_array_get( $block_type->supports, array( '__experimentalFontStyle' ), false );
    24     $has_font_weight_support     = _wp_array_get( $block_type->supports, array( '__experimentalFontWeight' ), false );
    25     $has_line_height_support     = _wp_array_get( $block_type->supports, array( 'lineHeight' ), false );
    26     $has_text_decoration_support = _wp_array_get( $block_type->supports, array( '__experimentalTextDecoration' ), false );
    27     $has_text_transform_support  = _wp_array_get( $block_type->supports, array( '__experimentalTextTransform' ), false );
    28 
    29     $has_typography_support = $has_font_size_support
     22    $typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false );
     23    if ( ! $typography_supports ) {
     24        return;
     25    }
     26
     27    $has_font_family_support     = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false );
     28    $has_font_size_support       = _wp_array_get( $typography_supports, array( 'fontSize' ), false );
     29    $has_font_style_support      = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false );
     30    $has_font_weight_support     = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false );
     31    $has_line_height_support     = _wp_array_get( $typography_supports, array( 'lineHeight' ), false );
     32    $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
     33    $has_text_transform_support  = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );
     34
     35    $has_typography_support = $has_font_family_support
     36        || $has_font_size_support
     37        || $has_font_style_support
    3038        || $has_font_weight_support
    31         || $has_font_style_support
    3239        || $has_line_height_support
    33         || $has_text_transform_support
    34         || $has_text_decoration_support;
     40        || $has_text_decoration_support
     41        || $has_text_transform_support;
    3542
    3643    if ( ! $block_type->attributes ) {
     
    6976    }
    7077
     78    $typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false );
     79    if ( ! $typography_supports ) {
     80        return array();
     81    }
     82
     83    $skip_typography_serialization = _wp_array_get( $typography_supports, array( '__experimentalSkipSerialization' ), false );
     84    if ( $skip_typography_serialization ) {
     85        return array();
     86    }
     87
    7188    $attributes = array();
    7289    $classes    = array();
    7390    $styles     = array();
    7491
    75     $has_font_family_support     = _wp_array_get( $block_type->supports, array( '__experimentalFontFamily' ), false );
    76     $has_font_style_support      = _wp_array_get( $block_type->supports, array( '__experimentalFontStyle' ), false );
    77     $has_font_weight_support     = _wp_array_get( $block_type->supports, array( '__experimentalFontWeight' ), false );
    78     $has_font_size_support       = _wp_array_get( $block_type->supports, array( 'fontSize' ), false );
    79     $has_line_height_support     = _wp_array_get( $block_type->supports, array( 'lineHeight' ), false );
    80     $has_text_decoration_support = _wp_array_get( $block_type->supports, array( '__experimentalTextDecoration' ), false );
    81     $has_text_transform_support  = _wp_array_get( $block_type->supports, array( '__experimentalTextTransform' ), false );
    82 
    83     $skip_font_size_support_serialization = _wp_array_get( $block_type->supports, array( '__experimentalSkipFontSizeSerialization' ), false );
    84 
    85     // Covers all typography features _except_ font size.
    86     $skip_typography_serialization = _wp_array_get( $block_type->supports, array( '__experimentalSkipTypographySerialization' ), false );
    87 
    88     // Font Size.
    89     if ( $has_font_size_support && ! $skip_font_size_support_serialization ) {
     92    $has_font_family_support     = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false );
     93    $has_font_size_support       = _wp_array_get( $typography_supports, array( 'fontSize' ), false );
     94    $has_font_style_support      = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false );
     95    $has_font_weight_support     = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false );
     96    $has_line_height_support     = _wp_array_get( $typography_supports, array( 'lineHeight' ), false );
     97    $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
     98    $has_text_transform_support  = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );
     99
     100    if ( $has_font_size_support ) {
    90101        $has_named_font_size  = array_key_exists( 'fontSize', $block_attributes );
    91102        $has_custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] );
    92103
    93         // Apply required class or style.
    94104        if ( $has_named_font_size ) {
    95105            $classes[] = sprintf( 'has-%s-font-size', $block_attributes['fontSize'] );
     
    99109    }
    100110
    101     // Font Family.
    102     if ( $has_font_family_support && ! $skip_typography_serialization ) {
     111    if ( $has_font_family_support ) {
    103112        $has_font_family = isset( $block_attributes['style']['typography']['fontFamily'] );
    104         // Apply required class and style.
    105113        if ( $has_font_family ) {
    106114            $font_family = $block_attributes['style']['typography']['fontFamily'];
     
    116124    }
    117125
    118     // Font style.
    119     if ( $has_font_style_support && ! $skip_typography_serialization ) {
    120         // Apply font style.
    121         $font_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'fontStyle', 'font-style' );
     126    if ( $has_font_style_support ) {
     127        $font_style = gutenberg_typography_get_css_variable_inline_style( $block_attributes, 'fontStyle', 'font-style' );
    122128        if ( $font_style ) {
    123129            $styles[] = $font_style;
     
    125131    }
    126132
    127     // Font weight.
    128     if ( $has_font_weight_support && ! $skip_typography_serialization ) {
    129         // Apply font weight.
    130         $font_weight = wp_typography_get_css_variable_inline_style( $block_attributes, 'fontWeight', 'font-weight' );
     133    if ( $has_font_weight_support ) {
     134        $font_weight = gutenberg_typography_get_css_variable_inline_style( $block_attributes, 'fontWeight', 'font-weight' );
    131135        if ( $font_weight ) {
    132136            $styles[] = $font_weight;
     
    134138    }
    135139
    136     // Line Height.
    137     if ( $has_line_height_support && ! $skip_typography_serialization ) {
     140    if ( $has_line_height_support ) {
    138141        $has_line_height = isset( $block_attributes['style']['typography']['lineHeight'] );
    139         // Add the style (no classes for line-height).
    140142        if ( $has_line_height ) {
    141143            $styles[] = sprintf( 'line-height: %s;', $block_attributes['style']['typography']['lineHeight'] );
     
    143145    }
    144146
    145     // Text Decoration.
    146     if ( $has_text_decoration_support && ! $skip_typography_serialization ) {
    147         $text_decoration_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'textDecoration', 'text-decoration' );
     147    if ( $has_text_decoration_support ) {
     148        $text_decoration_style = gutenberg_typography_get_css_variable_inline_style( $block_attributes, 'textDecoration', 'text-decoration' );
    148149        if ( $text_decoration_style ) {
    149150            $styles[] = $text_decoration_style;
     
    151152    }
    152153
    153     // Text Transform.
    154     if ( $has_text_transform_support && ! $skip_typography_serialization ) {
    155         $text_transform_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'textTransform', 'text-transform' );
     154    if ( $has_text_transform_support ) {
     155        $text_transform_style = gutenberg_typography_get_css_variable_inline_style( $block_attributes, 'textTransform', 'text-transform' );
    156156        if ( $text_transform_style ) {
    157157            $styles[] = $text_transform_style;
Note: See TracChangeset for help on using the changeset viewer.