Changeset 51089 for trunk/src/wp-includes/block-supports/typography.php
- Timestamp:
- 06/08/2021 08:07:15 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/typography.php
r50945 r51089 20 20 } 21 21 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 30 38 || $has_font_weight_support 31 || $has_font_style_support32 39 || $has_line_height_support 33 || $has_text_ transform_support34 || $has_text_ decoration_support;40 || $has_text_decoration_support 41 || $has_text_transform_support; 35 42 36 43 if ( ! $block_type->attributes ) { … … 69 76 } 70 77 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 71 88 $attributes = array(); 72 89 $classes = array(); 73 90 $styles = array(); 74 91 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 ) { 90 101 $has_named_font_size = array_key_exists( 'fontSize', $block_attributes ); 91 102 $has_custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] ); 92 103 93 // Apply required class or style.94 104 if ( $has_named_font_size ) { 95 105 $classes[] = sprintf( 'has-%s-font-size', $block_attributes['fontSize'] ); … … 99 109 } 100 110 101 // Font Family. 102 if ( $has_font_family_support && ! $skip_typography_serialization ) { 111 if ( $has_font_family_support ) { 103 112 $has_font_family = isset( $block_attributes['style']['typography']['fontFamily'] ); 104 // Apply required class and style.105 113 if ( $has_font_family ) { 106 114 $font_family = $block_attributes['style']['typography']['fontFamily']; … … 116 124 } 117 125 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' ); 122 128 if ( $font_style ) { 123 129 $styles[] = $font_style; … … 125 131 } 126 132 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' ); 131 135 if ( $font_weight ) { 132 136 $styles[] = $font_weight; … … 134 138 } 135 139 136 // Line Height. 137 if ( $has_line_height_support && ! $skip_typography_serialization ) { 140 if ( $has_line_height_support ) { 138 141 $has_line_height = isset( $block_attributes['style']['typography']['lineHeight'] ); 139 // Add the style (no classes for line-height).140 142 if ( $has_line_height ) { 141 143 $styles[] = sprintf( 'line-height: %s;', $block_attributes['style']['typography']['lineHeight'] ); … … 143 145 } 144 146 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' ); 148 149 if ( $text_decoration_style ) { 149 150 $styles[] = $text_decoration_style; … … 151 152 } 152 153 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' ); 156 156 if ( $text_transform_style ) { 157 157 $styles[] = $text_transform_style;
Note: See TracChangeset
for help on using the changeset viewer.