| 1 |
<?php |
| 2 |
/** |
| 3 |
* Optin |
| 4 |
* |
| 5 |
* @package |
| 6 |
*/ |
| 7 |
namespace WPFunnels\Widgets\Oxygen; |
| 8 |
|
| 9 |
use CT_Text_Block; |
| 10 |
use WPFunnels\Widgets\Wpfnl_Widgets_Manager; |
| 11 |
use WPFunnels\Wpfnl_functions; |
| 12 |
|
| 13 |
/** |
| 14 |
* Class Optin |
| 15 |
* |
| 16 |
* @package WPFunnels\Widgets\Oxygen |
| 17 |
*/ |
| 18 |
class Optin extends Elements { |
| 19 |
|
| 20 |
function init() { |
| 21 |
// Do some initial things here. |
| 22 |
} |
| 23 |
|
| 24 |
function afterInit() { |
| 25 |
// Do things after init, like remove apply params button and remove the add button. |
| 26 |
$this->removeApplyParamsButton(); |
| 27 |
// $this->removeAddButton(); |
| 28 |
} |
| 29 |
|
| 30 |
function name() { |
| 31 |
return 'WPF Optin'; |
| 32 |
} |
| 33 |
|
| 34 |
function slug() { |
| 35 |
return "wpfnl-optin"; |
| 36 |
} |
| 37 |
|
| 38 |
function icon() { |
| 39 |
return plugin_dir_url(__FILE__) . 'icon/optin_form.svg'; |
| 40 |
} |
| 41 |
|
| 42 |
// function button_place() { |
| 43 |
// // return "interactive"; |
| 44 |
// } |
| 45 |
|
| 46 |
function button_priority() { |
| 47 |
// return 9; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Renders an opt-in form from Oxygen builder based on provided options and defaults in a WPFunnels Landing page. |
| 52 |
* |
| 53 |
* This function first checks the step type to determine if the element should be placed in a specific context. |
| 54 |
* If the step type is "checkout," "upsell," "downsell," or "thankyou," it displays an error message and returns. |
| 55 |
* |
| 56 |
* If the step type is not one of the restricted types, it proceeds to assign various variables from the given options and query parameters: |
| 57 |
* - $step_id: The current step's ID retrieved from the query parameter "post_id" or the current page's ID if the parameter is not provided. |
| 58 |
* - $layout: The layout option retrieved from the given options array. |
| 59 |
* - $admin_email: The admin email option retrieved from the given options array. |
| 60 |
* - $admin_email_subject: The admin email subject option retrieved from the given options array. |
| 61 |
* - $notification_text: The notification text option retrieved from the given options array. |
| 62 |
* - $other_action: The other action option retrieved from the given options array. |
| 63 |
* - $redirect_url: The redirect URL option retrieved from the given options array. |
| 64 |
* |
| 65 |
* Additionally, it retrieves the reCAPTCHA settings using the Wpfnl_functions::get_recaptcha_settings() method: |
| 66 |
* - $recaptcha_setting: The reCAPTCHA settings array. |
| 67 |
* - $is_recaptch: The "enable_recaptcha" option from the reCAPTCHA settings, or an empty string if the option is not provided. |
| 68 |
* - $site_key: The "recaptcha_site_key" option from the reCAPTCHA settings, or an empty string if the option is not provided. |
| 69 |
* - $site_secret_key: The "recaptcha_site_secret" option from the reCAPTCHA settings, or an empty string if the option is not provided. |
| 70 |
* |
| 71 |
* If reCAPTCHA is enabled and both the site key and secret key are not empty strings, the function generates the following HTML elements related to reCAPTCHA: |
| 72 |
* - $is_recaptch_input: A hidden input field for the "enable_recaptcha" option. |
| 73 |
* - $token_input: A hidden input field for the reCAPTCHA token. |
| 74 |
* - $token_secret_key: A hidden input field for the reCAPTCHA secret key. |
| 75 |
* - $recaptch_script: A script tag to load the reCAPTCHA API script from Google. |
| 76 |
* |
| 77 |
* Finally, the function echoes the reCAPTCHA script and includes the template for rendering the optin element, |
| 78 |
* which is fetched from a specific file location. |
| 79 |
* |
| 80 |
* @param array $options The provided options array. |
| 81 |
* @param array $defaults The default values array. |
| 82 |
* @param string $content The content to be rendered. |
| 83 |
* @return void |
| 84 |
*/ |
| 85 |
function render( $options, $defaults, $content ) { |
| 86 |
if( Wpfnl_functions::check_if_this_is_step_type( 'checkout' ) || Wpfnl_functions::check_if_this_is_step_type( 'upsell' ) || Wpfnl_functions::check_if_this_is_step_type( 'downsell' ) || Wpfnl_functions::check_if_this_is_step_type( 'thankyou' ) ) { |
| 87 |
echo __( 'Sorry, Please place the element in WPFunnels Landing or Custom page', 'wpfnl' ); |
| 88 |
} |
| 89 |
else { |
| 90 |
if ( !isset( $options[ 'optin_form_source' ] ) || ( !empty( $options[ 'optin_form_source' ] ) && 'mailmint_forms' !== $options[ 'optin_form_source' ] ) ) { |
| 91 |
$recaptcha_setting = Wpfnl_functions::get_recaptcha_settings(); |
| 92 |
$is_recaptch = $recaptcha_setting[ 'enable_recaptcha' ] ?? ''; |
| 93 |
$site_key = $recaptcha_setting[ 'recaptcha_site_key' ] ?? ''; |
| 94 |
$site_secret_key = $recaptcha_setting[ 'recaptcha_site_secret' ] ?? ''; |
| 95 |
|
| 96 |
if ( 'on' === $is_recaptch && '' !== $site_key && '' !== $site_secret_key ) { |
| 97 |
$is_recaptch_input = "<input type='hidden' id='wpf-is-recapcha' name='wpf-is-recapcha' value='{$is_recaptch}'/>"; |
| 98 |
$token_input = '<input type="hidden" id="wpf-optin-g-token" name="wpf-optin-g-token"/>'; |
| 99 |
$token_secret_key = "<input type='hidden' id='wpf-optin-g-secret-key' name='wpf-optin-g-secret-key' value='{$site_secret_key}'/>"; |
| 100 |
$recaptch_script = "<script src='https://www.google.com/recaptcha/api.js?render={$site_key}'></script>"; |
| 101 |
} |
| 102 |
|
| 103 |
echo $recaptch_script ?? ''; |
| 104 |
|
| 105 |
//mm contact |
| 106 |
$enable_mm_contact = isset($options['enable_mm_contact']) && $options['enable_mm_contact'] == 'on' ? 'yes' : 'no'; |
| 107 |
$mm_contact_status = isset($options['mm_contact_status']) ? $options['mm_contact_status'] : 'pending'; |
| 108 |
$mm_lists = isset($options['mm_lists']) ? $options['mm_lists'] : ''; |
| 109 |
$mm_tags = isset($options['mm_tags']) ? $options['mm_tags'] : ''; |
| 110 |
require WPFNL_DIR . 'includes/core/widgets/oxygen/elements/optin/template/template-optin.php'; |
| 111 |
} |
| 112 |
elseif ( !empty( $options[ 'optin_form_source' ] ) && !empty( $options[ 'mailmint_form_id' ] ) ) { |
| 113 |
Wpfnl_Widgets_Manager::render_mailmint_form( $options[ 'mailmint_form_id' ], $options ); |
| 114 |
} |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
function controls() { |
| 119 |
$form_source = $this->addControlSection( "optin_source", __( "Form Source", "wpfnl" ), "assets/icon.png", $this ); |
| 120 |
$form_source->addOptionControl( |
| 121 |
array( |
| 122 |
"type" => 'dropdown', |
| 123 |
"name" => __( "Source", "wpfnl" ), |
| 124 |
"slug" => 'optin_form_source', |
| 125 |
"default" => "wpfnl_forms" |
| 126 |
) |
| 127 |
)->setValue( [ |
| 128 |
'wpfnl_forms' => 'WPFunnels', |
| 129 |
'mailmint_forms' => 'Mail Mint' |
| 130 |
] )->rebuildElementOnChange(); |
| 131 |
|
| 132 |
$mailmint_forms = Wpfnl_Widgets_Manager::get_mailmint_forms(); |
| 133 |
|
| 134 |
$form_source->addOptionControl( |
| 135 |
array( |
| 136 |
"type" => 'dropdown', |
| 137 |
"name" => __( "Mail Mint Form", "wpfnl" ), |
| 138 |
"slug" => 'mailmint_form_id', |
| 139 |
"default" => array_key_first( $mailmint_forms ), |
| 140 |
"condition" => 'optin_form_source=mailmint_forms' |
| 141 |
) |
| 142 |
)->setValue( $mailmint_forms )->rebuildElementOnChange(); |
| 143 |
|
| 144 |
|
| 145 |
if( \WPFunnels\Integrations\Helper::maybe_enabled() ){ |
| 146 |
|
| 147 |
$form_source->addOptionControl( |
| 148 |
array( |
| 149 |
"type" => 'dropdown', |
| 150 |
"name" => __("Send leads to Mail Mint","wpfnl"), |
| 151 |
"slug" => 'enable_mm_contact', |
| 152 |
"default" => "off", |
| 153 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 154 |
) |
| 155 |
)->setValue(array( |
| 156 |
'on' => __('Yes',"wpfnl" ), |
| 157 |
'off' => __('No',"wpfnl" ), |
| 158 |
))->rebuildElementOnChange(); |
| 159 |
|
| 160 |
$form_source->addOptionControl( |
| 161 |
array( |
| 162 |
"type" => 'dropdown', |
| 163 |
"name" => __("Contact Status","wpfnl"), |
| 164 |
"slug" => 'mm_contact_status', |
| 165 |
"default" => "subscribed", |
| 166 |
"condition" => 'enable_mm_contact=on' |
| 167 |
) |
| 168 |
)->setValue([ |
| 169 |
'pending' => __('Pending', 'wpfnl'), |
| 170 |
'subscribed' => __('Subscribed', 'wpfnl'), |
| 171 |
'unsubscribed' => __('Unsubscribed', 'wpfnl'), |
| 172 |
])->rebuildElementOnChange(); |
| 173 |
|
| 174 |
$form_source->addOptionControl( |
| 175 |
array( |
| 176 |
"type" => 'dropdown', |
| 177 |
"name" => __("Select List","wpfnl"), |
| 178 |
"slug" => 'mm_lists', |
| 179 |
"default" => "", |
| 180 |
"condition" => 'enable_mm_contact=on' |
| 181 |
) |
| 182 |
)->setValue(\WPFunnels\Integrations\Helper::get_lists())->rebuildElementOnChange(); |
| 183 |
|
| 184 |
$form_source->addOptionControl( |
| 185 |
array( |
| 186 |
"type" => 'dropdown', |
| 187 |
"name" => __("Select Tag","wpfnl"), |
| 188 |
"slug" => 'mm_tags', |
| 189 |
"default" => "", |
| 190 |
"condition" => 'enable_mm_contact=on' |
| 191 |
) |
| 192 |
)->setValue(\WPFunnels\Integrations\Helper::get_tags())->rebuildElementOnChange(); |
| 193 |
} |
| 194 |
|
| 195 |
// Layout |
| 196 |
$layout = $this->addControlSection("optin_layout", __("Layout","wpfnl"), "assets/icon.png", $this); |
| 197 |
$layout->addOptionControl( |
| 198 |
array( |
| 199 |
"type" => 'dropdown', |
| 200 |
"name" => __("Layout","wpfnl"), |
| 201 |
"slug" => 'layout', |
| 202 |
"default" => "", |
| 203 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 204 |
) |
| 205 |
)->setValue(array( |
| 206 |
'' => __( 'Default Style',"wpfnl" ), |
| 207 |
'form-style1' => __( 'Form Style-1',"wpfnl" ), |
| 208 |
'form-style2' => __( 'Form Style-2',"wpfnl" ), |
| 209 |
'form-style3' => __( 'Form Style-3',"wpfnl" ), |
| 210 |
'form-style4' => __( 'Form Style-4',"wpfnl" ), |
| 211 |
))->rebuildElementOnChange(); |
| 212 |
|
| 213 |
$form_field = $this->addControlSection("optin_form_field", __("Form Fields","wpfnl"), "assets/icon.png", $this); |
| 214 |
|
| 215 |
//first name |
| 216 |
$field_first_name = $form_field->addControlSection("field_first_name", __("First Name","wpfnl"), "assets/icon.png", $this); |
| 217 |
$field_first_name->addOptionControl( |
| 218 |
array( |
| 219 |
"type" => 'dropdown', |
| 220 |
"name" => __("Enable First Name","wpfnl"), |
| 221 |
"slug" => 'first_name', |
| 222 |
"default" => "off", |
| 223 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 224 |
) |
| 225 |
)->setValue(array( |
| 226 |
'on' => __('Yes' ,"wpfnl"), |
| 227 |
'off' => __('No',"wpfnl" ), |
| 228 |
))->rebuildElementOnChange(); |
| 229 |
|
| 230 |
//First Name label |
| 231 |
$field_first_name->addOptionControl( |
| 232 |
array( |
| 233 |
"type" => 'textfield', |
| 234 |
"name" => __("First Name Label","wpfnl"), |
| 235 |
"slug" => 'first_name_label', |
| 236 |
"default" => __("First Name","wpfnl"), |
| 237 |
"condition" => 'first_name=on', |
| 238 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 239 |
) |
| 240 |
)->rebuildElementOnChange(); |
| 241 |
|
| 242 |
$field_first_name->addOptionControl( |
| 243 |
array( |
| 244 |
"type" => 'textfield', |
| 245 |
"name" => __("First Name Placeholder Text","wpfnl"), |
| 246 |
"slug" => 'first_name_placeholder', |
| 247 |
"default" => __("First Name","wpfnl"), |
| 248 |
"condition" => 'first_name=on', |
| 249 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 250 |
) |
| 251 |
)->rebuildElementOnChange(); |
| 252 |
|
| 253 |
$field_first_name->addOptionControl( |
| 254 |
array( |
| 255 |
"type" => 'dropdown', |
| 256 |
"name" => __("Mark First Name As Required","wpfnl"), |
| 257 |
"slug" => 'is_required_name', |
| 258 |
"default" => "off", |
| 259 |
"condition" => 'first_name=on', |
| 260 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 261 |
) |
| 262 |
)->setValue(array( |
| 263 |
'on' => __('Yes' ,"wpfnl"), |
| 264 |
'off' => __('No',"wpfnl" ), |
| 265 |
))->rebuildElementOnChange(); |
| 266 |
|
| 267 |
|
| 268 |
//Last Name |
| 269 |
$field_last_name = $form_field->addControlSection("field_last_name", __("Last Name","wpfnl"), "assets/icon.png", $this); |
| 270 |
$field_last_name->addOptionControl( |
| 271 |
array( |
| 272 |
"type" => 'dropdown', |
| 273 |
"name" => __("Enable Last Name","wpfnl"), |
| 274 |
"slug" => 'last_name', |
| 275 |
"default" => "off", |
| 276 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 277 |
) |
| 278 |
)->setValue(array( |
| 279 |
'on' => __('Yes',"wpfnl" ), |
| 280 |
'off' => __('No',"wpfnl" ), |
| 281 |
))->rebuildElementOnChange(); |
| 282 |
|
| 283 |
//Last Name label |
| 284 |
$field_last_name->addOptionControl( |
| 285 |
array( |
| 286 |
"type" => 'textfield', |
| 287 |
"name" => __("Last Name Label","wpfnl"), |
| 288 |
"slug" => 'last_name_label', |
| 289 |
"default" => __("Last Name","wpfnl"), |
| 290 |
"condition" => 'last_name=on', |
| 291 |
) |
| 292 |
)->rebuildElementOnChange(); |
| 293 |
|
| 294 |
$field_last_name->addOptionControl( |
| 295 |
array( |
| 296 |
"type" => 'textfield', |
| 297 |
"name" => __("Last Name Placeholder Text","wpfnl"), |
| 298 |
"slug" => 'last_name_placeholder', |
| 299 |
"default" => __("Last Name","wpfnl"), |
| 300 |
"condition" => 'last_name=on', |
| 301 |
) |
| 302 |
)->rebuildElementOnChange(); |
| 303 |
|
| 304 |
$field_last_name->addOptionControl( |
| 305 |
array( |
| 306 |
"type" => 'dropdown', |
| 307 |
"name" => __("Mark Last Name As Required","wpfnl"), |
| 308 |
"slug" => 'is_required_last_name', |
| 309 |
"default" => "off", |
| 310 |
"condition" => 'last_name=on', |
| 311 |
) |
| 312 |
)->setValue(array( |
| 313 |
'on' => __('Yes' ,"wpfnl"), |
| 314 |
'off' => __('No',"wpfnl" ), |
| 315 |
))->rebuildElementOnChange(); |
| 316 |
|
| 317 |
|
| 318 |
//Email label |
| 319 |
$field_email = $form_field->addControlSection("field_email", __("Email","wpfnl"), "assets/icon.png", $this); |
| 320 |
$field_email->addOptionControl( |
| 321 |
array( |
| 322 |
"type" => 'textfield', |
| 323 |
"name" => __("Email Label","wpfnl"), |
| 324 |
"slug" => 'email_label', |
| 325 |
"default" => __("Email","wpfnl"), |
| 326 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 327 |
) |
| 328 |
)->rebuildElementOnChange(); |
| 329 |
|
| 330 |
$field_email->addOptionControl( |
| 331 |
array( |
| 332 |
"type" => 'textfield', |
| 333 |
"name" => __("Email Placeholder Text","wpfnl"), |
| 334 |
"slug" => 'email_placeholder', |
| 335 |
"default" => __("Email","wpfnl"), |
| 336 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 337 |
) |
| 338 |
)->rebuildElementOnChange(); |
| 339 |
|
| 340 |
//phone |
| 341 |
$field_phone = $form_field->addControlSection("field_phone", __("Phone","wpfnl"), "assets/icon.png", $this); |
| 342 |
$field_phone->addOptionControl( |
| 343 |
array( |
| 344 |
"type" => 'dropdown', |
| 345 |
"name" => __("Enable Phone","wpfnl"), |
| 346 |
"slug" => 'phone', |
| 347 |
"default" => "off", |
| 348 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 349 |
) |
| 350 |
)->setValue(array( |
| 351 |
'on' => __('Yes',"wpfnl" ), |
| 352 |
'off' => __('No',"wpfnl" ), |
| 353 |
))->rebuildElementOnChange(); |
| 354 |
|
| 355 |
//phone label |
| 356 |
$field_phone->addOptionControl( |
| 357 |
array( |
| 358 |
"type" => 'textfield', |
| 359 |
"name" => __("Phone Label","wpfnl"), |
| 360 |
"slug" => 'phone_label', |
| 361 |
"default" => __("Phone","wpfnl"), |
| 362 |
"condition" => 'phone=on', |
| 363 |
) |
| 364 |
)->rebuildElementOnChange(); |
| 365 |
|
| 366 |
$field_phone->addOptionControl( |
| 367 |
array( |
| 368 |
"type" => 'textfield', |
| 369 |
"name" => __("Phone Placeholder Text","wpfnl"), |
| 370 |
"slug" => 'phone_placeholder', |
| 371 |
"default" => __("Phone","wpfnl"), |
| 372 |
"condition" => 'phone=on', |
| 373 |
) |
| 374 |
)->rebuildElementOnChange(); |
| 375 |
|
| 376 |
$field_phone->addOptionControl( |
| 377 |
array( |
| 378 |
"type" => 'dropdown', |
| 379 |
"name" => __("Mark Phone As Required","wpfnl"), |
| 380 |
"slug" => 'is_required_phone', |
| 381 |
"default" => "off", |
| 382 |
"condition" => 'phone=on', |
| 383 |
) |
| 384 |
)->setValue(array( |
| 385 |
'on' => __('Yes' ,"wpfnl"), |
| 386 |
'off' => __('No',"wpfnl" ), |
| 387 |
))->rebuildElementOnChange(); |
| 388 |
|
| 389 |
|
| 390 |
//website url |
| 391 |
$field_website_url = $form_field->addControlSection("field_website_url", __("Website Url","wpfnl"), "assets/icon.png", $this); |
| 392 |
$field_website_url->addOptionControl( |
| 393 |
array( |
| 394 |
"type" => 'dropdown', |
| 395 |
"name" => __("Website Url","wpfnl"), |
| 396 |
"slug" => 'website_url', |
| 397 |
"default" => "off", |
| 398 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 399 |
) |
| 400 |
)->setValue(array( |
| 401 |
'on' => __('Yes',"wpfnl" ), |
| 402 |
'off' => __('No',"wpfnl" ), |
| 403 |
))->rebuildElementOnChange(); |
| 404 |
|
| 405 |
//website label |
| 406 |
$field_website_url->addOptionControl( |
| 407 |
array( |
| 408 |
"type" => 'textfield', |
| 409 |
"name" => __("Website Url Label","wpfnl"), |
| 410 |
"slug" => 'website_url_label', |
| 411 |
"default" => __("Website Url","wpfnl"), |
| 412 |
"condition" => 'website_url=on', |
| 413 |
) |
| 414 |
)->rebuildElementOnChange(); |
| 415 |
|
| 416 |
$field_website_url->addOptionControl( |
| 417 |
array( |
| 418 |
"type" => 'textfield', |
| 419 |
"name" => __("Website Url Placeholder Text","wpfnl"), |
| 420 |
"slug" => 'website_url_placeholder', |
| 421 |
"default" => __("Website Url","wpfnl"), |
| 422 |
"condition" => 'website_url=on', |
| 423 |
) |
| 424 |
)->rebuildElementOnChange(); |
| 425 |
|
| 426 |
$field_website_url->addOptionControl( |
| 427 |
array( |
| 428 |
"type" => 'dropdown', |
| 429 |
"name" => __("Mark Website Url As Required","wpfnl"), |
| 430 |
"slug" => 'is_required_website_url', |
| 431 |
"default" => "off", |
| 432 |
"condition" => 'website_url=on', |
| 433 |
) |
| 434 |
)->setValue(array( |
| 435 |
'on' => __('Yes' ,"wpfnl"), |
| 436 |
'off' => __('No',"wpfnl" ), |
| 437 |
))->rebuildElementOnChange(); |
| 438 |
|
| 439 |
|
| 440 |
//message |
| 441 |
$field_message = $form_field->addControlSection("field_message", __("Message","wpfnl"), "assets/icon.png", $this); |
| 442 |
$field_message->addOptionControl( |
| 443 |
array( |
| 444 |
"type" => 'dropdown', |
| 445 |
"name" => __("Message","wpfnl"), |
| 446 |
"slug" => 'message', |
| 447 |
"default" => "off", |
| 448 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 449 |
) |
| 450 |
)->setValue(array( |
| 451 |
'on' => __('Yes',"wpfnl" ), |
| 452 |
'off' => __('No',"wpfnl" ), |
| 453 |
))->rebuildElementOnChange(); |
| 454 |
|
| 455 |
|
| 456 |
//Message label |
| 457 |
$field_message->addOptionControl( |
| 458 |
array( |
| 459 |
"type" => 'textfield', |
| 460 |
"name" => __("Message Label","wpfnl"), |
| 461 |
"slug" => 'message_label', |
| 462 |
"default" => __("Message","wpfnl"), |
| 463 |
"condition" => 'message=on', |
| 464 |
) |
| 465 |
)->rebuildElementOnChange(); |
| 466 |
|
| 467 |
$field_message->addOptionControl( |
| 468 |
array( |
| 469 |
"type" => 'textfield', |
| 470 |
"name" => __("Message Placeholder Text","wpfnl"), |
| 471 |
"slug" => 'message_placeholder', |
| 472 |
"default" => __("Message","wpfnl"), |
| 473 |
"condition" => 'message=on', |
| 474 |
) |
| 475 |
)->rebuildElementOnChange(); |
| 476 |
|
| 477 |
$field_message->addOptionControl( |
| 478 |
array( |
| 479 |
"type" => 'dropdown', |
| 480 |
"name" => __("Mark Message As Required","wpfnl"), |
| 481 |
"slug" => 'is_required_message', |
| 482 |
"default" => "off", |
| 483 |
"condition" => 'message=on', |
| 484 |
) |
| 485 |
)->setValue(array( |
| 486 |
'on' => __('Yes' ,"wpfnl"), |
| 487 |
'off' => __('No',"wpfnl" ), |
| 488 |
))->rebuildElementOnChange(); |
| 489 |
|
| 490 |
|
| 491 |
//Acceptance |
| 492 |
$field_acceptance = $form_field->addControlSection("field_acceptance", __("Acceptance","wpfnl"), "assets/icon.png", $this); |
| 493 |
$field_acceptance->addOptionControl( |
| 494 |
array( |
| 495 |
"type" => 'dropdown', |
| 496 |
"name" => __("Acceptance Checkbox","wpfnl"), |
| 497 |
"slug" => 'acceptance_checkbox', |
| 498 |
"default" => "off", |
| 499 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 500 |
) |
| 501 |
)->setValue(array( |
| 502 |
'on' => __('Yes',"wpfnl" ), |
| 503 |
'off' => __('No',"wpfnl" ), |
| 504 |
))->rebuildElementOnChange(); |
| 505 |
|
| 506 |
//Acceptance Text |
| 507 |
$field_acceptance->addOptionControl( |
| 508 |
array( |
| 509 |
"type" => 'content', |
| 510 |
"name" => __("Acceptance Text","wpfnl"), |
| 511 |
"slug" => 'acceptance_checkbox_text', |
| 512 |
"default" => __("I have read and agree the Terms & Condition.","wpfnl"), |
| 513 |
"condition" => 'acceptance_checkbox=on', |
| 514 |
) |
| 515 |
)->rebuildElementOnChange(); |
| 516 |
|
| 517 |
$field_acceptance->addOptionControl( |
| 518 |
array( |
| 519 |
"type" => 'dropdown', |
| 520 |
"name" => __("Mark Acceptance As Required","wpfnl"), |
| 521 |
"slug" => 'is_required_acceptance', |
| 522 |
"default" => "off", |
| 523 |
"condition" => 'acceptance_checkbox=on', |
| 524 |
) |
| 525 |
)->setValue(array( |
| 526 |
'on' => __('Yes' ,"wpfnl"), |
| 527 |
'off' => __('No',"wpfnl" ), |
| 528 |
))->rebuildElementOnChange(); |
| 529 |
|
| 530 |
|
| 531 |
//Input field Icon |
| 532 |
$field_icon = $form_field->addControlSection("field_icon", __("Fiels Icon","wpfnl"), "assets/icon.png", $this); |
| 533 |
$field_icon->addOptionControl( |
| 534 |
array( |
| 535 |
"type" => 'dropdown', |
| 536 |
"name" => __("Show Input Field Icon(s)","wpfnl"), |
| 537 |
"slug" => 'input_fields_icon', |
| 538 |
"default" => "off", |
| 539 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 540 |
) |
| 541 |
)->setValue(array( |
| 542 |
'on' => __('Yes' ,"wpfnl"), |
| 543 |
'off' => __('No',"wpfnl" ), |
| 544 |
))->rebuildElementOnChange(); |
| 545 |
|
| 546 |
//Input field Label |
| 547 |
$field_label = $form_field->addControlSection("field_label", __("Field Label","wpfnl"), "assets/icon.png", $this); |
| 548 |
$field_label->addOptionControl( |
| 549 |
array( |
| 550 |
"type" => 'dropdown', |
| 551 |
"name" => __("Show Field Label(s)","wpfnl"), |
| 552 |
"slug" => 'field_label', |
| 553 |
"default" => "off", |
| 554 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 555 |
) |
| 556 |
)->setValue(array( |
| 557 |
'on' => __('Yes',"wpfnl" ), |
| 558 |
'off' => __('No',"wpfnl" ), |
| 559 |
))->rebuildElementOnChange(); |
| 560 |
|
| 561 |
//Input field Require Mark |
| 562 |
$field_label->addOptionControl( |
| 563 |
array( |
| 564 |
"type" => 'dropdown', |
| 565 |
"name" => __("Show Field Required Mark","wpfnl"), |
| 566 |
"slug" => 'field_required_mark', |
| 567 |
"default" => "off", |
| 568 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 569 |
) |
| 570 |
)->setValue(array( |
| 571 |
'on' => __('Yes',"wpfnl" ), |
| 572 |
'off' => __('No',"wpfnl" ), |
| 573 |
))->rebuildElementOnChange(); |
| 574 |
|
| 575 |
|
| 576 |
//Button Text |
| 577 |
$button = $this->addControlSection("optin_form_button", __("Form Button","wpfnl"), "assets/icon.png", $this); |
| 578 |
$button_selector = '.wpfnl-optin-form-group .btn-optin-oxygen'; |
| 579 |
|
| 580 |
$button->addOptionControl( |
| 581 |
array( |
| 582 |
"type" => 'textfield', |
| 583 |
"name" => __("Button Text","wpfnl"), |
| 584 |
"slug" => 'button_text', |
| 585 |
"default" => "Submit", |
| 586 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 587 |
) |
| 588 |
)->rebuildElementOnChange(); |
| 589 |
|
| 590 |
$button->typographySection( |
| 591 |
__("Typography","wpfnl"), |
| 592 |
$button_selector."", |
| 593 |
$this |
| 594 |
); |
| 595 |
$button->borderSection( |
| 596 |
__("Button Border","wpfnl"), |
| 597 |
$button_selector."", |
| 598 |
$this |
| 599 |
); |
| 600 |
$button->addPreset( |
| 601 |
"padding", |
| 602 |
"menu_item_padding", |
| 603 |
__("Button Padding","wpfnl"), |
| 604 |
$button_selector |
| 605 |
)->whiteList(); |
| 606 |
|
| 607 |
$button->addPreset( |
| 608 |
"margin", |
| 609 |
"menu_item_margin", |
| 610 |
__("Button Margin","wpfnl"), |
| 611 |
$button_selector |
| 612 |
)->whiteList(); |
| 613 |
|
| 614 |
$button->addStyleControls( |
| 615 |
array( |
| 616 |
array( |
| 617 |
"name" => __('Background Color',"wpfnl"), |
| 618 |
"selector" => $button_selector."", |
| 619 |
"property" => 'background-color', |
| 620 |
), |
| 621 |
array( |
| 622 |
"name" => __('Background Hover Color',"wpfnl"), |
| 623 |
"selector" => $button_selector.":hover", |
| 624 |
"property" => 'background-color', |
| 625 |
), |
| 626 |
|
| 627 |
) |
| 628 |
); |
| 629 |
|
| 630 |
//Form style |
| 631 |
$form_style = $this->addControlSection("optin_form_style", __("Form Label Style","wpfnl"), "assets/icon.png", $this); |
| 632 |
$form_selector = '.wpfnl-optin-form form'; |
| 633 |
|
| 634 |
$form_style->typographySection( |
| 635 |
__("Typography","wpfnl"), |
| 636 |
".wpfnl-optin-form .wpfnl-optin-form-group > label", |
| 637 |
$this |
| 638 |
); |
| 639 |
$form_style->addStyleControls( |
| 640 |
array( |
| 641 |
array( |
| 642 |
"name" => __('Checkbox Size',"wpfnl"), |
| 643 |
"selector" => ".wpfnl-optin-form .wpfnl-optin-form-group > label .check-box", |
| 644 |
"property" => 'width|height', |
| 645 |
"control_type" => 'slider-measurebox', |
| 646 |
"unit" => 'px' |
| 647 |
), |
| 648 |
|
| 649 |
array( |
| 650 |
"name" => __('Checkbox Spacing',"wpfnl"), |
| 651 |
"selector" => ".wpfnl-optin-form .wpfnl-optin-form-group.acceptance-checkbox > label, .wpfnl-optin-form .wpfnl-optin-form-group.user-registration-checkbox > label", |
| 652 |
"property" => 'padding-left', |
| 653 |
"control_type" => 'slider-measurebox', |
| 654 |
"unit" => 'px' |
| 655 |
), |
| 656 |
array( |
| 657 |
"name" => __('Row Spacing',"wpfnl"), |
| 658 |
"selector" => ".wpfnl-optin-form .wpfnl-optin-form-group:not(:last-child)", |
| 659 |
"property" => 'margin-bottom', |
| 660 |
"control_type" => 'slider-measurebox', |
| 661 |
"unit" => 'px' |
| 662 |
), |
| 663 |
) |
| 664 |
); |
| 665 |
|
| 666 |
$input_style = $this->addControlSection("optin_form_input_style", __("Form Input Style","wpfnl"), "assets/icon.png", $this); |
| 667 |
|
| 668 |
$input_style->typographySection( |
| 669 |
__("Typography","wpfnl"), |
| 670 |
".wpfnl-optin-form .wpfnl-optin-form-group input, .wpfnl-optin-form .wpfnl-optin-form-group textarea", |
| 671 |
$this |
| 672 |
); |
| 673 |
$input_style->borderSection( |
| 674 |
__("Button Border","wpfnl"), |
| 675 |
".wpfnl-optin-form .wpfnl-optin-form-group input, .wpfnl-optin-form .wpfnl-optin-form-group textarea", |
| 676 |
$this |
| 677 |
); |
| 678 |
$input_style->addStyleControls( |
| 679 |
array( |
| 680 |
array( |
| 681 |
"name" => __('Background Color',"wpfnl"), |
| 682 |
"selector" => ".wpfnl-optin-form .wpfnl-optin-form-group input, .wpfnl-optin-form .wpfnl-optin-form-group textarea", |
| 683 |
"property" => 'background-color', |
| 684 |
), |
| 685 |
|
| 686 |
) |
| 687 |
); |
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
//Admin Email |
| 693 |
$ac_submit = $this->addControlSection("optin_after_submit", __("Action After Submission","wpfnl"), "assets/icon.png", $this); |
| 694 |
$admin_email = Wpfnl_functions::get_optin_settings('sender_email'); |
| 695 |
$email_subject = Wpfnl_functions::get_optin_settings('email_subject'); |
| 696 |
$ac_submit->addOptionControl( |
| 697 |
array( |
| 698 |
"type" => 'textfield', |
| 699 |
"name" => __("Admin Email","wpfnl"), |
| 700 |
"slug" => 'admin_email', |
| 701 |
"default" => $admin_email, |
| 702 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 703 |
) |
| 704 |
)->rebuildElementOnChange(); |
| 705 |
|
| 706 |
//Admin Email Subject |
| 707 |
$ac_submit->addOptionControl( |
| 708 |
array( |
| 709 |
"type" => 'textfield', |
| 710 |
"name" => __("Admin Email Subject","wpfnl"), |
| 711 |
"slug" => 'admin_email_subject', |
| 712 |
"default" => $email_subject, |
| 713 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 714 |
) |
| 715 |
)->rebuildElementOnChange(); |
| 716 |
|
| 717 |
//Notification Text |
| 718 |
$ac_submit->addOptionControl( |
| 719 |
array( |
| 720 |
"type" => 'textfield', |
| 721 |
"name" => __("Notification Text","wpfnl"), |
| 722 |
"slug" => 'notification_text', |
| 723 |
"default" => "Thank you! Your form was submitted successfully!", |
| 724 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 725 |
) |
| 726 |
)->rebuildElementOnChange(); |
| 727 |
|
| 728 |
// Other action |
| 729 |
$ac_submit->addOptionControl( |
| 730 |
array( |
| 731 |
"type" => 'dropdown', |
| 732 |
"name" => __("Other action","wpfnl"), |
| 733 |
"slug" => 'other_action', |
| 734 |
"default" => "notification", |
| 735 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 736 |
) |
| 737 |
)->setValue(array( |
| 738 |
'notification' => __( 'None','wpfnl' ), |
| 739 |
'redirect_to' => __( 'Redirect to url','wpfnl' ), |
| 740 |
'next_step' => __( 'Next Step','wpfnl' ), |
| 741 |
|
| 742 |
))->rebuildElementOnChange(); |
| 743 |
|
| 744 |
//Redirect URL |
| 745 |
$ac_submit->addOptionControl( |
| 746 |
array( |
| 747 |
"type" => 'textfield', |
| 748 |
"name" => __("Redirect url","wpfnl"), |
| 749 |
"slug" => 'redirect_url', |
| 750 |
"default" => "", |
| 751 |
"condition" => 'other_action=redirect_to', |
| 752 |
) |
| 753 |
)->rebuildElementOnChange(); |
| 754 |
|
| 755 |
|
| 756 |
//Send data to Checkout |
| 757 |
$ac_submit->addOptionControl( |
| 758 |
array( |
| 759 |
"type" => 'dropdown', |
| 760 |
"name" => __("Carry data to the Next Form","wpfnl"), |
| 761 |
"slug" => 'data_to_checkout', |
| 762 |
"default" => "off", |
| 763 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 764 |
) |
| 765 |
)->setValue(array( |
| 766 |
'off' => __('No',"wpfnl" ), |
| 767 |
'on' => __('Yes',"wpfnl" ), |
| 768 |
))->rebuildElementOnChange(); |
| 769 |
|
| 770 |
//Optin Registration |
| 771 |
$ac_submit->addOptionControl( |
| 772 |
array( |
| 773 |
"type" => 'dropdown', |
| 774 |
"name" => __("Register User As Subscriber","wpfnl"), |
| 775 |
"slug" => 'register_as_subscriber', |
| 776 |
"default" => "off", |
| 777 |
"condition" => 'optin_form_source=wpfnl_forms' |
| 778 |
) |
| 779 |
)->setValue(array( |
| 780 |
'off' => __('No',"wpfnl" ), |
| 781 |
'on' => __('Yes',"wpfnl" ), |
| 782 |
))->rebuildElementOnChange(); |
| 783 |
|
| 784 |
// Subscribed permission |
| 785 |
$ac_submit->addOptionControl( |
| 786 |
array( |
| 787 |
"type" => 'dropdown', |
| 788 |
"name" => __("Registration Permission","wpfnl"), |
| 789 |
"slug" => 'subscription_permission', |
| 790 |
"default" => "off", |
| 791 |
"condition" => 'register_as_subscriber=on', |
| 792 |
) |
| 793 |
)->setValue(array( |
| 794 |
'off' => __('No',"wpfnl" ), |
| 795 |
'on' => __('Yes',"wpfnl" ), |
| 796 |
))->rebuildElementOnChange(); |
| 797 |
// Subscribed permission Text |
| 798 |
$ac_submit->addOptionControl( |
| 799 |
array( |
| 800 |
"type" => 'textfield', |
| 801 |
"name" => __("Registration Permission Text","wpfnl"), |
| 802 |
"slug" => 'subscription_permission_text', |
| 803 |
"default" => __("I agree to be registered as a subscriber.","wpfnl"), |
| 804 |
"condition" => 'subscription_permission=on', |
| 805 |
) |
| 806 |
)->rebuildElementOnChange(); |
| 807 |
|
| 808 |
|
| 809 |
} |
| 810 |
|
| 811 |
function defaultCSS() { |
| 812 |
|
| 813 |
} |
| 814 |
|
| 815 |
|
| 816 |
} |
| 817 |
|