PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.3.0
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.3.0
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / modules / bricks / elements / class-cartflows-bricks-optin-form.php

class-cartflows-bricks-optin-form.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.3.0, at modules/bricks/elements/class-cartflows-bricks-optin-form.php

408 lines 10.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bricks Classes.
4 *
5 * @package cartflows
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Optin Form Widget
14 *
15 * @since 1.6.15
16 */
17 class CartFlows_Bricks_Optin_Form extends \Bricks\Element {
18 /**
19 * Category of the element.
20 *
21 * @var instance
22 */
23 public $category = 'CartFlows';
24
25 /**
26 * Name of the element.
27 *
28 * @var instance
29 */
30
31 public $name = 'bricks-optin-form';
32
33 /**
34 * Icon of the element.
35 *
36 * @var instance
37 */
38 public $icon = 'fa-solid fa-envelope-open-text';
39
40 /**
41 * Label of the element.
42 *
43 * @var instance
44 */
45 public function get_label() {
46 return esc_html__( 'Optin Form', 'cartflows' );
47 }
48
49 /**
50 * Retrieve Widget Keywords.
51 *
52 * @since 1.6.15
53 * @access public
54 *
55 * @return string Widget keywords.
56 */
57 public function get_keywords() {
58 return array( 'cartflows', 'optin', 'form' );
59 }
60 /**
61 * Set builder control groups
62 *
63 * @since 3.1.0
64 * @access public
65 */
66 public function set_control_groups() {
67 $this->control_groups['general_fields'] = array(
68 'title' => esc_html__( 'General', 'cartflows' ),
69 'tab' => 'style',
70 );
71 $this->control_groups['input_fields'] = array(
72 'title' => esc_html__( 'Input Fields', 'cartflows' ),
73 'tab' => 'style',
74 );
75 $this->control_groups['button_fields'] = array(
76 'title' => esc_html__( 'Button', 'cartflows' ),
77 'tab' => 'style',
78 );
79 }
80 /**
81 * Register cart controls controls.
82 *
83 * @since 1.6.15
84 * @access protected
85 */
86 public function set_controls() {
87
88 // Style Tab.
89 $this->register_general_style_controls();
90 $this->register_input_style_controls();
91 $this->register_button_style_controls();
92 }
93
94 /**
95 * Function to get skin types.
96 *
97 * @since 1.6.15
98 * @access protected
99 */
100 public function get_skin_types() {
101
102 $skin_options = array(
103 'default' => __( 'Default', 'cartflows' ),
104 'floating-labels' => __( 'Floating Labels', 'cartflows' ),
105 );
106
107 return $skin_options;
108 }
109
110 /**
111 * Register General Style Controls.
112 *
113 * @since 1.6.15
114 * @access protected
115 */
116 public function register_general_style_controls() {
117
118 $this->controls['general_primary_color'] = array(
119 'label' => __( 'Primary Color', 'cartflows' ),
120 'type' => 'color',
121 'default' => '',
122 'group' => 'general_fields',
123 'css' => array(
124 array(
125 'property' => 'background-color',
126 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order',
127 ),
128 array(
129 'property' => 'border-color',
130 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order',
131 ),
132 ),
133 );
134
135 $this->controls['general_typography'] = array(
136 'label' => 'Typography',
137 'type' => 'typography',
138 'group' => 'general_fields',
139 'css' => array(
140 array(
141 'property' => 'font',
142 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout label',
143 ),
144 array(
145 'property' => 'font',
146 'selector' => ' .wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout input',
147 ),
148 array(
149 'property' => 'font',
150 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order',
151 ),
152 ),
153 );
154 }
155
156 /**
157 * Register Input Fields Style Controls.
158 *
159 * @since 1.6.15
160 * @access protected
161 */
162 public function register_input_style_controls() {
163 $this->controls['input_skins'] = array(
164 'label' => __( 'Style', 'cartflows' ),
165 'type' => 'select',
166 'default' => 'default',
167 'options' => $this->get_skin_types(),
168 'group' => 'input_fields',
169 );
170
171 $this->controls['input_text_color'] = array(
172 'label' => __( 'Text Color', 'cartflows' ),
173 'type' => 'typography',
174 'group' => 'input_fields',
175 'css' => array(
176 array(
177 'property' => 'font',
178 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout label',
179 ),
180 array(
181 'property' => 'font',
182 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout input',
183 ),
184 ),
185 );
186
187 $this->controls['input_bgcolor'] = array(
188 'label' => __( 'Field Background Color', 'cartflows' ),
189 'type' => 'color',
190 'default' => '',
191 'group' => 'input_fields',
192 'css' => array(
193 array(
194 'property' => 'background-color',
195 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout input',
196 ),
197 ),
198 );
199
200 $this->controls['input_color'] = array(
201 'label' => __( 'Input Text / Placeholder Color', 'cartflows' ),
202 'type' => 'color',
203 'default' => '',
204 'group' => 'input_fields',
205 'css' => array(
206 array(
207 'property' => 'color',
208 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout input',
209 ),
210
211 ),
212 );
213
214 $this->controls['input_border'] = array(
215 'label' => __( 'Border', 'cartflows' ),
216 'type' => 'border',
217 'default' => array(),
218 'group' => 'input_fields',
219 'css' => array(
220 array(
221 'property' => 'border',
222 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout input',
223 ),
224 ),
225 );
226
227
228 }
229
230 /**
231 * Register Button Style Controls.
232 *
233 * @since 1.6.15
234 * @access protected
235 */
236 public function register_button_style_controls() {
237
238 $this->controls['buttons_typography'] = array(
239 'label' => 'Typography',
240 'type' => 'typography',
241 'group' => 'button_fields',
242 'css' => array(
243 array(
244 'property' => 'font',
245 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order',
246 ),
247 ),
248 );
249
250 $this->controls['button_text_color'] = array(
251 'label' => __( 'Text Color', 'cartflows' ),
252 'type' => 'color',
253 'default' => '',
254 'group' => 'button_fields',
255 'css' => array(
256 array(
257 'property' => 'color',
258 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order',
259 ),
260 ),
261 );
262
263 $this->controls['btn_background_color'] = array(
264 'label' => __( 'Background Color', 'cartflows' ),
265 'type' => 'color',
266 'default' => '',
267 'group' => 'button_fields',
268 'css' => array(
269 array(
270 'property' => 'background-color',
271 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order',
272 ),
273 ),
274 );
275
276 $this->controls['btn_border'] = array(
277 'label' => __( 'Border', 'cartflows' ),
278 'type' => 'border',
279 'default' => array(),
280 'group' => 'button_fields',
281 'css' => array(
282 array(
283 'property' => 'border',
284 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order',
285 ),
286 ),
287 );
288
289 $this->controls['button_box_shadow'] = array(
290 'label' => __( 'Box Shadow', 'cartflows' ),
291 'type' => 'box-shadow',
292 'default' => array(),
293 'group' => 'button_fields',
294 'css' => array(
295 array(
296 'property' => 'box-shadow',
297 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order',
298 ),
299 ),
300 );
301
302 $this->controls['button_hover_color'] = array(
303 'label' => __( 'Text Color', 'cartflows' ),
304 'type' => 'color',
305 'default' => '',
306 'group' => 'button_fields',
307 'css' => array(
308 array(
309 'property' => 'color',
310 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order:hover',
311 ),
312 ),
313 );
314
315 $this->controls['button_hover_border_color'] = array(
316 'label' => __( 'Border Hover Color', 'cartflows' ),
317 'type' => 'color',
318 'default' => '',
319 'group' => 'button_fields',
320 'css' => array(
321 array(
322 'property' => 'border-color',
323 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order:hover',
324 ),
325 ),
326 );
327
328 $this->controls['button_background_hover_color'] = array(
329 'label' => __( 'Background Color', 'cartflows' ),
330 'type' => 'color',
331 'default' => '',
332 'group' => 'button_fields',
333 'css' => array(
334 array(
335 'property' => 'background-color',
336 'selector' => '.wcf-bricks-optin-form.cartflows-bricks__optin-form .wcf-optin-form .checkout.woocommerce-checkout .wcf-order-wrap #order_review .woocommerce-checkout-payment button#place_order:hover',
337 ),
338 ),
339 );
340 }
341
342
343 /**
344 * Render element HTML on frontend
345 *
346 * If no 'render_builder' function is defined then this code is used to render element HTML in builder, too.
347 */
348 public function render() {
349 $this->set_attribute( '_root', 'data-element-id', $this->id );
350 $checkout_id = $this->post_id;
351
352 $this->dynamic_option_filters();
353
354 do_action( 'cartflows_bricks_before_optin_shortcode', $checkout_id );
355
356 ?>
357 <div <?php echo $this->render_attributes( '_root' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> >
358 <div class = "wcf-bricks-optin-form cartflows-bricks__optin-form">
359 <?php
360 echo do_shortcode( '[cartflows_optin]' );
361 ?>
362 </div>
363 </div>
364 <?php
365 }
366
367 /**
368 * Dynamic options of elementor and add filters.
369 *
370 * @since 1.6.15
371 */
372 public function dynamic_option_filters() {
373
374 $optin_fields = array(
375
376 // Input Fields.
377 array(
378 'filter_slug' => 'wcf-input-fields-skins',
379 'setting_name' => 'input_skins',
380 ),
381 );
382
383 if ( isset( $optin_fields ) && is_array( $optin_fields ) ) {
384
385 foreach ( $optin_fields as $key => $field ) {
386
387 $setting_name = $field['setting_name'];
388
389 add_filter(
390 'cartflows_optin_meta_' . $field['filter_slug'],
391 function ( $value ) use ( $setting_name ) {
392 if ( ! empty( $this->settings[ $setting_name ] ) ) {
393 $value = $this->settings[ $setting_name ];
394
395 return $value;
396 }
397
398 },
399 10,
400 1
401 );
402 }
403 }
404
405 do_action( 'cartflows_bricks_optin_options_filters', $this->settings );
406 }
407 }
408