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-password-reset-form/block.php +200 -0 1.0 → 2.14.0 View file →
@@ -1,0 +1,200 @@
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\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-password-reset-form';
19 +
20 + public function __construct() {
21 + parent::__construct();
22 +
23 + add_filter( 'academy/shortcode/password_reset_form_is_user_logged_in', [ $this, 'force_showing_reset_form_in_editor' ] );
24 +
25 + }
26 +
27 + public function force_showing_reset_form_in_editor( $flag ) {
28 + if ( Helper::is_gutenberg_editor() ) {
29 + return false;
30 + }
31 + return $flag;
32 + }
33 +
34 + public function build_css( $attributes ) {
35 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
36 +
37 + $css_generator->add_class_styles(
38 + '{{WRAPPER}} .academy-password-reset-form-wrapper',
39 + $this->getResetFormCss( $attributes ),
40 + $this->getResetFormCss( $attributes, 'Tablet' ),
41 + $this->getResetFormCss( $attributes, 'Mobile' ),
42 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormCss( $attributes, $device ); } )
43 + );
44 + $css_generator->add_class_styles(
45 + '{{WRAPPER}} .academy-password-reset-form-wrapper:hover',
46 + $this->getResetFormHoverCss( $attributes ),
47 + $this->getResetFormHoverCss( $attributes, 'Tablet' ),
48 + $this->getResetFormHoverCss( $attributes, 'Mobile' ),
49 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormHoverCss( $attributes, $device ); } )
50 + );
51 +
52 + $css_generator->add_class_styles(
53 + '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group label',
54 + $this->getResetFormLabelCss( $attributes ),
55 + $this->getResetFormLabelCss( $attributes, 'Tablet' ),
56 + $this->getResetFormLabelCss( $attributes, 'Mobile' ),
57 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormLabelCss( $attributes, $device ); } )
58 + );
59 +
60 + $css_generator->add_class_styles(
61 + '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group input',
62 + $this->getResetFormInputCss( $attributes ),
63 + $this->getResetFormInputCss( $attributes, 'Tablet' ),
64 + $this->getResetFormInputCss( $attributes, 'Mobile' ),
65 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormInputCss( $attributes, $device ); } )
66 + );
67 + $css_generator->add_class_styles(
68 + '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group input:hover',
69 + $this->getResetFormInputHoverCss( $attributes ),
70 + $this->getResetFormInputHoverCss( $attributes, 'Tablet' ),
71 + $this->getResetFormInputHoverCss( $attributes, 'Mobile' ),
72 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormInputHoverCss( $attributes, $device ); } )
73 + );
74 + $css_generator->add_class_styles(
75 + '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group button',
76 + $this->getResetFormButtonCss( $attributes ),
77 + $this->getResetFormButtonCss( $attributes, 'Tablet' ),
78 + $this->getResetFormButtonCss( $attributes, 'Mobile' ),
79 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormButtonCss( $attributes, $device ); } )
80 + );
81 + $css_generator->add_class_styles(
82 + '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form .academy-form-group button:hover',
83 + $this->getResetFormButtonHoverCss( $attributes ),
84 + $this->getResetFormButtonHoverCss( $attributes, 'Tablet' ),
85 + $this->getResetFormButtonHoverCss( $attributes, 'Mobile' ),
86 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormButtonHoverCss( $attributes, $device ); } )
87 + );
88 + $css_generator->add_class_styles(
89 + '{{WRAPPER}} .academy-password-reset-form-wrapper h2.academy-password-reset-form-heading',
90 + $this->getResetFormHeaderCss( $attributes ),
91 + $this->getResetFormHeaderCss( $attributes, 'Tablet' ),
92 + $this->getResetFormHeaderCss( $attributes, 'Mobile' ),
93 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormHeaderCss( $attributes, $device ); } )
94 + );
95 +
96 + $css_generator->add_class_styles(
97 + '{{WRAPPER}} .academy-password-reset-form-wrapper .academy-password-reset-form-info a',
98 + $this->getResetFormFooterCss( $attributes ),
99 + $this->getResetFormFooterCss( $attributes, 'Tablet' ),
100 + $this->getResetFormFooterCss( $attributes, 'Mobile' ),
101 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->getResetFormFooterCss( $attributes, $device ); } )
102 + );
103 +
104 + return $css_generator->generate_css();
105 + }
106 +
107 + public function getResetFormCss( $attributes, $device = '' ) {
108 + $form_border_css = ! empty( $attributes['form_border'] ) ? Border::get_css( $attributes['form_border'], '', $device ) : array();
109 + $form_padding_css = ! empty( $attributes['form_padding'] ) ? Dimensions::get_css( $attributes['form_padding'], 'padding', $device ) : array();
110 + return array_merge(
111 + [ 'background' => Color::get_css( isset( $attributes['form_background_color'] ) ? $attributes['form_background_color'] : '' ) ],
112 + $form_border_css,
113 + $form_padding_css,
114 + );
115 + }
116 + public function getResetFormHoverCss( $attributes, $device = '' ) {
117 + $form_border_hover_css = ! empty( $attributes['form_border'] ) ? Border::get_hover_css( $attributes['form_border'], '', $device ) : array();
118 + return array_merge(
119 + [ 'background' => Color::get_css( isset( $attributes['form_background_hover_color'] ) ? $attributes['form_background_hover_color'] : '' ) ],
120 + $form_border_hover_css
121 + );
122 + }
123 + public function getResetFormLabelCss( $attributes, $device = '' ) {
124 + $typographyValueGlobal = ! empty( $attributes['label_typographyGlobal'] ) ? $attributes['label_typographyGlobal'] : '';
125 + $reset_form_label_typography_css = isset( $attributes['label_typography'] ) ? $attributes['label_typography'] : [];
126 + return array_merge(
127 + [ 'color' => Color::get_css( isset( $attributes['label_color'] ) ? $attributes['label_color'] : '' ) ],
128 + Typography::get_css( $reset_form_label_typography_css, '', $device, $typographyValueGlobal ),
129 + );
130 + }
131 + public function getResetFormInputCss( $attributes, $device = '' ) {
132 + $form_input_border_css = ! empty( $attributes['input_border'] ) ? Border::get_css( $attributes['input_border'], '', $device ) : array();
133 + $form_input_padding_css = ! empty( $attributes['input_padding'] ) ? Dimensions::get_css( $attributes['input_padding'], 'padding', $device ) : array();
134 + $typographyValueGlobal = ! empty( $attributes['input_field_typographyGlobal'] ) ? $attributes['input_field_typographyGlobal'] : '';
135 + $form_input_typography_css = isset( $attributes['input_field_typography'] ) ? $attributes['input_field_typography'] : [];
136 + return array_merge(
137 + [ 'color' => Color::get_css( isset( $attributes['input_field_color'] ) ? $attributes['input_field_color'] : '' ) ],
138 + $form_input_border_css,
139 + $form_input_padding_css,
140 + Typography::get_css( $form_input_typography_css, '', $device, $typographyValueGlobal ),
141 + );
142 + }
143 + public function getResetFormInputHoverCss( $attributes, $device = '' ) {
144 +
145 + $form_input_border_hover_css = ! empty( $attributes['input_border'] ) ? Border::get_hover_css( $attributes['input_border'], '', $device ) : array();
146 + return $form_input_border_hover_css;
147 + }
148 +
149 + public function getResetFormButtonCss( $attributes, $device = '' ) {
150 + $button_border = ! empty( $attributes['button_border'] ) ? Border::get_css( $attributes['button_border'], '', $device ) : array();
151 + $button_padding = ! empty( $attributes['button_padding'] ) ? Dimensions::get_css( $attributes['button_padding'], 'padding', $device ) : array();
152 + $typographyValueGlobal = ! empty( $attributes['button_typographyGlobal'] ) ? $attributes['button_typographyGlobal'] : '';
153 + $button_typography = isset( $attributes['button_typography'] ) ? $attributes['button_typography'] : [];
154 + return array_merge(
155 + [ 'color' => Color::get_css( isset( $attributes['button_color'] ) ? $attributes['button_color'] : '' ) ],
156 + [ 'background' => Color::get_css( isset( $attributes['button_background_color'] ) ? $attributes['button_background_color'] : '' ) ],
157 + $button_border,
158 + $button_padding,
159 + Typography::get_css( $button_typography, '', $device, $typographyValueGlobal ), $button_typography,
160 + );
161 + }
162 + public function getResetFormButtonHoverCss( $attributes, $device = '' ) {
163 + $button_hover_border = ! empty( $attributes['button_border'] ) ? Border::get_hover_css( $attributes['button_border'], '', $device ) : array();
164 + return array_merge(
165 + [ 'color' => Color::get_css( isset( $attributes['button_hover_color'] ) ? $attributes['button_hover_color'] : '' ) ],
166 + [ 'background' => Color::get_css( isset( $attributes['button_background_hover_color'] ) ? $attributes['button_background_hover_color'] : '' ) ],
167 + $button_hover_border,
168 + );
169 + }
170 + public function getResetFormHeaderCss( $attributes, $device = '' ) {
171 + $typographyValueGlobal = ! empty( $attributes['form_title_typographyGlobal'] ) ? $attributes['form_title_typographyGlobal'] : '';
172 + $form_title_typography = isset( $attributes['form_title_typography'] ) ? $attributes['form_title_typography'] : [];
173 + return array_merge(
174 + [ 'color' => Color::get_css( isset( $attributes['form_title_color'] ) ? $attributes['form_title_color'] : '' ) ],
175 + Typography::get_css( $form_title_typography, '', $device, $typographyValueGlobal ),
176 + );
177 + }
178 + public function getResetFormFooterCss( $attributes, $device = '' ) {
179 + $typographyValueGlobal = ! empty( $attributes['form_footer_title_typographyGlobal'] ) ? $attributes['form_footer_title_typographyGlobal'] : '';
180 + $form_footer_title_typography = isset( $attributes['form_footer_title_typography'] ) ? $attributes['form_footer_title_typography'] : [];
181 + return array_merge(
182 + [ 'color' => Color::get_css( isset( $attributes['form_footer_title_color'] ) ? $attributes['form_footer_title_color'] : '' ) ],
183 + Typography::get_css( $form_footer_title_typography, '', $device, $typographyValueGlobal ),
184 + );
185 + }
186 +
187 + public function render_block_content( $attributes, $content, $block_instance ) {
188 + $attr_array = [
189 + 'form_title' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'form_title' ) ),
190 + 'username_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'username_label' ) ),
191 + 'reset_button_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'reset_button_label' ) ),
192 + 'login_button_label' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'login_button_label' ) ),
193 + 'show_logged_in_message' => filter_var( Helper::get_attribute_value( $attributes, 'show_logged_in_message' ), FILTER_VALIDATE_BOOLEAN ),
194 + ];
195 +
196 + $shortcode = '[academy_password_reset_form ' . Helper::attr_shortcode( $attr_array ) . ']';
197 + echo do_shortcode( $shortcode );
198 + }
199 +
200 +}