| 1 |
<?php |
| 2 |
/** |
| 3 |
* Namespace for the Optin class. |
| 4 |
* This class is part of the WPFunnels\Widgets\Bricks namespace. |
| 5 |
*/ |
| 6 |
namespace WPFunnels\Widgets\Bricks; |
| 7 |
|
| 8 |
require_once get_template_directory() . '/includes/elements/base.php'; |
| 9 |
|
| 10 |
use \Bricks\Element; |
| 11 |
use WPFunnels\Widgets\Wpfnl_Widgets_Manager; |
| 12 |
use WPFunnels\Wpfnl_functions; |
| 13 |
|
| 14 |
if (! defined('ABSPATH')) { |
| 15 |
exit; |
| 16 |
} // Exit if accessed directly |
| 17 |
|
| 18 |
|
| 19 |
/** |
| 20 |
* Class Optin |
| 21 |
* |
| 22 |
* Represents an optin element. |
| 23 |
* Extends the Element class. |
| 24 |
* |
| 25 |
* @package WPFunnels\Widgets\Bricks |
| 26 |
*/ |
| 27 |
class Optin extends Element |
| 28 |
{ |
| 29 |
|
| 30 |
// Element properties |
| 31 |
public $category = 'wpfunnels'; // Use predefined element category 'general' |
| 32 |
public $name = 'wpfnl_optin'; // Make sure to prefix your elements |
| 33 |
public $icon = 'fa-solid fa-cart-shopping'; // Themify icon font class |
| 34 |
public $scripts = []; // Script(s) run when element is rendered on frontend or updated in builder |
| 35 |
|
| 36 |
|
| 37 |
/** |
| 38 |
* Return localised element label |
| 39 |
* |
| 40 |
* @return string |
| 41 |
* @since 3.1.0 |
| 42 |
* @access public |
| 43 |
*/ |
| 44 |
public function get_label() |
| 45 |
{ |
| 46 |
return esc_html__('Opt-in', 'wpfnl'); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
/** |
| 51 |
* Sets the control for the source of the opt-in form. |
| 52 |
* |
| 53 |
* @since 3.1.0 |
| 54 |
* |
| 55 |
* @access public |
| 56 |
*/ |
| 57 |
public function optin_form_source_control(){ |
| 58 |
// Group: Opt-in form Source |
| 59 |
$this->controls['optin_form_source'] = [ |
| 60 |
'tab' => 'content', |
| 61 |
'group' => 'optin_form_source_group', |
| 62 |
'label' => esc_html__( 'Form Source', 'wpfnl' ), |
| 63 |
'type' => 'select', |
| 64 |
'options' => [ |
| 65 |
'wpfnl_forms' => 'WPFunnels', |
| 66 |
'mailmint_forms' => 'Mail Mint', |
| 67 |
], |
| 68 |
'inline' => false, |
| 69 |
'default' => 'wpfnl_forms', |
| 70 |
]; |
| 71 |
|
| 72 |
$mailmint_forms = Wpfnl_Widgets_Manager::get_mailmint_forms(); |
| 73 |
|
| 74 |
$this->controls['mailmint_form_id'] = [ |
| 75 |
'tab' => 'content', |
| 76 |
'group' => 'optin_form_source_group', |
| 77 |
'label' => esc_html__( 'Choose form', 'wpfnl' ), |
| 78 |
'type' => 'select', |
| 79 |
'default' => array_key_first( $mailmint_forms ), |
| 80 |
'options' => $mailmint_forms, |
| 81 |
'inline' => false, |
| 82 |
'required' => [ 'optin_form_source', '=', 'mailmint_forms' ], |
| 83 |
]; |
| 84 |
|
| 85 |
if( \WPFunnels\Integrations\Helper::maybe_enabled() ) { |
| 86 |
$this->controls['enable_mm_contact'] = [ |
| 87 |
'tab' => 'content', |
| 88 |
'group' => 'optin_form_source_group', |
| 89 |
'label' => esc_html__( 'Send leads to Mail Mint', 'wpfnl' ), |
| 90 |
'type' => 'checkbox', |
| 91 |
]; |
| 92 |
|
| 93 |
$this->controls['mm_contact_status'] = [ |
| 94 |
'tab' => 'content', |
| 95 |
'group' => 'optin_form_source_group', |
| 96 |
'label' => esc_html__( 'Contact Status', 'wpfnl' ), |
| 97 |
'type' => 'select', |
| 98 |
'options' => [ |
| 99 |
'pending' => __('Pending', 'wpfnl'), |
| 100 |
'subscribed' => __('Subscribed', 'wpfnl'), |
| 101 |
'unsubscribed' => __('Unsubscribed', 'wpfnl'), |
| 102 |
], |
| 103 |
'inline' => true, |
| 104 |
'default' => 'subscribed', |
| 105 |
'required' => [ 'enable_mm_contact'], |
| 106 |
]; |
| 107 |
|
| 108 |
$this->controls['mm_lists'] = [ |
| 109 |
'tab' => 'content', |
| 110 |
'group' => 'optin_form_source_group', |
| 111 |
'label' => esc_html__( 'Select List', 'wpfnl' ), |
| 112 |
'type' => 'select', |
| 113 |
'options' => \WPFunnels\Integrations\Helper::get_lists(), |
| 114 |
'inline' => true, |
| 115 |
'default' => '', |
| 116 |
'required' => [ 'enable_mm_contact'], |
| 117 |
]; |
| 118 |
|
| 119 |
$this->controls['mm_tags'] = [ |
| 120 |
'tab' => 'content', |
| 121 |
'group' => 'optin_form_source_group', |
| 122 |
'label' => esc_html__( 'Select Tag', 'wpfnl' ), |
| 123 |
'type' => 'select', |
| 124 |
'options' => \WPFunnels\Integrations\Helper::get_tags(), |
| 125 |
'inline' => true, |
| 126 |
'default' => '', |
| 127 |
'required' => [ 'enable_mm_contact'], |
| 128 |
]; |
| 129 |
}else{ |
| 130 |
$this->controls['mm_install'] = [ |
| 131 |
'tab' => 'content', |
| 132 |
'group' => 'optin_form_source_group', |
| 133 |
'content' => sprintf( __( 'Manage your leads easily using Mail Mint. <a href="https://wordpress.org/plugins/mail-mint/" target="_blank" rel="noopener">Try it now</a>.', 'wpfnl' )), |
| 134 |
'type' => 'info', |
| 135 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 136 |
]; |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
/** |
| 142 |
* Sets the control for the optin form type. |
| 143 |
* |
| 144 |
* @since 3.1.0 |
| 145 |
* |
| 146 |
* @access public |
| 147 |
*/ |
| 148 |
public function optin_form_type_control(){ |
| 149 |
// Group: Opt-in form Type |
| 150 |
$this->controls['optin_form_type'] = [ |
| 151 |
'tab' => 'content', |
| 152 |
'group' => 'form_layout_group', |
| 153 |
'label' => esc_html__( 'Opt-in Form Type', 'wpfnl' ), |
| 154 |
'type' => 'select', |
| 155 |
'options' => [ |
| 156 |
'general-optin' => 'General Opt-in', |
| 157 |
'clickto-expand-optin' => 'Click To Expand', |
| 158 |
], |
| 159 |
'inline' => true, |
| 160 |
'default' => 'general-optin', |
| 161 |
]; |
| 162 |
|
| 163 |
$this->controls['optin_form_layout'] = [ |
| 164 |
'tab' => 'content', |
| 165 |
'group' => 'form_layout_group', |
| 166 |
'label' => esc_html__( 'Form Style', 'wpfnl' ), |
| 167 |
'type' => 'select', |
| 168 |
'options' => [ |
| 169 |
'' => __( 'Default Style', 'wpfnl' ), |
| 170 |
'form-style1' => __('Form Style-1', 'wpfnl'), |
| 171 |
'form-style2' => __('Form Style-2', 'wpfnl'), |
| 172 |
'form-style3' => __('Form Style-3', 'wpfnl'), |
| 173 |
'form-style4' => __('Form Style-4', 'wpfnl'), |
| 174 |
], |
| 175 |
'inline' => true, |
| 176 |
'default' => '', |
| 177 |
]; |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
/** |
| 182 |
* Sets the control for the optin form field. |
| 183 |
* |
| 184 |
* @since 3.1.0 |
| 185 |
* |
| 186 |
* @access public |
| 187 |
*/ |
| 188 |
public function optin_form_field_control(){ |
| 189 |
// Group: Form fields |
| 190 |
|
| 191 |
// Label condition |
| 192 |
$this->controls['field_label'] = [ |
| 193 |
'tab' => 'content', |
| 194 |
'group' => 'form_field_group', |
| 195 |
'label' => esc_html__( 'Show Field Label', 'wpfnl' ), |
| 196 |
'type' => 'checkbox', |
| 197 |
]; |
| 198 |
|
| 199 |
//Icon condition |
| 200 |
$this->controls['input_fields_icon'] = [ |
| 201 |
'tab' => 'content', |
| 202 |
'group' => 'form_field_group', |
| 203 |
'label' => esc_html__( 'Show Input Field Icon', 'wpfnl' ), |
| 204 |
'type' => 'checkbox', |
| 205 |
'default' => true |
| 206 |
]; |
| 207 |
|
| 208 |
|
| 209 |
$this->controls['labelSeparator'] = [ |
| 210 |
'type' => 'separator', |
| 211 |
'group' => 'form_field_group', |
| 212 |
]; |
| 213 |
|
| 214 |
|
| 215 |
//------Email------ |
| 216 |
$this->controls['email_label'] = [ |
| 217 |
'tab' => 'content', |
| 218 |
'group' => 'form_field_group', |
| 219 |
'label' => esc_html__( 'Email Label', 'wpfnl' ), |
| 220 |
'type' => 'text', |
| 221 |
'spellcheck' => true, // Default: false |
| 222 |
'inlineEditing' => false, |
| 223 |
'default' => 'Email', |
| 224 |
'required' => [ 'field_label'], |
| 225 |
]; |
| 226 |
|
| 227 |
$this->controls['email_placeholder'] = [ |
| 228 |
'tab' => 'content', |
| 229 |
'group' => 'form_field_group', |
| 230 |
'label' => esc_html__( 'Email Placeholder Text', 'wpfnl' ), |
| 231 |
'type' => 'text', |
| 232 |
'spellcheck' => true, // Default: false |
| 233 |
'inlineEditing' => false, |
| 234 |
'default' => 'Email', |
| 235 |
'placeholder' => 'Email Placeholder Text', |
| 236 |
]; |
| 237 |
|
| 238 |
$this->controls['emailSeparator'] = [ |
| 239 |
'type' => 'separator', |
| 240 |
'group' => 'form_field_group', |
| 241 |
]; |
| 242 |
|
| 243 |
|
| 244 |
// First Name |
| 245 |
$this->controls['first_name'] = [ |
| 246 |
'tab' => 'content', |
| 247 |
'group' => 'form_field_group', |
| 248 |
'label' => esc_html__( 'First Name', 'wpfnl' ), |
| 249 |
'type' => 'checkbox', |
| 250 |
]; |
| 251 |
$this->controls['first_name_label'] = [ |
| 252 |
'tab' => 'content', |
| 253 |
'group' => 'form_field_group', |
| 254 |
'label' => esc_html__( 'Label', 'wpfnl' ), |
| 255 |
'type' => 'text', |
| 256 |
'inline' => true, |
| 257 |
'spellcheck' => true, // Default: false |
| 258 |
'inlineEditing' => false, |
| 259 |
'default' => 'First Name', |
| 260 |
'placeholder' => 'First Name', |
| 261 |
'required' => [ 'field_label'], |
| 262 |
'required' => [ 'first_name'], |
| 263 |
]; |
| 264 |
$this->controls['first_name_placeholder'] = [ |
| 265 |
'tab' => 'content', |
| 266 |
'group' => 'form_field_group', |
| 267 |
'label' => esc_html__( 'Placeholder Text', 'wpfnl' ), |
| 268 |
'type' => 'text', |
| 269 |
'inline' => true, |
| 270 |
'spellcheck' => true, // Default: false |
| 271 |
'inlineEditing' => false, |
| 272 |
'default' => 'First Name', |
| 273 |
'placeholder' => 'First Name', |
| 274 |
'required' => [ 'first_name'], |
| 275 |
]; |
| 276 |
$this->controls['is_required_name'] = [ |
| 277 |
'tab' => 'content', |
| 278 |
'group' => 'form_field_group', |
| 279 |
'label' => esc_html__( 'Mark First Name As Required', 'wpfnl' ), |
| 280 |
'type' => 'checkbox', |
| 281 |
'required' => [ 'first_name'], |
| 282 |
]; |
| 283 |
// End First Name |
| 284 |
|
| 285 |
|
| 286 |
$this->controls['firstNameSeparator'] = [ |
| 287 |
'type' => 'separator', |
| 288 |
'group' => 'form_field_group', |
| 289 |
]; |
| 290 |
|
| 291 |
|
| 292 |
// Last Name |
| 293 |
$this->controls['last_name'] = [ |
| 294 |
'tab' => 'content', |
| 295 |
'group' => 'form_field_group', |
| 296 |
'label' => esc_html__( 'Last Name', 'wpfnl' ), |
| 297 |
'type' => 'checkbox', |
| 298 |
]; |
| 299 |
$this->controls['last_name_label'] = [ |
| 300 |
'tab' => 'content', |
| 301 |
'group' => 'form_field_group', |
| 302 |
'label' => esc_html__( 'Label', 'wpfnl' ), |
| 303 |
'type' => 'text', |
| 304 |
'inline' => true, |
| 305 |
'spellcheck' => true, // Default: false |
| 306 |
'inlineEditing' => false, |
| 307 |
'default' => 'Last Name', |
| 308 |
'placeholder' => 'Last Name', |
| 309 |
'required' => [ 'field_label'], |
| 310 |
'required' => [ 'last_name'], |
| 311 |
]; |
| 312 |
$this->controls['last_name_placeholder'] = [ |
| 313 |
'tab' => 'content', |
| 314 |
'group' => 'form_field_group', |
| 315 |
'label' => esc_html__( 'Placeholder Text', 'wpfnl' ), |
| 316 |
'type' => 'text', |
| 317 |
'inline' => true, |
| 318 |
'spellcheck' => true, // Default: false |
| 319 |
'inlineEditing' => false, |
| 320 |
'default' => 'Last Name', |
| 321 |
'placeholder' => 'Last Name', |
| 322 |
'required' => [ 'last_name'], |
| 323 |
]; |
| 324 |
$this->controls['is_required_last_name'] = [ |
| 325 |
'tab' => 'content', |
| 326 |
'group' => 'form_field_group', |
| 327 |
'label' => esc_html__( 'Mark Last Name As Required', 'wpfnl' ), |
| 328 |
'type' => 'checkbox', |
| 329 |
'required' => [ 'last_name'], |
| 330 |
]; |
| 331 |
// End Last Name |
| 332 |
|
| 333 |
|
| 334 |
$this->controls['lastNameSeparator'] = [ |
| 335 |
'type' => 'separator', |
| 336 |
'group' => 'form_field_group', |
| 337 |
]; |
| 338 |
|
| 339 |
|
| 340 |
// Phone |
| 341 |
$this->controls['phone'] = [ |
| 342 |
'tab' => 'content', |
| 343 |
'group' => 'form_field_group', |
| 344 |
'label' => esc_html__( 'Phone', 'wpfnl' ), |
| 345 |
'type' => 'checkbox', |
| 346 |
]; |
| 347 |
$this->controls['phone_label'] = [ |
| 348 |
'tab' => 'content', |
| 349 |
'group' => 'form_field_group', |
| 350 |
'label' => esc_html__( 'Label', 'wpfnl' ), |
| 351 |
'type' => 'text', |
| 352 |
'inline' => true, |
| 353 |
'spellcheck' => true, // Default: false |
| 354 |
'inlineEditing' => false, |
| 355 |
'default' => 'Phone', |
| 356 |
'placeholder' => 'Phone', |
| 357 |
'required' => [ 'field_label'], |
| 358 |
'required' => [ 'phone'], |
| 359 |
]; |
| 360 |
$this->controls['phone_placeholder'] = [ |
| 361 |
'tab' => 'content', |
| 362 |
'group' => 'form_field_group', |
| 363 |
'label' => esc_html__( 'Placeholder Text', 'wpfnl' ), |
| 364 |
'type' => 'text', |
| 365 |
'inline' => true, |
| 366 |
'spellcheck' => true, // Default: false |
| 367 |
'inlineEditing' => false, |
| 368 |
'default' => 'Phone', |
| 369 |
'placeholder' => 'Phone', |
| 370 |
'required' => [ 'phone'], |
| 371 |
]; |
| 372 |
$this->controls['is_required_phone'] = [ |
| 373 |
'tab' => 'content', |
| 374 |
'group' => 'form_field_group', |
| 375 |
'label' => esc_html__( 'Mark Phone As Required', 'wpfnl' ), |
| 376 |
'type' => 'checkbox', |
| 377 |
'required' => [ 'phone'], |
| 378 |
]; |
| 379 |
// End Phone |
| 380 |
|
| 381 |
|
| 382 |
$this->controls['phoneSeparator'] = [ |
| 383 |
'type' => 'separator', |
| 384 |
'group' => 'form_field_group', |
| 385 |
]; |
| 386 |
|
| 387 |
|
| 388 |
// Website URL |
| 389 |
$this->controls['website_url'] = [ |
| 390 |
'tab' => 'content', |
| 391 |
'group' => 'form_field_group', |
| 392 |
'label' => esc_html__( 'Website Url', 'wpfnl' ), |
| 393 |
'type' => 'checkbox', |
| 394 |
]; |
| 395 |
$this->controls['website_url_label'] = [ |
| 396 |
'tab' => 'content', |
| 397 |
'group' => 'form_field_group', |
| 398 |
'label' => esc_html__( 'Label', 'wpfnl' ), |
| 399 |
'type' => 'text', |
| 400 |
'inline' => true, |
| 401 |
'spellcheck' => true, // Default: false |
| 402 |
'inlineEditing' => false, |
| 403 |
'default' => 'Website Url', |
| 404 |
'placeholder' => 'Website Url', |
| 405 |
'required' => [ 'field_label'], |
| 406 |
'required' => [ 'website_url'], |
| 407 |
]; |
| 408 |
$this->controls['website_url_placeholder'] = [ |
| 409 |
'tab' => 'content', |
| 410 |
'group' => 'form_field_group', |
| 411 |
'label' => esc_html__( 'Placeholder Text', 'wpfnl' ), |
| 412 |
'type' => 'text', |
| 413 |
'inline' => true, |
| 414 |
'spellcheck' => true, // Default: false |
| 415 |
'inlineEditing' => false, |
| 416 |
'default' => 'Website Url', |
| 417 |
'placeholder' => 'Website Url', |
| 418 |
'required' => [ 'website_url'], |
| 419 |
]; |
| 420 |
$this->controls['is_required_website_url'] = [ |
| 421 |
'tab' => 'content', |
| 422 |
'group' => 'form_field_group', |
| 423 |
'label' => esc_html__( 'Mark Website Url As Required', 'wpfnl' ), |
| 424 |
'type' => 'checkbox', |
| 425 |
'required' => [ 'website_url'], |
| 426 |
]; |
| 427 |
// End Website URL |
| 428 |
|
| 429 |
|
| 430 |
$this->controls['weburlSeparator'] = [ |
| 431 |
'type' => 'separator', |
| 432 |
'group' => 'form_field_group', |
| 433 |
]; |
| 434 |
|
| 435 |
|
| 436 |
// Message |
| 437 |
$this->controls['message'] = [ |
| 438 |
'tab' => 'content', |
| 439 |
'group' => 'form_field_group', |
| 440 |
'label' => esc_html__( 'Message', 'wpfnl' ), |
| 441 |
'type' => 'checkbox', |
| 442 |
]; |
| 443 |
$this->controls['message_label'] = [ |
| 444 |
'tab' => 'content', |
| 445 |
'group' => 'form_field_group', |
| 446 |
'label' => esc_html__( 'Label', 'wpfnl' ), |
| 447 |
'type' => 'text', |
| 448 |
'inline' => true, |
| 449 |
'spellcheck' => true, // Default: false |
| 450 |
'inlineEditing' => false, |
| 451 |
'default' => 'Message', |
| 452 |
'placeholder' => 'Message', |
| 453 |
'required' => [ 'field_label'], |
| 454 |
'required' => [ 'message'], |
| 455 |
]; |
| 456 |
$this->controls['message_placeholder'] = [ |
| 457 |
'tab' => 'content', |
| 458 |
'group' => 'form_field_group', |
| 459 |
'label' => esc_html__( 'Placeholder Text', 'wpfnl' ), |
| 460 |
'type' => 'text', |
| 461 |
'inline' => false, |
| 462 |
'spellcheck' => true, // Default: false |
| 463 |
'inlineEditing' => false, |
| 464 |
'default' => '', |
| 465 |
'placeholder' => 'Write your message here...', |
| 466 |
'required' => [ 'message'], |
| 467 |
]; |
| 468 |
$this->controls['is_required_message'] = [ |
| 469 |
'tab' => 'content', |
| 470 |
'group' => 'form_field_group', |
| 471 |
'label' => esc_html__( 'Mark Message As Required', 'wpfnl' ), |
| 472 |
'type' => 'checkbox', |
| 473 |
'required' => [ 'message'], |
| 474 |
]; |
| 475 |
// End Message |
| 476 |
|
| 477 |
|
| 478 |
$this->controls['messageSeparator'] = [ |
| 479 |
'type' => 'separator', |
| 480 |
'group' => 'form_field_group', |
| 481 |
]; |
| 482 |
|
| 483 |
|
| 484 |
// Acceptance Checkbox |
| 485 |
$this->controls['acceptance_checkbox'] = [ |
| 486 |
'tab' => 'content', |
| 487 |
'group' => 'form_field_group', |
| 488 |
'label' => esc_html__( 'Acceptance Checkbox', 'wpfnl' ), |
| 489 |
'type' => 'checkbox', |
| 490 |
]; |
| 491 |
$this->controls['acceptance_checkbox_text'] = [ |
| 492 |
'tab' => 'content', |
| 493 |
'group' => 'form_field_group', |
| 494 |
'label' => esc_html__( 'Acceptance Text', 'wpfnl' ), |
| 495 |
'type' => 'editor', |
| 496 |
'inline' => false, |
| 497 |
'spellcheck' => true, // Default: false |
| 498 |
'inlineEditing' => [ |
| 499 |
'selector' => '.text-editor', // Mount inline editor to this CSS selector |
| 500 |
'toolbar' => true, // Enable/disable inline editing toolbar |
| 501 |
], |
| 502 |
'default' => 'I have read and agree the Terms & Condition.', |
| 503 |
'required' => [ 'field_label'], |
| 504 |
'required' => [ 'acceptance_checkbox'], |
| 505 |
]; |
| 506 |
$this->controls['is_required_acceptance'] = [ |
| 507 |
'tab' => 'content', |
| 508 |
'group' => 'form_field_group', |
| 509 |
'label' => esc_html__( 'Mark Acceptance As Required', 'wpfnl' ), |
| 510 |
'type' => 'checkbox', |
| 511 |
'required' => [ 'acceptance_checkbox'], |
| 512 |
]; |
| 513 |
// End Acceptance Checkbox |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
/** |
| 518 |
* Sets the control for the optin form click to expand button. |
| 519 |
* |
| 520 |
* @since 3.1.0 |
| 521 |
* |
| 522 |
* @access public |
| 523 |
* |
| 524 |
*/ |
| 525 |
public function optin_form_expand_button_control(){ |
| 526 |
// Group: Expand Button |
| 527 |
$this->controls['expandButtonText'] = [ |
| 528 |
'tab' => 'content', |
| 529 |
'group' => 'expand_button_group', |
| 530 |
'label' => esc_html__( 'Text', 'wpfnl' ), |
| 531 |
'type' => 'text', |
| 532 |
'inline' => true, |
| 533 |
'placeholder' => esc_html__( 'Send', 'wpfnl' ), |
| 534 |
]; |
| 535 |
|
| 536 |
$this->controls['expandButtonSize'] = [ |
| 537 |
'tab' => 'content', |
| 538 |
'group' => 'expand_button_group', |
| 539 |
'label' => esc_html__( 'Size', 'wpfnl' ), |
| 540 |
'type' => 'select', |
| 541 |
'default' => 'xl', |
| 542 |
'inline' => true, |
| 543 |
'options' => $this->control_options['buttonSizes'], |
| 544 |
]; |
| 545 |
|
| 546 |
$this->controls['expandButtonMargin'] = [ |
| 547 |
'tab' => 'content', |
| 548 |
'group' => 'expand_button_group', |
| 549 |
'label' => esc_html__( 'Margin', 'wpfnl' ), |
| 550 |
'type' => 'spacing', |
| 551 |
'css' => [ |
| 552 |
[ |
| 553 |
'property' => 'margin', |
| 554 |
'selector' => '.expand-bricks-button', |
| 555 |
], |
| 556 |
], |
| 557 |
]; |
| 558 |
|
| 559 |
$this->controls['expandButtonPadding'] = [ |
| 560 |
'tab' => 'content', |
| 561 |
'group' => 'expand_button_group', |
| 562 |
'label' => esc_html__( 'Padding', 'wpfnl' ), |
| 563 |
'type' => 'spacing', |
| 564 |
'css' => [ |
| 565 |
[ |
| 566 |
'property' => 'padding', |
| 567 |
'selector' => '.expand-bricks-button', |
| 568 |
], |
| 569 |
], |
| 570 |
]; |
| 571 |
|
| 572 |
$this->controls['expandButtonTypography'] = [ |
| 573 |
'tab' => 'content', |
| 574 |
'group' => 'expand_button_group', |
| 575 |
'label' => esc_html__( 'Typography', 'wpfnl' ), |
| 576 |
'type' => 'typography', |
| 577 |
'css' => [ |
| 578 |
[ |
| 579 |
'property' => 'font', |
| 580 |
'selector' => '.expand-bricks-button', |
| 581 |
] |
| 582 |
], |
| 583 |
]; |
| 584 |
|
| 585 |
$this->controls['expandButtonBackgroundColor'] = [ |
| 586 |
'tab' => 'content', |
| 587 |
'group' => 'expand_button_group', |
| 588 |
'label' => esc_html__( 'Background', 'wpfnl' ), |
| 589 |
'type' => 'color', |
| 590 |
'default' => '#6E42D3', |
| 591 |
'css' => [ |
| 592 |
[ |
| 593 |
'property' => 'background-color', |
| 594 |
'selector' => '.expand-bricks-button', |
| 595 |
] |
| 596 |
], |
| 597 |
]; |
| 598 |
|
| 599 |
$this->controls['expandButtonBorder'] = [ |
| 600 |
'tab' => 'content', |
| 601 |
'group' => 'expand_button_group', |
| 602 |
'label' => esc_html__( 'Border', 'wpfnl' ), |
| 603 |
'type' => 'border', |
| 604 |
'css' => [ |
| 605 |
[ |
| 606 |
'property' => 'border', |
| 607 |
'selector' => '.expand-bricks-button', |
| 608 |
], |
| 609 |
], |
| 610 |
]; |
| 611 |
|
| 612 |
$this->controls['expandButtonIcon'] = [ |
| 613 |
'tab' => 'content', |
| 614 |
'group' => 'expand_button_group', |
| 615 |
'label' => esc_html__( 'Icon', 'wpfnl' ), |
| 616 |
'type' => 'icon', |
| 617 |
]; |
| 618 |
|
| 619 |
$this->controls['expandButtonIconPosition'] = [ |
| 620 |
'tab' => 'content', |
| 621 |
'group' => 'expand_button_group', |
| 622 |
'label' => esc_html__( 'Icon position', 'wpfnl' ), |
| 623 |
'type' => 'select', |
| 624 |
'options' => $this->control_options['iconPosition'], |
| 625 |
'inline' => true, |
| 626 |
'placeholder' => esc_html__( 'Right', 'wpfnl' ), |
| 627 |
'required' => [ 'expandButtonIcon', '!=', '' ], |
| 628 |
]; |
| 629 |
|
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
/** |
| 634 |
* Sets the control for the optin form submit button. |
| 635 |
* |
| 636 |
* @since 3.1.0 |
| 637 |
* |
| 638 |
* @access public |
| 639 |
* |
| 640 |
*/ |
| 641 |
public function optin_form_submit_button_control(){ |
| 642 |
// Group: Submit Button |
| 643 |
$this->controls['submitButtonText'] = [ |
| 644 |
'tab' => 'content', |
| 645 |
'group' => 'submit_button_group', |
| 646 |
'label' => esc_html__( 'Text', 'wpfnl' ), |
| 647 |
'type' => 'text', |
| 648 |
'inline' => true, |
| 649 |
'placeholder' => esc_html__( 'Send', 'wpfnl' ), |
| 650 |
]; |
| 651 |
|
| 652 |
$this->controls['submitButtonSize'] = [ |
| 653 |
'tab' => 'content', |
| 654 |
'group' => 'submit_button_group', |
| 655 |
'label' => esc_html__( 'Size', 'wpfnl' ), |
| 656 |
'type' => 'select', |
| 657 |
'inline' => true, |
| 658 |
'options' => $this->control_options['buttonSizes'], |
| 659 |
]; |
| 660 |
|
| 661 |
$this->controls['submitButtonWidth'] = [ |
| 662 |
'tab' => 'content', |
| 663 |
'group' => 'submit_button_group', |
| 664 |
'label' => esc_html__( 'Width', 'wpfnl' ) . ' (%)', |
| 665 |
'type' => 'number', |
| 666 |
'unit' => '%', |
| 667 |
'css' => [ |
| 668 |
[ |
| 669 |
'property' => 'width', |
| 670 |
'selector' => '.submit-button-wrapper', |
| 671 |
], |
| 672 |
], |
| 673 |
]; |
| 674 |
|
| 675 |
$this->controls['submitButtonMargin'] = [ |
| 676 |
'tab' => 'content', |
| 677 |
'group' => 'submit_button_group', |
| 678 |
'label' => esc_html__( 'Margin', 'wpfnl' ), |
| 679 |
'type' => 'spacing', |
| 680 |
'css' => [ |
| 681 |
[ |
| 682 |
'property' => 'margin', |
| 683 |
'selector' => '.submit-button-wrapper', |
| 684 |
], |
| 685 |
], |
| 686 |
]; |
| 687 |
|
| 688 |
$this->controls['submitButtonPadding'] = [ |
| 689 |
'tab' => 'content', |
| 690 |
'group' => 'submit_button_group', |
| 691 |
'label' => esc_html__( 'Padding', 'wpfnl' ), |
| 692 |
'type' => 'spacing', |
| 693 |
'css' => [ |
| 694 |
[ |
| 695 |
'property' => 'padding', |
| 696 |
'selector' => '.bricks-button', |
| 697 |
], |
| 698 |
], |
| 699 |
]; |
| 700 |
|
| 701 |
$this->controls['submitButtonTypography'] = [ |
| 702 |
'tab' => 'content', |
| 703 |
'group' => 'submit_button_group', |
| 704 |
'label' => esc_html__( 'Typography', 'wpfnl' ), |
| 705 |
'type' => 'typography', |
| 706 |
'css' => [ |
| 707 |
[ |
| 708 |
'property' => 'font', |
| 709 |
'selector' => '.bricks-button', |
| 710 |
] |
| 711 |
], |
| 712 |
]; |
| 713 |
|
| 714 |
$this->controls['submitButtonBackgroundColor'] = [ |
| 715 |
'tab' => 'content', |
| 716 |
'group' => 'submit_button_group', |
| 717 |
'label' => esc_html__( 'Background', 'wpfnl' ), |
| 718 |
'type' => 'color', |
| 719 |
'default' => '#6E42D3', |
| 720 |
'css' => [ |
| 721 |
[ |
| 722 |
'property' => 'background-color', |
| 723 |
'selector' => '.bricks-button', |
| 724 |
] |
| 725 |
], |
| 726 |
]; |
| 727 |
|
| 728 |
$this->controls['submitButtonBorder'] = [ |
| 729 |
'tab' => 'content', |
| 730 |
'group' => 'submit_button_group', |
| 731 |
'label' => esc_html__( 'Border', 'wpfnl' ), |
| 732 |
'type' => 'border', |
| 733 |
'css' => [ |
| 734 |
[ |
| 735 |
'property' => 'border', |
| 736 |
'selector' => 'button[type=submit].bricks-button', |
| 737 |
], |
| 738 |
], |
| 739 |
]; |
| 740 |
|
| 741 |
$this->controls['submitButtonIcon'] = [ |
| 742 |
'tab' => 'content', |
| 743 |
'group' => 'submit_button_group', |
| 744 |
'label' => esc_html__( 'Icon', 'wpfnl' ), |
| 745 |
'type' => 'icon', |
| 746 |
]; |
| 747 |
|
| 748 |
$this->controls['submitButtonIconPosition'] = [ |
| 749 |
'tab' => 'content', |
| 750 |
'group' => 'submit_button_group', |
| 751 |
'label' => esc_html__( 'Icon position', 'wpfnl' ), |
| 752 |
'type' => 'select', |
| 753 |
'options' => $this->control_options['iconPosition'], |
| 754 |
'inline' => true, |
| 755 |
'placeholder' => esc_html__( 'Right', 'wpfnl' ), |
| 756 |
'required' => [ 'submitButtonIcon', '!=', '' ], |
| 757 |
]; |
| 758 |
|
| 759 |
} |
| 760 |
|
| 761 |
|
| 762 |
/** |
| 763 |
* Sets the control for "after submission of opt-in form". |
| 764 |
* |
| 765 |
* @since 3.1.0 |
| 766 |
* |
| 767 |
* @access public |
| 768 |
*/ |
| 769 |
public function optin_form_after_submission_control(){ |
| 770 |
// Group: Action After Submission |
| 771 |
$this->controls['admin_email'] = [ |
| 772 |
'tab' => 'content', |
| 773 |
'group' => 'action_after_submission_group', |
| 774 |
'label' => esc_html__( 'Admin Email', 'wpfnl' ), |
| 775 |
'type' => 'text', |
| 776 |
'inlineEditing' => false, |
| 777 |
'default' => Wpfnl_functions::get_optin_settings('sender_email'), |
| 778 |
'placeholder' => wp_get_current_user()->user_email, |
| 779 |
]; |
| 780 |
$this->controls['admin_email_subject'] = [ |
| 781 |
'tab' => 'content', |
| 782 |
'group' => 'action_after_submission_group', |
| 783 |
'label' => esc_html__( 'Admin Email Subject', 'wpfnl' ), |
| 784 |
'type' => 'text', |
| 785 |
'inlineEditing' => false, |
| 786 |
'default' => Wpfnl_functions::get_optin_settings('email_subject'), |
| 787 |
'placeholder' => Wpfnl_functions::get_optin_settings('email_subject'), |
| 788 |
]; |
| 789 |
$this->controls['notification_text'] = [ |
| 790 |
'tab' => 'content', |
| 791 |
'group' => 'action_after_submission_group', |
| 792 |
'label' => esc_html__( 'Confirmation Text', 'wpfnl' ), |
| 793 |
'type' => 'textarea', |
| 794 |
'inlineEditing' => false, |
| 795 |
'default' => 'Thank you! Your form was submitted successfully!', |
| 796 |
'placeholder' => 'Type notification texts here', |
| 797 |
]; |
| 798 |
|
| 799 |
$this->controls['post_action'] = [ |
| 800 |
'tab' => 'content', |
| 801 |
'group' => 'action_after_submission_group', |
| 802 |
'label' => esc_html__( 'Other action', 'wpfnl' ), |
| 803 |
'type' => 'select', |
| 804 |
'options' => [ |
| 805 |
'notification' => 'None', |
| 806 |
'redirect_to' => 'Redirect to url', |
| 807 |
'next_step' => 'Next Step', |
| 808 |
], |
| 809 |
'inline' => true, |
| 810 |
'default' => 'notification', |
| 811 |
]; |
| 812 |
$this->controls['redirect_url'] = [ |
| 813 |
'tab' => 'content', |
| 814 |
'group' => 'action_after_submission_group', |
| 815 |
'label' => esc_html__( 'Redirect url', 'wpfnl' ), |
| 816 |
'type' => 'link', |
| 817 |
'pasteStyles' => false, |
| 818 |
'placeholder' => esc_html__( 'https://your-link.com', 'wpfnl' ), |
| 819 |
'default' => '', |
| 820 |
'required' => [ 'post_action', '=', 'redirect_to' ], |
| 821 |
]; |
| 822 |
|
| 823 |
$this->controls['data_to_checkout'] = [ |
| 824 |
'tab' => 'content', |
| 825 |
'group' => 'action_after_submission_group', |
| 826 |
'label' => esc_html__( 'Carry data to the Next Form', 'wpfnl' ), |
| 827 |
'type' => 'checkbox', |
| 828 |
]; |
| 829 |
|
| 830 |
$this->controls['allow_registration'] = [ |
| 831 |
'tab' => 'content', |
| 832 |
'group' => 'action_after_submission_group', |
| 833 |
'label' => esc_html__( 'Register User As Subscriber', 'wpfnl' ), |
| 834 |
'type' => 'checkbox', |
| 835 |
]; |
| 836 |
$this->controls['allow_user_permission'] = [ |
| 837 |
'tab' => 'content', |
| 838 |
'group' => 'action_after_submission_group', |
| 839 |
'label' => esc_html__( 'Registration Permission', 'wpfnl' ), |
| 840 |
'type' => 'checkbox', |
| 841 |
'required' => [ 'allow_registration'], |
| 842 |
]; |
| 843 |
$this->controls['allow_user_registration_permission_text'] = [ |
| 844 |
'tab' => 'content', |
| 845 |
'group' => 'action_after_submission_group', |
| 846 |
'label' => esc_html__( 'Registration Permission Text', 'wpfnl' ), |
| 847 |
'type' => 'editor', |
| 848 |
'inline' => false, |
| 849 |
'spellcheck' => true, // Default: false |
| 850 |
'inlineEditing' => [ |
| 851 |
'selector' => '.text-editor', // Mount inline editor to this CSS selector |
| 852 |
'toolbar' => true, // Enable/disable inline editing toolbar |
| 853 |
], |
| 854 |
'default' => 'I agree to be registered as a subscriber.', |
| 855 |
'required' => [ 'allow_user_permission'], |
| 856 |
]; |
| 857 |
} |
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
/** |
| 862 |
* Sets the style control for the optin form's field label style. |
| 863 |
* |
| 864 |
* @since 3.1.0 |
| 865 |
* |
| 866 |
* @access public |
| 867 |
*/ |
| 868 |
public function optin_form_field_label_style_control(){ |
| 869 |
$this->controls['fieldLabelTypography'] = [ |
| 870 |
'tab' => 'content', |
| 871 |
'group' => 'form_field_label_style_group', |
| 872 |
'label' => esc_html__( 'Typography', 'wpfnl' ), |
| 873 |
'type' => 'typography', |
| 874 |
'css' => [ |
| 875 |
[ |
| 876 |
'property' => 'font', |
| 877 |
'selector' => '.wpfnl-optin-form-group:not(.acceptance-checkbox):not(.user-registration-checkbox) > label', |
| 878 |
], |
| 879 |
], |
| 880 |
]; |
| 881 |
|
| 882 |
$this->controls['fieldLabelMargin'] = [ |
| 883 |
'tab' => 'content', |
| 884 |
'group' => 'form_field_label_style_group', |
| 885 |
'label' => esc_html__( 'Margin', 'wpfnl' ), |
| 886 |
'type' => 'spacing', |
| 887 |
'css' => [ |
| 888 |
[ |
| 889 |
'property' => 'margin', |
| 890 |
'selector' => '.wpfnl-optin-form-group:not(.acceptance-checkbox):not(.user-registration-checkbox) > label', |
| 891 |
], |
| 892 |
], |
| 893 |
'placeholder' => [ |
| 894 |
'top' => 0, |
| 895 |
'right' => 0, |
| 896 |
'bottom' => '7px', |
| 897 |
'left' => 0, |
| 898 |
], |
| 899 |
]; |
| 900 |
} |
| 901 |
|
| 902 |
|
| 903 |
/** |
| 904 |
* Sets the style control for the optin form field. |
| 905 |
* |
| 906 |
* @since 3.1.0 |
| 907 |
* |
| 908 |
* @access public |
| 909 |
*/ |
| 910 |
public function optin_form_field_style_control(){ |
| 911 |
$this->controls['fieldTypography'] = [ |
| 912 |
'tab' => 'style', |
| 913 |
'group' => 'form_field_style_group', |
| 914 |
'label' => esc_html__( 'Typography', 'wpfnl' ), |
| 915 |
'type' => 'typography', |
| 916 |
'css' => [ |
| 917 |
[ |
| 918 |
'property' => 'font', |
| 919 |
'selector' => '.wpfnl-optin-form-group input:not([type=checkbox]):not([type=radio])', |
| 920 |
], |
| 921 |
[ |
| 922 |
'property' => 'font', |
| 923 |
'selector' => '.wpfnl-optin-form-group select', |
| 924 |
], |
| 925 |
[ |
| 926 |
'property' => 'font', |
| 927 |
'selector' => '.wpfnl-optin-form-group textarea', |
| 928 |
], |
| 929 |
], |
| 930 |
]; |
| 931 |
|
| 932 |
$this->controls['fieldBackgroundColor'] = [ |
| 933 |
'tab' => 'style', |
| 934 |
'group' => 'form_field_style_group', |
| 935 |
'label' => esc_html__( 'Background color', 'wpfnl' ), |
| 936 |
'type' => 'color', |
| 937 |
'css' => [ |
| 938 |
[ |
| 939 |
'property' => 'background-color', |
| 940 |
'selector' => '.wpfnl-optin-form-group input:not([type=checkbox]):not([type=radio])', |
| 941 |
], |
| 942 |
[ |
| 943 |
'property' => 'background-color', |
| 944 |
'selector' => '.wpfnl-optin-form-group select', |
| 945 |
], |
| 946 |
[ |
| 947 |
'property' => 'background-color', |
| 948 |
'selector' => '.wpfnl-optin-form-group textarea', |
| 949 |
], |
| 950 |
], |
| 951 |
]; |
| 952 |
|
| 953 |
$this->controls['fieldBorder'] = [ |
| 954 |
'tab' => 'style', |
| 955 |
'group' => 'form_field_style_group', |
| 956 |
'label' => esc_html__( 'Border', 'wpfnl' ), |
| 957 |
'type' => 'border', |
| 958 |
'css' => [ |
| 959 |
[ |
| 960 |
'property' => 'border', |
| 961 |
'selector' => '.wpfnl-optin-form-group input:not([type=checkbox]):not([type=radio])', |
| 962 |
], |
| 963 |
[ |
| 964 |
'property' => 'border', |
| 965 |
'selector' => '.wpfnl-optin-form-group select', |
| 966 |
], |
| 967 |
[ |
| 968 |
'property' => 'border', |
| 969 |
'selector' => '.wpfnl-optin-form-group textarea', |
| 970 |
], |
| 971 |
|
| 972 |
], |
| 973 |
]; |
| 974 |
|
| 975 |
$this->controls['fieldShadow'] = [ |
| 976 |
'tab' => 'style', |
| 977 |
'group' => 'form_field_style_group', |
| 978 |
'label' => esc_html__( 'BoxShadow', 'wpfnl' ), |
| 979 |
'type' => 'box-shadow', |
| 980 |
'css' => [ |
| 981 |
[ |
| 982 |
'property' => 'box-shadow', |
| 983 |
'selector' => '.wpfnl-optin-form-group input:not([type=checkbox]):not([type=radio])', |
| 984 |
], |
| 985 |
[ |
| 986 |
'property' => 'box-shadow', |
| 987 |
'selector' => '.wpfnl-optin-form-group select', |
| 988 |
], |
| 989 |
[ |
| 990 |
'property' => 'box-shadow', |
| 991 |
'selector' => '.wpfnl-optin-form-group textarea', |
| 992 |
], |
| 993 |
|
| 994 |
], |
| 995 |
'inline' => true, |
| 996 |
'small' => true, |
| 997 |
'default' => [ |
| 998 |
'values' => [ |
| 999 |
'offsetX' => 0, |
| 1000 |
'offsetY' => 0, |
| 1001 |
'blur' => 2, |
| 1002 |
'spread' => 0, |
| 1003 |
], |
| 1004 |
'color' => [ |
| 1005 |
'rgb' => 'rgba(0, 0, 0, .1)', |
| 1006 |
], |
| 1007 |
], |
| 1008 |
]; |
| 1009 |
|
| 1010 |
$this->controls['fieldMargin'] = [ |
| 1011 |
'tab' => 'content', |
| 1012 |
'group' => 'form_field_style_group', |
| 1013 |
'label' => esc_html__( 'Margin', 'wpfnl' ), |
| 1014 |
'type' => 'spacing', |
| 1015 |
'css' => [ |
| 1016 |
[ |
| 1017 |
'property' => 'margin', |
| 1018 |
'selector' => '.wpfnl-optin-form-group:not(.submit-button-wrapper)', |
| 1019 |
], |
| 1020 |
], |
| 1021 |
'placeholder' => [ |
| 1022 |
'top' => 0, |
| 1023 |
'right' => 0, |
| 1024 |
'bottom' => '12px', |
| 1025 |
'left' => 0, |
| 1026 |
], |
| 1027 |
]; |
| 1028 |
|
| 1029 |
$this->controls['fieldPadding'] = [ |
| 1030 |
'tab' => 'style', |
| 1031 |
'group' => 'form_field_style_group', |
| 1032 |
'label' => esc_html__( 'Padding', 'wpfnl' ), |
| 1033 |
'type' => 'spacing', |
| 1034 |
'css' => [ |
| 1035 |
[ |
| 1036 |
'property' => 'padding', |
| 1037 |
'selector' => '.wpfnl-optin-form-group input:not([type=checkbox]):not([type=radio])', |
| 1038 |
], |
| 1039 |
[ |
| 1040 |
'property' => 'padding', |
| 1041 |
'selector' => '.wpfnl-optin-form-group select', |
| 1042 |
], |
| 1043 |
[ |
| 1044 |
'property' => 'padding', |
| 1045 |
'selector' => '.wpfnl-optin-form-group textarea', |
| 1046 |
], |
| 1047 |
], |
| 1048 |
]; |
| 1049 |
} |
| 1050 |
|
| 1051 |
|
| 1052 |
/** |
| 1053 |
* Sets the style control for the optin form's checkbox style. |
| 1054 |
* |
| 1055 |
* @since 3.1.0 |
| 1056 |
* |
| 1057 |
* @access public |
| 1058 |
*/ |
| 1059 |
public function optin_form_field_checkbox_style_control(){ |
| 1060 |
$this->controls['fieldCheckboxTypography'] = [ |
| 1061 |
'tab' => 'style', |
| 1062 |
'group' => 'form_field_checkbox_style_group', |
| 1063 |
'label' => esc_html__( 'Typography', 'wpfnl' ), |
| 1064 |
'type' => 'typography', |
| 1065 |
'css' => [ |
| 1066 |
[ |
| 1067 |
'property' => 'font', |
| 1068 |
'selector' => '.wpfnl-optin-form-group.acceptance-checkbox > label', |
| 1069 |
], |
| 1070 |
[ |
| 1071 |
'property' => 'font', |
| 1072 |
'selector' => '.wpfnl-optin-form-group.user-registration-checkbox > label', |
| 1073 |
], |
| 1074 |
], |
| 1075 |
]; |
| 1076 |
|
| 1077 |
$this->controls['fieldCheckboxBorderColor'] = [ |
| 1078 |
'tab' => 'style', |
| 1079 |
'group' => 'form_field_checkbox_style_group', |
| 1080 |
'label' => esc_html__( 'Checkbox border color', 'wpfnl' ), |
| 1081 |
'type' => 'color', |
| 1082 |
'inline' => true, |
| 1083 |
'css' => [ |
| 1084 |
[ |
| 1085 |
'property' => 'border-color', |
| 1086 |
'selector' => '.wpfnl-optin-form-group.acceptance-checkbox > label .check-box', |
| 1087 |
], |
| 1088 |
[ |
| 1089 |
'property' => 'border-color', |
| 1090 |
'selector' => '.wpfnl-optin-form-group.user-registration-checkbox > label .check-box', |
| 1091 |
], |
| 1092 |
], |
| 1093 |
'default' => [ |
| 1094 |
'hex' => '#3ce77b', |
| 1095 |
'rgb' => 'rgba(60, 231, 123, 0.9)', |
| 1096 |
], |
| 1097 |
]; |
| 1098 |
|
| 1099 |
$this->controls['fieldCheckboxActiveBorderColor'] = [ |
| 1100 |
'tab' => 'style', |
| 1101 |
'group' => 'form_field_checkbox_style_group', |
| 1102 |
'label' => esc_html__( 'Active checkbox border color', 'wpfnl' ), |
| 1103 |
'type' => 'color', |
| 1104 |
'inline' => true, |
| 1105 |
'css' => [ |
| 1106 |
[ |
| 1107 |
'property' => 'border-color', |
| 1108 |
'selector' => '.wpfnl-optin-form-group.acceptance-checkbox input[type=checkbox]:checked + label .check-box', |
| 1109 |
], |
| 1110 |
[ |
| 1111 |
'property' => 'border-color', |
| 1112 |
'selector' => '.wpfnl-optin-form-group.user-registration-checkbox input[type=checkbox]:checked + label .check-box', |
| 1113 |
], |
| 1114 |
[ |
| 1115 |
'property' => 'background-color', |
| 1116 |
'selector' => '.wpfnl-optin-form-group.acceptance-checkbox input[type=checkbox]:checked + label .check-box', |
| 1117 |
], |
| 1118 |
[ |
| 1119 |
'property' => 'background-color', |
| 1120 |
'selector' => '.wpfnl-optin-form-group.user-registration-checkbox input[type=checkbox]:checked + label .check-box', |
| 1121 |
], |
| 1122 |
], |
| 1123 |
'default' => [ |
| 1124 |
'hex' => '#3ce77b', |
| 1125 |
'rgb' => 'rgba(60, 231, 123, 0.9)', |
| 1126 |
], |
| 1127 |
]; |
| 1128 |
|
| 1129 |
$this->controls['fieldCheckboxTickColor'] = [ |
| 1130 |
'tab' => 'style', |
| 1131 |
'group' => 'form_field_checkbox_style_group', |
| 1132 |
'label' => esc_html__( 'Checkbox Tick color', 'wpfnl' ), |
| 1133 |
'type' => 'color', |
| 1134 |
'inline' => true, |
| 1135 |
'css' => [ |
| 1136 |
[ |
| 1137 |
'property' => 'border-color', |
| 1138 |
'selector' => '.wpfnl-optin-form-group.acceptance-checkbox > label .check-box::after', |
| 1139 |
], |
| 1140 |
[ |
| 1141 |
'property' => 'border-color', |
| 1142 |
'selector' => '.wpfnl-optin-form-group.user-registration-checkbox > label .check-box::after', |
| 1143 |
], |
| 1144 |
], |
| 1145 |
'default' => [ |
| 1146 |
'hex' => '#3ce77b', |
| 1147 |
'rgb' => 'rgba(60, 231, 123, 0.9)', |
| 1148 |
], |
| 1149 |
]; |
| 1150 |
} |
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
/** |
| 1155 |
* Set builder control groups |
| 1156 |
* |
| 1157 |
* @since 3.1.0 |
| 1158 |
* |
| 1159 |
* @access public |
| 1160 |
*/ |
| 1161 |
public function set_control_groups() |
| 1162 |
{ |
| 1163 |
|
| 1164 |
//form source group |
| 1165 |
$this->control_groups['optin_form_source_group'] = [ |
| 1166 |
'title' => esc_html__('Opt-in Form Source', 'wpfnl'), |
| 1167 |
'tab' => 'content', |
| 1168 |
]; |
| 1169 |
|
| 1170 |
//form layout group |
| 1171 |
$this->control_groups['form_layout_group'] = [ |
| 1172 |
'title' => esc_html__('Form Layout', 'wpfnl'), |
| 1173 |
'tab' => 'content', |
| 1174 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 1175 |
]; |
| 1176 |
|
| 1177 |
//form field group |
| 1178 |
$this->control_groups['form_field_group'] = [ |
| 1179 |
'title' => esc_html__('Form Fields', 'wpfnl'), |
| 1180 |
'tab' => 'content', |
| 1181 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 1182 |
]; |
| 1183 |
|
| 1184 |
//expand button group |
| 1185 |
$this->control_groups['expand_button_group'] = [ |
| 1186 |
'title' => esc_html__('Expand Button', 'wpfnl'), |
| 1187 |
'tab' => 'content', |
| 1188 |
'required' => [ 'optin_form_type', '=', 'clickto-expand-optin' ], |
| 1189 |
]; |
| 1190 |
|
| 1191 |
//submit button group |
| 1192 |
$this->control_groups['submit_button_group'] = [ |
| 1193 |
'title' => esc_html__('Submit Button', 'wpfnl'), |
| 1194 |
'tab' => 'content', |
| 1195 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 1196 |
]; |
| 1197 |
|
| 1198 |
//after sumbission group |
| 1199 |
$this->control_groups['action_after_submission_group'] = [ |
| 1200 |
'title' => esc_html__('Action After Submission', 'wpfnl'), |
| 1201 |
'tab' => 'content', |
| 1202 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 1203 |
]; |
| 1204 |
|
| 1205 |
if( \WPFunnels\Integrations\Helper::maybe_enabled() ) { |
| 1206 |
//MM contact |
| 1207 |
$this->control_groups['mm_contact_group'] = [ |
| 1208 |
'title' => esc_html__('MailMint Contact Control', 'wpfnl'), |
| 1209 |
'tab' => 'content', |
| 1210 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 1211 |
]; |
| 1212 |
} |
| 1213 |
|
| 1214 |
|
| 1215 |
//field label style group |
| 1216 |
$this->control_groups['form_field_label_style_group'] = [ |
| 1217 |
'title' => esc_html__('Form Fields Label Style', 'wpfnl'), |
| 1218 |
'tab' => 'style', |
| 1219 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 1220 |
]; |
| 1221 |
|
| 1222 |
//field style group |
| 1223 |
$this->control_groups['form_field_style_group'] = [ |
| 1224 |
'title' => esc_html__('Form Fields Style', 'wpfnl'), |
| 1225 |
'tab' => 'style', |
| 1226 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 1227 |
]; |
| 1228 |
|
| 1229 |
//field checkbox style group |
| 1230 |
$this->control_groups['form_field_checkbox_style_group'] = [ |
| 1231 |
'title' => esc_html__('Checkbox Fields Style', 'wpfnl'), |
| 1232 |
'tab' => 'style', |
| 1233 |
'required' => [ 'optin_form_source', '=', 'wpfnl_forms' ], |
| 1234 |
]; |
| 1235 |
|
| 1236 |
} |
| 1237 |
|
| 1238 |
|
| 1239 |
/** |
| 1240 |
* Set builder controls |
| 1241 |
* |
| 1242 |
* @since 3.1.0 |
| 1243 |
* |
| 1244 |
* @access public |
| 1245 |
*/ |
| 1246 |
public function set_controls(){ |
| 1247 |
|
| 1248 |
$this->optin_form_source_control(); |
| 1249 |
$this->optin_form_type_control(); |
| 1250 |
$this->optin_form_field_control(); |
| 1251 |
$this->optin_form_expand_button_control(); |
| 1252 |
$this->optin_form_submit_button_control(); |
| 1253 |
$this->optin_form_after_submission_control(); |
| 1254 |
|
| 1255 |
|
| 1256 |
//----style controls---- |
| 1257 |
$this->optin_form_field_label_style_control(); |
| 1258 |
$this->optin_form_field_style_control(); |
| 1259 |
$this->optin_form_field_checkbox_style_control(); |
| 1260 |
|
| 1261 |
} |
| 1262 |
|
| 1263 |
|
| 1264 |
/** |
| 1265 |
* Get wrapper classes |
| 1266 |
* @since 3.1.0 |
| 1267 |
* |
| 1268 |
* @access public |
| 1269 |
* @return array |
| 1270 |
*/ |
| 1271 |
public function get_wrapper_classes() { |
| 1272 |
$settings = $this->settings; |
| 1273 |
|
| 1274 |
if( 'clickto-expand-optin' == $settings['optin_form_type'] ) { |
| 1275 |
return array( 'wpfnl', 'wpfnl-optin-form', 'wpfnl-bricks-optin-form-wrapper', 'clickto-expand-optin'); |
| 1276 |
|
| 1277 |
}else { |
| 1278 |
return array( 'wpfnl', 'wpfnl-optin-form', 'wpfnl-bricks-optin-form-wrapper'); |
| 1279 |
|
| 1280 |
} |
| 1281 |
} |
| 1282 |
|
| 1283 |
/** |
| 1284 |
* Render Expand buton. |
| 1285 |
* |
| 1286 |
*/ |
| 1287 |
public function render_wpfnl_optin_expand_btn() { |
| 1288 |
$settings = $this->settings; |
| 1289 |
|
| 1290 |
// We need the form element ID to recover the element settings on form expand button |
| 1291 |
$this->set_attribute( '_root', 'data-element-id', $this->id ); |
| 1292 |
|
| 1293 |
// expand button |
| 1294 |
$expand_button_icon_position = ! empty( $settings['expandButtonIconPosition'] ) ? $settings['expandButtonIconPosition'] : 'right'; |
| 1295 |
|
| 1296 |
$this->set_attribute( 'expand-wrapper', 'class', ['submit-button-wrapper', 'wpfnl-optin-clickto-expand']); |
| 1297 |
|
| 1298 |
$expand_button_classes[] = 'expand-bricks-button bricks-button clickto-expand-btn'; |
| 1299 |
|
| 1300 |
if ( ! empty( $settings['expandButtonSize'] ) ) { |
| 1301 |
$expand_button_classes[] = $settings['expandButtonSize']; |
| 1302 |
} |
| 1303 |
|
| 1304 |
if ( isset( $settings['expandButtonCircle'] ) ) { |
| 1305 |
$expand_button_classes[] = 'circle'; |
| 1306 |
} |
| 1307 |
|
| 1308 |
if ( ! empty( $settings['expandButtonIcon'] ) ) { |
| 1309 |
$expand_button_classes[] = "icon-$expand_button_icon_position"; |
| 1310 |
} |
| 1311 |
|
| 1312 |
$this->set_attribute( 'expand-button', 'class', $expand_button_classes ); |
| 1313 |
|
| 1314 |
// expand button icon |
| 1315 |
$expand_button_icon = isset( $settings['expandButtonIcon'] ) ? self::render_icon( $settings['expandButtonIcon'] ) : false; |
| 1316 |
|
| 1317 |
?> |
| 1318 |
<div <?php echo $this->render_attributes( 'expand-wrapper' ); echo $this->render_attributes( '_root' ); ?> > |
| 1319 |
<button type="button" <?php echo $this->render_attributes( 'expand-button' ); ?>> |
| 1320 |
<?php |
| 1321 |
if ( $expand_button_icon_position === 'left' && $expand_button_icon ) { |
| 1322 |
echo $expand_button_icon; |
| 1323 |
} |
| 1324 |
|
| 1325 |
if ( ! isset( $settings['expandButtonIcon'] ) || ( isset( $settings['expandButtonIcon'] ) && isset( $settings['expandButtonText'] ) ) ) { |
| 1326 |
$this->set_attribute( 'expandButtonText', 'class', 'text' ); |
| 1327 |
|
| 1328 |
$expand_button_text = isset( $settings['expandButtonText'] ) ? esc_html( $settings['expandButtonText'] ) : esc_html__( 'Click to Expand', 'wpfnl' ); |
| 1329 |
|
| 1330 |
echo "<span {$this->render_attributes( 'expandButtonText' )}>$expand_button_text</span>"; |
| 1331 |
} |
| 1332 |
|
| 1333 |
if ( $expand_button_icon_position === 'right' && $expand_button_icon ) { |
| 1334 |
echo $expand_button_icon; |
| 1335 |
} |
| 1336 |
?> |
| 1337 |
</button> |
| 1338 |
</div> |
| 1339 |
<?php |
| 1340 |
} |
| 1341 |
|
| 1342 |
|
| 1343 |
/** |
| 1344 |
* Render the widget output on the frontend for WPFunnels' default forms. |
| 1345 |
* |
| 1346 |
* Written in PHP and used to generate the final HTML. |
| 1347 |
* |
| 1348 |
* @since 3.1.0 |
| 1349 |
* |
| 1350 |
* @access public |
| 1351 |
*/ |
| 1352 |
public function render_wpfnl_form( $settings, $classes ) { |
| 1353 |
$recaptcha_setting = Wpfnl_functions::get_recaptcha_settings(); |
| 1354 |
$is_recaptch = isset($recaptcha_setting['enable_recaptcha']) ? $recaptcha_setting['enable_recaptcha'] : ''; |
| 1355 |
$site_key = isset($recaptcha_setting['recaptcha_site_key']) ? $recaptcha_setting['recaptcha_site_key'] : ''; |
| 1356 |
$site_secret_key = isset($recaptcha_setting['recaptcha_site_secret']) ? $recaptcha_setting['recaptcha_site_secret'] : ''; |
| 1357 |
$token_input = ''; |
| 1358 |
$recaptch_script = ''; |
| 1359 |
$is_recaptch_input = ''; |
| 1360 |
$token_secret_key = ''; |
| 1361 |
if('on' == $is_recaptch && '' != $site_key && '' != $site_secret_key){ |
| 1362 |
$is_recaptch_input = '<input type="hidden" id="wpf-is-recapcha" name="wpf-is-recapcha" value="'.$is_recaptch.'"/>'; |
| 1363 |
$token_input = '<input type="hidden" id="wpf-optin-g-token" name="wpf-optin-g-token" />'; |
| 1364 |
$token_secret_key = '<input type="hidden" id="wpf-optin-g-secret-key" name="wpf-optin-g-secret-key" value="'.$site_secret_key.'" />'; |
| 1365 |
$recaptch_script = '<script src="https://www.google.com/recaptcha/api.js?render='.$site_key.'"></script>'; |
| 1366 |
} |
| 1367 |
|
| 1368 |
|
| 1369 |
//mm contact |
| 1370 |
$enable_mm_contact = isset($settings['enable_mm_contact']) && $settings['enable_mm_contact'] == 'on' ? 'yes' : 'no'; |
| 1371 |
$mm_contact_status = isset($settings['mm_contact_status']) ? $settings['mm_contact_status'] : 'pending'; |
| 1372 |
$mm_lists = isset($settings['mm_lists']) ? $settings['mm_lists'] : ''; |
| 1373 |
$mm_tags = isset($settings['mm_tags']) ? $settings['mm_tags'] : ''; |
| 1374 |
|
| 1375 |
$post_action = isset($settings['post_action']) ? $settings['post_action'] : 'notification'; |
| 1376 |
$redirect_url = isset($settings['redirect_url']['url']) ? $settings['redirect_url']['url'] : '#'; |
| 1377 |
$admin_email_subject = isset($settings['admin_email_subject']) ? $settings['admin_email_subject'] : ''; |
| 1378 |
$admin_email = isset($settings['admin_email']) ? $settings['admin_email'] : ''; |
| 1379 |
$notification_text = isset($settings['notification_text']) ? $settings['notification_text'] : ''; |
| 1380 |
|
| 1381 |
// We need the form element ID to recover the element settings on form submit |
| 1382 |
$this->set_attribute( '_root', 'data-element-id', $this->id ); |
| 1383 |
|
| 1384 |
// Submit button |
| 1385 |
$submit_button_icon_position = ! empty( $settings['submitButtonIconPosition'] ) ? $settings['submitButtonIconPosition'] : 'right'; |
| 1386 |
|
| 1387 |
$this->set_attribute( 'submit-wrapper', 'class', [ 'wpfnl-optin-form-group submit', 'submit-button-wrapper' ] ); |
| 1388 |
|
| 1389 |
$submit_button_classes[] = 'bricks-button btn-optin'; |
| 1390 |
|
| 1391 |
if ( ! empty( $settings['submitButtonSize'] ) ) { |
| 1392 |
$submit_button_classes[] = $settings['submitButtonSize']; |
| 1393 |
} |
| 1394 |
|
| 1395 |
if ( isset( $settings['submitButtonCircle'] ) ) { |
| 1396 |
$submit_button_classes[] = 'circle'; |
| 1397 |
} |
| 1398 |
|
| 1399 |
if ( ! empty( $settings['submitButtonIcon'] ) ) { |
| 1400 |
$submit_button_classes[] = "icon-$submit_button_icon_position"; |
| 1401 |
} |
| 1402 |
|
| 1403 |
$this->set_attribute( 'submit-button', 'class', $submit_button_classes ); |
| 1404 |
|
| 1405 |
// Submit button icon |
| 1406 |
$submit_button_icon = isset( $settings['submitButtonIcon'] ) ? self::render_icon( $settings['submitButtonIcon'] ) : false; |
| 1407 |
|
| 1408 |
$randomId = rand(); |
| 1409 |
|
| 1410 |
|
| 1411 |
echo $recaptch_script; |
| 1412 |
|
| 1413 |
//-----expand button------- |
| 1414 |
if( isset($settings['optin_form_type']) && 'clickto-expand-optin' === $settings['optin_form_type'] ) { |
| 1415 |
$this->render_wpfnl_optin_expand_btn(); |
| 1416 |
} |
| 1417 |
?> |
| 1418 |
|
| 1419 |
<div class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>" <?php echo $this->render_attributes( '_root' ); ?> > |
| 1420 |
<form method="post"> |
| 1421 |
<input type="hidden" name="post_id" value="<?php echo $this->post_id; ?>" /> |
| 1422 |
<input type="hidden" name="enable_mm_contact" value="<?php echo $enable_mm_contact; ?>" /> |
| 1423 |
<input type="hidden" name="mm_contact_status" value="<?php echo $mm_contact_status; ?>" /> |
| 1424 |
<input type="hidden" name="mm_lists" value="<?php echo $mm_lists; ?>" /> |
| 1425 |
<input type="hidden" name="mm_tags" value="<?php echo $mm_tags; ?>" /> |
| 1426 |
<input type="hidden" name="post_action" value="<?php echo $post_action; ?>" /> |
| 1427 |
<input type="hidden" name="redirect_url" value="<?php echo $redirect_url; ?>" /> |
| 1428 |
<input type="hidden" name="admin_email_subject" value="<?php echo $admin_email_subject; ?>" /> |
| 1429 |
<input type="hidden" name="admin_email" value="<?php echo $admin_email; ?>" /> |
| 1430 |
<input type="hidden" name="notification_text" value="<?php echo $notification_text; ?>" /> |
| 1431 |
<?php |
| 1432 |
echo $is_recaptch_input; |
| 1433 |
echo $token_input; |
| 1434 |
echo $token_secret_key; |
| 1435 |
|
| 1436 |
if( isset($settings['submitButtonWidth']) && null != $settings['submitButtonWidth'] ){ |
| 1437 |
?> |
| 1438 |
<style id="submit-btn-style"> |
| 1439 |
.wpfnl-bricks-optin-form-wrapper .wpfnl-optin-form-group.submit { |
| 1440 |
width: auto; |
| 1441 |
display: flex; |
| 1442 |
flex-direction: column; |
| 1443 |
} |
| 1444 |
</style> |
| 1445 |
<?php |
| 1446 |
} |
| 1447 |
?> |
| 1448 |
<div class="wpfnl-optin-form-wrapper <?php echo isset($settings['optin_form_layout']) ? $settings['optin_form_layout'] : ''; ?>" > |
| 1449 |
<?php if( isset($settings['first_name']) && 'yes' == $settings['first_name'] ){ ?> |
| 1450 |
<div class="wpfnl-optin-form-group first-name"> |
| 1451 |
|
| 1452 |
<?php if( isset($settings['field_label']) && 'yes' == $settings['field_label'] ){ ?> |
| 1453 |
<label for="wpfnl-first-name"> |
| 1454 |
<?php |
| 1455 |
echo isset($settings['first_name_label']) && $settings['first_name_label'] ? $settings['first_name_label'] : __('First Name','wpfnl'); |
| 1456 |
|
| 1457 |
if( isset($settings['is_required_name']) && 'yes' == $settings['is_required_name'] ){ ?> |
| 1458 |
<span class="required-mark">*</span> |
| 1459 |
<?php } ?> |
| 1460 |
</label> |
| 1461 |
<?php } ?> |
| 1462 |
|
| 1463 |
<span class="input-wrapper"> |
| 1464 |
<?php if( isset($settings['input_fields_icon']) && 'yes' == $settings['input_fields_icon'] ){ ?> |
| 1465 |
<span class="field-icon"> |
| 1466 |
<img src="<?php echo WPFNL_DIR_URL.'/public/assets/images/user-icon.svg'; ?>" alt="icon"> |
| 1467 |
</span> |
| 1468 |
<?php } |
| 1469 |
$f_name_placeholder = isset($settings['first_name_placeholder']) ? $settings['first_name_placeholder'] : ''; |
| 1470 |
?> |
| 1471 |
<input type="text" name="first_name" class="wpfnl-first-name" id="wpfnl-first-name" placeholder="<?php echo $f_name_placeholder; ?>" <?php echo isset($settings['is_required_name']) && 'yes' == $settings['is_required_name'] ? 'required' : ''; ?> > |
| 1472 |
</span> |
| 1473 |
|
| 1474 |
</div> |
| 1475 |
<?php } ?> |
| 1476 |
|
| 1477 |
<?php if( isset($settings['last_name']) && 'yes' == $settings['last_name'] ){ ?> |
| 1478 |
<div class="wpfnl-optin-form-group last-name"> |
| 1479 |
|
| 1480 |
<?php if( isset($settings['field_label']) & 'yes' == $settings['field_label'] ){ ?> |
| 1481 |
<label for="wpfnl-last-name"> |
| 1482 |
<?php |
| 1483 |
echo isset($settings['last_name_label']) && $settings['last_name_label'] ? $settings['last_name_label'] : __('Last Name','wpfnl'); |
| 1484 |
|
| 1485 |
if( isset($settings['is_required_last_name']) && 'yes' == $settings['is_required_last_name'] ){ ?> |
| 1486 |
<span class="required-mark">*</span> |
| 1487 |
<?php } ?> |
| 1488 |
</label> |
| 1489 |
<?php } ?> |
| 1490 |
|
| 1491 |
<span class="input-wrapper"> |
| 1492 |
<?php if( isset($settings['input_fields_icon']) && 'yes' == $settings['input_fields_icon'] ){ ?> |
| 1493 |
<span class="field-icon"> |
| 1494 |
<img src="<?php echo WPFNL_DIR_URL.'/public/assets/images/user-icon.svg'; ?>" alt="icon"> |
| 1495 |
</span> |
| 1496 |
<?php } |
| 1497 |
$l_name_placeholder = isset($settings['last_name_placeholder']) ? $settings['last_name_placeholder'] : ''; |
| 1498 |
?> |
| 1499 |
<input type="text" name="last_name" class="wpfnl-last-name" id="wpfnl-last-name" placeholder="<?php echo $l_name_placeholder;?>" <?php echo isset($settings['is_required_last_name']) && 'yes' == $settings['is_required_last_name'] ? 'required' : ''; ?> > |
| 1500 |
</span> |
| 1501 |
</div> |
| 1502 |
<?php } ?> |
| 1503 |
|
| 1504 |
<div class="wpfnl-optin-form-group email"> |
| 1505 |
<?php if( isset($settings['field_label']) && 'yes' == $settings['field_label'] ){ ?> |
| 1506 |
<label for="wpfnl-email"> |
| 1507 |
<?php |
| 1508 |
echo isset($settings['email_label']) && $settings['email_label'] ? $settings['email_label'] : __('Email','wpfnl'); |
| 1509 |
|
| 1510 |
if( isset($settings['required_mark']) && 'yes' == $settings['required_mark'] ){ ?> |
| 1511 |
<span class="required-mark">*</span> |
| 1512 |
<?php } ?> |
| 1513 |
</label> |
| 1514 |
<?php } ?> |
| 1515 |
<span class="input-wrapper"> |
| 1516 |
<?php if( isset($settings['input_fields_icon']) && 'yes' == $settings['input_fields_icon'] ){ ?> |
| 1517 |
<span class="field-icon"> |
| 1518 |
<img src="<?php echo WPFNL_DIR_URL.'/public/assets/images/email-open-icon.svg'; ?>" alt="icon"> |
| 1519 |
</span> |
| 1520 |
<?php } |
| 1521 |
$email_placeholder = isset($settings['email_placeholder']) ? $settings['email_placeholder'] : ''; |
| 1522 |
?> |
| 1523 |
<input type="email" name="email" class="wpfnl-email" id="wpfnl-email" placeholder="<?php echo $email_placeholder; ?>" pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" required > |
| 1524 |
</span> |
| 1525 |
</div> |
| 1526 |
|
| 1527 |
<?php if( isset($settings['phone']) && 'yes' == $settings['phone'] ){ ?> |
| 1528 |
<div class="wpfnl-optin-form-group phone"> |
| 1529 |
|
| 1530 |
<?php if( isset($settings['field_label']) && 'yes' == $settings['field_label'] ){ ?> |
| 1531 |
<label for="wpfnl-phone"> |
| 1532 |
<?php |
| 1533 |
echo isset($settings['phone_label']) && $settings['phone_label'] ? $settings['phone_label'] : __('Phone','wpfnl'); |
| 1534 |
|
| 1535 |
if( isset($settings['is_required_phone']) && 'yes' == $settings['is_required_phone'] ){ ?> |
| 1536 |
<span class="required-mark">*</span> |
| 1537 |
<?php } ?> |
| 1538 |
</label> |
| 1539 |
<?php } ?> |
| 1540 |
|
| 1541 |
<span class="input-wrapper"> |
| 1542 |
<?php if( isset($settings['input_fields_icon']) && 'yes' == $settings['input_fields_icon'] ){ ?> |
| 1543 |
<span class="field-icon"> |
| 1544 |
<img src="<?php echo WPFNL_DIR_URL.'/public/assets/images/phone.svg'; ?>" alt="icon"> |
| 1545 |
</span> |
| 1546 |
<?php } |
| 1547 |
$phone_placeholder = isset($settings['phone_placeholder']) && $settings['phone_placeholder'] ? $settings['phone_placeholder'] : ''; |
| 1548 |
?> |
| 1549 |
<input type="text" name="phone" class="wpfnl-phone" id="wpfnl-phone" placeholder="<?php echo $phone_placeholder; ?>" <?php echo isset($settings['is_required_phone']) && 'yes' == $settings['is_required_phone'] ? 'required' : ''; ?> > |
| 1550 |
</span> |
| 1551 |
</div> |
| 1552 |
<?php } ?> |
| 1553 |
|
| 1554 |
<?php if( isset($settings['website_url']) && 'yes' == $settings['website_url'] ){ ?> |
| 1555 |
<div class="wpfnl-optin-form-group website-url"> |
| 1556 |
|
| 1557 |
<?php if( isset($settings['field_label']) && 'yes' == $settings['field_label'] ){ ?> |
| 1558 |
<label for="wpfnl-web-url"> |
| 1559 |
<?php |
| 1560 |
echo isset($settings['website_url_label']) && $settings['website_url_label'] ? $settings['website_url_label'] : __('Website Url','wpfnl'); |
| 1561 |
|
| 1562 |
if( isset($settings['is_required_website_url']) && 'yes' == $settings['is_required_website_url'] ){ ?> |
| 1563 |
<span class="required-mark">*</span> |
| 1564 |
<?php } ?> |
| 1565 |
</label> |
| 1566 |
<?php } ?> |
| 1567 |
|
| 1568 |
<span class="input-wrapper"> |
| 1569 |
<?php if( isset($settings['input_fields_icon']) && 'yes' == $settings['input_fields_icon'] ){ ?> |
| 1570 |
<span class="field-icon"> |
| 1571 |
<img src="<?php echo WPFNL_DIR_URL.'/public/assets/images/web-url.svg'; ?>" alt="icon"> |
| 1572 |
</span> |
| 1573 |
<?php } |
| 1574 |
$weburl_placeholder = isset($settings['website_url_placeholder']) && $settings['website_url_placeholder'] ? $settings['website_url_placeholder'] : ''; |
| 1575 |
?> |
| 1576 |
<input type="text" name="web-url" class="wpfnl-web-url" id="wpfnl-web-url" pattern="(https?://)?.+" size="30" placeholder="<?php echo $weburl_placeholder; ?>" <?php echo isset($settings['is_required_website_url']) && 'yes' == $settings['is_required_website_url'] ? 'required' : ''; ?> > |
| 1577 |
</span> |
| 1578 |
</div> |
| 1579 |
<?php } ?> |
| 1580 |
|
| 1581 |
<?php if( isset($settings['message']) && 'yes' == $settings['message'] ){ ?> |
| 1582 |
<div class="wpfnl-optin-form-group message"> |
| 1583 |
|
| 1584 |
<?php if( isset($settings['field_label']) && 'yes' == $settings['field_label'] ){ ?> |
| 1585 |
<label for="wpfnl-message"> |
| 1586 |
<?php |
| 1587 |
echo isset($settings['message_label']) && $settings['message_label'] ? $settings['message_label'] : __('Message','wpfnl'); |
| 1588 |
|
| 1589 |
if( isset($settings['is_required_message']) && 'yes' == $settings['is_required_message'] ){ ?> |
| 1590 |
<span class="required-mark">*</span> |
| 1591 |
<?php } ?> |
| 1592 |
</label> |
| 1593 |
<?php } |
| 1594 |
|
| 1595 |
$message_placeholder = isset($settings['message_placeholder']) && $settings['message_placeholder'] ? $settings['message_placeholder'] : ''; |
| 1596 |
?> |
| 1597 |
|
| 1598 |
<span class="input-wrapper"> |
| 1599 |
<textarea name="message" class="wpfnl-message" id="wpfnl-message" cols="30" rows="3" placeholder="<?php echo $message_placeholder; ?>" <?php echo isset($settings['is_required_message']) && 'yes' == $settings['is_required_message'] ? 'required' : ''; ?> ></textarea> |
| 1600 |
</span> |
| 1601 |
</div> |
| 1602 |
<?php } ?> |
| 1603 |
|
| 1604 |
<?php |
| 1605 |
if( isset($settings['acceptance_checkbox']) && 'yes' == $settings['acceptance_checkbox'] ){ |
| 1606 |
?> |
| 1607 |
<div class="wpfnl-optin-form-group acceptance-checkbox"> |
| 1608 |
<input type="checkbox" name="acceptance_checkbox" class="wpfnl-acceptance_checkbox" id="wpfnl-acceptance_checkbox-<?php echo $randomId; ?>" <?php echo isset($settings['is_required_acceptance']) && 'yes' == $settings['is_required_acceptance'] ? 'required' : ''; ?> > |
| 1609 |
|
| 1610 |
<label for="wpfnl-acceptance_checkbox-<?php echo $randomId; ?>"> |
| 1611 |
<span class="check-box"></span> |
| 1612 |
<?php |
| 1613 |
echo isset($settings['acceptance_checkbox_text']) && $settings['acceptance_checkbox_text'] ? $settings['acceptance_checkbox_text'] : ''; |
| 1614 |
|
| 1615 |
if( isset($settings['is_required_acceptance']) && 'yes' == $settings['is_required_acceptance'] ){ |
| 1616 |
echo '<span class="required-mark">*</span>'; |
| 1617 |
} |
| 1618 |
?> |
| 1619 |
</label> |
| 1620 |
</div> |
| 1621 |
<?php |
| 1622 |
} |
| 1623 |
?> |
| 1624 |
|
| 1625 |
<?php |
| 1626 |
if( isset($settings['allow_registration']) && 'yes' == $settings['allow_registration']){ |
| 1627 |
?> |
| 1628 |
<input type="hidden" name="optin_allow_registration" value="<?php echo esc_attr( 'yes' ); ?>"/> |
| 1629 |
<?php |
| 1630 |
if(isset($settings['allow_user_permission']) && 'yes' == $settings['allow_user_permission']){ |
| 1631 |
?> |
| 1632 |
<div class="wpfnl-optin-form-group user-registration-checkbox"> |
| 1633 |
<input type="checkbox" name="user_registration_checkbox" class="wpfnl-registration_checkbox" id="wpfnl-registration_checkbox-<?php echo $randomId; ?>" required > |
| 1634 |
|
| 1635 |
<label for="wpfnl-registration_checkbox-<?php echo $randomId; ?>"> |
| 1636 |
<span class="check-box"></span> |
| 1637 |
<?php |
| 1638 |
echo isset($settings['allow_user_registration_permission_text']) && $settings['allow_user_registration_permission_text'] ? $settings['allow_user_registration_permission_text'] : ''; |
| 1639 |
?> |
| 1640 |
<span class="required-mark">*</span> |
| 1641 |
</label> |
| 1642 |
</div> |
| 1643 |
<?php |
| 1644 |
} |
| 1645 |
} |
| 1646 |
?> |
| 1647 |
<?php |
| 1648 |
if( isset($settings['data_to_checkout']) && 'yes' == $settings['data_to_checkout']){ |
| 1649 |
?> |
| 1650 |
<input type="hidden" name="data_to_checkout" value="<?php echo esc_attr( 'yes' ); ?>"/> |
| 1651 |
<?php |
| 1652 |
} |
| 1653 |
?> |
| 1654 |
|
| 1655 |
<div <?php echo $this->render_attributes( 'submit-wrapper' ); ?>> |
| 1656 |
<button type="submit" <?php echo $this->render_attributes( 'submit-button' ); ?>> |
| 1657 |
<?php |
| 1658 |
if ( $submit_button_icon_position === 'left' && $submit_button_icon ) { |
| 1659 |
echo $submit_button_icon; |
| 1660 |
} |
| 1661 |
|
| 1662 |
if ( ! isset( $settings['submitButtonIcon'] ) || ( isset( $settings['submitButtonIcon'] ) && isset( $settings['submitButtonText'] ) ) ) { |
| 1663 |
$this->set_attribute( 'submitButtonText', 'class', 'text' ); |
| 1664 |
|
| 1665 |
$submit_button_text = isset( $settings['submitButtonText'] ) ? esc_html( $settings['submitButtonText'] ) : esc_html__( 'Send', 'wpfnl' ); |
| 1666 |
|
| 1667 |
echo "<span {$this->render_attributes( 'submitButtonText' )}>$submit_button_text</span>"; |
| 1668 |
} |
| 1669 |
|
| 1670 |
echo '<span class="wpfnl-loader"></span>'; |
| 1671 |
|
| 1672 |
if ( $submit_button_icon_position === 'right' && $submit_button_icon ) { |
| 1673 |
echo $submit_button_icon; |
| 1674 |
} |
| 1675 |
?> |
| 1676 |
</button> |
| 1677 |
</div> |
| 1678 |
|
| 1679 |
</div> |
| 1680 |
</form> |
| 1681 |
|
| 1682 |
<?php |
| 1683 |
if('on' == $is_recaptch && '' != $site_key && '' != $site_secret_key){?> |
| 1684 |
<script> |
| 1685 |
grecaptcha.ready(function() { |
| 1686 |
grecaptcha.execute('<?php echo $site_key ?>', {action: 'homepage'}).then(function(token) { |
| 1687 |
document.getElementById("wpf-optin-g-token").value = token; |
| 1688 |
}); |
| 1689 |
}); |
| 1690 |
</script> |
| 1691 |
<?php |
| 1692 |
} |
| 1693 |
?> |
| 1694 |
<div class="response"></div> |
| 1695 |
</div> |
| 1696 |
<?php |
| 1697 |
} |
| 1698 |
|
| 1699 |
|
| 1700 |
/** |
| 1701 |
* Render the widget output on the frontend. |
| 1702 |
* |
| 1703 |
* Written in PHP and used to generate the final HTML. |
| 1704 |
* |
| 1705 |
* @since 3.1.0 |
| 1706 |
* |
| 1707 |
* @access public |
| 1708 |
*/ |
| 1709 |
public function render() |
| 1710 |
{ |
| 1711 |
$settings = $this->settings; |
| 1712 |
$classes = $this->get_wrapper_classes(); |
| 1713 |
|
| 1714 |
if ( !isset( $settings[ 'optin_form_source' ] ) || ( !empty( $settings[ 'optin_form_source' ] ) && 'mailmint_forms' !== $settings[ 'optin_form_source' ] ) ) { |
| 1715 |
$this->render_wpfnl_form( $settings, $classes ); |
| 1716 |
} |
| 1717 |
elseif ( !empty( $settings[ 'optin_form_source' ] ) && !empty( $settings[ 'mailmint_form_id' ] ) ) { |
| 1718 |
ob_start(); |
| 1719 |
Wpfnl_Widgets_Manager::render_mailmint_form( $settings[ 'mailmint_form_id' ] ); |
| 1720 |
$mailmint_form = ob_get_clean(); |
| 1721 |
$replace = 'id="mrm-form">'; |
| 1722 |
$replace .= '<input type="hidden" name="widget_id" value="'.$settings[ 'mailmint_form_id' ].'"/>'; |
| 1723 |
if ( !empty( $settings[ 'data_to_checkout' ] ) && 'yes' == $settings[ 'data_to_checkout' ] ) { |
| 1724 |
$replace .= '<input type="hidden" name="data_to_checkout" value="yes"/>'; |
| 1725 |
} |
| 1726 |
if ( !empty( $settings[ 'allow_registration' ] ) && 'yes' == $settings[ 'allow_registration' ] ) { |
| 1727 |
$replace .= '<input type="hidden" name="optin_allow_registration" value="yes"/>'; |
| 1728 |
} |
| 1729 |
echo str_replace( 'id="mrm-form">', $replace, $mailmint_form ); |
| 1730 |
} |
| 1731 |
|
| 1732 |
} |
| 1733 |
|
| 1734 |
} |
| 1735 |
|