@@ -31,6 +31,7 @@ function wp_register_typography_support( $block_type ) {
31
31
$ has_font_weight_support = isset ( $ typography_supports ['__experimentalFontWeight ' ] ) ? $ typography_supports ['__experimentalFontWeight ' ] : false ;
32
32
$ has_letter_spacing_support = isset ( $ typography_supports ['__experimentalLetterSpacing ' ] ) ? $ typography_supports ['__experimentalLetterSpacing ' ] : false ;
33
33
$ has_line_height_support = isset ( $ typography_supports ['lineHeight ' ] ) ? $ typography_supports ['lineHeight ' ] : false ;
34
+ $ has_text_align_support = isset ( $ typography_supports ['textAlign ' ] ) ? $ typography_supports ['textAlign ' ] : false ;
34
35
$ has_text_columns_support = isset ( $ typography_supports ['textColumns ' ] ) ? $ typography_supports ['textColumns ' ] : false ;
35
36
$ has_text_decoration_support = isset ( $ typography_supports ['__experimentalTextDecoration ' ] ) ? $ typography_supports ['__experimentalTextDecoration ' ] : false ;
36
37
$ has_text_transform_support = isset ( $ typography_supports ['__experimentalTextTransform ' ] ) ? $ typography_supports ['__experimentalTextTransform ' ] : false ;
@@ -42,6 +43,7 @@ function wp_register_typography_support( $block_type ) {
42
43
|| $ has_font_weight_support
43
44
|| $ has_letter_spacing_support
44
45
|| $ has_line_height_support
46
+ || $ has_text_align_support
45
47
|| $ has_text_columns_support
46
48
|| $ has_text_decoration_support
47
49
|| $ has_text_transform_support
@@ -106,6 +108,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
106
108
$ has_font_weight_support = isset ( $ typography_supports ['__experimentalFontWeight ' ] ) ? $ typography_supports ['__experimentalFontWeight ' ] : false ;
107
109
$ has_letter_spacing_support = isset ( $ typography_supports ['__experimentalLetterSpacing ' ] ) ? $ typography_supports ['__experimentalLetterSpacing ' ] : false ;
108
110
$ has_line_height_support = isset ( $ typography_supports ['lineHeight ' ] ) ? $ typography_supports ['lineHeight ' ] : false ;
111
+ $ has_text_align_support = isset ( $ typography_supports ['textAlign ' ] ) ? $ typography_supports ['textAlign ' ] : false ;
109
112
$ has_text_columns_support = isset ( $ typography_supports ['textColumns ' ] ) ? $ typography_supports ['textColumns ' ] : false ;
110
113
$ has_text_decoration_support = isset ( $ typography_supports ['__experimentalTextDecoration ' ] ) ? $ typography_supports ['__experimentalTextDecoration ' ] : false ;
111
114
$ has_text_transform_support = isset ( $ typography_supports ['__experimentalTextTransform ' ] ) ? $ typography_supports ['__experimentalTextTransform ' ] : false ;
@@ -117,6 +120,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
117
120
$ should_skip_font_style = wp_should_skip_block_supports_serialization ( $ block_type , 'typography ' , 'fontStyle ' );
118
121
$ should_skip_font_weight = wp_should_skip_block_supports_serialization ( $ block_type , 'typography ' , 'fontWeight ' );
119
122
$ should_skip_line_height = wp_should_skip_block_supports_serialization ( $ block_type , 'typography ' , 'lineHeight ' );
123
+ $ should_skip_text_align = wp_should_skip_block_supports_serialization ( $ block_type , 'typography ' , 'textAlign ' );
120
124
$ should_skip_text_columns = wp_should_skip_block_supports_serialization ( $ block_type , 'typography ' , 'textColumns ' );
121
125
$ should_skip_text_decoration = wp_should_skip_block_supports_serialization ( $ block_type , 'typography ' , 'textDecoration ' );
122
126
$ should_skip_text_transform = wp_should_skip_block_supports_serialization ( $ block_type , 'typography ' , 'textTransform ' );
@@ -176,6 +180,12 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
176
180
: null ;
177
181
}
178
182
183
+ if ( $ has_text_align_support && ! $ should_skip_text_align ) {
184
+ $ typography_block_styles ['textAlign ' ] = isset ( $ block_attributes ['style ' ]['typography ' ]['textAlign ' ] )
185
+ ? $ block_attributes ['style ' ]['typography ' ]['textAlign ' ]
186
+ : null ;
187
+ }
188
+
179
189
if ( $ has_text_columns_support && ! $ should_skip_text_columns && isset ( $ block_attributes ['style ' ]['typography ' ]['textColumns ' ] ) ) {
180
190
$ typography_block_styles ['textColumns ' ] = isset ( $ block_attributes ['style ' ]['typography ' ]['textColumns ' ] )
181
191
? $ block_attributes ['style ' ]['typography ' ]['textColumns ' ]
@@ -225,13 +235,22 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
225
235
}
226
236
227
237
$ attributes = array ();
238
+ $ classnames = array ();
228
239
$ styles = wp_style_engine_get_styles (
229
240
array ( 'typography ' => $ typography_block_styles ),
230
241
array ( 'convert_vars_to_classnames ' => true )
231
242
);
232
243
233
244
if ( ! empty ( $ styles ['classnames ' ] ) ) {
234
- $ attributes ['class ' ] = $ styles ['classnames ' ];
245
+ $ classnames [] = $ styles ['classnames ' ];
246
+ }
247
+
248
+ if ( $ has_text_align_support && ! $ should_skip_text_align && isset ( $ block_attributes ['style ' ]['typography ' ]['textAlign ' ] ) ) {
249
+ $ classnames [] = 'has-text-align- ' . $ block_attributes ['style ' ]['typography ' ]['textAlign ' ];
250
+ }
251
+
252
+ if ( ! empty ( $ classnames ) ) {
253
+ $ attributes ['class ' ] = implode ( ' ' , $ classnames );
235
254
}
236
255
237
256
if ( ! empty ( $ styles ['css ' ] ) ) {
0 commit comments