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
ablocks / includes / blocks / price-menu-item / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.14.0, at includes/blocks/price-menu-item/block.php

185 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\PriceMenuItem;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Controls\Icon;
11 use ABlocks\Controls\Alignment;
12 use ABlocks\Controls\Typography;
13 use ABlocks\Controls\TextShadow;
14 use ABlocks\Controls\TextStroke;
15 use ABlocks\Controls\Range;
16 use ABlocks\Controls\Color;
17
18 class Block extends BlockBaseAbstract {
19 protected $parent_block_name = 'price-menu';
20 protected $block_name = 'price-menu-item';
21
22 public function build_css( $attributes ) {
23
24 $css_generator = new CssGenerator( $attributes, $this->block_name );
25 // Icon Style
26 $css_generator->add_class_styles(
27 '{{WRAPPER}} .ablocks-icon-wrap',
28 Icon::get_wrapper_css( $attributes ),
29 Icon::get_wrapper_css( $attributes, 'Tablet' ),
30 Icon::get_wrapper_css( $attributes, 'Mobile' ),
31 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_css( $attributes, $device ); } )
32 );
33 $css_generator->add_class_styles(
34 '{{WRAPPER}} .ablocks-icon-wrap:hover',
35 Icon::get_wrapper_hover_css( $attributes ),
36 Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
37 Icon::get_wrapper_hover_css( $attributes, 'Mobile' ),
38 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_hover_css( $attributes, $device ); } )
39 );
40 $css_generator->add_class_styles(
41 '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon',
42 Icon::get_element_image_css( $attributes ),
43 Icon::get_element_image_css( $attributes, 'Tablet' ),
44 Icon::get_element_image_css( $attributes, 'Mobile' ),
45 );
46 $css_generator->add_class_styles(
47 '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon:hover',
48 Icon::get_element_image_hover_css( $attributes ),
49 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
50 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
51 );
52 $css_generator->add_class_styles(
53 '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon',
54 Icon::get_element_css( $attributes ),
55 Icon::get_element_css( $attributes, 'Tablet' ),
56 Icon::get_element_css( $attributes, 'Mobile' ),
57 );
58 $css_generator->add_class_styles(
59 '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
60 Icon::get_element_image_hover_css( $attributes ),
61 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
62 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
63 );
64 // TitleText CSS
65 $css_generator->add_class_styles(
66 '{{WRAPPER}} .ablocks-price-menu-item-details-title',
67 $this->get_title_text_css( $attributes, '' ),
68 $this->get_title_text_css( $attributes, 'Tablet' ),
69 $this->get_title_text_css( $attributes, 'Mobile' ),
70 );
71 // DescriptionText CSS
72 $css_generator->add_class_styles(
73 '{{WRAPPER}} .ablocks-price-menu-item-details-des',
74 $this->get_description_text_css( $attributes, '' ),
75 $this->get_description_text_css( $attributes, 'Tablet' ),
76 $this->get_description_text_css( $attributes, 'Mobile' ),
77 );
78 // SeparatorText CSS
79 $css_generator->add_class_styles(
80 '{{WRAPPER}} .ablocks-price-menu-divider__pattern-' . ( $attributes['dividerType'] === 'mask-style' ? 'mask' : 'css' ),
81 $this->get_divider_css( $attributes, '' ),
82 $this->get_divider_css( $attributes, 'Tablet' ),
83 $this->get_divider_css( $attributes, 'Mobile' ),
84 );
85 // PriceText CSS
86 $css_generator->add_class_styles(
87 '{{WRAPPER}} .ablocks-price-menu-item-price',
88 $this->get_price_text_css( $attributes, '' ),
89 $this->get_price_text_css( $attributes, 'Tablet' ),
90 $this->get_price_text_css( $attributes, 'Mobile' ),
91 );
92
93 return $css_generator->generate_css();
94 }
95
96 public function get_title_text_css( $attributes, $device = '' ) {
97 $typographyValueGlobal = ! empty( $attributes['titleTypographyGlobal'] ) ? $attributes['titleTypographyGlobal'] : array();
98 return array_merge(
99 [ 'color' => Color::get_css( isset( $attributes['titleColor'] ) ? $attributes['titleColor'] : '' ) ],
100 isset( $attributes['titleTypography'] ) ? Typography::get_css( $attributes['titleTypography'], '', $device, $typographyValueGlobal ) : [],
101 isset( $attributes['titleTextStroke'] ) ? TextStroke::get_css( $attributes['titleTextStroke'], '', $device ) : [],
102 isset( $attributes['titleTextShadow'] ) ? TextShadow::get_css( $attributes['titleTextShadow'], '', $device ) : [],
103 isset( $attributes['titleAlignment'] ) ? Alignment::get_css( $attributes['titleAlignment'], 'text-align', $device ) : [],
104 );
105 }
106 public function get_description_text_css( $attributes, $device = '' ) {
107 $typographyValueGlobal = ! empty( $attributes['descriptionTypographyGlobal'] ) ? $attributes['descriptionTypographyGlobal'] : array();
108
109 return array_merge(
110 [ 'color' => Color::get_css( isset( $attributes['descriptionColor'] ) ? $attributes['descriptionColor'] : '' ) ],
111 isset( $attributes['descriptionTypography'] ) ? Typography::get_css( $attributes['descriptionTypography'], '', $device, $typographyValueGlobal ) : [],
112 isset( $attributes['descriptionTextStroke'] ) ? TextStroke::get_css( $attributes['descriptionTextStroke'], '', $device ) : [],
113 isset( $attributes['descriptionTextShadow'] ) ? TextShadow::get_css( $attributes['descriptionTextShadow'], '', $device ) : [],
114 isset( $attributes['descriptionAlignment'] ) ? Alignment::get_css( $attributes['descriptionAlignment'], 'text-align', $device ) : [],
115 );
116 }
117 public function get_divider_css( $attributes, $device = '' ) {
118 $css = [];
119 $divider_width = isset( $attributes['width'][ 'value' . $device ] ) ? $attributes['width'][ 'value' . $device ] : 60;
120 $default_Unit = $attributes['allowDescription'] === true ? '%' : 'px';
121
122 if ( ! empty( $attributes['color'] ) ) {
123 $css['--ablocks-divider-pattern-color'] = Color::get_css(
124 isset( $attributes['color'] ) ? $attributes['color'] : '#000000');
125
126 }
127
128 $moreRangeCSS = [];
129 if ( isset( $attributes['dividerType'] ) && $attributes['dividerType'] === 'mask-style' && isset( $attributes['size'] ) && ! empty( $attributes['size'] ) ) {
130 $moreRangeCSS = Range::get_css([
131 'attributeValue' => $attributes['size'],
132 'attribute_object_key' => 'value',
133 'isResponsive' => false,
134 'defaultValue' => null,
135 'hasUnit' => false,
136 'unitDefaultValue' => 'px',
137 'property' => '--ablocks-divider-pattern-height',
138 ]);
139 } elseif ( isset( $attributes['weight'] ) && ! empty( $attributes['weight'] ) ) {
140 $moreRangeCSS = Range::get_css([
141 'attributeValue' => $attributes['weight'],
142 'attribute_object_key' => 'value',
143 'isResponsive' => false,
144 'defaultValue' => null,
145 'hasUnit' => false,
146 'unitDefaultValue' => 'px',
147 'property' => '--ablocks-divider-pattern-weight',
148 ]);
149 }//end if
150
151 if ( ! empty( $attributes['dividerPatternUrl'] ) ) {
152 if ( $attributes['dividerType'] === 'mask-style' ) {
153 $css['--ablocks-divider-pattern-url'] = 'url(' . $attributes['dividerPatternUrl'] . ')';
154 } else {
155 $css['--ablocks-divider-pattern-style'] = $attributes['dividerPatternUrl'];
156 }
157 }
158
159 return array_merge(
160 $css,
161 Range::get_css([
162 'attributeValue' => $attributes['width'],
163 'attribute_object_key' => 'value',
164 'isResponsive' => true,
165 'defaultValue' => null,
166 'hasUnit' => false,
167 'unitDefaultValue' => $attributes['allowDescription'] === true ? '%' : 'px',
168 'property' => 'width',
169 'device' => $device,
170 ]),
171 $moreRangeCSS,
172 );
173 }
174 public function get_price_text_css( $attributes, $device = '' ) {
175 $typographyValueGlobal = ! empty( $attributes['priceTypographyGlobal'] ) ? $attributes['priceTypographyGlobal'] : array();
176 return array_merge(
177 [ 'color' => Color::get_css( isset( $attributes['priceColor'] ) ? $attributes['priceColor'] : '' ) ],
178 isset( $attributes['priceTypography'] ) ? Typography::get_css( $attributes['priceTypography'], '', $device, $typographyValueGlobal ) : [],
179 isset( $attributes['priceTextStroke'] ) ? TextStroke::get_css( $attributes['priceTextStroke'], '', $device ) : [],
180 isset( $attributes['priceTextShadow'] ) ? TextShadow::get_css( $attributes['priceTextShadow'], '', $device ) : [],
181 isset( $attributes['priceAlignment'] ) ? Alignment::get_css( $attributes['priceAlignment'], 'text-align', $device ) : [],
182 );
183 }
184 }
185