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/storeengine-login-form/block.php +263 -0 2.7.5 → 2.14.0 View file →
@@ -1,0 +1,263 @@
1 +<?php
2 +
3 +namespace ABlocks\Blocks\StoreengineLoginForm;
4 +
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit;
7 +}
8 +
9 +use ABlocks\Classes\BlockBaseAbstract;
10 +use ABlocks\Classes\CssGenerator;
11 +use ABlocks\Helper;
12 +use ABlocks\Controls\Typography;
13 +use ABlocks\Controls\Background;
14 +use ABlocks\Controls\Border;
15 +use ABlocks\Controls\Dimensions;
16 +use ABlocks\Controls\Color;
17 +
18 +
19 +class Block extends BlockBaseAbstract {
20 + protected $block_name = 'storeengine-login-form';
21 +
22 + public function __construct() {
23 + parent::__construct();
24 +
25 + add_filter( 'storeengine/shortcode/login_form_is_user_logged_in', [
26 + $this,
27 + 'force_showing_login_form_in_editor'
28 + ] );
29 +
30 + }
31 +
32 + public function force_showing_login_form_in_editor( $flag ) {
33 + if ( Helper::is_gutenberg_editor() ) {
34 + return false;
35 + }
36 +
37 + return $flag;
38 + }
39 +
40 + public function build_css( $attributes ) {
41 + $css_generator = new CssGenerator( $attributes );
42 + $css_generator->add_class_styles(
43 + '{{WRAPPER}} .storeengine-login-form-heading',
44 + $this->get_form_title_css( $attributes ),
45 + $this->get_form_title_css( $attributes, 'Tablet' ),
46 + $this->get_form_title_css( $attributes, 'Mobile' ),
47 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_title_css( $attributes, $device ); } )
48 + );
49 +
50 + $css_generator->add_class_styles(
51 + '{{WRAPPER}} .storeengine-login-form-heading:hover',
52 + $this->form_title_desktop_hover_css( $attributes )
53 + );
54 +
55 + $css_generator->add_class_styles(
56 + '{{WRAPPER}} .storeengine-login-form-wrapper .storeengine-login-form .storeengine-form-group
57 + label',
58 + $this->get_input_field_label_css( $attributes ),
59 + $this->get_input_field_label_css( $attributes, 'Tablet' ),
60 + $this->get_input_field_label_css( $attributes, 'Mobile' ),
61 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_label_css( $attributes, $device ); } )
62 + );
63 +
64 + $css_generator->add_class_styles(
65 + '{{WRAPPER}} .storeengine-login-form-wrapper .storeengine-login-form .storeengine-form-group
66 + label:hover',
67 + $this->get_input_field_label_hover_css( $attributes ),
68 + $this->get_input_field_label_hover_css( $attributes, 'Tablet' ),
69 + $this->get_input_field_label_hover_css( $attributes, 'Mobile' ),
70 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_label_hover_css( $attributes, $device ); } )
71 + );
72 +
73 + $css_generator->add_class_styles(
74 + '{{WRAPPER}} .storeengine-login-form-wrapper .storeengine-login-form .storeengine-form-group input',
75 + $this->get_input_field_css( $attributes ),
76 + $this->get_input_field_css( $attributes, 'Tablet' ),
77 + $this->get_input_field_css( $attributes, 'Mobile' ),
78 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_css( $attributes, $device ); } )
79 + );
80 + $css_generator->add_class_styles(
81 + '{{WRAPPER}} .storeengine-login-form-wrapper .storeengine-login-form .storeengine-form-group input:hover',
82 + $this->get_input_field_hover_css( $attributes ),
83 + $this->get_input_field_hover_css( $attributes, 'Tablet' ),
84 + $this->get_input_field_hover_css( $attributes, 'Mobile' ),
85 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_hover_css( $attributes, $device ); } )
86 + );
87 +
88 + $css_generator->add_class_styles(
89 + '{{WRAPPER}} .storeengine-login-form-wrapper .storeengine-login-form .storeengine-form-group input::placeholder',
90 + $this->get_input_field_placeholder_css( $attributes ),
91 + $this->get_input_field_placeholder_css( $attributes, 'Tablet' ),
92 + $this->get_input_field_placeholder_css( $attributes, 'Mobile' ),
93 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_input_field_placeholder_css( $attributes, $device ); } )
94 + );
95 +
96 + $css_generator->add_class_styles(
97 + '{{WRAPPER}} .storeengine-login-form-wrapper .storeengine-form-group button',
98 + $this->get_login_form_button_css( $attributes ),
99 + $this->get_login_form_button_css( $attributes, 'Tablet' ),
100 + $this->get_login_form_button_css( $attributes, 'Mobile' ),
101 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_login_form_button_css( $attributes, $device ); } )
102 + );
103 +
104 + $css_generator->add_class_styles(
105 + '{{WRAPPER}} .storeengine-login-form-wrapper .storeengine-form-group button:hover',
106 + $this->get_login_btn_hover_css( $attributes ),
107 + $this->get_login_btn_hover_css( $attributes, 'Tablet' ),
108 + $this->get_login_btn_hover_css( $attributes, 'Mobile' ),
109 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_login_btn_hover_css( $attributes, $device ); } )
110 + );
111 + $css_generator->add_class_styles(
112 + '{{WRAPPER}} .storeengine-login-form-wrapper .storeengine-login-form-info p,
113 + {{WRAPPER}} .storeengine-login-form-wrapper .storeengine-login-form-info p a ',
114 + $this->get_login_form_footer_css( $attributes ),
115 + $this->get_login_form_footer_css( $attributes, 'Tablet' ),
116 + $this->get_login_form_footer_css( $attributes, 'Mobile' ),
117 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_login_form_footer_css( $attributes, $device ); } )
118 + );
119 +
120 + $css_generator->add_class_styles(
121 + '{{WRAPPER}} .storeengine-login-form-wrapper',
122 + $this->get_form_card_css( $attributes ),
123 + $this->get_form_card_css( $attributes, 'Tablet' ),
124 + $this->get_form_card_css( $attributes, 'Mobile' ),
125 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_card_css( $attributes, $device ); } )
126 + );
127 +
128 + $css_generator->add_class_styles(
129 + '{{WRAPPER}} .storeengine-login-form-wrapper:hover',
130 + $this->get_form_card_hover_css( $attributes ),
131 + $this->get_form_card_hover_css( $attributes, 'Tablet' ),
132 + $this->get_form_card_hover_css( $attributes, 'Mobile' ),
133 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_form_card_hover_css( $attributes, $device ); } )
134 + );
135 +
136 + return $css_generator->generate_css();
137 + }
138 +
139 + public function get_form_title_css( $attributes, $device = '' ) {
140 + $form_title_typography_css = ! empty( $attributes['title_typography'] ) ? $attributes['title_typography'] : [];
141 + $typographyGlobal = ( isset( $attributes['title_typographyGlobal'] ) ? $attributes['title_typographyGlobal'] : '' );
142 + return array_merge(
143 + [ 'color' => Color::get_css( isset( $attributes['title_color'] ) ? $attributes['title_color'] : '' ) ],
144 + Typography::get_css( $form_title_typography_css, '', $device, $typographyGlobal ),
145 + );
146 + }
147 +
148 + public function get_input_field_label_css( $attributes, $device = '' ) {
149 + $input_field_label_typography_css = ! empty( $attributes['input_field_label_typography'] ) ? $attributes['input_field_label_typography'] : [];
150 + $typographyGlobal = ( isset( $attributes['input_field_label_typographyGlobal'] ) ? $attributes['input_field_label_typographyGlobal'] : '' );
151 +
152 + return array_merge(
153 + [ 'color' => Color::get_css( isset( $attributes['input_field_label_color'] ) ? $attributes['input_field_label_color'] : '' ) ],
154 + Typography::get_css( $input_field_label_typography_css, '', $device, $typographyGlobal ),
155 + );
156 + }
157 +
158 + public function get_input_field_label_hover_css( $attributes, $device = '' ) {
159 + return [ 'color' => Color::get_css( isset( $attributes['input_field_label_hover_color'] ) ? $attributes['input_field_label_hover_color'] : '' ) ];
160 + }
161 +
162 + public function get_input_field_css( $attributes, $device = '' ) {
163 + $input_border_css = ! empty( $attributes['input_field_border'] ) ? Border::get_css( $attributes['input_field_border'], '', $device ) : array();
164 + $input_field_padding = ! empty( $attributes['input_field_padding'] ) ? Dimensions::get_css( $attributes['input_field_padding'], 'padding', $device ) : array();
165 +
166 + return array_merge(
167 + [ 'color' => Color::get_css( isset( $attributes['inputFieldColor'] ) ? $attributes['inputFieldColor'] : '' ) ],
168 + [ 'background' => Color::get_css( isset( $attributes['input_field_bg_color'] ) ? $attributes['input_field_bg_color'] : '' ) ],
169 + $input_border_css,
170 + $input_field_padding
171 + );
172 + }
173 +
174 + public function get_input_field_hover_css( $attributes, $device = '' ) {
175 + return array_merge(
176 + [ 'color' => Color::get_css( isset( $attributes['inputFieldColorH'] ) ? $attributes['inputFieldColorH'] : '' ) ],
177 + [ 'background' => Color::get_css( isset( $attributes['input_field_bg_hover_color'] ) ? $attributes['input_field_bg_hover_color'] : '' ) ],
178 + );
179 + }
180 +
181 +
182 + public function get_input_field_placeholder_css( $attributes, $device = '' ) {
183 + return [ 'color' => Color::get_css( isset( $attributes['inputFieldColor'] ) ? $attributes['inputFieldColor'] : '' ) ];
184 + }
185 +
186 +
187 + public function get_login_form_button_css( $attributes, $device = '' ) {
188 + $login_form_button_typography_css = ! empty( $attributes['login_btn_typography'] ) ? $attributes['login_btn_typography'] : [];
189 + $typographyGlobal = ( isset( $attributes['login_btn_typographyGlobal'] ) ? $attributes['login_btn_typographyGlobal'] : '' );
190 + return array_merge(
191 + Typography::get_css( $login_form_button_typography_css, '', $device, $typographyGlobal ),
192 + [ 'background' => Color::get_css( isset( $attributes['login_btn_bg_color'] ) ? $attributes['login_btn_bg_color'] : '' ) ],
193 + [ 'color' => Color::get_css( isset( $attributes['login_btn_color'] ) ? $attributes['login_btn_color'] : '' ) ],
194 + );
195 + }
196 +
197 + public function get_login_btn_hover_css( $attributes, $device = '' ) {
198 + return array_merge(
199 + [ 'color' => Color::get_css( isset( $attributes['login_btn_hover_color'] ) ? $attributes['login_btn_hover_color'] : '' ) ],
200 + [ 'background' => Color::get_css( isset( $attributes['login_btn_bg_hover_color'] ) ? $attributes['login_btn_bg_hover_color'] : '' ) ],
201 + );
202 + }
203 +
204 + public function get_login_form_footer_css( $attributes, $device = '' ) {
205 + $login_form_footer_typography_css = ! empty( $attributes['form_footer_title_typography'] ) ? $attributes['form_footer_title_typography'] : [];
206 + $typographyGlobal = ( isset( $attributes['form_footer_title_typographyGlobal'] ) ? $attributes['form_footer_title_typographyGlobal'] : '' );
207 +
208 + return array_merge(
209 + [ 'color' => Color::get_css( isset( $attributes['form_footer_title_color'] ) ? $attributes['form_footer_title_color'] : '' ) ],
210 + // $login_form_footer_typography_css
211 + Typography::get_css( $login_form_footer_typography_css, '', $device, $typographyGlobal ),
212 + );
213 + }
214 +
215 + public function get_form_card_css( $attributes, $device = '' ) {
216 + $form_background_css = ! empty( $attributes['form_bg_color'] ) ? Background::get_css( $attributes['form_bg_color'], 'background', $device ) : array();
217 + $form_border = ! empty( $attributes['form_border'] ) ? Border::get_css( $attributes['form_border'], '', $device ) : array();
218 + $form_padding = ! empty( $attributes['form_padding'] ) ? Dimensions::get_css( $attributes['form_padding'], 'padding', $device ) : array();
219 +
220 + return array_merge(
221 + $form_background_css,
222 + $form_border,
223 + $form_padding
224 + );
225 + }
226 +
227 + public function get_form_card_hover_css( $attributes, $device = '' ) {
228 + $form_background_hover_css = ! empty( $attributes['form_bg_color'] ) ? Background::get_hover_css( $attributes['form_bg_color'], 'background', $device ) : array();
229 +
230 + return $form_background_hover_css;
231 + }
232 + public function form_title_desktop_hover_css( $attributes, $device = '' ) {
233 +
234 + return [ 'color' => Color::get_css( isset( $attributes['title_hover_color'] ) ? $attributes['title_hover_color'] : '' ) ];
235 + }
236 +
237 + public function render_block_content( $attributes, $content, $block_instance ) {
238 + $attr_array = [
239 + 'form_title' => Helper::get_attribute_value( $attributes, 'form_title' ),
240 + 'username_label' => Helper::get_attribute_value( $attributes, 'username_label' ),
241 + 'username_placeholder' => Helper::get_attribute_value( $attributes, 'username_placeholder' ),
242 + 'password_label' => Helper::get_attribute_value( $attributes, 'password_label' ),
243 + 'password_placeholder' => Helper::get_attribute_value( $attributes, 'password_placeholder' ),
244 + 'remember_label' => Helper::get_attribute_value( $attributes, 'remember_label' ),
245 + 'login_button_label' => Helper::get_attribute_value( $attributes, 'login_button_label' ),
246 + 'reset_password_label' => Helper::get_attribute_value( $attributes, 'reset_password_label' ),
247 + 'show_logged_in_message' => Helper::get_attribute_value( $attributes, 'show_logged_in_message' ),
248 + 'register_url' => Helper::get_attribute_value( $attributes, 'register_url' ),
249 + 'login_redirect_url' => Helper::get_attribute_value( $attributes, 'login_redirect_url' ),
250 + 'logout_redirect_url' => Helper::get_attribute_value( $attributes, 'logout_redirect_url' ),
251 + ];
252 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
253 + if ( isset( $_GET['context'] ) && 'edit' === sanitize_text_field( $_GET['context'] ) ) {
254 + add_filter( 'storeengine/shortcode/login_form_is_user_logged_in', function () {
255 + return false;
256 + } );
257 + }
258 +
259 + $shortcode = '[storeengine_login_form ' . Helper::attr_shortcode( $attr_array ) . ']';
260 + echo do_shortcode( $shortcode );
261 + }
262 +
263 +}