PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.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/blocks/price-menu/block.php +115 -44 2.9.1 → 2.14.0 View file →
@@ -1,9 +1,14 @@
1 1 <?php
2 2 namespace ABlocks\Blocks\PriceMenu;
3 3
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
4 8 use ABlocks\Classes\BlockBaseAbstract;
5 9 use ABlocks\Classes\CssGenerator;
10 +use ABlocks\Classes\CssGeneratorV2;
6 11 use ABlocks\Controls\Alignment;
7 12 use ABlocks\Controls\Border;
8 13 use ABlocks\Controls\Dimensions;
9 14 use ABlocks\Controls\Typography;
@@ -9,13 +14,13 @@
9 14 use ABlocks\Controls\Typography;
10 15 use ABlocks\Controls\TextShadow;
11 16 use ABlocks\Controls\TextStroke;
12 17 use ABlocks\Controls\Range;
13 -
18 +use ABlocks\Controls\Color;
14 19 class Block extends BlockBaseAbstract {
15 20 protected $block_name = 'price-menu';
16 21
17 - public function build_css( $attributes ) {
22 + public function build_css_v1( $attributes ) {
18 23
19 24 $css_generator = new CssGenerator( $attributes, $this->block_name );
20 25
21 26 $css_generator->add_class_styles(
@@ -86,20 +91,106 @@
86 91 );
87 92
88 93 return $css_generator->generate_css();
89 94 }
95 + public function build_css_v2( $attributes ) {
90 96
97 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
98 +
99 + $css_generator->add_class_styles(
100 + '{{WRAPPER}}:not(.ablocks-has-block-container), {{WRAPPER}}.ablocks-block--price-menu > .ablocks-block-container',
101 + $this->get_all_menu_css( $attributes, '' ),
102 + $this->get_all_menu_css( $attributes, 'Tablet' ),
103 + $this->get_all_menu_css( $attributes, 'Mobile' ),
104 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_all_menu_css( $attributes, $device ); } )
105 + );
106 + $css_generator->add_class_styles(
107 + '{{WRAPPER}} .ablocks-price-menu-item, {{WRAPPER}} .ablocks-price-menu-item-details',
108 + $this->get_gap_around_css( $attributes, '' ),
109 + $this->get_gap_around_css( $attributes, 'Tablet' ),
110 + $this->get_gap_around_css( $attributes, 'Mobile' ),
111 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_gap_around_css( $attributes, $device ); } )
112 + );
113 + $css_generator->add_class_styles(
114 + '{{WRAPPER}} .ablocks-price-menu-item-details-brief',
115 + $this->get_details_brief_css( $attributes, '' ),
116 + $this->get_details_brief_css( $attributes, 'Tablet' ),
117 + $this->get_details_brief_css( $attributes, 'Mobile' ),
118 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_details_brief_css( $attributes, $device ); } )
119 + );
120 + $css_generator->add_class_styles(
121 + '{{WRAPPER}} .ablocks-block--price-menu-item',
122 + $this->get_item_css( $attributes, '' ),
123 + $this->get_item_css( $attributes, 'Tablet' ),
124 + $this->get_item_css( $attributes, 'Mobile' ),
125 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_item_css( $attributes, $device ); } )
126 + );
127 + $css_generator->add_class_styles(
128 + '{{WRAPPER}} .ablocks-block--price-menu-item:hover',
129 + $this->get_item_hover_css( $attributes, '' ),
130 + $this->get_item_hover_css( $attributes, 'Tablet' ),
131 + $this->get_item_hover_css( $attributes, 'Mobile' ),
132 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_item_hover_css( $attributes, $device ); } )
133 + );
134 +
135 + $css_generator->add_class_styles(
136 + '{{WRAPPER}} .ablocks-price-menu-item',
137 + $this->get_inner_item_css( $attributes, '' ),
138 + $this->get_inner_item_css( $attributes, 'Tablet' ),
139 + $this->get_inner_item_css( $attributes, 'Mobile' ),
140 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_inner_item_css( $attributes, $device ); } )
141 + );
142 +
143 + // TitleText CSS
144 + $css_generator->add_class_styles(
145 + '{{WRAPPER}} .ablocks-price-menu-item-details-title',
146 + $this->get_title_text_css( $attributes, '' ),
147 + $this->get_title_text_css( $attributes, 'Tablet' ),
148 + $this->get_title_text_css( $attributes, 'Mobile' ),
149 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_title_text_css( $attributes, $device ); } )
150 + );
151 + // DescriptionText CSS
152 + $css_generator->add_class_styles(
153 + '{{WRAPPER}} .ablocks-price-menu-item-details-des',
154 + $this->get_description_text_css( $attributes, '' ),
155 + $this->get_description_text_css( $attributes, 'Tablet' ),
156 + $this->get_description_text_css( $attributes, 'Mobile' ),
157 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_description_text_css( $attributes, $device ); } )
158 + );
159 + // SeparatorText CSS
160 + $css_generator->add_class_styles(
161 + '{{WRAPPER}} .ablocks-price-menu-divider__pattern-' . ( $attributes['dividerType'] === 'mask-style' ? 'mask' : 'css' ),
162 + $this->get_divider_css( $attributes, '' ),
163 + $this->get_divider_css( $attributes, 'Tablet' ),
164 + $this->get_divider_css( $attributes, 'Mobile' ),
165 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_divider_css( $attributes, $device ); } )
166 + );
167 + // PriceText CSS
168 + $css_generator->add_class_styles(
169 + '{{WRAPPER}} .ablocks-price-menu-item-price',
170 + $this->get_price_text_css( $attributes, '' ),
171 + $this->get_price_text_css( $attributes, 'Tablet' ),
172 + $this->get_price_text_css( $attributes, 'Mobile' ),
173 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_price_text_css( $attributes, $device ); } )
174 + );
175 +
176 + return $css_generator->generate_css();
177 + }
178 + public function build_css( $attributes ) {
179 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
180 + return $this->build_css_v2( $attributes );
181 + }
182 + return $this->build_css_v1( $attributes );
183 + }
184 +
91 185 public function get_item_css( $attributes, $device = '' ) {
92 186 $css = [];
93 187
94 - if ( isset( $attributes['transition'] ) ) {
188 + if ( ! empty( $attributes['transition'] ) ) {
95 189 $css['transition-duration'] = $attributes['transition'] . 's';
96 190 }
97 -
98 - if ( isset( $attributes['itemBackground'] ) ) {
99 - $css['background'] = $attributes['itemBackground'];
100 - }
101 191 return array_merge(
192 + [ 'background' => Color::get_css( isset( $attributes['itemBackground'] ) ? $attributes['itemBackground'] : '' ) ],
102 193 $css,
103 194 isset( $attributes['alignment'] ) ? Alignment::get_css( $attributes['alignment'], 'justify-content', $device ) : [],
104 195 isset( $attributes['itemBorder'] ) ? Border::get_css( $attributes['itemBorder'], '', $device ) : [],
105 196 isset( $attributes['itemPadding'] ) ? Dimensions::get_css( $attributes['itemPadding'], 'padding', $device ) : [],
@@ -106,14 +197,10 @@
106 197 );
107 198 }
108 199
109 200 public function get_item_hover_css( $attributes, $device = '' ) {
110 - $css = [];
111 - if ( isset( $attributes['itemBackgroundH'] ) ) {
112 - $css['background'] = $attributes['itemBackgroundH'];
113 - }
114 201 return array_merge(
115 - $css,
202 + [ 'background' => Color::get_css( isset( $attributes['itemBackgroundH'] ) ? $attributes['itemBackgroundH'] : '' ) ],
116 203 isset( $attributes['itemBorder'] ) ? Border::get_hover_css( $attributes['itemBorder'], '', $device ) : [],
117 204 );
118 205 }
119 206
@@ -177,10 +264,15 @@
177 264 );
178 265 }
179 266
180 267 public function get_all_menu_css( $attributes, $device = '' ) {
268 + $css = [];
269 + $css['display'] = 'flex';
270 + $css['flex-wrap'] = 'wrap';
271 + $css['flex-direction'] = 'column';
181 272
182 273 return array_merge(
274 + $css,
183 275 Range::get_css([
184 276 'attributeValue' => $attributes['columnGap'],
185 277 'attribute_object_key' => 'value',
186 278 'isResponsive' => true,
@@ -193,18 +285,12 @@
193 285 );
194 286 }
195 287
196 288 public function get_title_text_css( $attributes, $device = '' ) {
197 - $css = [];
198 - $title_color = isset( $attributes['titleColor'] ) ? $attributes['titleColor'] : '';
199 -
200 - if ( isset( $attributes['titleColor'] ) ) {
201 - $css['color'] = $title_color;
202 - }
203 -
289 + $typographyValueGlobal = ! empty( $attributes['titleTypographyGlobal'] ) ? $attributes['titleTypographyGlobal'] : array();
204 290 return array_merge(
205 - $css,
206 - isset( $attributes['titleTypography'] ) ? Typography::get_css( $attributes['titleTypography'], '', $device ) : [],
291 + [ 'color' => Color::get_css( isset( $attributes['titleColor'] ) ? $attributes['titleColor'] : '' ) ],
292 + isset( $attributes['titleTypography'] ) ? Typography::get_css( $attributes['titleTypography'], '', $device, $typographyValueGlobal ) : [],
207 293 isset( $attributes['titleTextStroke'] ) ? TextStroke::get_css( $attributes['titleTextStroke'], '', $device ) : [],
208 294 isset( $attributes['titleTextShadow'] ) ? TextShadow::get_css( $attributes['titleTextShadow'], '', $device ) : [],
209 295 isset( $attributes['titleAlignment'] ) ? Alignment::get_css( $attributes['titleAlignment'], 'text-align', $device ) : [],
210 296 );
@@ -209,18 +295,12 @@
209 295 isset( $attributes['titleAlignment'] ) ? Alignment::get_css( $attributes['titleAlignment'], 'text-align', $device ) : [],
210 296 );
211 297 }
212 298 public function get_description_text_css( $attributes, $device = '' ) {
213 - $css = [];
214 - $description_color = isset( $attributes['descriptionColor'] ) ? $attributes['descriptionColor'] : '';
215 -
216 - if ( isset( $attributes['descriptionColor'] ) && isset( $attributes['descriptionColor'] ) ) {
217 - $css['color'] = $description_color;
218 - }
219 -
299 + $typographyValueGlobal = ! empty( $attributes['descriptionTypographyGlobal'] ) ? $attributes['descriptionTypographyGlobal'] : array();
220 300 return array_merge(
221 - $css,
222 - isset( $attributes['descriptionTypography'] ) ? Typography::get_css( $attributes['descriptionTypography'], '', $device ) : [],
301 + [ 'color' => Color::get_css( isset( $attributes['descriptionColor'] ) ? $attributes['descriptionColor'] : '' ) ],
302 + isset( $attributes['descriptionTypography'] ) ? Typography::get_css( $attributes['descriptionTypography'], '', $device, $typographyValueGlobal ) : [],
223 303 isset( $attributes['descriptionTextStroke'] ) ? TextStroke::get_css( $attributes['descriptionTextStroke'], '', $device ) : [],
224 304 isset( $attributes['descriptionTextShadow'] ) ? TextShadow::get_css( $attributes['descriptionTextShadow'], '', $device ) : [],
225 305 isset( $attributes['descriptionAlignment'] ) ? Alignment::get_css( $attributes['descriptionAlignment'], 'text-align', $device ) : [],
226 306 );
@@ -227,15 +307,12 @@
227 307 }
228 308 public function get_divider_css( $attributes, $device = '' ) {
229 309 $css = [];
230 310 $divider_width = isset( $attributes['width'][ 'value' . $device ] ) ? $attributes['width'][ 'value' . $device ] : 60;
231 - $divider_color = isset( $attributes['color'] ) ? $attributes['color'] : '#000000';
232 311 $default_Unit = $attributes['allowDescription'] === true ? '%' : 'px';
312 + $css['--ablocks-divider-pattern-color'] = Color::get_css(
313 + isset( $attributes['color'] ) ? $attributes['color'] : '#000000');
233 314
234 - if ( isset( $attributes['color'] ) && ! empty( $attributes['color'] ) ) {
235 - $css['--ablocks-divider-pattern-color'] = $divider_color;
236 - }
237 -
238 315 $moreRangeCSS = [];
239 316 if ( isset( $attributes['dividerType'] ) && $attributes['dividerType'] === 'mask-style' && isset( $attributes['size'] ) && ! empty( $attributes['size'] ) ) {
240 317 $moreRangeCSS = Range::get_css([
241 318 'attributeValue' => $attributes['size'],
@@ -281,18 +358,12 @@
281 358 $moreRangeCSS,
282 359 );
283 360 }
284 361 public function get_price_text_css( $attributes, $device = '' ) {
285 - $css = [];
286 - $price_color = isset( $attributes['priceColor'] ) ? $attributes['priceColor'] : '';
287 -
288 - if ( isset( $attributes['priceColor'] ) ) {
289 - $css['color'] = $price_color;
290 - }
291 -
362 + $typographyValueGlobal = ! empty( $attributes['priceTypographyGlobal'] ) ? $attributes['priceTypographyGlobal'] : array();
292 363 return array_merge(
293 - $css,
294 - isset( $attributes['priceTypography'] ) ? Typography::get_css( $attributes['priceTypography'], '', $device ) : [],
364 + [ 'color' => Color::get_css( isset( $attributes['priceColor'] ) ? $attributes['priceColor'] : '' ) ],
365 + isset( $attributes['priceTypography'] ) ? Typography::get_css( $attributes['priceTypography'], '', $device, $typographyValueGlobal ) : [],
295 366 isset( $attributes['priceTextStroke'] ) ? TextStroke::get_css( $attributes['priceTextStroke'], '', $device ) : [],
296 367 isset( $attributes['priceTextShadow'] ) ? TextShadow::get_css( $attributes['priceTextShadow'], '', $device ) : [],
297 368 isset( $attributes['priceAlignment'] ) ? Alignment::get_css( $attributes['priceAlignment'], 'text-align', $device ) : [],
298 369 );