PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.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
ablocks / includes / blocks / price-menu-item / block.php

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

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