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