From df3137aca1888b428a32f358ab97a78e542764e1 Mon Sep 17 00:00:00 2001 From: isabel_brison Date: Mon, 18 Sep 2023 06:49:20 +0000 Subject: [PATCH] Editor: add text orientation for blocks with typography support. Adds a new text orientation option to the typography block support, implemented with CSS writing-mode. Props poena. Fixes #59306. Built from https://develop.svn.wordpress.org/trunk@56605 git-svn-id: http://core.svn.wordpress.org/trunk@56117 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-supports/typography.php | 17 ++++++++++++++++- wp-includes/class-wp-theme-json.php | 6 +++++- wp-includes/theme.json | 3 ++- wp-includes/version.php | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/wp-includes/block-supports/typography.php b/wp-includes/block-supports/typography.php index b31464c12d..f1a69572a0 100644 --- a/wp-includes/block-supports/typography.php +++ b/wp-includes/block-supports/typography.php @@ -34,6 +34,7 @@ function wp_register_typography_support( $block_type ) { $has_text_columns_support = _wp_array_get( $typography_supports, array( 'textColumns' ), false ); $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false ); $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false ); + $has_writing_mode_support = _wp_array_get( $typography_supports, array( '__experimentalWritingMode' ), false ); $has_typography_support = $has_font_family_support || $has_font_size_support @@ -43,7 +44,8 @@ function wp_register_typography_support( $block_type ) { || $has_line_height_support || $has_text_columns_support || $has_text_decoration_support - || $has_text_transform_support; + || $has_text_transform_support + || $has_writing_mode_support; if ( ! $block_type->attributes ) { $block_type->attributes = array(); @@ -105,6 +107,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) { $has_text_columns_support = _wp_array_get( $typography_supports, array( 'textColumns' ), false ); $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false ); $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false ); + $has_writing_mode_support = _wp_array_get( $typography_supports, array( '__experimentalWritingMode' ), false ); // Whether to skip individual block support features. $should_skip_font_size = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontSize' ); @@ -116,6 +119,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) { $should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' ); $should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' ); $should_skip_letter_spacing = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' ); + $should_skip_writing_mode = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'writingMode' ); $typography_block_styles = array(); if ( $has_font_size_support && ! $should_skip_font_size ) { @@ -205,6 +209,17 @@ function wp_apply_typography_support( $block_type, $block_attributes ) { ); } + if ( $has_writing_mode_support && + ! $should_skip_writing_mode && + isset( $block_attributes['style']['typography']['writingMode'] ) + ) { + $typography_block_styles['writingMode'] = _wp_array_get( + $block_attributes, + array( 'style', 'typography', 'writingMode' ), + null + ); + } + $attributes = array(); $styles = wp_style_engine_get_styles( array( 'typography' => $typography_block_styles ), diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index 95cbac23c3..14a2d80408 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -203,6 +203,7 @@ class WP_Theme_JSON { * removed the `--wp--style--block-gap` property. * @since 6.2.0 Added `outline-*`, and `min-height` properties. * @since 6.3.0 Added `column-count` property. + * @since 6.4.0 Added `writing-mode` property. * * @var array */ @@ -261,6 +262,7 @@ class WP_Theme_JSON { 'text-transform' => array( 'typography', 'textTransform' ), 'filter' => array( 'filter', 'duotone' ), 'box-shadow' => array( 'shadow' ), + 'writing-mode' => array( 'typography', 'writingMode' ), ); /** @@ -340,7 +342,7 @@ class WP_Theme_JSON { * @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', 'shadow.defaultPresets', * `position.fixed` and `position.sticky`. * @since 6.3.0 Added support for `typography.textColumns`, removed `layout.definitions`. - * @since 6.4.0 Added `layout.allowEditing`. + * @since 6.4.0 Added `layout.allowEditing` and `typography.writingMode`. * * @var array */ @@ -409,6 +411,7 @@ class WP_Theme_JSON { 'textColumns' => null, 'textDecoration' => null, 'textTransform' => null, + 'writingMode' => null, ), ); @@ -471,6 +474,7 @@ class WP_Theme_JSON { 'textColumns' => null, 'textDecoration' => null, 'textTransform' => null, + 'writingMode' => null, ), 'css' => null, ); diff --git a/wp-includes/theme.json b/wp-includes/theme.json index fd116a42ba..e209d947d1 100644 --- a/wp-includes/theme.json +++ b/wp-includes/theme.json @@ -263,7 +263,8 @@ "letterSpacing": true, "lineHeight": false, "textDecoration": true, - "textTransform": true + "textTransform": true, + "writingMode": false }, "blocks": { "core/button": { diff --git a/wp-includes/version.php b/wp-includes/version.php index 3dc32d286e..33f424d32a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56604'; +$wp_version = '6.4-alpha-56605'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.