PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
← All changes | includes/controls/typography.php +55 -3 2.10.0 → 2.13.0 View file →
@@ -63,9 +63,18 @@
63 63 ]
64 64 ];
65 65 }
66 66
67 - public static function get_css( $attribute_value, $property = '', $device = '', $attribute_global_name = '' ) {
67 + /**
68 + * @param mixed $attribute_value Stored typography object.
69 + * @param string $property Unused legacy argument.
70 + * @param string $device Device suffix.
71 + * @param string $attribute_global_name Global typography id, if any.
72 + * @param bool $expand_font_stack Whether to turn the stored family into
73 + * a full stack. The atomic compiler must
74 + * pass false — see below.
75 + */
76 + public static function get_css( $attribute_value, $property = '', $device = '', $attribute_global_name = '', $expand_font_stack = true ) {
68 77 $global_value = [];
69 78 if ( $attribute_global_name ) {
70 79 $global_typography = wp_list_pluck( \Ablocks\Helper::get_settings( 'global_typography', [] ), 'value', 'id' );
71 80 $global_value = ( isset( $global_typography[ $attribute_global_name ] ) ? (array) $global_typography[ $attribute_global_name ] : [] );
@@ -87,17 +96,36 @@
87 96 $css[ $prop ] = $local_unit ? $local_val . $local_unit : $local_val;
88 97 }
89 98 };
90 99
91 - // Font family (special: also track font weights for enqueue)
92 100 // Font family. Output the CSS value only — font *discovery* is no longer
93 101 // done at render time. The set of fonts a page uses is collected from
94 102 // saved block attributes (FontCollector) and emitted by core via
95 103 // theme.json (CoreFontRegistry). See docs/FONT-MANAGEMENT-PLAN.md.
104 + //
105 + // The stored attribute is a bare family name (that name doubles as the
106 + // download key), so FontStack turns it into a real stack — quoted, with a
107 + // metric-adjusted fallback face and a generic tail derived from the font's
108 + // own category. There is no per-block fallback field: `fontFallback` is
109 + // read only so a value set through a filter still wins.
96 110 if ( ! empty( $global_value['fontFamily'] ) ) {
97 111 $css['font-family'] = "var(--ablocks-{$attribute_global_name}-font-family)";
98 112 } elseif ( ! empty( $value['fontFamily'] ) ) {
99 - $css['font-family'] = $value['fontFamily'];
113 + // A stored family becomes a full stack everywhere EXCEPT the atomic
114 + // compiler, whose declarations are hashed in JS at save time and
115 + // again here at render time and must agree byte for byte. A stack
116 + // cannot take part in that: it depends on the metrics table, the
117 + // `font_metric_fallback` setting and the `ablocks/font_stack`
118 + // filter, none of which the editor can see.
119 + $family = $expand_font_stack
120 + ? \ABlocks\Classes\FontStack::build(
121 + $value['fontFamily'],
122 + isset( $value['fontFallback'] ) ? $value['fontFallback'] : ''
123 + )
124 + : $value['fontFamily'];
125 + if ( '' !== $family ) {
126 + $css['font-family'] = $family;
127 + }
100 128 }
101 129
102 130 // Desktop-only styles
103 131 if ( empty( $device ) ) {
@@ -122,8 +150,32 @@
122 150
123 151 $css_var_name = $css_prop . ( $device ? '-' . strtolower( $device ) : '' );
124 152
125 153 $add_prop( $css_prop, $local_val, $local_unit, $global_key, $css_var_name );
154 + }
155 +
156 + /*
157 + * Columns, direction and text stroke. Appended after the original
158 + * members so anything saved before these existed compiles byte-for-byte
159 + * as it did — for atomic blocks the style class is a hash of this
160 + * output. Desktop-only, like weight/transform/style/decoration above,
161 + * and with no global-typography equivalent to fall back to. Mirrors the
162 + * tail of typographyPairs() in src/blocks/atomic-shared/styles.js.
163 + */
164 + if ( empty( $device ) ) {
165 + if ( isset( $value['columns'] ) && '' !== $value['columns'] ) {
166 + $css['column-count'] = $value['columns'];
167 + }
168 + if ( ! empty( $value['direction'] ) ) {
169 + $css['direction'] = $value['direction'];
170 + }
171 + if ( isset( $value['strokeWidth'] ) && '' !== $value['strokeWidth'] ) {
172 + $stroke_unit = ! empty( $value['strokeWidthUnit'] ) ? $value['strokeWidthUnit'] : 'px';
173 + $css['-webkit-text-stroke-width'] = $value['strokeWidth'] . $stroke_unit;
174 + }
175 + if ( ! empty( $value['strokeColor'] ) ) {
176 + $css['-webkit-text-stroke-color'] = $value['strokeColor'];
177 + }
126 178 }
127 179
128 180 return $css;
129 181 }