PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.1
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 1.1.2 All 80 releases
← All changes | includes/classes/global-css-generator.php +11 -34 2.9.02.13.1 View file →
@@ -5,13 +5,13 @@
5 5 exit;
6 6 }
7 7
8 8 use ABlocks\Classes\AssetsGenerator;
9 +use ABlocks\Classes\FontStack;
9 10 use ABlocks\Controls\Typography;
10 11 use ABlocks\Controls\Range;
11 12
12 13 class GlobalCssGenerator {
13 - private $font_category;
14 14 private $custom_css = '';
15 15 private $parent_class;
16 16 private $class_styles = [];
17 17
@@ -19,9 +19,8 @@
19 19 $this->parent_class = '';
20 20 if ( isset( $attributes['_custom_css'] ) ) {
21 21 $this->custom_css = $attributes['_custom_css'];
22 22 }
23 - $this->font_category = include ABLOCKS_BLOCKS_DIR_PATH . 'fonts.php';
24 23 }
25 24
26 25 public function add_class_styles( $class_name, $desktop_styles, $tablet_styles = [], $mobile_styles = [] ) {
27 26 $this->class_styles[] = [
@@ -98,13 +97,14 @@
98 97 return $css_string . "\n";
99 98 }
100 99
101 100 public function get_breakpoint( $media_query ) {
101 + $bp = \ABlocks\Helper::get_breakpoints();
102 102 switch ( $media_query ) {
103 103 case 'tablet':
104 - return '800px';
104 + return $bp['tablet'] . 'px';
105 105 case 'mobile':
106 - return '480px';
106 + return $bp['mobile'] . 'px';
107 107 default:
108 108 return '1200px';
109 109 }
110 110 }
@@ -119,10 +119,12 @@
119 119
120 120 $styles = [];
121 121
122 122 foreach ( $base_styles as $prop => $value ) {
123 - if ( 'font-family' === $prop && isset( $this->font_category[ $value ] ) ) {
124 - $value = $this->get_font_family_css( $value, $this->font_category[ $value ] );
123 + if ( 'font-family' === $prop ) {
124 + // Safety net for styles that bypass the Typography control and set a
125 + // bare family name directly. FontStack leaves finished values alone.
126 + $value = FontStack::build( $value );
125 127 }
126 128 // Trim value to avoid whitespace-only entries
127 129 $trimmed = trim( $value );
128 130 // // Remove if empty, or if it matches only a unit (like 'px', '%', 'em') without any number
@@ -159,36 +161,11 @@
159 161 return $difference;
160 162 }
161 163
162 164
163 - public function get_font_family_css( string $font_name, string $category ): string {
164 - // Quote font name if it contains spaces
165 - if ( strpos( $font_name, ' ' ) !== false ) {
166 - $font_name = '"' . $font_name . '"';
167 - }
168 -
169 - // Map category to fallback
170 - switch ( $category ) {
171 - case 'serif':
172 - $fallback = 'serif';
173 - break;
174 - case 'sans-serif':
175 - $fallback = 'sans-serif';
176 - break;
177 - case 'monospace':
178 - $fallback = 'monospace';
179 - break;
180 - case 'display':
181 - $fallback = 'sans-serif';
182 - break;
183 - case 'handwriting':
184 - $fallback = 'cursive';
185 - break;
186 - default:
187 - $fallback = 'sans-serif';
188 - }
189 -
190 - return $font_name . ', ' . $fallback;
165 + public function get_font_family_css( string $font_name, string $category = '' ): string {
166 + // Kept for back-compat; the stack is built centrally now.
167 + return FontStack::build( $font_name );
191 168 }
192 169
193 170
194 171 // Global CSS necessary method