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 / academy-password-reset-form / block.php

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

225 lines 8.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\AcademyPasswordResetForm;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
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
16 class Block extends BlockBaseAbstract {
17 protected $block_name = 'academy-password-reset-form';
18
19 public function __construct() {
20 parent::__construct();
21
22 add_filter( 'academy/shortcode/password_reset_form_is_user_logged_in', [ $this, 'force_showing_reset_form_in_editor' ] );
23
24 }
25
26 public function force_showing_reset_form_in_editor( $flag ) {
27 if ( Helper::is_gutenberg_editor() ) {
28 return false;
29 }
30 return $flag;
31 }
32
33 public function build_css( $attributes ) {
34 $css_generator = new CssGenerator( $attributes );
35
36 $css_generator->add_class_styles(
37 '{{WRAPPER}} .academy-password-reset-form-wrapper',
38 $this->getResetFormCss( $attributes ),
39 $this->getResetFormCss( $attributes, 'Tablet' ),
40 $this->getResetFormCss( $attributes, 'Mobile' )
41 );
42 $css_generator->add_class_styles(
43 '{{WRAPPER}} .academy-password-reset-form-wrapper:hover',
44 $this->getResetFormHoverCss( $attributes ),
45 $this->getResetFormHoverCss( $attributes, 'Tablet' ),
46 $this->getResetFormHoverCss( $attributes, 'Mobile' )
47 );
48
49 $css_generator->add_class_styles(
50 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group label',
51 $this->getResetFormLabelCss( $attributes ),
52 $this->getResetFormLabelCss( $attributes, 'Tablet' ),
53 $this->getResetFormLabelCss( $attributes, 'Mobile' )
54 );
55
56 $css_generator->add_class_styles(
57 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group input',
58 $this->getResetFormInputCss( $attributes ),
59 $this->getResetFormInputCss( $attributes, 'Tablet' ),
60 $this->getResetFormInputCss( $attributes, 'Mobile' )
61 );
62 $css_generator->add_class_styles(
63 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group input:hover',
64 $this->getResetFormInputHoverCss( $attributes ),
65 $this->getResetFormInputHoverCss( $attributes, 'Tablet' ),
66 $this->getResetFormInputHoverCss( $attributes, 'Mobile' )
67 );
68 $css_generator->add_class_styles(
69 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group button',
70 $this->getResetFormButtonCss( $attributes ),
71 $this->getResetFormButtonCss( $attributes, 'Tablet' ),
72 $this->getResetFormButtonCss( $attributes, 'Mobile' )
73 );
74 $css_generator->add_class_styles(
75 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group button:hover',
76 $this->getResetFormButtonHoverCss( $attributes ),
77 $this->getResetFormButtonHoverCss( $attributes, 'Tablet' ),
78 $this->getResetFormButtonHoverCss( $attributes, 'Mobile' )
79 );
80 $css_generator->add_class_styles(
81 '{{WRAPPER}} .academy-password-reset-form-wrapper h2.academy-password-reset-form-heading',
82 $this->getResetFormHeaderCss( $attributes ),
83 $this->getResetFormHeaderCss( $attributes, 'Tablet' ),
84 $this->getResetFormHeaderCss( $attributes, 'Mobile' )
85 );
86
87 $css_generator->add_class_styles(
88 '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form-info a',
89 $this->getResetFormFooterCss( $attributes ),
90 $this->getResetFormFooterCss( $attributes, 'Tablet' ),
91 $this->getResetFormFooterCss( $attributes, 'Mobile' )
92 );
93
94 return $css_generator->generate_css();
95 }
96
97 public function getResetFormCss( $attributes, $device = '' ) {
98 $css = array();
99 $form_border_css = ! empty( $attributes['form_border'] ) ? Border::get_css( $attributes['form_border'], '', $device ) : array();
100 $form_padding_css = ! empty( $attributes['form_padding'] ) ? Dimensions::get_css( $attributes['form_padding'], 'padding', $device ) : array();
101 if ( ! empty( $attributes['form_background_color'] ) ) {
102 $css['background'] = $attributes['form_background_color'];
103 }
104 return array_merge(
105 $form_border_css,
106 $form_padding_css,
107 $css
108 );
109 }
110 public function getResetFormHoverCss( $attributes, $device = '' ) {
111 $css = array();
112 $form_border_hover_css = ! empty( $attributes['form_border'] ) ? Border::get_hover_css( $attributes['form_border'], '', $device ) : array();
113 if ( ! empty( $attributes['form_background_hover_color'] ) ) {
114 $css['background'] = $attributes['form_background_hover_color'];
115 }
116 return array_merge(
117 $form_border_hover_css,
118 $css
119 );
120 }
121 public function getResetFormLabelCss( $attributes, $device = '' ) {
122 $css = array();
123 $reset_form_label_typography_css = ! empty( $attributes['label_typography'] ) ? Typography::get_css( $attributes['label_typography'], '', $device ) : array();
124 if ( ! empty( $attributes['label_color'] ) ) {
125 $css['color'] = $attributes['label_color'];
126 }
127 return array_merge(
128 $reset_form_label_typography_css,
129 $css
130 );
131 }
132 public function getResetFormInputCss( $attributes, $device = '' ) {
133 $css = array();
134 $form_input_border_css = ! empty( $attributes['input_border'] ) ? Border::get_css( $attributes['input_border'], '', $device ) : array();
135 $form_input_padding_css = ! empty( $attributes['input_padding'] ) ? Dimensions::get_css( $attributes['input_padding'], 'padding', $device ) : array();
136 $form_input_typography_css = ! empty( $attributes['input_field_typography'] ) ? Typography::get_css( $attributes['input_field_typography'], '', $device ) : array();
137 if ( ! empty( $attributes['input_field_color'] ) ) {
138 $css['color'] = $attributes['input_field_color'];
139 }
140 return array_merge(
141 $form_input_border_css,
142 $form_input_padding_css,
143 $form_input_typography_css,
144 $css
145 );
146 }
147 public function getResetFormInputHoverCss( $attributes, $device = '' ) {
148 $css = array();
149 $form_input_border_hover_css = ! empty( $attributes['input_border'] ) ? Border::get_hover_css( $attributes['input_border'], '', $device ) : array();
150 return array_merge(
151 $form_input_border_hover_css,
152 $css
153 );
154 }
155
156 public function getResetFormButtonCss( $attributes, $device = '' ) {
157 $css = array();
158 $button_border = ! empty( $attributes['button_border'] ) ? Border::get_css( $attributes['button_border'], '', $device ) : array();
159 $button_padding = ! empty( $attributes['button_padding'] ) ? Dimensions::get_css( $attributes['button_padding'], 'padding', $device ) : array();
160 $button_typography = ! empty( $attributes['button_typography'] ) ? Typography::get_css( $attributes['button_typography'], '', $device ) : array();
161 if ( ! empty( $attributes['button_color'] ) ) {
162 $css['color'] = $attributes['button_color'];
163 }
164 if ( ! empty( $attributes['button_background_color'] ) ) {
165 $css['background'] = $attributes['button_background_color'];
166 }
167 return array_merge(
168 $button_border,
169 $button_padding,
170 $button_typography,
171 $css
172 );
173 }
174 public function getResetFormButtonHoverCss( $attributes, $device = '' ) {
175 $css = array();
176 $button_hover_border = ! empty( $attributes['button_border'] ) ? Border::get_hover_css( $attributes['button_border'], '', $device ) : array();
177 if ( ! empty( $attributes['button_hover_color'] ) ) {
178 $css['color'] = $attributes['button_hover_color'];
179 }
180 if ( ! empty( $attributes['button_background_hover_color'] ) ) {
181 $css['background'] = $attributes['button_background_hover_color'];
182 }
183 return array_merge(
184 $button_hover_border,
185 $css
186 );
187 }
188 public function getResetFormHeaderCss( $attributes, $device = '' ) {
189 $css = array();
190 $form_title_typography = ! empty( $attributes['form_title_typography'] ) ? Typography::get_css( $attributes['form_title_typography'], '', $device ) : array();
191 if ( ! empty( $attributes['form_title_color'] ) ) {
192 $css['color'] = $attributes['form_title_color'];
193 }
194 return array_merge(
195 $form_title_typography,
196 $css
197 );
198 }
199 public function getResetFormFooterCss( $attributes, $device = '' ) {
200 $css = array();
201 $form_footer_title_typography = ! empty( $attributes['form_footer_title_typography'] ) ? Typography::get_css( $attributes['form_footer_title_typography'], '', $device ) : array();
202 if ( ! empty( $attributes['form_footer_title_color'] ) ) {
203 $css['color'] = $attributes['form_footer_title_color'];
204 }
205 return array_merge(
206 $form_footer_title_typography,
207 $css
208 );
209 }
210
211
212 public function render_block_content( $attributes, $content, $block_instance ) {
213 $attr_array = [
214 'form_title' => Helper::get_attribute_value( $attributes, 'form_title' ),
215 'username_label' => Helper::get_attribute_value( $attributes, 'username_label' ),
216 'reset_button_label' => Helper::get_attribute_value( $attributes, 'reset_button_label' ),
217 'login_button_label' => Helper::get_attribute_value( $attributes, 'login_button_label' ),
218 'show_logged_in_message' => Helper::get_attribute_value( $attributes, 'show_logged_in_message' ),
219 ];
220 $shortcode = '[academy_password_reset_form ' . Helper::attr_shortcode( $attr_array ) . ']';
221 echo do_shortcode( $shortcode );
222 }
223
224 }
225