PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.10.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.10.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 / academy-enroll-form / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.10.0, at includes/blocks/academy-enroll-form/block.php

319 lines 14.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\AcademyEnrollForm;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGeneratorV2;
10 use ABlocks\Helper;
11 use ABlocks\Controls\Typography;
12 use ABlocks\Controls\Background;
13 use ABlocks\Controls\Border;
14 use ABlocks\Controls\Dimensions;
15 use ABlocks\Controls\Range;
16 use ABlocks\Controls\Color;
17
18 class Block extends BlockBaseAbstract {
19 protected $block_name = 'academy-enroll-form';
20
21 public function build_css( $attributes ) {
22 $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
23
24 $css_generator->add_class_styles(
25 '{{WRAPPER}} .academy-enroll-form .academy-widget-enroll__continue a,
26 {{WRAPPER}} .academy-widget-enroll__continue .academy-btn,
27 {{WRAPPER}} .academy-enroll-form-shortcode__continue a',
28 $this->getStartButtonCss( $attributes ),
29 $this->getStartButtonCss( $attributes, 'Tablet' ),
30 $this->getStartButtonCss( $attributes, 'Mobile' )
31 );
32
33 $css_generator->add_class_styles(
34 '{{WRAPPER}} .academy-enroll-form .academy-widget-enroll__continue a:hover,
35 {{WRAPPER}} .academy-widget-enroll__continue .academy-btn:hover,
36 {{WRAPPER}} .academy-enroll-form-shortcode__continue a:hover',
37 $this->getStartButtonHoverCss( $attributes ),
38 $this->getStartButtonHoverCss( $attributes, 'Tablet' ),
39 $this->getStartButtonHoverCss( $attributes, 'Mobile' )
40 );
41
42 $css_generator->add_class_styles(
43 '{{WRAPPER}} .academy-enroll-form .academy-widget-enroll__enroll-form button,
44 {{WRAPPER}} .academy-enroll-form-shortcode__prerequisite-button,
45 {{WRAPPER}} .academy-enroll-form-shortcode__button,
46 {{WRAPPER}} .academy-enroll-form-shortcode .academy-course-enroll-form .academy-btn--bg-purple,
47 {{WRAPPER}} .academy-widget-enroll__enroll-form .academy-btn,
48 {{WRAPPER}} .academy-add-to-cart-button button,
49 {{WRAPPER}} .academy-enroll-form-shortcode .academy-course-enroll-form .academy-btn--preset-purple,
50 {{WRAPPER}} .academy-widget-enroll__complete-form .academy-btn,
51 {{WRAPPER}} .academy-widget-enroll__add-to-cart form button',
52 $this->getEnrollButtonCss( $attributes ),
53 $this->getEnrollButtonCss( $attributes, 'Tablet' ),
54 $this->getEnrollButtonCss( $attributes, 'Mobile' )
55 );
56
57 $css_generator->add_class_styles(
58 '{{WRAPPER}} .academy-enroll-form .academy-widget-enroll__enroll-form button:hover,
59 {{WRAPPER}} .academy-enroll-form-shortcode__prerequisite-button:hover,
60 {{WRAPPER}} .academy-enroll-form-shortcode__button:hover,
61 {{WRAPPER}} .academy-enroll-form-shortcode .academy-course-enroll-form .academy-btn--bg-purple:hover,
62 {{WRAPPER}} .academy-widget-enroll__enr oll-form .academy-btn:hover,
63 {{WRAPPER}} .academy-add-to-cart-button button:hover,
64 {{WRAPPER}} .academy-enroll-form-shortcode .academy-course-enroll-form .academy-btn--preset-purple:hover,
65 {{WRAPPER}} .academy-widget-enroll__complete-form .academy-btn:hover',
66 $this->getEnrollButtonHoverCss( $attributes ),
67 $this->getEnrollButtonHoverCss( $attributes, 'Tablet' ),
68 $this->getEnrollButtonHoverCss( $attributes, 'Mobile' )
69 );
70 $css_generator->add_class_styles(
71 '{{WRAPPER}} .academy-enroll-form-shortcode__prerequisite .academy-shortcode-prerequisites-message',
72 $this->get_massage_title_css( $attributes, '' ),
73 $this->get_massage_title_css( $attributes, 'Tablet' ),
74 $this->get_massage_title_css( $attributes, 'Mobile' )
75 );
76 $css_generator->add_class_styles(
77 '{{WRAPPER}} .academy-enroll-form-shortcode__prerequisite .academy-shortcode-prerequisites-message:hover',
78 $this->get_massage_title_hover_css( $attributes, '' ),
79 $this->get_massage_title_hover_css( $attributes, 'Tablet' ),
80 $this->get_massage_title_hover_css( $attributes, 'Mobile' )
81 );
82 $css_generator->add_class_styles(
83 '{{WRAPPER}} .academy-enroll-form-shortcode__prerequisite',
84 $this->get_modal_css( $attributes, '' ),
85 $this->get_modal_css( $attributes, 'Tablet' ),
86 $this->get_modal_css( $attributes, 'Mobile' )
87 );
88 $css_generator->add_class_styles(
89 '{{WRAPPER}} .academy-enroll-form-shortcode__prerequisite .academy-shortcode-prerequisites-lists li a',
90 $this->get_modal_list_css( $attributes, '' ),
91 $this->get_modal_list_css( $attributes, 'Tablet' ),
92 $this->get_modal_list_css( $attributes, 'Mobile' )
93 );
94 $css_generator->add_class_styles(
95 '{{WRAPPER}} .academy-enroll-form-shortcode__prerequisite .academy-shortcode-prerequisites-lists li a:hover',
96 $this->get_modal_list_hover_css( $attributes, '' ),
97 $this->get_modal_list_hover_css( $attributes, 'Tablet' ),
98 $this->get_modal_list_hover_css( $attributes, 'Mobile' )
99 );
100 $css_generator->add_class_styles(
101 '{{WRAPPER}} .academy-enroll-form-shortcode__price,
102 {{WRAPPER}} .academy-widget-enroll__head .academy-course-type,
103 {{WRAPPER}} .academy-widget-enroll__head .academy-course-price del,
104 {{WRAPPER}} .academy-widget-enroll__head .academy-course-price ins',
105 $this->get_price_css( $attributes, '' ),
106 $this->get_price_css( $attributes, 'Tablet' ),
107 $this->get_price_css( $attributes, 'Mobile' )
108 );
109 $css_generator->add_class_styles(
110 '{{WRAPPER}} .academy-enroll-form-shortcode__price:hover,
111 {{WRAPPER}} .academy-widget-enroll__head .academy-course-type:hover,
112 {{WRAPPER}} .academy-widget-enroll__head .academy-course-price del:hover,
113 {{WRAPPER}} .academy-widget-enroll__head .academy-course-price ins:hover',
114 $this->get_price_hover_css( $attributes, '' ),
115 $this->get_price_hover_css( $attributes, 'Tablet' ),
116 $this->get_price_hover_css( $attributes, 'Mobile' )
117 );
118 $css_generator->add_class_styles(
119 '{{WRAPPER}} .academy-widget-enroll__head .title',
120 $this->get_price_title_css( $attributes, '' ),
121 $this->get_price_title_css( $attributes, 'Tablet' ),
122 $this->get_price_title_css( $attributes, 'Mobile' )
123 );
124 $css_generator->add_class_styles(
125 '{{WRAPPER}} .academy-widget-enroll__head .title',
126 $this->get_price_title_hover_css( $attributes, '' ),
127 $this->get_price_title_hover_css( $attributes, 'Tablet' ),
128 $this->get_price_title_hover_css( $attributes, 'Mobile' )
129 );
130 $css_generator->add_class_styles(
131 '{{WRAPPER}} .academy-widget-enroll__enrolled-info',
132 $this->get_enroll_info_css( $attributes, '' ),
133 $this->get_enroll_info_css( $attributes, 'Tablet' ),
134 $this->get_enroll_info_css( $attributes, 'Mobile' )
135 );
136 $css_generator->add_class_styles(
137 '{{WRAPPER}} .academy-widget-enroll__enrolled-info:hover',
138 $this->get_enroll_info_hover_css( $attributes, '' ),
139 $this->get_enroll_info_hover_css( $attributes, 'Tablet' ),
140 $this->get_enroll_info_hover_css( $attributes, 'Mobile' )
141 );
142
143 return $css_generator->generate_css();
144 }
145
146
147
148 public function getStartButtonCss( $attributes, $device = '' ) {
149 $typographyValueGlobal = ! empty( $attributes['start_btn_typographyGlobal'] ) ? $attributes['start_btn_typographyGlobal'] : '';
150 $start_btn_typography = isset( $attributes['start_btn_typography'] ) ? $attributes['start_btn_typography'] : [];
151 $start_btn_padding = ! empty( $attributes['start_btn_padding'] ) ? Dimensions::get_css( $attributes['start_btn_padding'], 'padding', $device ) : array();
152 $start_btn_border = ! empty( $attributes['start_btn_border'] ) ? Border::get_css( $attributes['start_btn_border'], '', $device ) : array();
153 return array_merge(
154 [ 'color' => Color::get_css( isset( $attributes['start_btn_color'] ) ? $attributes['start_btn_color'] : '' ) ],
155 [ 'background' => Color::get_css( isset( $attributes['start_btn_bg_color'] ) ? $attributes['start_btn_bg_color'] : '' ) ],
156 Typography::get_css( $start_btn_typography, '', $device, $typographyValueGlobal ),
157 $start_btn_padding,
158 $start_btn_border,
159 );
160 }
161 public function getStartButtonHoverCss( $attributes, $device = '' ) {
162 $start_btn_border = ! empty( $attributes['start_btn_border'] ) ? Border::get_hover_css( $attributes['start_btn_border'], '', $device ) : array();
163 return array_merge(
164 [ 'color' => Color::get_css( isset( $attributes['start_btn_color_hover'] ) ? $attributes['start_btn_color_hover'] : '' ) ],
165 [ 'background' => Color::get_css( isset( $attributes['start_btn_bg_hover_color'] ) ? $attributes['start_btn_bg_hover_color'] : '' ) ],
166 $start_btn_border
167 );
168 }
169
170 public function getEnrollButtonCss( $attributes, $device = '' ) {
171 $typographyValueGlobal = ! empty( $attributes['enroll_btn_typographyGlobal'] ) ? $attributes['enroll_btn_typographyGlobal'] : '';
172 $enroll_btn_typography = isset( $attributes['enroll_btn_typography'] ) ? $attributes['enroll_btn_typography'] : [];
173 $enroll_btn_padding = ! empty( $attributes['enroll_btn_padding'] ) ? Dimensions::get_css( $attributes['enroll_btn_padding'], 'padding', $device ) : array();
174 $enroll_btn_border = ! empty( $attributes['enroll_btn_border'] ) ? Border::get_css( $attributes['enroll_btn_border'], '', $device ) : array();
175
176 return array_merge(
177 [ 'color' => Color::get_css( isset( $attributes['enroll_btn_color'] ) ? $attributes['enroll_btn_color'] : '' ) ],
178 [ 'background' => Color::get_css( isset( $attributes['enroll_btn_bg_color'] ) ? $attributes['enroll_btn_bg_color'] : '' ) ],
179 Typography::get_css( $enroll_btn_typography, '', $device, $typographyValueGlobal ),
180 $enroll_btn_padding,
181 $enroll_btn_border,
182 );
183 }
184 public function getEnrollButtonHoverCss( $attributes, $device = '' ) {
185 $enroll_btn_border = ! empty( $attributes['enroll_btn_border'] ) ? Border::get_hover_css( $attributes['enroll_btn_border'], '', $device ) : array();
186 return array_merge(
187 [ 'color' => Color::get_css( isset( $attributes['enroll_btn_color_hover'] ) ? $attributes['enroll_btn_color_hover'] : '' ) ],
188 [ 'background' => Color::get_css( isset( $attributes['enroll_btn_bg_hover_color'] ) ? $attributes['enroll_btn_bg_hover_color'] : '' ) ],
189 $enroll_btn_border
190 );
191 }
192
193 public function get_massage_title_css( $attributes, $device = '' ) {
194 $typographyValueGlobal = ! empty( $attributes['massage_title_typographyGlobal'] ) ? $attributes['massage_title_typographyGlobal'] : '';
195 $typography_value = isset( $attributes['massage_title_typography'] ) ? $attributes['massage_title_typography'] : [];
196
197 return array_merge(
198 [ 'color' => Color::get_css( isset( $attributes['massage_title_color'] ) ? $attributes['massage_title_color'] : '' ) ],
199 [ 'background' => Color::get_css( isset( $attributes['massage_title_bg'] ) ? $attributes['massage_title_bg'] : '' ) ],
200 Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
201 );
202 }
203 public function get_massage_title_hover_css( $attributes, $device = '' ) {
204 return array_merge(
205 [ 'color' => Color::get_css( isset( $attributes['massage_title_hover_color'] ) ? $attributes['massage_title_hover_color'] : '' ) ],
206 [ 'background' => Color::get_css( isset( $attributes['massage_title_hover_bg'] ) ? $attributes['massage_title_hover_bg'] : '' ) ]
207 );
208
209 }
210 public function get_modal_css( $attributes, $device = '' ) {
211 return array_merge(
212 Range::get_css([
213 'attributeValue' => $attributes['modalWidth'],
214 'attribute_object_key' => 'value',
215 'isResponsive' => true,
216 'defaultValue' => 150,
217 'hasUnit' => true,
218 'unitDefaultValue' => 'px',
219 'property' => 'width',
220 'device' => $device,
221 ]),
222 );
223
224 }
225
226 public function get_modal_list_css( $attributes, $device = '' ) {
227 $css = [];
228 $css['text-decoration'] = 'none';
229 $typographyValueGlobal = ! empty( $attributes['list_typographyGlobal'] ) ? $attributes['list_typographyGlobal'] : '';
230 $typography_value = isset( $attributes['list_typography'] ) ? $attributes['list_typography'] : [];
231
232 return array_merge(
233 [ 'color' => Color::get_css( isset( $attributes['list_color'] ) ? $attributes['list_color'] : '' ) ],
234 $css,
235 Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
236 );
237 }
238
239 public function get_modal_list_hover_css( $attributes, $device = '' ) {
240 return [ 'color' => Color::get_css( isset( $attributes['list_hover_color'] ) ? $attributes['list_hover_color'] : '' ) ];
241
242 }
243
244 public function get_price_css( $attributes, $device = '' ) {
245 $typographyValueGlobal = ! empty( $attributes['price_typographyGlobal'] ) ? $attributes['price_typographyGlobal'] : '';
246 $typography_value = isset( $attributes['price_typography'] ) ? $attributes['price_typography'] : [];
247 return array_merge(
248 [ 'color' => Color::get_css( isset( $attributes['price_color'] ) ? $attributes['price_color'] : '' ) ],
249 Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ), );
250 }
251
252 public function get_price_hover_css( $attributes, $device = '' ) {
253 return [ 'color' => Color::get_css( isset( $attributes['price_hover_color'] ) ? $attributes['price_hover_color'] : '' ) ];
254 }
255
256 public function get_price_title_css( $attributes, $device = '' ) {
257 $css = [];
258 $css['color'] = $attributes['price_title_color'] ?? '';
259 $typography_value = ! empty( $attributes['price_title_typography'] ) ? Typography::get_css( $attributes['price_title_typography'], '', $device ) : array();
260
261 return array_merge(
262 $css,
263 $typography_value,
264 );
265
266 }
267 public function get_price_title_hover_css( $attributes, $device = '' ) {
268 $css = [];
269 $css['color'] = $attributes['price_title_hover_color'] ?? '';
270 return $css;
271 }
272
273 public function get_enroll_info_css( $attributes, $device = '' ) {
274 $css = [];
275 $css['color'] = $attributes['info_color'] ?? '#7b68ee';
276 $css['background'] = $attributes['info_bg'] ?? '#eae8fa';
277
278 $typography_value = $attributes['info_typography'] ? Typography::get_css( $attributes['info_typography'], '', $device ) : array();
279
280 return array_merge(
281 $css,
282 $typography_value
283 );
284 }
285
286 public function get_enroll_info_hover_css( $attributes, $device = '' ) {
287 $css = [];
288 $css['color'] = $attributes['info_color_hover'] ?? '#7b68ee';
289 $css['background'] = $attributes['info_bg_hover'] ?? '#eae8fa';
290
291 return array_merge(
292 $css,
293 Range::get_css([
294 'attributeValue' => $attributes['bg_transition'],
295 'attribute_object_key' => 'value',
296 'defaultValue' => 0,
297 'unitDefaultValue' => 's',
298 'property' => 'transition-duration',
299 'device' => $device,
300 ]),
301 );
302 }
303
304 public function render_block_content( $attributes, $content, $block_instance ) {
305 $attr_array = [
306 'course_id' => absint( Helper::get_attribute_value( $attributes, 'course_id' ) ),
307 'layout' => (string) ( Helper::get_attribute_value( $attributes, 'layout' ) )
308 ];
309
310 if ( isset( $block_instance->context['postId'] ) && ! empty( $block_instance->context['postId'] ) && empty( $attr_array['course_id'] ) ) {
311 $attr_array['course_id'] = $block_instance->context['postId'];
312 }
313
314 $shortcode = '[academy_enroll_form ' . Helper::attr_shortcode( $attr_array ) . ']';
315 echo do_shortcode( $shortcode );
316 }
317
318 }
319