Merged in feature/81-dev-dev01 (pull request #5)
auto-patch 81-dev-dev01-2023-12-05T22_45_26 * auto-patch 81-dev-dev01-2023-12-05T22_45_26
This commit is contained in:
@@ -16,24 +16,25 @@
|
||||
* @param WP_Block_Type $block_type Block Type.
|
||||
*/
|
||||
function wp_register_typography_support( $block_type ) {
|
||||
if ( ! property_exists( $block_type, 'supports' ) ) {
|
||||
if ( ! ( $block_type instanceof WP_Block_Type ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false );
|
||||
$typography_supports = isset( $block_type->supports['typography'] ) ? $block_type->supports['typography'] : false;
|
||||
if ( ! $typography_supports ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false );
|
||||
$has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false );
|
||||
$has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false );
|
||||
$has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false );
|
||||
$has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false );
|
||||
$has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false );
|
||||
$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_font_family_support = isset( $typography_supports['__experimentalFontFamily'] ) ? $typography_supports['__experimentalFontFamily'] : false;
|
||||
$has_font_size_support = isset( $typography_supports['fontSize'] ) ? $typography_supports['fontSize'] : false;
|
||||
$has_font_style_support = isset( $typography_supports['__experimentalFontStyle'] ) ? $typography_supports['__experimentalFontStyle'] : false;
|
||||
$has_font_weight_support = isset( $typography_supports['__experimentalFontWeight'] ) ? $typography_supports['__experimentalFontWeight'] : false;
|
||||
$has_letter_spacing_support = isset( $typography_supports['__experimentalLetterSpacing'] ) ? $typography_supports['__experimentalLetterSpacing'] : false;
|
||||
$has_line_height_support = isset( $typography_supports['lineHeight'] ) ? $typography_supports['lineHeight'] : false;
|
||||
$has_text_columns_support = isset( $typography_supports['textColumns'] ) ? $typography_supports['textColumns'] : false;
|
||||
$has_text_decoration_support = isset( $typography_supports['__experimentalTextDecoration'] ) ? $typography_supports['__experimentalTextDecoration'] : false;
|
||||
$has_text_transform_support = isset( $typography_supports['__experimentalTextTransform'] ) ? $typography_supports['__experimentalTextTransform'] : false;
|
||||
$has_writing_mode_support = isset( $typography_supports['__experimentalWritingMode'] ) ? $typography_supports['__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();
|
||||
@@ -83,11 +85,13 @@ function wp_register_typography_support( $block_type ) {
|
||||
* @return array Typography CSS classes and inline styles.
|
||||
*/
|
||||
function wp_apply_typography_support( $block_type, $block_attributes ) {
|
||||
if ( ! property_exists( $block_type, 'supports' ) ) {
|
||||
if ( ! ( $block_type instanceof WP_Block_Type ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false );
|
||||
$typography_supports = isset( $block_type->supports['typography'] )
|
||||
? $block_type->supports['typography']
|
||||
: false;
|
||||
if ( ! $typography_supports ) {
|
||||
return array();
|
||||
}
|
||||
@@ -96,15 +100,16 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false );
|
||||
$has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false );
|
||||
$has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false );
|
||||
$has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false );
|
||||
$has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false );
|
||||
$has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false );
|
||||
$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_font_family_support = isset( $typography_supports['__experimentalFontFamily'] ) ? $typography_supports['__experimentalFontFamily'] : false;
|
||||
$has_font_size_support = isset( $typography_supports['fontSize'] ) ? $typography_supports['fontSize'] : false;
|
||||
$has_font_style_support = isset( $typography_supports['__experimentalFontStyle'] ) ? $typography_supports['__experimentalFontStyle'] : false;
|
||||
$has_font_weight_support = isset( $typography_supports['__experimentalFontWeight'] ) ? $typography_supports['__experimentalFontWeight'] : false;
|
||||
$has_letter_spacing_support = isset( $typography_supports['__experimentalLetterSpacing'] ) ? $typography_supports['__experimentalLetterSpacing'] : false;
|
||||
$has_line_height_support = isset( $typography_supports['lineHeight'] ) ? $typography_supports['lineHeight'] : false;
|
||||
$has_text_columns_support = isset( $typography_supports['textColumns'] ) ? $typography_supports['textColumns'] : false;
|
||||
$has_text_decoration_support = isset( $typography_supports['__experimentalTextDecoration'] ) ? $typography_supports['__experimentalTextDecoration'] : false;
|
||||
$has_text_transform_support = isset( $typography_supports['__experimentalTextTransform'] ) ? $typography_supports['__experimentalTextTransform'] : false;
|
||||
$has_writing_mode_support = isset( $typography_supports['__experimentalWritingMode'] ) ? $typography_supports['__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 +121,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 ) {
|
||||
@@ -165,11 +171,15 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
|
||||
}
|
||||
|
||||
if ( $has_line_height_support && ! $should_skip_line_height ) {
|
||||
$typography_block_styles['lineHeight'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'lineHeight' ) );
|
||||
$typography_block_styles['lineHeight'] = isset( $block_attributes['style']['typography']['lineHeight'] )
|
||||
? $block_attributes['style']['typography']['lineHeight']
|
||||
: null;
|
||||
}
|
||||
|
||||
if ( $has_text_columns_support && ! $should_skip_text_columns && isset( $block_attributes['style']['typography']['textColumns'] ) ) {
|
||||
$typography_block_styles['textColumns'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'textColumns' ), null );
|
||||
$typography_block_styles['textColumns'] = isset( $block_attributes['style']['typography']['textColumns'] )
|
||||
? $block_attributes['style']['typography']['textColumns']
|
||||
: null;
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -205,6 +215,15 @@ 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'] = isset( $block_attributes['style']['typography']['writingMode'] )
|
||||
? $block_attributes['style']['typography']['writingMode']
|
||||
: null;
|
||||
}
|
||||
|
||||
$attributes = array();
|
||||
$styles = wp_style_engine_get_styles(
|
||||
array( 'typography' => $typography_block_styles ),
|
||||
@@ -471,6 +490,7 @@ function wp_get_computed_fluid_typography_value( $args = array() ) {
|
||||
* @since 6.1.1 Adjusted rules for min and max font sizes.
|
||||
* @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support.
|
||||
* @since 6.3.0 Using layout.wideSize as max viewport width, and logarithmic scale factor to calculate minimum font scale.
|
||||
* @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema.
|
||||
*
|
||||
* @param array $preset {
|
||||
* Required. fontSizes preset value as seen in theme.json.
|
||||
@@ -517,14 +537,21 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
|
||||
: array();
|
||||
|
||||
// Defaults.
|
||||
$default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : '1600px';
|
||||
$default_maximum_viewport_width = '1600px';
|
||||
$default_minimum_viewport_width = '320px';
|
||||
$default_minimum_font_size_factor_max = 0.75;
|
||||
$default_minimum_font_size_factor_min = 0.25;
|
||||
$default_scale_factor = 1;
|
||||
$has_min_font_size = isset( $fluid_settings['minFontSize'] ) &&
|
||||
! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
|
||||
$default_minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px';
|
||||
$default_minimum_font_size_limit = '14px';
|
||||
|
||||
// Defaults overrides.
|
||||
$minimum_viewport_width = isset( $fluid_settings['minViewportWidth'] ) ? $fluid_settings['minViewportWidth'] : $default_minimum_viewport_width;
|
||||
$maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( wp_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : $default_maximum_viewport_width;
|
||||
if ( isset( $fluid_settings['maxViewportWidth'] ) ) {
|
||||
$maximum_viewport_width = $fluid_settings['maxViewportWidth'];
|
||||
}
|
||||
$has_min_font_size = isset( $fluid_settings['minFontSize'] ) && ! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
|
||||
$minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : $default_minimum_font_size_limit;
|
||||
|
||||
// Font sizes.
|
||||
$fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;
|
||||
@@ -551,7 +578,7 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
|
||||
* in order to perform comparative checks.
|
||||
*/
|
||||
$minimum_font_size_limit = wp_get_typography_value_and_unit(
|
||||
$default_minimum_font_size_limit,
|
||||
$minimum_font_size_limit,
|
||||
array(
|
||||
'coerce_to' => $preferred_size['unit'],
|
||||
)
|
||||
@@ -600,8 +627,8 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
|
||||
|
||||
$fluid_font_size_value = wp_get_computed_fluid_typography_value(
|
||||
array(
|
||||
'minimum_viewport_width' => $default_minimum_viewport_width,
|
||||
'maximum_viewport_width' => $default_maximum_viewport_width,
|
||||
'minimum_viewport_width' => $minimum_viewport_width,
|
||||
'maximum_viewport_width' => $maximum_viewport_width,
|
||||
'minimum_font_size' => $minimum_font_size_raw,
|
||||
'maximum_font_size' => $maximum_font_size_raw,
|
||||
'scale_factor' => $default_scale_factor,
|
||||
|
||||
Reference in New Issue
Block a user