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 / academy-student-registration-form / block.php

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

194 lines 9.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\AcademyStudentRegistrationForm;
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\Color;
16
17
18 class Block extends BlockBaseAbstract {
19 protected $block_name = 'academy-student-registration-form';
20
21 public function __construct() {
22 parent::__construct();
23
24 add_filter( 'academy/shortcode/student_registration_form_is_user_logged_in', [ $this, 'force_showing_student_registration_form_in_editor' ] );
25
26 }
27
28 public function force_showing_student_registration_form_in_editor( $flag ) {
29
30 if ( Helper::is_gutenberg_editor() ) {
31 return false;
32 }
33 return $flag;
34 }
35
36
37 public function build_css( $attributes ) {
38 $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
39 $css_generator->add_class_styles(
40 '{{WRAPPER}} .academy-reg-form--student .academy-form-group label',
41 $this->get_form_input_label_css( $attributes ),
42 $this->get_form_input_label_css( $attributes, 'Tablet' ),
43 $this->get_form_input_label_css( $attributes, 'Mobile' ),
44 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_label_css( $attributes, $device ); } )
45 );
46
47 $css_generator->add_class_styles(
48 '{{WRAPPER}} .academy-reg-form--student .academy-form-group label:hover',
49 $this->get_form_input_label_hover_css( $attributes ),
50 $this->get_form_input_label_hover_css( $attributes, 'Tablet' ),
51 $this->get_form_input_label_hover_css( $attributes, 'Mobile' ),
52 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_label_hover_css( $attributes, $device ); } )
53 );
54
55 $css_generator->add_class_styles(
56 '{{WRAPPER}} .academy-reg-form--student .academy-form-group input',
57 $this->get_form_input_field_css( $attributes ),
58 $this->get_form_input_field_css( $attributes, 'Tablet' ),
59 $this->get_form_input_field_css( $attributes, 'Mobile' ),
60 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_css( $attributes, $device ); } )
61 );
62 $css_generator->add_class_styles(
63 '{{WRAPPER}} .academy-reg-form--student .academy-form-group input:hover',
64 $this->get_form_input_field_hover_css( $attributes ),
65 $this->get_form_input_field_hover_css( $attributes, 'Tablet' ),
66 $this->get_form_input_field_hover_css( $attributes, 'Mobile' ),
67 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_hover_css( $attributes, $device ); } )
68 );
69
70 $css_generator->add_class_styles(
71 '{{WRAPPER}} .academy-reg-form--student .academy-form-group input::placeholder',
72 $this->get_form_input_field_placeholder_css( $attributes ),
73 $this->get_form_input_field_placeholder_css( $attributes, 'Tablet' ),
74 $this->get_form_input_field_placeholder_css( $attributes, 'Mobile' ),
75 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_input_field_placeholder_css( $attributes, $device ); } )
76 );
77
78 $css_generator->add_class_styles(
79 '{{WRAPPER}} .academy-reg-form--student .academy-form-group button',
80 $this->get_form_button_css( $attributes ),
81 $this->get_form_button_css( $attributes, 'Tablet' ),
82 $this->get_form_button_css( $attributes, 'Mobile' ),
83 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_button_css( $attributes, $device ); } )
84 );
85
86 $css_generator->add_class_styles(
87 '{{WRAPPER}} .academy-reg-form--student .academy-form-group button:hover',
88 $this->get_form_button_hover_css( $attributes ),
89 $this->get_form_button_hover_css( $attributes, 'Tablet' ),
90 $this->get_form_button_hover_css( $attributes, 'Mobile' ),
91 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_button_hover_css( $attributes, $device ); } )
92 );
93
94 $css_generator->add_class_styles(
95 '{{WRAPPER}} .academy-reg-form',
96 $this->get_form_css( $attributes ),
97 $this->get_form_css( $attributes, 'Tablet' ),
98 $this->get_form_css( $attributes, 'Mobile' ),
99 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_css( $attributes, $device ); } )
100 );
101 $css_generator->add_class_styles(
102 '{{WRAPPER}} .academy-reg-form:hover',
103 $this->get_form_hover_css( $attributes ),
104 $this->get_form_hover_css( $attributes, 'Tablet' ),
105 $this->get_form_hover_css( $attributes, 'Mobile' ),
106 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_hover_css( $attributes, $device ); } )
107 );
108
109 return $css_generator->generate_css();
110 }
111
112 public function get_form_input_label_css( $attributes, $device = '' ) {
113 $typographyValueGlobal = ! empty( $attributes['input_label_typhographyGlobal'] ) ? $attributes['input_label_typhographyGlobal'] : '';
114 $input_label_typography_css = isset( $attributes['input_label_typhography'] ) ? $attributes['input_label_typhography'] : [];
115 return array_merge(
116 [ 'color' => Color::get_css( isset( $attributes['input_label_color'] ) ? $attributes['input_label_color'] : '' ) ],
117 Typography::get_css( $input_label_typography_css, '', $device, $typographyValueGlobal ),
118 );
119 }
120
121 public function get_form_input_label_hover_css( $attributes, $device = '' ) {
122 return [ 'color' => Color::get_css( isset( $attributes['input_label_hover_color'] ) ? $attributes['input_label_hover_color'] : '' ) ];
123 }
124
125 public function get_form_input_field_css( $attributes, $device = '' ) {
126 $input_field_border_css = ! empty( $attributes['form_field_border'] ) ? Border::get_css( $attributes['form_field_border'], '', $device ) : array();
127 return array_merge(
128 [ 'color' => Color::get_css( isset( $attributes['input_field_color'] ) ? $attributes['input_field_color'] : '' ) ],
129 [ 'background' => Color::get_css( isset( $attributes['input_field_bg_color'] ) ? $attributes['input_field_bg_color'] : '' ) ],
130 $input_field_border_css,
131 );
132 }
133
134 public function get_form_input_field_hover_css( $attributes, $device = '' ) {
135 $input_field_border_hover_css = ! empty( $attributes['form_field_border'] ) ? Border::get_hover_css( $attributes['form_field_border'], '', $device ) : array();
136 return $input_field_border_hover_css;
137 }
138 public function get_form_input_field_placeholder_css( $attributes, $device = '' ) {
139 return [ 'color' => Color::get_css( isset( $attributes['input_field_placeholder_color'] ) ? $attributes['input_field_placeholder_color'] : '' ) ];
140 }
141
142 public function get_form_button_css( $attributes, $device = '' ) {
143 $typographyValueGlobal = ! empty( $attributes['form_button_typhographyGlobal'] ) ? $attributes['form_button_typhographyGlobal'] : '';
144 $form_button_typography_css = isset( $attributes['form_button_typhography'] ) ? $attributes['form_button_typhography'] : [];
145 $form_button_padding = ! empty( $attributes['form_button_padding'] ) ? Dimensions::get_css( $attributes['form_button_padding'], 'padding', $device ) : array();
146 $form_button_border_css = ! empty( $attributes['form_button_border'] ) ? Border::get_css( $attributes['form_button_border'], '', $device ) : array();
147 return array_merge(
148 [ 'color' => Color::get_css( isset( $attributes['form_button_color'] ) ? $attributes['form_button_color'] : '' ) ],
149 [ 'background' => Color::get_css( isset( $attributes['form_button_background'] ) ? $attributes['form_button_background'] : '' ) ],
150 Typography::get_css( $form_button_typography_css, '', $device, $typographyValueGlobal ),
151 $form_button_padding,
152 $form_button_border_css,
153 );
154 }
155
156 public function get_form_css( $attributes, $device = '' ) {
157 $form_background = ! empty( $attributes['form_background'] ) ? Background::get_css( $attributes['form_background'], 'background', $device ) : array();
158 $form_padding = ! empty( $attributes['form_padding'] ) ? Dimensions::get_css( $attributes['form_padding'], 'padding', $device ) : array();
159 $form_border = ! empty( $attributes['form_border'] ) ? Border::get_css( $attributes['form_border'], '', $device ) : array();
160
161 return array_merge(
162 $form_background,
163 $form_padding,
164 $form_border
165 );
166 }
167 public function get_form_hover_css( $attributes, $device = '' ) {
168 $form_hover_background = ! empty( $attributes['form_background'] ) ? Background::get_hover_css( $attributes['form_background'], 'background', $device ) : array();
169 $form_hover_border = ! empty( $attributes['form_border'] ) ? Border::get_hover_css( $attributes['form_border'], '', $device ) : array();
170
171 return array_merge(
172 $form_hover_background,
173 $form_hover_border
174 );
175 }
176
177 public function get_form_button_hover_css( $attributes, $device = '' ) {
178 $form_button_border = ! empty( $attributes['form_button_border'] ) ? Border::get_hover_css( $attributes['form_button_border'], '', $device ) : array();
179 return array_merge(
180 [ 'color' => Color::get_css( isset( $attributes['form_button_hover_color'] ) ? $attributes['form_button_hover_color'] : '' ) ],
181 [ 'background' => Color::get_css( isset( $attributes['form_button_hover_background'] ) ? $attributes['form_button_hover_background'] : '' ) ],
182 $form_button_border
183 );
184 }
185
186 public function render_block_content( $attributes, $content, $block_instance ) {
187
188 $shortcode = '[academy_student_registration_form]';
189 echo do_shortcode( $shortcode );
190
191 }
192
193 }
194