| @@ -1,1222 +1,1522 @@ | ||
| 1 | -<?php | |
| 2 | -namespace UiCoreElements\Utils; | |
| 3 | - | |
| 4 | -use UiCoreElements\Helper; | |
| 5 | -use Elementor\Controls_Manager; | |
| 6 | -use Elementor\Group_Control_Typography; | |
| 7 | -use Elementor\Group_Control_Border; | |
| 8 | -use Elementor\Core\Kits\Documents\Tabs\Global_Colors; | |
| 9 | -use Elementor\Core\Kits\Documents\Tabs\Global_Typography; | |
| 10 | - | |
| 11 | -defined('ABSPATH') || exit(); | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * Register some Form Widgets controls and methods. | |
| 15 | - */ | |
| 16 | - | |
| 17 | -trait Form_Component { | |
| 18 | - | |
| 19 | - // Submission Controls | |
| 20 | - function TRAIT_register_submit_email_controls($instance, $slug = '') | |
| 21 | - { | |
| 22 | - $instance->add_control( | |
| 23 | - 'email_to' . $slug, | |
| 24 | - [ | |
| 25 | - 'label' => esc_html__( 'To', 'uicore-elements' ), | |
| 26 | - 'type' => Controls_Manager::TEXT, | |
| 27 | - 'default' => get_option( 'admin_email' ), | |
| 28 | - 'ai' => [ | |
| 29 | - 'active' => false, | |
| 30 | - ], | |
| 31 | - 'placeholder' => get_option( 'admin_email' ), | |
| 32 | - 'label_block' => true, | |
| 33 | - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ), | |
| 34 | - 'render_type' => 'none', | |
| 35 | - 'dynamic' => [ | |
| 36 | - 'active' => true, | |
| 37 | - ], | |
| 38 | - ] | |
| 39 | - ); | |
| 40 | - | |
| 41 | - /* translators: %s: Site title. */ | |
| 42 | - $default_message = sprintf( html_entity_decode( esc_html__( 'New message from "%s"', 'uicore-elements' ) ), get_option( 'blogname' ) ); | |
| 43 | - | |
| 44 | - $instance->add_control( | |
| 45 | - 'email_subject' . $slug, | |
| 46 | - [ | |
| 47 | - 'label' => esc_html__( 'Subject', 'uicore-elements' ), | |
| 48 | - 'type' => Controls_Manager::TEXT, | |
| 49 | - 'default' => $default_message, | |
| 50 | - 'ai' => [ | |
| 51 | - 'active' => false, | |
| 52 | - ], | |
| 53 | - 'placeholder' => $default_message, | |
| 54 | - 'label_block' => true, | |
| 55 | - 'render_type' => 'none', | |
| 56 | - 'dynamic' => [ | |
| 57 | - 'active' => true, | |
| 58 | - ], | |
| 59 | - ] | |
| 60 | - ); | |
| 61 | - | |
| 62 | - $instance->add_control( | |
| 63 | - 'email_content' . $slug, | |
| 64 | - [ | |
| 65 | - 'label' => esc_html__( 'Message', 'uicore-elements' ), | |
| 66 | - 'type' => Controls_Manager::TEXTAREA, | |
| 67 | - 'default' => '[all-fields]', | |
| 68 | - 'ai' => [ | |
| 69 | - 'active' => false, | |
| 70 | - ], | |
| 71 | - 'placeholder' => '[all-fields]', | |
| 72 | - 'description' => sprintf( | |
| 73 | - /* translators: %s: The [all-fields] shortcode. */ | |
| 74 | - esc_html__( 'By default, all form fields are sent via %s shortcode. To customize sent fields, copy the shortcode that appears inside each field and paste it above.', 'uicore-elements' ), | |
| 75 | - '<code>[all-fields]</code>' | |
| 76 | - ), | |
| 77 | - 'render_type' => 'none', | |
| 78 | - 'dynamic' => [ | |
| 79 | - 'active' => true, | |
| 80 | - ], | |
| 81 | - ] | |
| 82 | - ); | |
| 83 | - | |
| 84 | - $site_domain = Helper::get_site_domain(); | |
| 85 | - | |
| 86 | - $instance->add_control( | |
| 87 | - 'email_from' . $slug, | |
| 88 | - [ | |
| 89 | - 'label' => esc_html__( 'From Email', 'uicore-elements' ), | |
| 90 | - 'type' => Controls_Manager::TEXT, | |
| 91 | - 'default' => 'email@' . $site_domain, | |
| 92 | - 'ai' => [ | |
| 93 | - 'active' => false, | |
| 94 | - ], | |
| 95 | - 'render_type' => 'none', | |
| 96 | - 'dynamic' => [ | |
| 97 | - 'active' => true, | |
| 98 | - ], | |
| 99 | - ] | |
| 100 | - ); | |
| 101 | - | |
| 102 | - $instance->add_control( | |
| 103 | - 'email_from_name' . $slug, | |
| 104 | - [ | |
| 105 | - 'label' => esc_html__( 'From Name', 'uicore-elements' ), | |
| 106 | - 'type' => Controls_Manager::TEXT, | |
| 107 | - 'default' => get_bloginfo( 'name' ), | |
| 108 | - 'ai' => [ | |
| 109 | - 'active' => false, | |
| 110 | - ], | |
| 111 | - 'render_type' => 'none', | |
| 112 | - 'dynamic' => [ | |
| 113 | - 'active' => true, | |
| 114 | - ], | |
| 115 | - ] | |
| 116 | - ); | |
| 117 | - | |
| 118 | - $instance->add_control( | |
| 119 | - 'email_reply_to' . $slug, | |
| 120 | - [ | |
| 121 | - 'label' => esc_html__( 'Reply-To', 'uicore-elements' ), | |
| 122 | - 'type' => Controls_Manager::TEXT, | |
| 123 | - 'options' => [ | |
| 124 | - '' => '', | |
| 125 | - ], | |
| 126 | - 'default' => 'noreply@' . Helper::get_site_domain(), | |
| 127 | - 'render_type' => 'none', | |
| 128 | - ] | |
| 129 | - ); | |
| 130 | - | |
| 131 | - $instance->add_control( | |
| 132 | - 'email_to_cc' . $slug, | |
| 133 | - [ | |
| 134 | - 'label' => esc_html__( 'Cc', 'uicore-elements' ), | |
| 135 | - 'type' => Controls_Manager::TEXT, | |
| 136 | - 'default' => '', | |
| 137 | - 'ai' => [ | |
| 138 | - 'active' => false, | |
| 139 | - ], | |
| 140 | - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ), | |
| 141 | - 'render_type' => 'none', | |
| 142 | - 'dynamic' => [ | |
| 143 | - 'active' => true, | |
| 144 | - ], | |
| 145 | - ] | |
| 146 | - ); | |
| 147 | - | |
| 148 | - $instance->add_control( | |
| 149 | - 'email_to_bcc' . $slug, | |
| 150 | - [ | |
| 151 | - 'label' => esc_html__( 'Bcc', 'uicore-elements' ), | |
| 152 | - 'type' => Controls_Manager::TEXT, | |
| 153 | - 'default' => '', | |
| 154 | - 'ai' => [ | |
| 155 | - 'active' => false, | |
| 156 | - ], | |
| 157 | - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ), | |
| 158 | - 'render_type' => 'none', | |
| 159 | - 'dynamic' => [ | |
| 160 | - 'active' => true, | |
| 161 | - ], | |
| 162 | - ] | |
| 163 | - ); | |
| 164 | - | |
| 165 | - $instance->add_control( | |
| 166 | - 'form_metadata' . $slug, | |
| 167 | - [ | |
| 168 | - 'label' => esc_html__( 'Meta Data', 'uicore-elements' ), | |
| 169 | - 'type' => Controls_Manager::SELECT2, | |
| 170 | - 'multiple' => true, | |
| 171 | - 'label_block' => true, | |
| 172 | - 'separator' => 'before', | |
| 173 | - 'default' => [ | |
| 174 | - 'date', | |
| 175 | - 'time', | |
| 176 | - 'page_url', | |
| 177 | - 'user_agent', | |
| 178 | - 'remote_ip', | |
| 179 | - ], | |
| 180 | - 'options' => [ | |
| 181 | - 'date' => esc_html__( 'Date', 'uicore-elements' ), | |
| 182 | - 'time' => esc_html__( 'Time', 'uicore-elements' ), | |
| 183 | - 'page_url' => esc_html__( 'Page URL', 'uicore-elements' ), | |
| 184 | - 'user_agent' => esc_html__( 'User Agent', 'uicore-elements' ), | |
| 185 | - 'remote_ip' => esc_html__( 'Remote IP', 'uicore-elements' ), | |
| 186 | - ], | |
| 187 | - 'render_type' => 'none', | |
| 188 | - ] | |
| 189 | - ); | |
| 190 | - | |
| 191 | - $instance->add_control( | |
| 192 | - 'email_content_type' . $slug, | |
| 193 | - [ | |
| 194 | - 'label' => esc_html__( 'Send As', 'uicore-elements' ), | |
| 195 | - 'type' => Controls_Manager::SELECT, | |
| 196 | - 'default' => 'html', | |
| 197 | - 'render_type' => 'none', | |
| 198 | - 'options' => [ | |
| 199 | - 'html' => esc_html__( 'HTML', 'uicore-elements' ), | |
| 200 | - 'plain' => esc_html__( 'Plain', 'uicore-elements' ), | |
| 201 | - ], | |
| 202 | - ] | |
| 203 | - ); | |
| 204 | - } | |
| 205 | - function TRAIT_register_submit_redirect_controls() | |
| 206 | - { | |
| 207 | - $this->add_control( | |
| 208 | - 'redirect_to', | |
| 209 | - [ | |
| 210 | - 'label' => esc_html__( 'Redirect To', 'uicore-elements' ), | |
| 211 | - 'type' => Controls_Manager::TEXT, | |
| 212 | - 'placeholder' => esc_html__( 'https://your-link.com', 'uicore-elements' ), | |
| 213 | - 'ai' => [ | |
| 214 | - 'active' => false, | |
| 215 | - ], | |
| 216 | - 'dynamic' => [ | |
| 217 | - 'active' => true, | |
| 218 | - 'categories' => [ | |
| 219 | - 'url', | |
| 220 | - ], | |
| 221 | - ], | |
| 222 | - 'label_block' => true, | |
| 223 | - 'render_type' => 'none', | |
| 224 | - ] | |
| 225 | - ); | |
| 226 | - } | |
| 227 | - /** | |
| 228 | - * Register MailChimp controls for the submit action. | |
| 229 | - * | |
| 230 | - * @param $instance - The widget instance. Required if $has_repeaters is true. | |
| 231 | - * @param bool $has_repeaters - Enable Field Mapping control if the widget has dynamic fields widh repeaters. | |
| 232 | - * | |
| 233 | - * @return void | |
| 234 | - */ | |
| 235 | - function TRAIT_register_submit_mailchimp_controls($instance = null, bool $has_repeaters = false) | |
| 236 | - { | |
| 237 | - | |
| 238 | - if( !get_option('uicore_elements_mailchimp_secret_key') ) { | |
| 239 | - $this->add_control( | |
| 240 | - 'mailchimp_warning', | |
| 241 | - [ | |
| 242 | - 'type' => Controls_Manager::ALERT, | |
| 243 | - 'alert_type' => 'warning', | |
| 244 | - 'dismissible' => false, | |
| 245 | - 'heading' => esc_html__("You haven't set your Mailchimp API key yet.", 'uicore-elements'), | |
| 246 | - 'content' => Helper::get_admin_settings_url(esc_html__("Click here to configure your API keys.", 'uicore-elements' )), | |
| 247 | - ] | |
| 248 | - ); | |
| 249 | - } | |
| 250 | - | |
| 251 | - $this->add_control( | |
| 252 | - 'mailchimp_audience_id', | |
| 253 | - [ | |
| 254 | - 'label' => esc_html__( 'Audience ID', 'uicore-elements' ), | |
| 255 | - 'type' => Controls_Manager::TEXT, | |
| 256 | - 'description' => esc_html__( 'Enter the Audience ID to subscribe the user to.', 'uicore-elements' ), | |
| 257 | - 'ai' => [ | |
| 258 | - 'active' => false, | |
| 259 | - ], | |
| 260 | - 'dynamic' => [ | |
| 261 | - 'active' => true, | |
| 262 | - ], | |
| 263 | - 'label_block' => true, | |
| 264 | - 'render_type' => 'none', | |
| 265 | - ] | |
| 266 | - ); | |
| 267 | - | |
| 268 | - // If repeaters, than we need the field mapping controls | |
| 269 | - if($has_repeaters) { | |
| 270 | - $this->add_control( | |
| 271 | - 'mailchimp_map_description', | |
| 272 | - [ | |
| 273 | - 'label' => esc_html__( 'Field Mapping', 'uicore-elements' ), | |
| 274 | - 'type' => Controls_Manager::RAW_HTML, | |
| 275 | - 'raw' => esc_html__( 'You need to set the "ID" of the field you want to map.', 'uicore-elements' ), | |
| 276 | - 'content_classes' => 'elementor-control-field-description', | |
| 277 | - 'separator' => 'before', | |
| 278 | - ] | |
| 279 | - ); | |
| 280 | - $this->add_control( | |
| 281 | - 'mailchimp_email_id', | |
| 282 | - [ | |
| 283 | - 'label' => esc_html__( 'Email*', 'uicore-elements' ), | |
| 284 | - 'type' => Controls_Manager::TEXT, | |
| 285 | - 'ai' => [ | |
| 286 | - 'active' => false, | |
| 287 | - ], | |
| 288 | - 'render_type' => 'none', | |
| 289 | - ] | |
| 290 | - ); | |
| 291 | - $this->add_control( | |
| 292 | - 'mailchimp_birthday_id', | |
| 293 | - [ | |
| 294 | - 'label' => esc_html__( 'Birthday', 'uicore-elements' ), | |
| 295 | - 'type' => Controls_Manager::TEXT, | |
| 296 | - 'description' => esc_html__( 'Expects the format MM/DD.', 'uicore-elements' ), | |
| 297 | - 'ai' => [ | |
| 298 | - 'active' => false, | |
| 299 | - ], | |
| 300 | - 'render_type' => 'none', | |
| 301 | - ] | |
| 302 | - ); | |
| 303 | - $this->add_control( | |
| 304 | - 'mailchimp_fname_id', | |
| 305 | - [ | |
| 306 | - 'label' => esc_html__( 'First Name', 'uicore-elements' ), | |
| 307 | - 'type' => Controls_Manager::TEXT, | |
| 308 | - 'ai' => [ | |
| 309 | - 'active' => false, | |
| 310 | - ], | |
| 311 | - 'render_type' => 'none', | |
| 312 | - ] | |
| 313 | - ); | |
| 314 | - $this->add_control( | |
| 315 | - 'mailchimp_lname_id', | |
| 316 | - [ | |
| 317 | - 'label' => esc_html__( 'Last Name', 'uicore-elements' ), | |
| 318 | - 'type' => Controls_Manager::TEXT, | |
| 319 | - 'ai' => [ | |
| 320 | - 'active' => false, | |
| 321 | - ], | |
| 322 | - 'render_type' => 'none', | |
| 323 | - ] | |
| 324 | - ); | |
| 325 | - $this->add_control( | |
| 326 | - 'mailchimp_phone_id', | |
| 327 | - [ | |
| 328 | - 'label' => esc_html__( 'Phone', 'uicore-elements' ), | |
| 329 | - 'type' => Controls_Manager::TEXT, | |
| 330 | - 'ai' => [ | |
| 331 | - 'active' => false, | |
| 332 | - ], | |
| 333 | - 'render_type' => 'none', | |
| 334 | - ] | |
| 335 | - ); | |
| 336 | - | |
| 337 | - } | |
| 338 | - } | |
| 339 | - | |
| 340 | - // Settings and Content Controls | |
| 341 | - function TRAIT_register_additional_controls($messages) | |
| 342 | - { | |
| 343 | - $this->add_control( | |
| 344 | - 'form_id', | |
| 345 | - [ | |
| 346 | - 'label' => esc_html__( 'Form ID', 'uicore-elements' ), | |
| 347 | - 'type' => Controls_Manager::TEXT, | |
| 348 | - 'ai' => [ | |
| 349 | - 'active' => false, | |
| 350 | - ], | |
| 351 | - 'placeholder' => 'new_form_id', | |
| 352 | - 'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements' ), | |
| 353 | - 'separator' => 'after', | |
| 354 | - 'dynamic' => [ | |
| 355 | - 'active' => true, | |
| 356 | - ], | |
| 357 | - ] | |
| 358 | - ); | |
| 359 | - $this->add_control( | |
| 360 | - 'form_validation', | |
| 361 | - [ | |
| 362 | - 'label' => esc_html__( 'Form Validation', 'uicore-elements' ), | |
| 363 | - 'type' => Controls_Manager::SELECT, | |
| 364 | - 'options' => [ | |
| 365 | - '' => esc_html__( 'Browser Default', 'uicore-elements' ), | |
| 366 | - 'no' => esc_html__( 'No validation', 'uicore-elements' ), | |
| 367 | - ], | |
| 368 | - 'default' => '', | |
| 369 | - ] | |
| 370 | - ); | |
| 371 | - $this->add_control( | |
| 372 | - 'custom_messages', | |
| 373 | - [ | |
| 374 | - 'label' => esc_html__( 'Custom Messages', 'uicore-elements' ), | |
| 375 | - 'type' => Controls_Manager::SWITCHER, | |
| 376 | - 'default' => '', | |
| 377 | - 'separator' => 'before', | |
| 378 | - 'render_type' => 'none', | |
| 379 | - ] | |
| 380 | - ); | |
| 381 | - $this->add_control( | |
| 382 | - 'success_message', | |
| 383 | - [ | |
| 384 | - 'label' => esc_html__( 'Success Message', 'uicore-elements' ), | |
| 385 | - 'type' => Controls_Manager::TEXT, | |
| 386 | - 'default' => $messages['success'], | |
| 387 | - 'placeholder' => $messages['success'], | |
| 388 | - 'label_block' => true, | |
| 389 | - 'condition' => [ | |
| 390 | - 'custom_messages!' => '', | |
| 391 | - ], | |
| 392 | - 'render_type' => 'none', | |
| 393 | - 'dynamic' => [ | |
| 394 | - 'active' => true, | |
| 395 | - ], | |
| 396 | - ] | |
| 397 | - ); | |
| 398 | - $this->add_control( | |
| 399 | - 'error_message', | |
| 400 | - [ | |
| 401 | - 'label' => esc_html__( 'Form Error', 'uicore-elements' ), | |
| 402 | - 'type' => Controls_Manager::TEXT, | |
| 403 | - 'default' => $messages['error'], | |
| 404 | - 'placeholder' => $messages['error'], | |
| 405 | - 'label_block' => true, | |
| 406 | - 'condition' => [ | |
| 407 | - 'custom_messages!' => '', | |
| 408 | - ], | |
| 409 | - 'render_type' => 'none', | |
| 410 | - 'dynamic' => [ | |
| 411 | - 'active' => true, | |
| 412 | - ], | |
| 413 | - ] | |
| 414 | - ); | |
| 415 | - $this->add_control( | |
| 416 | - 'mail_error_message', | |
| 417 | - [ | |
| 418 | - 'label' => esc_html__( 'Email Sending Error', 'uicore-elements' ), | |
| 419 | - 'type' => Controls_Manager::TEXT, | |
| 420 | - 'default' => $messages['mail_error'], | |
| 421 | - 'placeholder' => $messages['mail_error'], | |
| 422 | - 'label_block' => true, | |
| 423 | - 'condition' => [ | |
| 424 | - 'custom_messages!' => '', | |
| 425 | - ], | |
| 426 | - 'render_type' => 'none', | |
| 427 | - 'dynamic' => [ | |
| 428 | - 'active' => true, | |
| 429 | - ], | |
| 430 | - ] | |
| 431 | - ); | |
| 432 | - $this->add_control( | |
| 433 | - 'redirect_message', | |
| 434 | - [ | |
| 435 | - 'label' => esc_html__( 'Sucessfull Redirect', 'uicore-elements' ), | |
| 436 | - 'type' => Controls_Manager::TEXT, | |
| 437 | - 'default' => $messages['redirect'], | |
| 438 | - 'placeholder' => $messages['redirect'], | |
| 439 | - 'label_block' => true, | |
| 440 | - 'conditions' => [ | |
| 441 | - 'terms' => [ | |
| 442 | - [ | |
| 443 | - 'name' => 'custom_messages', | |
| 444 | - 'operator' => '!=', | |
| 445 | - 'value' => '', | |
| 446 | - ], | |
| 447 | - [ | |
| 448 | - 'name' => 'submit_actions', | |
| 449 | - 'operator' => 'contains', | |
| 450 | - 'value' => 'redirect', | |
| 451 | - ] | |
| 452 | - ], | |
| 453 | - ], | |
| 454 | - 'render_type' => 'none', | |
| 455 | - 'dynamic' => [ | |
| 456 | - 'active' => true, | |
| 457 | - ], | |
| 458 | - ] | |
| 459 | - ); | |
| 460 | - } | |
| 461 | - function TRAIT_register_button_controls(string $submit_text = 'send') | |
| 462 | - { | |
| 463 | - $this->add_responsive_control( | |
| 464 | - 'button_width', | |
| 465 | - [ | |
| 466 | - 'label' => esc_html__( 'Column Width', 'uicore-elements' ), | |
| 467 | - 'type' => Controls_Manager::SELECT, | |
| 468 | - 'options' => $this->TRAIT_get_width_values(), | |
| 469 | - 'default' => '20', | |
| 470 | - ] | |
| 471 | - ); | |
| 472 | - $this->add_responsive_control( | |
| 473 | - 'button_align', | |
| 474 | - [ | |
| 475 | - 'label' => esc_html__( 'Alignment', 'uicore-elements' ), | |
| 476 | - 'type' => Controls_Manager::CHOOSE, | |
| 477 | - 'options' => [ | |
| 478 | - 'left' => [ | |
| 479 | - 'title' => esc_html__( 'Left', 'uicore-elements' ), | |
| 480 | - 'icon' => 'eicon-text-align-left', | |
| 481 | - ], | |
| 482 | - 'center' => [ | |
| 483 | - 'title' => esc_html__( 'Center', 'uicore-elements' ), | |
| 484 | - 'icon' => 'eicon-text-align-center', | |
| 485 | - ], | |
| 486 | - 'right' => [ | |
| 487 | - 'title' => esc_html__( 'Right', 'uicore-elements' ), | |
| 488 | - 'icon' => 'eicon-text-align-right', | |
| 489 | - ], | |
| 490 | - 'stretch' => [ | |
| 491 | - 'title' => esc_html__( 'Justified', 'uicore-elements' ), | |
| 492 | - 'icon' => 'eicon-text-align-justify', | |
| 493 | - ], | |
| 494 | - ], | |
| 495 | - 'default' => 'stretch', | |
| 496 | - 'prefix_class' => 'ui-e-submit-align-', | |
| 497 | - ] | |
| 498 | - ); | |
| 499 | - $this->add_control( | |
| 500 | - 'button_text', | |
| 501 | - [ | |
| 502 | - 'label' => esc_html__( 'Submit', 'uicore-elements' ), | |
| 503 | - 'type' => Controls_Manager::TEXT, | |
| 504 | - 'default' => esc_html__( $submit_text, 'uicore-elements' ), | |
| 505 | - 'placeholder' => esc_html__( $submit_text, 'uicore-elements' ), | |
| 506 | - 'dynamic' => [ | |
| 507 | - 'active' => true, | |
| 508 | - ], | |
| 509 | - 'ai' => [ | |
| 510 | - 'active' => false, | |
| 511 | - ], | |
| 512 | - ] | |
| 513 | - ); | |
| 514 | - $this->add_control( | |
| 515 | - 'selected_button_icon', | |
| 516 | - [ | |
| 517 | - 'label' => esc_html__( 'Icon', 'uicore-elements' ), | |
| 518 | - 'type' => Controls_Manager::ICONS, | |
| 519 | - 'skin' => 'inline', | |
| 520 | - 'label_block' => false, | |
| 521 | - ] | |
| 522 | - ); | |
| 523 | - $this->add_control( | |
| 524 | - 'button_icon_align', | |
| 525 | - [ | |
| 526 | - 'label' => esc_html__( 'Icon Position', 'uicore-elements' ), | |
| 527 | - 'type' => Controls_Manager::SELECT, | |
| 528 | - 'default' => 'left', | |
| 529 | - 'options' => [ | |
| 530 | - 'left' => esc_html__( 'Before', 'uicore-elements' ), | |
| 531 | - 'right' => esc_html__( 'After', 'uicore-elements' ), | |
| 532 | - ], | |
| 533 | - 'condition' => [ | |
| 534 | - 'selected_button_icon[value]!' => '', | |
| 535 | - ], | |
| 536 | - ] | |
| 537 | - ); | |
| 538 | - $this->add_control( | |
| 539 | - 'button_icon_indent', | |
| 540 | - [ | |
| 541 | - 'label' => esc_html__( 'Icon Spacing', 'uicore-elements' ), | |
| 542 | - 'type' => Controls_Manager::SLIDER, | |
| 543 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 544 | - 'range' => [ | |
| 545 | - 'px' => [ | |
| 546 | - 'max' => 100, | |
| 547 | - ], | |
| 548 | - 'em' => [ | |
| 549 | - 'max' => 10, | |
| 550 | - ], | |
| 551 | - 'rem' => [ | |
| 552 | - 'max' => 10, | |
| 553 | - ], | |
| 554 | - ], | |
| 555 | - 'condition' => [ | |
| 556 | - 'selected_button_icon[value]!' => '', | |
| 557 | - ], | |
| 558 | - 'selectors' => [ | |
| 559 | - '{{WRAPPER}} .elementor-button .ui-e-align-right' => 'margin-left: {{SIZE}}{{UNIT}};', | |
| 560 | - '{{WRAPPER}} .elementor-button .ui-e-align-left' => 'margin-right: {{SIZE}}{{UNIT}};', | |
| 561 | - ], | |
| 562 | - ] | |
| 563 | - ); | |
| 564 | - $this->add_control( | |
| 565 | - 'button_css_id', | |
| 566 | - [ | |
| 567 | - 'label' => esc_html__( 'Button ID', 'uicore-elements' ), | |
| 568 | - 'type' => Controls_Manager::TEXT, | |
| 569 | - 'default' => '', | |
| 570 | - 'ai' => [ | |
| 571 | - 'active' => false, | |
| 572 | - ], | |
| 573 | - 'title' => esc_html__( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'uicore-elements' ), | |
| 574 | - 'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements' ), | |
| 575 | - 'separator' => 'before', | |
| 576 | - 'dynamic' => [ | |
| 577 | - 'active' => true, | |
| 578 | - ], | |
| 579 | - ] | |
| 580 | - ); | |
| 581 | - } | |
| 582 | - | |
| 583 | - // TODO: this style controls were copied from newsletter, not contact form. Carefull when updating contact form with this functions | |
| 584 | - // Style Controls | |
| 585 | - function TRAIT_register_form_style_controls($section = true) | |
| 586 | - { | |
| 587 | - if($section){ | |
| 588 | - $this->start_controls_section( | |
| 589 | - 'section_form_style', | |
| 590 | - [ | |
| 591 | - 'label' => esc_html__( 'Form', 'uicore-elements' ), | |
| 592 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 593 | - ] | |
| 594 | - ); | |
| 595 | - } | |
| 596 | - $this->add_control( | |
| 597 | - 'column_gap', | |
| 598 | - [ | |
| 599 | - 'label' => esc_html__( 'Columns Gap', 'uicore-elements' ), | |
| 600 | - 'type' => Controls_Manager::SLIDER, | |
| 601 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 602 | - 'default' => [ | |
| 603 | - 'size' => 10, | |
| 604 | - ], | |
| 605 | - 'range' => [ | |
| 606 | - 'px' => [ | |
| 607 | - 'max' => 60, | |
| 608 | - ], | |
| 609 | - 'em' => [ | |
| 610 | - 'max' => 6, | |
| 611 | - ], | |
| 612 | - 'rem' => [ | |
| 613 | - 'max' => 6, | |
| 614 | - ], | |
| 615 | - ], | |
| 616 | - 'selectors' => [ | |
| 617 | - '{{WRAPPER}} .ui-e-field-group' => 'padding-right: calc( {{SIZE}}{{UNIT}}/2 ); padding-left: calc( {{SIZE}}{{UNIT}}/2 );', | |
| 618 | - '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-left: calc( -{{SIZE}}{{UNIT}}/2 ); margin-right: calc( -{{SIZE}}{{UNIT}}/2 );', | |
| 619 | - ], | |
| 620 | - ] | |
| 621 | - ); | |
| 622 | - $this->add_control( | |
| 623 | - 'row_gap', | |
| 624 | - [ | |
| 625 | - 'label' => esc_html__( 'Rows Gap', 'uicore-elements' ), | |
| 626 | - 'type' => Controls_Manager::SLIDER, | |
| 627 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 628 | - 'default' => [ | |
| 629 | - 'size' => 10, | |
| 630 | - ], | |
| 631 | - 'range' => [ | |
| 632 | - 'px' => [ | |
| 633 | - 'max' => 60, | |
| 634 | - ], | |
| 635 | - 'em' => [ | |
| 636 | - 'max' => 6, | |
| 637 | - ], | |
| 638 | - 'rem' => [ | |
| 639 | - 'max' => 6, | |
| 640 | - ], | |
| 641 | - ], | |
| 642 | - 'selectors' => [ | |
| 643 | - '{{WRAPPER}} .ui-e-field-group' => 'margin-bottom: {{SIZE}}{{UNIT}};', | |
| 644 | - '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-bottom: -{{SIZE}}{{UNIT}};', | |
| 645 | - ], | |
| 646 | - ] | |
| 647 | - ); | |
| 648 | - $this->add_control( | |
| 649 | - 'heading_label', | |
| 650 | - [ | |
| 651 | - 'label' => esc_html__( 'Label', 'uicore-elements' ), | |
| 652 | - 'type' => Controls_Manager::HEADING, | |
| 653 | - 'separator' => 'before', | |
| 654 | - ] | |
| 655 | - ); | |
| 656 | - $this->add_control( | |
| 657 | - 'label_spacing', | |
| 658 | - [ | |
| 659 | - 'label' => esc_html__( 'Spacing', 'uicore-elements' ), | |
| 660 | - 'type' => Controls_Manager::SLIDER, | |
| 661 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 662 | - 'default' => [ | |
| 663 | - 'size' => 0, | |
| 664 | - ], | |
| 665 | - 'range' => [ | |
| 666 | - 'px' => [ | |
| 667 | - 'max' => 60, | |
| 668 | - ], | |
| 669 | - 'em' => [ | |
| 670 | - 'max' => 6, | |
| 671 | - ], | |
| 672 | - 'rem' => [ | |
| 673 | - 'max' => 6, | |
| 674 | - ], | |
| 675 | - ], | |
| 676 | - 'selectors' => [ | |
| 677 | - 'body {{WRAPPER}} .ui-e-field-group > label' => 'padding-bottom: {{SIZE}}{{UNIT}};', | |
| 678 | - ], | |
| 679 | - ] | |
| 680 | - ); | |
| 681 | - $this->add_control( | |
| 682 | - 'label_color', | |
| 683 | - [ | |
| 684 | - 'label' => esc_html__( 'Text Color', 'uicore-elements' ), | |
| 685 | - 'type' => Controls_Manager::COLOR, | |
| 686 | - 'selectors' => [ | |
| 687 | - '{{WRAPPER}} .ui-e-field-group > label, {{WRAPPER}} .ui-e-field-subgroup label' => 'color: {{VALUE}};', | |
| 688 | - ], | |
| 689 | - 'global' => [ | |
| 690 | - 'default' => Global_Colors::COLOR_TEXT, | |
| 691 | - ], | |
| 692 | - ] | |
| 693 | - ); | |
| 694 | - $this->add_control( | |
| 695 | - 'mark_required_color', | |
| 696 | - [ | |
| 697 | - 'label' => esc_html__( 'Mark Color', 'uicore-elements' ), | |
| 698 | - 'type' => Controls_Manager::COLOR, | |
| 699 | - 'default' => '', | |
| 700 | - 'selectors' => [ | |
| 701 | - '{{WRAPPER}} .ui-e-required .ui-e-label:after' => 'color: {{COLOR}};', | |
| 702 | - ], | |
| 703 | - 'condition' => [ | |
| 704 | - 'mark_required' => 'yes', | |
| 705 | - ], | |
| 706 | - ] | |
| 707 | - ); | |
| 708 | - $this->add_group_control( | |
| 709 | - Group_Control_Typography::get_type(), | |
| 710 | - [ | |
| 711 | - 'name' => 'label_typography', | |
| 712 | - 'selector' => '{{WRAPPER}} .ui-e-field-group > label', | |
| 713 | - 'global' => [ | |
| 714 | - 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 715 | - ], | |
| 716 | - ] | |
| 717 | - ); | |
| 718 | - if($section){ | |
| 719 | - $this->end_controls_section(); | |
| 720 | - } | |
| 721 | - } | |
| 722 | - function TRAIT_register_fields_style_controls($section = true) | |
| 723 | - { | |
| 724 | - if($section){ | |
| 725 | - $this->start_controls_section( | |
| 726 | - 'section_field_style', | |
| 727 | - [ | |
| 728 | - 'label' => esc_html__( 'Fields', 'uicore-elements' ), | |
| 729 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 730 | - ] | |
| 731 | - ); | |
| 732 | - } | |
| 733 | - | |
| 734 | - $this->start_controls_tabs( | |
| 735 | - 'field_style_tabs' | |
| 736 | - ); | |
| 737 | - | |
| 738 | - $this->start_controls_tab( | |
| 739 | - 'field_normal_tab', | |
| 740 | - [ | |
| 741 | - 'label' => esc_html__( 'Normal', 'uicore-elements' ), | |
| 742 | - ] | |
| 743 | - ); | |
| 744 | - | |
| 745 | - $this->add_group_control( | |
| 746 | - Group_Control_Typography::get_type(), | |
| 747 | - [ | |
| 748 | - 'name' => 'field_typography', | |
| 749 | - 'selector' => '{{WRAPPER}} .ui-e-field-group .ui-e-field, {{WRAPPER}} .ui-e-field-subgroup label', | |
| 750 | - 'global' => [ | |
| 751 | - 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 752 | - ], | |
| 753 | - ] | |
| 754 | - ); | |
| 755 | - $this->add_control( | |
| 756 | - 'field_text_color', | |
| 757 | - [ | |
| 758 | - 'label' => esc_html__( 'Text Color', 'uicore-elements' ), | |
| 759 | - 'type' => Controls_Manager::COLOR, | |
| 760 | - 'selectors' => [ | |
| 761 | - '{{WRAPPER}} .ui-e-field-group .ui-e-field' => 'color: {{VALUE}};', | |
| 762 | - ], | |
| 763 | - 'global' => [ | |
| 764 | - 'default' => Global_Colors::COLOR_TEXT, | |
| 765 | - ], | |
| 766 | - ] | |
| 767 | - ); | |
| 768 | - $this->add_control( | |
| 769 | - 'field_placeholder_color', | |
| 770 | - [ | |
| 771 | - 'label' => esc_html__( 'Placeholder Color', 'uicore-elements' ), | |
| 772 | - 'type' => Controls_Manager::COLOR, | |
| 773 | - 'selectors' => [ | |
| 774 | - '{{WRAPPER}} .ui-e-field-group .ui-e-field::placeholder' => 'color: {{VALUE}};', | |
| 775 | - ], | |
| 776 | - 'global' => [ | |
| 777 | - 'default' => Global_Colors::COLOR_TEXT, | |
| 778 | - ], | |
| 779 | - ] | |
| 780 | - ); | |
| 781 | - $this->add_control( | |
| 782 | - 'field_background_color', | |
| 783 | - [ | |
| 784 | - 'label' => esc_html__( 'Background Color', 'uicore-elements' ), | |
| 785 | - 'type' => Controls_Manager::COLOR, | |
| 786 | - 'default' => '#ffffff', | |
| 787 | - 'selectors' => [ | |
| 788 | - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};', | |
| 789 | - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'background-color: {{VALUE}};', | |
| 790 | - ], | |
| 791 | - ] | |
| 792 | - ); | |
| 793 | - $this->add_group_control( | |
| 794 | - Group_Control_Border::get_type(), | |
| 795 | - [ | |
| 796 | - 'name' => 'field_border', | |
| 797 | - 'selector' => | |
| 798 | - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select), | |
| 799 | - {{WRAPPER}} .ui-e-field-group .ui-e-field-select select', | |
| 800 | - ] | |
| 801 | - ); | |
| 802 | - | |
| 803 | - $this->end_controls_tab(); | |
| 804 | - | |
| 805 | - $this->start_controls_tab( | |
| 806 | - 'field_hover_tab', | |
| 807 | - [ | |
| 808 | - 'label' => esc_html__( 'Hover', 'uicore-elements' ), | |
| 809 | - ] | |
| 810 | - ); | |
| 811 | - | |
| 812 | - $this->add_control( | |
| 813 | - 'field_text_hover_color', | |
| 814 | - [ | |
| 815 | - 'label' => esc_html__( 'Text Color', 'uicore-elements' ), | |
| 816 | - 'type' => Controls_Manager::COLOR, | |
| 817 | - 'selectors' => [ | |
| 818 | - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field' => 'color: {{VALUE}};', | |
| 819 | - ], | |
| 820 | - 'global' => [ | |
| 821 | - 'default' => Global_Colors::COLOR_TEXT, | |
| 822 | - ], | |
| 823 | - ] | |
| 824 | - ); | |
| 825 | - $this->add_control( | |
| 826 | - 'field_placeholder_hover_color', | |
| 827 | - [ | |
| 828 | - 'label' => esc_html__( 'Placeholder Color', 'uicore-elements' ), | |
| 829 | - 'type' => Controls_Manager::COLOR, | |
| 830 | - 'selectors' => [ | |
| 831 | - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field::placeholder' => 'color: {{VALUE}};', | |
| 832 | - ], | |
| 833 | - 'global' => [ | |
| 834 | - 'default' => Global_Colors::COLOR_TEXT, | |
| 835 | - ], | |
| 836 | - ] | |
| 837 | - ); | |
| 838 | - $this->add_control( | |
| 839 | - 'field_background_hover_color', | |
| 840 | - [ | |
| 841 | - 'label' => esc_html__( 'Background Color', 'uicore-elements' ), | |
| 842 | - 'type' => Controls_Manager::COLOR, | |
| 843 | - 'default' => '#ffffff', | |
| 844 | - 'selectors' => [ | |
| 845 | - '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};', | |
| 846 | - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select' => 'background-color: {{VALUE}};', | |
| 847 | - ], | |
| 848 | - ] | |
| 849 | - ); | |
| 850 | - $this->add_group_control( | |
| 851 | - Group_Control_Border::get_type(), | |
| 852 | - [ | |
| 853 | - 'name' => 'field_hover_border', | |
| 854 | - 'selector' => | |
| 855 | - '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select), | |
| 856 | - {{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select', | |
| 857 | - ] | |
| 858 | - ); | |
| 859 | - | |
| 860 | - $this->end_controls_tab(); | |
| 861 | - | |
| 862 | - $this->start_controls_tab( | |
| 863 | - 'field_active_tab', | |
| 864 | - [ | |
| 865 | - 'label' => esc_html__( 'Active', 'uicore-elements' ), | |
| 866 | - ] | |
| 867 | - ); | |
| 868 | - | |
| 869 | - $this->add_control( | |
| 870 | - 'field_text_active_color', | |
| 871 | - [ | |
| 872 | - 'label' => esc_html__( 'Text Color', 'uicore-elements' ), | |
| 873 | - 'type' => Controls_Manager::COLOR, | |
| 874 | - 'selectors' => [ | |
| 875 | - '{{WRAPPER}} .ui-e-field-group .ui-e-field:focus' => 'color: {{VALUE}};', | |
| 876 | - ], | |
| 877 | - 'global' => [ | |
| 878 | - 'default' => Global_Colors::COLOR_TEXT, | |
| 879 | - ], | |
| 880 | - ] | |
| 881 | - ); | |
| 882 | - $this->add_control( | |
| 883 | - 'field_background_active_color', | |
| 884 | - [ | |
| 885 | - 'label' => esc_html__( 'Background Color', 'uicore-elements' ), | |
| 886 | - 'type' => Controls_Manager::COLOR, | |
| 887 | - 'default' => '#ffffff', | |
| 888 | - 'selectors' => [ | |
| 889 | - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:focus:not(.ui-e-field-select)' => 'background-color: {{VALUE}};', | |
| 890 | - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select' => 'background-color: {{VALUE}};', | |
| 891 | - ], | |
| 892 | - ] | |
| 893 | - ); | |
| 894 | - $this->add_group_control( | |
| 895 | - Group_Control_Border::get_type(), | |
| 896 | - [ | |
| 897 | - 'name' => 'field_active_border', | |
| 898 | - 'selector' => | |
| 899 | - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:focus:not(.ui-e-field-select), | |
| 900 | - {{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select', | |
| 901 | - ] | |
| 902 | - ); | |
| 903 | - | |
| 904 | - $this->end_controls_tab(); | |
| 905 | - | |
| 906 | - $this->end_controls_tabs(); | |
| 907 | - | |
| 908 | - $this->add_control( | |
| 909 | - 'field_border_radius', | |
| 910 | - [ | |
| 911 | - 'label' => esc_html__( 'Border Radius', 'uicore-elements' ), | |
| 912 | - 'type' => Controls_Manager::DIMENSIONS, | |
| 913 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], | |
| 914 | - 'selectors' => [ | |
| 915 | - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 916 | - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 917 | - ], | |
| 918 | - 'separator' => 'before' | |
| 919 | - ] | |
| 920 | - ); | |
| 921 | - $this->add_responsive_control( | |
| 922 | - 'field_padding', | |
| 923 | - [ | |
| 924 | - 'label' => esc_html__( 'Padding', 'uicore-elements' ), | |
| 925 | - 'type' => Controls_Manager::DIMENSIONS, | |
| 926 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], | |
| 927 | - 'selectors' => [ | |
| 928 | - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 929 | - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 930 | - ], | |
| 931 | - ] | |
| 932 | - ); | |
| 933 | - if($section){ | |
| 934 | - $this->end_controls_section(); | |
| 935 | - } | |
| 936 | - } | |
| 937 | - function TRAIT_register_button_style_controls($section = true) | |
| 938 | - { | |
| 939 | - if($section){ | |
| 940 | - $this->start_controls_section( | |
| 941 | - 'section_button_style', | |
| 942 | - [ | |
| 943 | - 'label' => esc_html__( 'Button', 'uicore-elements' ), | |
| 944 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 945 | - ] | |
| 946 | - ); | |
| 947 | - } | |
| 948 | - | |
| 949 | - $this->add_group_control( | |
| 950 | - Group_Control_Typography::get_type(), | |
| 951 | - [ | |
| 952 | - 'name' => 'button_typography', | |
| 953 | - 'global' => [ | |
| 954 | - 'default' => Global_Typography::TYPOGRAPHY_ACCENT, | |
| 955 | - ], | |
| 956 | - 'selector' => '{{WRAPPER}} .elementor-button', | |
| 957 | - ] | |
| 958 | - ); | |
| 959 | - $this->add_group_control( | |
| 960 | - Group_Control_Border::get_type(), [ | |
| 961 | - 'name' => 'button_border', | |
| 962 | - 'selector' => '{{WRAPPER}} .elementor-button', | |
| 963 | - 'exclude' => [ | |
| 964 | - 'color', | |
| 965 | - ], | |
| 966 | - ] | |
| 967 | - ); | |
| 968 | - | |
| 969 | - $this->start_controls_tabs( 'tabs_button_style' ); | |
| 970 | - | |
| 971 | - $this->start_controls_tab( | |
| 972 | - 'tab_button_normal', | |
| 973 | - [ | |
| 974 | - 'label' => esc_html__( 'Normal', 'uicore-elements' ), | |
| 975 | - ] | |
| 976 | - ); | |
| 977 | - | |
| 978 | - $this->add_control( | |
| 979 | - 'button_background_color', | |
| 980 | - [ | |
| 981 | - 'label' => esc_html__( 'Background Color', 'uicore-elements' ), | |
| 982 | - 'type' => Controls_Manager::COLOR, | |
| 983 | - 'global' => [ | |
| 984 | - 'default' => Global_Colors::COLOR_ACCENT, | |
| 985 | - ], | |
| 986 | - 'selectors' => [ | |
| 987 | - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'background-color: {{VALUE}};', | |
| 988 | - '{{WRAPPER}} .elementor-button[type="submit"]' => 'background-color: {{VALUE}};', | |
| 989 | - ], | |
| 990 | - ] | |
| 991 | - ); | |
| 992 | - $this->add_control( | |
| 993 | - 'button_text_color', | |
| 994 | - [ | |
| 995 | - 'label' => esc_html__( 'Text Color', 'uicore-elements' ), | |
| 996 | - 'type' => Controls_Manager::COLOR, | |
| 997 | - 'default' => '#ffffff', | |
| 998 | - 'selectors' => [ | |
| 999 | - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'color: {{VALUE}};', | |
| 1000 | - '{{WRAPPER}} .elementor-button[type="submit"]' => 'color: {{VALUE}};', | |
| 1001 | - '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'fill: {{VALUE}};', | |
| 1002 | - ], | |
| 1003 | - ] | |
| 1004 | - ); | |
| 1005 | - $this->add_control( | |
| 1006 | - 'button_border_color', | |
| 1007 | - [ | |
| 1008 | - 'label' => esc_html__( 'Border Color', 'uicore-elements' ), | |
| 1009 | - 'type' => Controls_Manager::COLOR, | |
| 1010 | - 'default' => '', | |
| 1011 | - 'selectors' => [ | |
| 1012 | - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'border-color: {{VALUE}};', | |
| 1013 | - '{{WRAPPER}} .elementor-button[type="submit"]' => 'border-color: {{VALUE}};', | |
| 1014 | - ], | |
| 1015 | - 'condition' => [ | |
| 1016 | - 'button_border_border!' => '', | |
| 1017 | - ], | |
| 1018 | - ] | |
| 1019 | - ); | |
| 1020 | - | |
| 1021 | - $this->end_controls_tab(); | |
| 1022 | - | |
| 1023 | - $this->start_controls_tab( | |
| 1024 | - 'tab_button_hover', | |
| 1025 | - [ | |
| 1026 | - 'label' => esc_html__( 'Hover', 'uicore-elements' ), | |
| 1027 | - ] | |
| 1028 | - ); | |
| 1029 | - | |
| 1030 | - $this->add_control( | |
| 1031 | - 'button_background_hover_color', | |
| 1032 | - [ | |
| 1033 | - 'label' => esc_html__( 'Background Color', 'uicore-elements' ), | |
| 1034 | - 'type' => Controls_Manager::COLOR, | |
| 1035 | - 'default' => '', | |
| 1036 | - 'selectors' => [ | |
| 1037 | - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'background-color: {{VALUE}};', | |
| 1038 | - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'background-color: {{VALUE}};', | |
| 1039 | - ], | |
| 1040 | - ] | |
| 1041 | - ); | |
| 1042 | - $this->add_control( | |
| 1043 | - 'button_hover_color', | |
| 1044 | - [ | |
| 1045 | - 'label' => esc_html__( 'Text Color', 'uicore-elements' ), | |
| 1046 | - 'type' => Controls_Manager::COLOR, | |
| 1047 | - 'default' => '#ffffff', | |
| 1048 | - 'selectors' => [ | |
| 1049 | - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'color: {{VALUE}};', | |
| 1050 | - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'color: {{VALUE}};', | |
| 1051 | - '{{WRAPPER}} .elementor-button[type="submit"]:hover svg *' => 'fill: {{VALUE}};', | |
| 1052 | - ], | |
| 1053 | - ] | |
| 1054 | - ); | |
| 1055 | - $this->add_control( | |
| 1056 | - 'button_hover_border_color', | |
| 1057 | - [ | |
| 1058 | - 'label' => esc_html__( 'Border Color', 'uicore-elements' ), | |
| 1059 | - 'type' => Controls_Manager::COLOR, | |
| 1060 | - 'default' => '', | |
| 1061 | - 'selectors' => [ | |
| 1062 | - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'border-color: {{VALUE}};', | |
| 1063 | - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'border-color: {{VALUE}};', | |
| 1064 | - ], | |
| 1065 | - 'condition' => [ | |
| 1066 | - 'button_border_border!' => '', | |
| 1067 | - ], | |
| 1068 | - ] | |
| 1069 | - ); | |
| 1070 | - $this->add_control( | |
| 1071 | - 'hover_transition_duration', | |
| 1072 | - [ | |
| 1073 | - 'label' => esc_html__( 'Transition Duration', 'uicore-elements' ), | |
| 1074 | - 'type' => Controls_Manager::SLIDER, | |
| 1075 | - 'size_units' => [ 's', 'ms', 'custom' ], | |
| 1076 | - 'default' => [ | |
| 1077 | - 'unit' => 'ms', | |
| 1078 | - ], | |
| 1079 | - 'selectors' => [ | |
| 1080 | - '{{WRAPPER}} .e-form__buttons__wrapper__button-previous' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 1081 | - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 1082 | - '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 1083 | - '{{WRAPPER}} .elementor-button[type="submit"]' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 1084 | - ], | |
| 1085 | - ] | |
| 1086 | - ); | |
| 1087 | - $this->add_control( | |
| 1088 | - 'button_hover_animation', | |
| 1089 | - [ | |
| 1090 | - 'label' => esc_html__( 'Animation', 'uicore-elements' ), | |
| 1091 | - 'type' => Controls_Manager::HOVER_ANIMATION, | |
| 1092 | - ] | |
| 1093 | - ); | |
| 1094 | - | |
| 1095 | - $this->end_controls_tab(); | |
| 1096 | - | |
| 1097 | - $this->end_controls_tabs(); | |
| 1098 | - | |
| 1099 | - $this->add_control( | |
| 1100 | - 'button_border_radius', | |
| 1101 | - [ | |
| 1102 | - 'label' => esc_html__( 'Border Radius', 'uicore-elements' ), | |
| 1103 | - 'type' => Controls_Manager::DIMENSIONS, | |
| 1104 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], | |
| 1105 | - 'selectors' => [ | |
| 1106 | - '{{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1107 | - ], | |
| 1108 | - 'separator' => 'before', | |
| 1109 | - ] | |
| 1110 | - ); | |
| 1111 | - | |
| 1112 | - $this->add_control( | |
| 1113 | - 'button_text_padding', | |
| 1114 | - [ | |
| 1115 | - 'label' => esc_html__( 'Text Padding', 'uicore-elements' ), | |
| 1116 | - 'type' => Controls_Manager::DIMENSIONS, | |
| 1117 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], | |
| 1118 | - 'selectors' => [ | |
| 1119 | - '{{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1120 | - ], | |
| 1121 | - ] | |
| 1122 | - ); | |
| 1123 | - | |
| 1124 | - if($section){ | |
| 1125 | - $this->end_controls_section(); | |
| 1126 | - } | |
| 1127 | - } | |
| 1128 | - function TRAIT_register_messages_style_controls($section = true) | |
| 1129 | - { | |
| 1130 | - if($section){ | |
| 1131 | - $this->start_controls_section( | |
| 1132 | - 'section_messages_style', | |
| 1133 | - [ | |
| 1134 | - 'label' => esc_html__( 'Messages', 'uicore-elements' ), | |
| 1135 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 1136 | - ] | |
| 1137 | - ); | |
| 1138 | - } | |
| 1139 | - | |
| 1140 | - $this->add_control( | |
| 1141 | - 'show_messages', | |
| 1142 | - [ | |
| 1143 | - 'label' => esc_html__( 'Show/Hide messages', 'uicore-elements' ), | |
| 1144 | - 'type' => Controls_Manager::BUTTON, | |
| 1145 | - 'separator' => 'before', | |
| 1146 | - 'text' => esc_html__( 'Toggle', 'uicore-elements' ), | |
| 1147 | - 'event' => 'ui-e-form-show-messages', | |
| 1148 | - ] | |
| 1149 | - ); | |
| 1150 | - $this->add_group_control( | |
| 1151 | - Group_Control_Typography::get_type(), | |
| 1152 | - [ | |
| 1153 | - 'name' => 'message_typography', | |
| 1154 | - 'global' => [ | |
| 1155 | - 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 1156 | - ], | |
| 1157 | - 'selector' => '{{WRAPPER}} .ui-e-message', | |
| 1158 | - ] | |
| 1159 | - ); | |
| 1160 | - $this->add_control( | |
| 1161 | - 'success_message_color', | |
| 1162 | - [ | |
| 1163 | - 'label' => esc_html__( 'Success Message Color', 'uicore-elements' ), | |
| 1164 | - 'type' => Controls_Manager::COLOR, | |
| 1165 | - 'default' => '#4CAF50', | |
| 1166 | - 'selectors' => [ | |
| 1167 | - '{{WRAPPER}} .ui-e-message span.success' => 'color: {{COLOR}};', | |
| 1168 | - ], | |
| 1169 | - ] | |
| 1170 | - ); | |
| 1171 | - $this->add_control( | |
| 1172 | - 'error_message_color', | |
| 1173 | - [ | |
| 1174 | - 'label' => esc_html__( 'Error Message Color', 'uicore-elements' ), | |
| 1175 | - 'type' => Controls_Manager::COLOR, | |
| 1176 | - 'default' => '#F44336', | |
| 1177 | - 'selectors' => [ | |
| 1178 | - '{{WRAPPER}} .ui-e-message span.error' => 'color: {{COLOR}};', | |
| 1179 | - ], | |
| 1180 | - ] | |
| 1181 | - ); | |
| 1182 | - | |
| 1183 | - if($section){ | |
| 1184 | - $this->end_controls_section(); | |
| 1185 | - } | |
| 1186 | - } | |
| 1187 | - function TRAIT_register_all_form_style_controls() | |
| 1188 | - { | |
| 1189 | - $this->TRAIT_register_form_style_controls(); | |
| 1190 | - $this->TRAIT_register_fields_style_controls(); | |
| 1191 | - $this->TRAIT_register_button_style_controls(); | |
| 1192 | - $this->TRAIT_register_messages_style_controls(); | |
| 1193 | - } | |
| 1194 | - | |
| 1195 | - // Helper and Utility Functions | |
| 1196 | - function TRAIT_get_width_values() | |
| 1197 | - { | |
| 1198 | - return [ | |
| 1199 | - '' => esc_html__( 'Default', 'uicore-elements' ), | |
| 1200 | - '100' => '100%', | |
| 1201 | - '80' => '80%', | |
| 1202 | - '75' => '75%', | |
| 1203 | - '70' => '70%', | |
| 1204 | - '66' => '66%', | |
| 1205 | - '60' => '60%', | |
| 1206 | - '50' => '50%', | |
| 1207 | - '40' => '40%', | |
| 1208 | - '33' => '33%', | |
| 1209 | - '30' => '30%', | |
| 1210 | - '25' => '25%', | |
| 1211 | - '20' => '20%', | |
| 1212 | - ]; | |
| 1213 | - } | |
| 1214 | - function TRAIT_recaptcha_key_js() | |
| 1215 | - { | |
| 1216 | - ?> | |
| 1217 | - <script> | |
| 1218 | - window.uicore_elements_recaptcha = '<?php echo get_option('uicore_elements_recaptcha_site_key'); ?>'; | |
| 1219 | - </script> | |
| 1220 | - <?php | |
| 1221 | - } | |
| 1222 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace UiCoreElements\Utils; | |
| 4 | + | |
| 5 | +use UiCoreElements\Helper; | |
| 6 | + | |
| 7 | +use Elementor\Controls_Manager; | |
| 8 | +use Elementor\Group_Control_Typography; | |
| 9 | +use Elementor\Group_Control_Border; | |
| 10 | +use Elementor\Group_Control_Box_Shadow; | |
| 11 | +use Elementor\Core\Kits\Documents\Tabs\Global_Colors; | |
| 12 | +use Elementor\Core\Kits\Documents\Tabs\Global_Typography; | |
| 13 | + | |
| 14 | +defined('ABSPATH') || exit(); | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Register some Form Widgets controls and methods. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +trait Form_Component | |
| 21 | +{ | |
| 22 | + | |
| 23 | + // Submission Controls | |
| 24 | + function TRAIT_register_submit_email_controls($instance, $slug = '') | |
| 25 | + { | |
| 26 | + $instance->add_control( | |
| 27 | + 'email_to' . $slug, | |
| 28 | + [ | |
| 29 | + 'label' => esc_html__('To', 'uicore-elements'), | |
| 30 | + 'type' => Controls_Manager::TEXT, | |
| 31 | + 'default' => get_option('admin_email'), | |
| 32 | + 'ai' => [ | |
| 33 | + 'active' => false, | |
| 34 | + ], | |
| 35 | + 'placeholder' => get_option('admin_email'), | |
| 36 | + 'label_block' => true, | |
| 37 | + 'title' => esc_html__('Separate emails with commas', 'uicore-elements'), | |
| 38 | + 'render_type' => 'none', | |
| 39 | + 'dynamic' => [ | |
| 40 | + 'active' => true, | |
| 41 | + ], | |
| 42 | + ] | |
| 43 | + ); | |
| 44 | + | |
| 45 | + /* translators: %s: Site title. */ | |
| 46 | + $default_message = sprintf(html_entity_decode(esc_html__('New message from "%s"', 'uicore-elements')), get_option('blogname')); | |
| 47 | + | |
| 48 | + $instance->add_control( | |
| 49 | + 'email_subject' . $slug, | |
| 50 | + [ | |
| 51 | + 'label' => esc_html__('Subject', 'uicore-elements'), | |
| 52 | + 'type' => Controls_Manager::TEXT, | |
| 53 | + 'default' => $default_message, | |
| 54 | + 'ai' => [ | |
| 55 | + 'active' => false, | |
| 56 | + ], | |
| 57 | + 'placeholder' => $default_message, | |
| 58 | + 'label_block' => true, | |
| 59 | + 'render_type' => 'none', | |
| 60 | + 'dynamic' => [ | |
| 61 | + 'active' => true, | |
| 62 | + ], | |
| 63 | + ] | |
| 64 | + ); | |
| 65 | + | |
| 66 | + $instance->add_control( | |
| 67 | + 'email_content' . $slug, | |
| 68 | + [ | |
| 69 | + 'label' => esc_html__('Message', 'uicore-elements'), | |
| 70 | + 'type' => Controls_Manager::TEXTAREA, | |
| 71 | + 'default' => '[all-fields]', | |
| 72 | + 'ai' => [ | |
| 73 | + 'active' => false, | |
| 74 | + ], | |
| 75 | + 'placeholder' => '[all-fields]', | |
| 76 | + 'description' => sprintf( | |
| 77 | + /* translators: %s: The [all-fields] shortcode. */ | |
| 78 | + esc_html__('By default, all form fields are sent via %s shortcode. To customize sent fields, copy the shortcode that appears inside each field and paste it above.', 'uicore-elements'), | |
| 79 | + '<code>[all-fields]</code>' | |
| 80 | + ), | |
| 81 | + 'render_type' => 'none', | |
| 82 | + 'dynamic' => [ | |
| 83 | + 'active' => true, | |
| 84 | + ], | |
| 85 | + ] | |
| 86 | + ); | |
| 87 | + | |
| 88 | + $site_domain = Helper::get_site_domain(); | |
| 89 | + | |
| 90 | + $instance->add_control( | |
| 91 | + 'email_from' . $slug, | |
| 92 | + [ | |
| 93 | + 'label' => esc_html__('From Email', 'uicore-elements'), | |
| 94 | + 'type' => Controls_Manager::TEXT, | |
| 95 | + 'default' => 'email@' . $site_domain, | |
| 96 | + 'ai' => [ | |
| 97 | + 'active' => false, | |
| 98 | + ], | |
| 99 | + 'render_type' => 'none', | |
| 100 | + 'dynamic' => [ | |
| 101 | + 'active' => true, | |
| 102 | + ], | |
| 103 | + ] | |
| 104 | + ); | |
| 105 | + | |
| 106 | + $instance->add_control( | |
| 107 | + 'email_from_name' . $slug, | |
| 108 | + [ | |
| 109 | + 'label' => esc_html__('From Name', 'uicore-elements'), | |
| 110 | + 'type' => Controls_Manager::TEXT, | |
| 111 | + 'default' => get_bloginfo('name'), | |
| 112 | + 'ai' => [ | |
| 113 | + 'active' => false, | |
| 114 | + ], | |
| 115 | + 'render_type' => 'none', | |
| 116 | + 'dynamic' => [ | |
| 117 | + 'active' => true, | |
| 118 | + ], | |
| 119 | + ] | |
| 120 | + ); | |
| 121 | + | |
| 122 | + $instance->add_control( | |
| 123 | + 'email_reply_to' . $slug, | |
| 124 | + [ | |
| 125 | + 'label' => esc_html__('Reply-To', 'uicore-elements'), | |
| 126 | + 'type' => Controls_Manager::TEXT, | |
| 127 | + 'options' => [ | |
| 128 | + '' => '', | |
| 129 | + ], | |
| 130 | + 'default' => 'noreply@' . Helper::get_site_domain(), | |
| 131 | + 'render_type' => 'none', | |
| 132 | + ] | |
| 133 | + ); | |
| 134 | + | |
| 135 | + $instance->add_control( | |
| 136 | + 'email_to_cc' . $slug, | |
| 137 | + [ | |
| 138 | + 'label' => esc_html__('Cc', 'uicore-elements'), | |
| 139 | + 'type' => Controls_Manager::TEXT, | |
| 140 | + 'default' => '', | |
| 141 | + 'ai' => [ | |
| 142 | + 'active' => false, | |
| 143 | + ], | |
| 144 | + 'title' => esc_html__('Separate emails with commas', 'uicore-elements'), | |
| 145 | + 'render_type' => 'none', | |
| 146 | + 'dynamic' => [ | |
| 147 | + 'active' => true, | |
| 148 | + ], | |
| 149 | + ] | |
| 150 | + ); | |
| 151 | + | |
| 152 | + $instance->add_control( | |
| 153 | + 'email_to_bcc' . $slug, | |
| 154 | + [ | |
| 155 | + 'label' => esc_html__('Bcc', 'uicore-elements'), | |
| 156 | + 'type' => Controls_Manager::TEXT, | |
| 157 | + 'default' => '', | |
| 158 | + 'ai' => [ | |
| 159 | + 'active' => false, | |
| 160 | + ], | |
| 161 | + 'title' => esc_html__('Separate emails with commas', 'uicore-elements'), | |
| 162 | + 'render_type' => 'none', | |
| 163 | + 'dynamic' => [ | |
| 164 | + 'active' => true, | |
| 165 | + ], | |
| 166 | + ] | |
| 167 | + ); | |
| 168 | + | |
| 169 | + $instance->add_control( | |
| 170 | + 'form_metadata' . $slug, | |
| 171 | + [ | |
| 172 | + 'label' => esc_html__('Meta Data', 'uicore-elements'), | |
| 173 | + 'type' => Controls_Manager::SELECT2, | |
| 174 | + 'multiple' => true, | |
| 175 | + 'label_block' => true, | |
| 176 | + 'separator' => 'before', | |
| 177 | + 'default' => [ | |
| 178 | + 'date', | |
| 179 | + 'time', | |
| 180 | + 'page_url', | |
| 181 | + 'user_agent', | |
| 182 | + 'remote_ip', | |
| 183 | + ], | |
| 184 | + 'options' => [ | |
| 185 | + 'date' => esc_html__('Date', 'uicore-elements'), | |
| 186 | + 'time' => esc_html__('Time', 'uicore-elements'), | |
| 187 | + 'page_url' => esc_html__('Page URL', 'uicore-elements'), | |
| 188 | + 'user_agent' => esc_html__('User Agent', 'uicore-elements'), | |
| 189 | + 'remote_ip' => esc_html__('Remote IP', 'uicore-elements'), | |
| 190 | + ], | |
| 191 | + 'render_type' => 'none', | |
| 192 | + ] | |
| 193 | + ); | |
| 194 | + | |
| 195 | + $instance->add_control( | |
| 196 | + 'email_content_type' . $slug, | |
| 197 | + [ | |
| 198 | + 'label' => esc_html__('Send As', 'uicore-elements'), | |
| 199 | + 'type' => Controls_Manager::SELECT, | |
| 200 | + 'default' => 'html', | |
| 201 | + 'render_type' => 'none', | |
| 202 | + 'options' => [ | |
| 203 | + 'html' => esc_html__('HTML', 'uicore-elements'), | |
| 204 | + 'plain' => esc_html__('Plain', 'uicore-elements'), | |
| 205 | + ], | |
| 206 | + ] | |
| 207 | + ); | |
| 208 | + } | |
| 209 | + function TRAIT_register_submit_redirect_controls() | |
| 210 | + { | |
| 211 | + $this->start_controls_section( | |
| 212 | + 'section_redirect', | |
| 213 | + [ | |
| 214 | + 'label' => esc_html__('Redirect', 'uicore-elements'), | |
| 215 | + 'condition' => [ | |
| 216 | + 'submit_actions' => 'redirect', | |
| 217 | + ], | |
| 218 | + ] | |
| 219 | + ); | |
| 220 | + | |
| 221 | + $this->add_control( | |
| 222 | + 'redirect_to', | |
| 223 | + [ | |
| 224 | + 'label' => esc_html__('Redirect To', 'uicore-elements'), | |
| 225 | + 'type' => Controls_Manager::TEXT, | |
| 226 | + 'placeholder' => esc_html__('https://your-link.com', 'uicore-elements'), | |
| 227 | + 'ai' => [ | |
| 228 | + 'active' => false, | |
| 229 | + ], | |
| 230 | + 'dynamic' => [ | |
| 231 | + 'active' => true, | |
| 232 | + 'categories' => [ | |
| 233 | + 'url', | |
| 234 | + ], | |
| 235 | + ], | |
| 236 | + 'label_block' => true, | |
| 237 | + 'render_type' => 'none', | |
| 238 | + ] | |
| 239 | + ); | |
| 240 | + | |
| 241 | + $this->end_controls_section(); | |
| 242 | + } | |
| 243 | + function TRAIT_register_submit_popup_controls() | |
| 244 | + { | |
| 245 | + if (defined('UICORE_ASSETS')) { | |
| 246 | + $this->start_controls_section( | |
| 247 | + 'section_popup', | |
| 248 | + [ | |
| 249 | + 'label' => esc_html__('Popup', 'uicore-elements'), | |
| 250 | + 'condition' => [ | |
| 251 | + 'submit_actions' => 'popup', | |
| 252 | + ], | |
| 253 | + ] | |
| 254 | + ); | |
| 255 | + $this->add_control( | |
| 256 | + 'popup_action', | |
| 257 | + [ | |
| 258 | + 'label' => esc_html__('Action', 'uicore-elements'), | |
| 259 | + 'type' => Controls_Manager::SELECT, | |
| 260 | + 'default' => '', | |
| 261 | + 'options' => [ | |
| 262 | + '' => esc_html__('Choose', 'uicore-elements'), | |
| 263 | + 'close' => esc_html__('Close Popup', 'uicore-elements'), | |
| 264 | + 'open' => esc_html__('Open Popup', 'uicore-elements'), | |
| 265 | + ], | |
| 266 | + 'label_block' => true, | |
| 267 | + 'render_type' => 'none', | |
| 268 | + ] | |
| 269 | + ); | |
| 270 | + $this->add_control( | |
| 271 | + 'open_popup', | |
| 272 | + [ | |
| 273 | + 'label' => esc_html__('Popup', 'uicore-elements'), | |
| 274 | + 'type' => Controls_Manager::SELECT2, | |
| 275 | + 'multiple' => false, | |
| 276 | + 'options' => Helper::get_uicore_popups(), | |
| 277 | + 'label_block' => true, | |
| 278 | + 'render_type' => 'none', | |
| 279 | + 'condition' => [ | |
| 280 | + 'popup_action' => 'open', | |
| 281 | + ], | |
| 282 | + ] | |
| 283 | + ); | |
| 284 | + $this->add_control( | |
| 285 | + 'popup_warning', | |
| 286 | + [ | |
| 287 | + 'type' => Controls_Manager::ALERT, | |
| 288 | + 'alert_type' => 'warning', | |
| 289 | + 'dismissible' => false, | |
| 290 | + 'heading' => esc_html__('Popup Visibility', 'uicore-elements'), | |
| 291 | + 'content' => esc_html__("Make sure the chosen popup is enabled on the pages where your widget will be shown. Otherwise, this action won't work.", 'uicore-elements'), | |
| 292 | + 'condition' => [ | |
| 293 | + 'popup_action' => 'open', | |
| 294 | + ], | |
| 295 | + ] | |
| 296 | + ); | |
| 297 | + | |
| 298 | + $this->end_controls_section(); | |
| 299 | + } | |
| 300 | + } | |
| 301 | + | |
| 302 | + function TRAIT_register_submit_webhook_controls() | |
| 303 | + { | |
| 304 | + $this->start_controls_section( | |
| 305 | + 'section_webhook', | |
| 306 | + [ | |
| 307 | + 'label' => esc_html__('Webhook', 'uicore-elements'), | |
| 308 | + 'condition' => [ | |
| 309 | + 'submit_actions' => 'webhook', | |
| 310 | + ], | |
| 311 | + ] | |
| 312 | + ); | |
| 313 | + | |
| 314 | + $this->add_control( | |
| 315 | + 'webhook_url', | |
| 316 | + [ | |
| 317 | + 'label' => esc_html__('Webhook URL', 'uicore-elements'), | |
| 318 | + 'type' => Controls_Manager::TEXT, | |
| 319 | + 'placeholder' => esc_html__('https://your-endpoint.com/webhook', 'uicore-elements'), | |
| 320 | + 'label_block' => true, | |
| 321 | + 'ai' => [ | |
| 322 | + 'active' => false, | |
| 323 | + ], | |
| 324 | + 'dynamic' => [ | |
| 325 | + 'active' => true, | |
| 326 | + 'categories' => [ | |
| 327 | + 'url', | |
| 328 | + ], | |
| 329 | + ], | |
| 330 | + 'render_type' => 'none', | |
| 331 | + ] | |
| 332 | + ); | |
| 333 | + | |
| 334 | + $this->add_control( | |
| 335 | + 'webhook_advanced_data', | |
| 336 | + [ | |
| 337 | + 'label' => esc_html__('Advanced Data', 'uicore-elements'), | |
| 338 | + 'type' => Controls_Manager::SWITCHER, | |
| 339 | + 'label_on' => esc_html__('On', 'uicore-elements'), | |
| 340 | + 'label_off' => esc_html__('Off', 'uicore-elements'), | |
| 341 | + 'return_value' => 'true', | |
| 342 | + 'default' => '', | |
| 343 | + 'render_type' => 'none', | |
| 344 | + ] | |
| 345 | + ); | |
| 346 | + | |
| 347 | + $this->end_controls_section(); | |
| 348 | + } | |
| 349 | + | |
| 350 | + /** | |
| 351 | + * Register Newsletter Services controls for the submit action. | |
| 352 | + * | |
| 353 | + * @param array $services - The list of services available. | |
| 354 | + * @param bool $field_mapping - Enable Field Mapping control if the widget accepts form fields management. | |
| 355 | + * | |
| 356 | + * @return void | |
| 357 | + */ | |
| 358 | + function TRAIT_register_submit_newsletter_services_controls(array $services, bool $field_mapping = false) | |
| 359 | + { | |
| 360 | + | |
| 361 | + // Get and build the newsletter services section conditional display | |
| 362 | + $terms = []; | |
| 363 | + foreach ($services as $service) { | |
| 364 | + $terms[] = [ | |
| 365 | + 'name' => 'submit_actions', | |
| 366 | + 'operator' => 'contains', | |
| 367 | + 'value' => $service, | |
| 368 | + ]; | |
| 369 | + } | |
| 370 | + | |
| 371 | + $this->start_controls_section( | |
| 372 | + 'newsletter_services_section', | |
| 373 | + [ | |
| 374 | + 'label' => esc_html__('Newsletter Service', 'uicore-elements'), | |
| 375 | + 'conditions' => [ | |
| 376 | + 'relation' => 'or', | |
| 377 | + 'terms' => $terms, | |
| 378 | + ], | |
| 379 | + ] | |
| 380 | + ); | |
| 381 | + | |
| 382 | + if (!get_option('uicore_elements_newsletter_service_key')) { | |
| 383 | + $this->add_control( | |
| 384 | + 'services_warning', | |
| 385 | + [ | |
| 386 | + 'type' => Controls_Manager::ALERT, | |
| 387 | + 'alert_type' => 'warning', | |
| 388 | + 'dismissible' => false, | |
| 389 | + 'heading' => esc_html__("You haven't set your Newsletter Service API key yet.", 'uicore-elements'), | |
| 390 | + 'content' => Helper::get_admin_settings_url(esc_html__("Click here to configure your API keys.", 'uicore-elements')), | |
| 391 | + ] | |
| 392 | + ); | |
| 393 | + } | |
| 394 | + | |
| 395 | + $this->add_control( | |
| 396 | + 'mailchimp_audience_id', | |
| 397 | + [ | |
| 398 | + 'label' => esc_html__('ID', 'uicore-elements'), | |
| 399 | + 'type' => Controls_Manager::TEXT, | |
| 400 | + 'description' => esc_html__('The ID of the service list, group, audience, or form where contacts will be saved.', 'uicore-elements'), | |
| 401 | + 'ai' => [ | |
| 402 | + 'active' => false, | |
| 403 | + ], | |
| 404 | + 'dynamic' => [ | |
| 405 | + 'active' => true, | |
| 406 | + ], | |
| 407 | + 'label_block' => true, | |
| 408 | + 'render_type' => 'none', | |
| 409 | + ] | |
| 410 | + ); | |
| 411 | + | |
| 412 | + if ($field_mapping) { | |
| 413 | + | |
| 414 | + $this->add_control( | |
| 415 | + 'services_map_description', | |
| 416 | + [ | |
| 417 | + 'label' => esc_html__('Field Mapping', 'uicore-elements'), | |
| 418 | + 'type' => Controls_Manager::RAW_HTML, | |
| 419 | + 'raw' => esc_html__('You need to set the "ID" of the field you want to map.', 'uicore-elements'), | |
| 420 | + 'content_classes' => 'elementor-control-field-description', | |
| 421 | + 'separator' => 'before', | |
| 422 | + ] | |
| 423 | + ); | |
| 424 | + $this->add_control( | |
| 425 | + 'mailchimp_fname_id', | |
| 426 | + [ | |
| 427 | + 'label' => esc_html__('First Name', 'uicore-elements'), | |
| 428 | + 'type' => Controls_Manager::TEXT, | |
| 429 | + 'ai' => [ | |
| 430 | + 'active' => false, | |
| 431 | + ], | |
| 432 | + 'render_type' => 'none', | |
| 433 | + ] | |
| 434 | + ); | |
| 435 | + $this->add_control( | |
| 436 | + 'mailchimp_lname_id', | |
| 437 | + [ | |
| 438 | + 'label' => esc_html__('Last Name', 'uicore-elements'), | |
| 439 | + 'type' => Controls_Manager::TEXT, | |
| 440 | + 'ai' => [ | |
| 441 | + 'active' => false, | |
| 442 | + ], | |
| 443 | + 'render_type' => 'none', | |
| 444 | + 'conditions' => [ | |
| 445 | + 'terms' => [ | |
| 446 | + [ | |
| 447 | + 'name' => 'submit_actions', | |
| 448 | + 'operator' => '!contains', | |
| 449 | + 'value' => 'moosend', | |
| 450 | + ], | |
| 451 | + [ | |
| 452 | + 'name' => 'submit_actions', | |
| 453 | + 'operator' => '!contains', | |
| 454 | + 'value' => 'getresponse', | |
| 455 | + ], | |
| 456 | + ] | |
| 457 | + ] | |
| 458 | + ] | |
| 459 | + ); | |
| 460 | + $this->add_control( | |
| 461 | + 'mailchimp_email_id', | |
| 462 | + [ | |
| 463 | + 'label' => esc_html__('Email*', 'uicore-elements'), | |
| 464 | + 'type' => Controls_Manager::TEXT, | |
| 465 | + 'ai' => [ | |
| 466 | + 'active' => false, | |
| 467 | + ], | |
| 468 | + 'render_type' => 'none', | |
| 469 | + ] | |
| 470 | + ); | |
| 471 | + $this->add_control( | |
| 472 | + 'mailchimp_birthday_id', | |
| 473 | + [ | |
| 474 | + 'label' => esc_html__('Birthday', 'uicore-elements'), | |
| 475 | + 'type' => Controls_Manager::TEXT, | |
| 476 | + 'ai' => [ | |
| 477 | + 'active' => false, | |
| 478 | + ], | |
| 479 | + 'render_type' => 'none', | |
| 480 | + 'conditions' => [ | |
| 481 | + 'terms' => [ | |
| 482 | + [ | |
| 483 | + 'name' => 'submit_actions', | |
| 484 | + 'operator' => '!contains', | |
| 485 | + 'value' => 'moosend', | |
| 486 | + ], | |
| 487 | + [ | |
| 488 | + 'name' => 'submit_actions', | |
| 489 | + 'operator' => '!contains', | |
| 490 | + 'value' => 'getresponse', | |
| 491 | + ], | |
| 492 | + [ | |
| 493 | + 'name' => 'submit_actions', | |
| 494 | + 'operator' => '!contains', | |
| 495 | + 'value' => 'mailerlite', | |
| 496 | + ], | |
| 497 | + ] | |
| 498 | + ] | |
| 499 | + ] | |
| 500 | + ); | |
| 501 | + $this->add_control( | |
| 502 | + 'mailchimp_phone_id', | |
| 503 | + [ | |
| 504 | + 'label' => esc_html__('Phone', 'uicore-elements'), | |
| 505 | + 'type' => Controls_Manager::TEXT, | |
| 506 | + 'ai' => [ | |
| 507 | + 'active' => false, | |
| 508 | + ], | |
| 509 | + 'render_type' => 'none', | |
| 510 | + 'conditions' => [ | |
| 511 | + 'terms' => [ | |
| 512 | + [ | |
| 513 | + 'name' => 'submit_actions', | |
| 514 | + 'operator' => '!contains', | |
| 515 | + 'value' => 'moosend', | |
| 516 | + ], | |
| 517 | + [ | |
| 518 | + 'name' => 'submit_actions', | |
| 519 | + 'operator' => '!contains', | |
| 520 | + 'value' => 'getresponse', | |
| 521 | + ], | |
| 522 | + ] | |
| 523 | + ] | |
| 524 | + ] | |
| 525 | + ); | |
| 526 | + | |
| 527 | + $this->add_control( | |
| 528 | + 'services_custom_fields_description', | |
| 529 | + [ | |
| 530 | + 'label' => esc_html__('Custom Fields', 'uicore-elements'), | |
| 531 | + 'type' => Controls_Manager::RAW_HTML, | |
| 532 | + 'raw' => esc_html__('Set the "ID" of the custom field you want to pass.', 'uicore-elements'), | |
| 533 | + 'content_classes' => 'elementor-control-field-description', | |
| 534 | + 'separator' => 'before', | |
| 535 | + ] | |
| 536 | + ); | |
| 537 | + $this->add_control( | |
| 538 | + 'newsletter_service_custom_fields', | |
| 539 | + [ | |
| 540 | + 'label' => esc_html__('Custom Fields', 'uicore-elements'), | |
| 541 | + 'type' => Controls_Manager::REPEATER, | |
| 542 | + 'prevent_empty' => false, | |
| 543 | + 'fields' => [ | |
| 544 | + [ | |
| 545 | + 'name' => 'field_name', | |
| 546 | + 'label' => esc_html__('API Field Key', 'uicore-elements'), | |
| 547 | + 'description' => esc_html__('How the field is called in the newsletter service provider.', 'uicore-elements'), | |
| 548 | + 'type' => Controls_Manager::TEXT, | |
| 549 | + ], | |
| 550 | + [ | |
| 551 | + 'name' => 'field_id', | |
| 552 | + 'label' => esc_html__('Form Field ID', 'uicore-elements'), | |
| 553 | + 'description' => esc_html__('The correspondent form field ID in the widget data.', 'uicore-elements'), | |
| 554 | + 'type' => Controls_Manager::TEXT, | |
| 555 | + ], | |
| 556 | + [ | |
| 557 | + 'name' => 'field_type', | |
| 558 | + 'label' => esc_html__('Sanitization Type', 'uicore-elements'), | |
| 559 | + 'description' => esc_html__('Defines which sanitization type this field should receive. E.g.: phone number validation.', 'uicore-elements'), | |
| 560 | + 'default' => 'text', | |
| 561 | + 'options' => [ | |
| 562 | + 'text' => esc_html__('Text', 'uicore-elements'), | |
| 563 | + 'email' => esc_html__('Email', 'uicore-elements'), | |
| 564 | + 'phone' => esc_html__('Phone', 'uicore-elements'), | |
| 565 | + 'birthday' => esc_html__('Birthday', 'uicore-elements'), | |
| 566 | + 'date' => esc_html__('Date', 'uicore-elements'), | |
| 567 | + ], | |
| 568 | + 'type' => Controls_Manager::SELECT, | |
| 569 | + ] | |
| 570 | + ], | |
| 571 | + ] | |
| 572 | + ); | |
| 573 | + } | |
| 574 | + | |
| 575 | + $this->end_controls_section(); | |
| 576 | + } | |
| 577 | + | |
| 578 | + // Settings and Content Controls | |
| 579 | + function TRAIT_register_additional_controls($messages) | |
| 580 | + { | |
| 581 | + $this->start_controls_section( | |
| 582 | + 'section_form_options', | |
| 583 | + [ | |
| 584 | + 'label' => esc_html__('Additional Options', 'uicore-elements'), | |
| 585 | + 'tab' => Controls_Manager::TAB_CONTENT, | |
| 586 | + ] | |
| 587 | + ); | |
| 588 | + | |
| 589 | + $this->add_control( | |
| 590 | + 'form_id', | |
| 591 | + [ | |
| 592 | + 'label' => esc_html__('Form ID', 'uicore-elements'), | |
| 593 | + 'type' => Controls_Manager::TEXT, | |
| 594 | + 'ai' => [ | |
| 595 | + 'active' => false, | |
| 596 | + ], | |
| 597 | + 'placeholder' => 'new_form_id', | |
| 598 | + 'description' => esc_html__('Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements'), | |
| 599 | + 'separator' => 'after', | |
| 600 | + 'dynamic' => [ | |
| 601 | + 'active' => true, | |
| 602 | + ], | |
| 603 | + ] | |
| 604 | + ); | |
| 605 | + $this->add_control( | |
| 606 | + 'form_validation', | |
| 607 | + [ | |
| 608 | + 'label' => esc_html__('Form Validation', 'uicore-elements'), | |
| 609 | + 'type' => Controls_Manager::SELECT, | |
| 610 | + 'options' => [ | |
| 611 | + '' => esc_html__('Browser Default', 'uicore-elements'), | |
| 612 | + 'no' => esc_html__('No validation', 'uicore-elements'), | |
| 613 | + ], | |
| 614 | + 'default' => '', | |
| 615 | + ] | |
| 616 | + ); | |
| 617 | + $this->add_control( | |
| 618 | + 'custom_messages', | |
| 619 | + [ | |
| 620 | + 'label' => esc_html__('Custom Messages', 'uicore-elements'), | |
| 621 | + 'type' => Controls_Manager::SWITCHER, | |
| 622 | + 'default' => '', | |
| 623 | + 'separator' => 'before', | |
| 624 | + 'render_type' => 'none', | |
| 625 | + ] | |
| 626 | + ); | |
| 627 | + $this->add_control( | |
| 628 | + 'success_message', | |
| 629 | + [ | |
| 630 | + 'label' => esc_html__('Success Message', 'uicore-elements'), | |
| 631 | + 'type' => Controls_Manager::TEXT, | |
| 632 | + 'default' => $messages['success'], | |
| 633 | + 'placeholder' => $messages['success'], | |
| 634 | + 'label_block' => true, | |
| 635 | + 'condition' => [ | |
| 636 | + 'custom_messages!' => '', | |
| 637 | + ], | |
| 638 | + 'render_type' => 'none', | |
| 639 | + 'dynamic' => [ | |
| 640 | + 'active' => true, | |
| 641 | + ], | |
| 642 | + ] | |
| 643 | + ); | |
| 644 | + $this->add_control( | |
| 645 | + 'error_message', | |
| 646 | + [ | |
| 647 | + 'label' => esc_html__('Form Error', 'uicore-elements'), | |
| 648 | + 'type' => Controls_Manager::TEXT, | |
| 649 | + 'default' => $messages['error'], | |
| 650 | + 'placeholder' => $messages['error'], | |
| 651 | + 'label_block' => true, | |
| 652 | + 'condition' => [ | |
| 653 | + 'custom_messages!' => '', | |
| 654 | + ], | |
| 655 | + 'render_type' => 'none', | |
| 656 | + 'dynamic' => [ | |
| 657 | + 'active' => true, | |
| 658 | + ], | |
| 659 | + ] | |
| 660 | + ); | |
| 661 | + $this->add_control( | |
| 662 | + 'mail_error_message', | |
| 663 | + [ | |
| 664 | + 'label' => esc_html__('Email Sending Error', 'uicore-elements'), | |
| 665 | + 'type' => Controls_Manager::TEXT, | |
| 666 | + 'default' => $messages['mail_error'], | |
| 667 | + 'placeholder' => $messages['mail_error'], | |
| 668 | + 'label_block' => true, | |
| 669 | + 'condition' => [ | |
| 670 | + 'custom_messages!' => '', | |
| 671 | + ], | |
| 672 | + 'render_type' => 'none', | |
| 673 | + 'dynamic' => [ | |
| 674 | + 'active' => true, | |
| 675 | + ], | |
| 676 | + ] | |
| 677 | + ); | |
| 678 | + $this->add_control( | |
| 679 | + 'redirect_message', | |
| 680 | + [ | |
| 681 | + 'label' => esc_html__('Sucessfull Redirect', 'uicore-elements'), | |
| 682 | + 'type' => Controls_Manager::TEXT, | |
| 683 | + 'default' => $messages['redirect'], | |
| 684 | + 'placeholder' => $messages['redirect'], | |
| 685 | + 'label_block' => true, | |
| 686 | + 'conditions' => [ | |
| 687 | + 'terms' => [ | |
| 688 | + [ | |
| 689 | + 'name' => 'custom_messages', | |
| 690 | + 'operator' => '!=', | |
| 691 | + 'value' => '', | |
| 692 | + ], | |
| 693 | + [ | |
| 694 | + 'name' => 'submit_actions', | |
| 695 | + 'operator' => 'contains', | |
| 696 | + 'value' => 'redirect', | |
| 697 | + ] | |
| 698 | + ], | |
| 699 | + ], | |
| 700 | + 'render_type' => 'none', | |
| 701 | + 'dynamic' => [ | |
| 702 | + 'active' => true, | |
| 703 | + ], | |
| 704 | + ] | |
| 705 | + ); | |
| 706 | + $this->end_controls_section(); | |
| 707 | + } | |
| 708 | + function TRAIT_register_button_controls(string $submit_text = 'send') | |
| 709 | + { | |
| 710 | + $this->add_responsive_control( | |
| 711 | + 'button_width', | |
| 712 | + [ | |
| 713 | + 'label' => esc_html__('Column Width', 'uicore-elements'), | |
| 714 | + 'type' => Controls_Manager::SELECT, | |
| 715 | + 'options' => $this->TRAIT_get_width_values(), | |
| 716 | + 'default' => '20', | |
| 717 | + ] | |
| 718 | + ); | |
| 719 | + $this->add_responsive_control( | |
| 720 | + 'button_align', | |
| 721 | + [ | |
| 722 | + 'label' => esc_html__('Alignment', 'uicore-elements'), | |
| 723 | + 'type' => Controls_Manager::CHOOSE, | |
| 724 | + 'options' => [ | |
| 725 | + 'left' => [ | |
| 726 | + 'title' => esc_html__('Left', 'uicore-elements'), | |
| 727 | + 'icon' => 'eicon-text-align-left', | |
| 728 | + ], | |
| 729 | + 'center' => [ | |
| 730 | + 'title' => esc_html__('Center', 'uicore-elements'), | |
| 731 | + 'icon' => 'eicon-text-align-center', | |
| 732 | + ], | |
| 733 | + 'right' => [ | |
| 734 | + 'title' => esc_html__('Right', 'uicore-elements'), | |
| 735 | + 'icon' => 'eicon-text-align-right', | |
| 736 | + ], | |
| 737 | + 'stretch' => [ | |
| 738 | + 'title' => esc_html__('Justified', 'uicore-elements'), | |
| 739 | + 'icon' => 'eicon-text-align-justify', | |
| 740 | + ], | |
| 741 | + ], | |
| 742 | + 'default' => 'stretch', | |
| 743 | + 'prefix_class' => 'ui-e-submit-align-', | |
| 744 | + ] | |
| 745 | + ); | |
| 746 | + $this->add_control( | |
| 747 | + 'button_text', | |
| 748 | + [ | |
| 749 | + 'label' => esc_html__('Submit', 'uicore-elements'), | |
| 750 | + 'type' => Controls_Manager::TEXT, | |
| 751 | + /* translators: %s: Submit text */ | |
| 752 | + 'default' => esc_html(sprintf('%s', $submit_text), 'uicore-elements'), | |
| 753 | + /* translators: %s: Submit text */ | |
| 754 | + 'placeholder' => esc_html(sprintf('%s', $submit_text), 'uicore-elements'), | |
| 755 | + 'dynamic' => [ | |
| 756 | + 'active' => true, | |
| 757 | + ], | |
| 758 | + 'ai' => [ | |
| 759 | + 'active' => false, | |
| 760 | + ], | |
| 761 | + ] | |
| 762 | + ); | |
| 763 | + $this->add_control( | |
| 764 | + 'selected_button_icon', | |
| 765 | + [ | |
| 766 | + 'label' => esc_html__('Icon', 'uicore-elements'), | |
| 767 | + 'type' => Controls_Manager::ICONS, | |
| 768 | + 'skin' => 'inline', | |
| 769 | + 'label_block' => false, | |
| 770 | + ] | |
| 771 | + ); | |
| 772 | + $this->add_control( | |
| 773 | + 'button_icon_align', | |
| 774 | + [ | |
| 775 | + 'label' => esc_html__('Icon Position', 'uicore-elements'), | |
| 776 | + 'type' => Controls_Manager::SELECT, | |
| 777 | + 'default' => 'left', | |
| 778 | + 'options' => [ | |
| 779 | + 'left' => esc_html__('Before', 'uicore-elements'), | |
| 780 | + 'right' => esc_html__('After', 'uicore-elements'), | |
| 781 | + ], | |
| 782 | + 'condition' => [ | |
| 783 | + 'selected_button_icon[value]!' => '', | |
| 784 | + ], | |
| 785 | + ] | |
| 786 | + ); | |
| 787 | + $this->add_control( | |
| 788 | + 'button_icon_indent', | |
| 789 | + [ | |
| 790 | + 'label' => esc_html__('Icon Spacing', 'uicore-elements'), | |
| 791 | + 'type' => Controls_Manager::SLIDER, | |
| 792 | + 'size_units' => ['px', 'em', 'rem', 'custom'], | |
| 793 | + 'range' => [ | |
| 794 | + 'px' => [ | |
| 795 | + 'max' => 100, | |
| 796 | + ], | |
| 797 | + 'em' => [ | |
| 798 | + 'max' => 10, | |
| 799 | + ], | |
| 800 | + 'rem' => [ | |
| 801 | + 'max' => 10, | |
| 802 | + ], | |
| 803 | + ], | |
| 804 | + 'condition' => [ | |
| 805 | + 'selected_button_icon[value]!' => '', | |
| 806 | + ], | |
| 807 | + 'selectors' => [ | |
| 808 | + '{{WRAPPER}} .elementor-button .ui-e-align-right' => 'margin-left: {{SIZE}}{{UNIT}};', | |
| 809 | + '{{WRAPPER}} .elementor-button .ui-e-align-left' => 'margin-right: {{SIZE}}{{UNIT}};', | |
| 810 | + ], | |
| 811 | + ] | |
| 812 | + ); | |
| 813 | + $this->add_control( | |
| 814 | + 'button_css_id', | |
| 815 | + [ | |
| 816 | + 'label' => esc_html__('Button ID', 'uicore-elements'), | |
| 817 | + 'type' => Controls_Manager::TEXT, | |
| 818 | + 'default' => '', | |
| 819 | + 'ai' => [ | |
| 820 | + 'active' => false, | |
| 821 | + ], | |
| 822 | + 'title' => esc_html__('Add your custom id WITHOUT the Pound key. e.g: my-id', 'uicore-elements'), | |
| 823 | + 'description' => esc_html__('Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements'), | |
| 824 | + 'separator' => 'before', | |
| 825 | + 'dynamic' => [ | |
| 826 | + 'active' => true, | |
| 827 | + ], | |
| 828 | + ] | |
| 829 | + ); | |
| 830 | + } | |
| 831 | + | |
| 832 | + /** | |
| 833 | + * Register the submit action options; | |
| 834 | + * | |
| 835 | + * @param array $options - The options list for the elementor SELECT2 control. | |
| 836 | + * | |
| 837 | + * @return void | |
| 838 | + */ | |
| 839 | + function TRAIT_register_submit_actions_controls($options) | |
| 840 | + { | |
| 841 | + $this->start_controls_section( | |
| 842 | + 'section_actions', | |
| 843 | + [ | |
| 844 | + 'label' => esc_html__('Actions After Submit', 'uicore-elements'), | |
| 845 | + ] | |
| 846 | + ); | |
| 847 | + | |
| 848 | + $this->add_control( | |
| 849 | + 'submit_actions', | |
| 850 | + [ | |
| 851 | + 'label' => esc_html__('Submit Actions', 'uicore-elements'), | |
| 852 | + 'type' => Controls_Manager::SELECT2, | |
| 853 | + 'label_block' => true, | |
| 854 | + 'multiple' => true, | |
| 855 | + 'options' => $options, | |
| 856 | + 'default' => ['email'], | |
| 857 | + ] | |
| 858 | + ); | |
| 859 | + | |
| 860 | + $this->end_controls_section(); | |
| 861 | + } | |
| 862 | + | |
| 863 | + // Style Controls | |
| 864 | + function TRAIT_register_form_style_controls($section = true) | |
| 865 | + { | |
| 866 | + if ($section) { | |
| 867 | + $this->start_controls_section( | |
| 868 | + 'section_form_style', | |
| 869 | + [ | |
| 870 | + 'label' => esc_html__('Form', 'uicore-elements'), | |
| 871 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 872 | + ] | |
| 873 | + ); | |
| 874 | + } | |
| 875 | + $this->add_control( | |
| 876 | + 'column_gap', | |
| 877 | + [ | |
| 878 | + 'label' => esc_html__('Columns Gap', 'uicore-elements'), | |
| 879 | + 'type' => Controls_Manager::SLIDER, | |
| 880 | + 'size_units' => ['px', 'em', 'rem', 'custom'], | |
| 881 | + 'default' => [ | |
| 882 | + 'size' => 10, | |
| 883 | + ], | |
| 884 | + 'range' => [ | |
| 885 | + 'px' => [ | |
| 886 | + 'max' => 60, | |
| 887 | + ], | |
| 888 | + 'em' => [ | |
| 889 | + 'max' => 6, | |
| 890 | + ], | |
| 891 | + 'rem' => [ | |
| 892 | + 'max' => 6, | |
| 893 | + ], | |
| 894 | + ], | |
| 895 | + 'selectors' => [ | |
| 896 | + '{{WRAPPER}} .ui-e-field-group' => 'padding-right: calc( {{SIZE}}{{UNIT}}/2 ); padding-left: calc( {{SIZE}}{{UNIT}}/2 );', | |
| 897 | + '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-left: calc( -{{SIZE}}{{UNIT}}/2 ); margin-right: calc( -{{SIZE}}{{UNIT}}/2 );', | |
| 898 | + ], | |
| 899 | + ] | |
| 900 | + ); | |
| 901 | + $this->add_control( | |
| 902 | + 'row_gap', | |
| 903 | + [ | |
| 904 | + 'label' => esc_html__('Rows Gap', 'uicore-elements'), | |
| 905 | + 'type' => Controls_Manager::SLIDER, | |
| 906 | + 'size_units' => ['px', 'em', 'rem', 'custom'], | |
| 907 | + 'default' => [ | |
| 908 | + 'size' => 10, | |
| 909 | + ], | |
| 910 | + 'range' => [ | |
| 911 | + 'px' => [ | |
| 912 | + 'max' => 60, | |
| 913 | + ], | |
| 914 | + 'em' => [ | |
| 915 | + 'max' => 6, | |
| 916 | + ], | |
| 917 | + 'rem' => [ | |
| 918 | + 'max' => 6, | |
| 919 | + ], | |
| 920 | + ], | |
| 921 | + 'selectors' => [ | |
| 922 | + '{{WRAPPER}} .ui-e-field-group' => 'margin-bottom: {{SIZE}}{{UNIT}};', | |
| 923 | + '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-bottom: -{{SIZE}}{{UNIT}};', | |
| 924 | + ], | |
| 925 | + ] | |
| 926 | + ); | |
| 927 | + $this->add_control( | |
| 928 | + 'heading_label', | |
| 929 | + [ | |
| 930 | + 'label' => esc_html__('Label', 'uicore-elements'), | |
| 931 | + 'type' => Controls_Manager::HEADING, | |
| 932 | + 'separator' => 'before', | |
| 933 | + ] | |
| 934 | + ); | |
| 935 | + $this->add_control( | |
| 936 | + 'label_spacing', | |
| 937 | + [ | |
| 938 | + 'label' => esc_html__('Spacing', 'uicore-elements'), | |
| 939 | + 'type' => Controls_Manager::SLIDER, | |
| 940 | + 'size_units' => ['px', 'em', 'rem', 'custom'], | |
| 941 | + 'default' => [ | |
| 942 | + 'size' => 0, | |
| 943 | + ], | |
| 944 | + 'range' => [ | |
| 945 | + 'px' => [ | |
| 946 | + 'max' => 60, | |
| 947 | + ], | |
| 948 | + 'em' => [ | |
| 949 | + 'max' => 6, | |
| 950 | + ], | |
| 951 | + 'rem' => [ | |
| 952 | + 'max' => 6, | |
| 953 | + ], | |
| 954 | + ], | |
| 955 | + 'selectors' => [ | |
| 956 | + 'body {{WRAPPER}} .ui-e-field-group > label' => 'padding-bottom: {{SIZE}}{{UNIT}};', | |
| 957 | + ], | |
| 958 | + ] | |
| 959 | + ); | |
| 960 | + $this->add_control( | |
| 961 | + 'label_color', | |
| 962 | + [ | |
| 963 | + 'label' => esc_html__('Text Color', 'uicore-elements'), | |
| 964 | + 'type' => Controls_Manager::COLOR, | |
| 965 | + 'selectors' => [ | |
| 966 | + '{{WRAPPER}} .ui-e-field-group > label, {{WRAPPER}} .ui-e-field-subgroup label' => 'color: {{VALUE}};', | |
| 967 | + ], | |
| 968 | + 'default' => 'var(--e-global-color-uicore_body)', | |
| 969 | + ] | |
| 970 | + ); | |
| 971 | + $this->add_control( | |
| 972 | + 'mark_required_color', | |
| 973 | + [ | |
| 974 | + 'label' => esc_html__('Mark Color', 'uicore-elements'), | |
| 975 | + 'type' => Controls_Manager::COLOR, | |
| 976 | + 'default' => '', | |
| 977 | + 'selectors' => [ | |
| 978 | + '{{WRAPPER}} .ui-e-required .ui-e-label:after' => 'color: {{COLOR}};', | |
| 979 | + ], | |
| 980 | + 'condition' => [ | |
| 981 | + 'mark_required' => 'yes', | |
| 982 | + ], | |
| 983 | + ] | |
| 984 | + ); | |
| 985 | + $this->add_group_control( | |
| 986 | + Group_Control_Typography::get_type(), | |
| 987 | + [ | |
| 988 | + 'name' => 'label_typography', | |
| 989 | + 'selector' => '{{WRAPPER}} .ui-e-field-group > label', | |
| 990 | + 'global' => [ | |
| 991 | + 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 992 | + ], | |
| 993 | + ] | |
| 994 | + ); | |
| 995 | + $this->add_control( | |
| 996 | + 'form_styles_component_divider', | |
| 997 | + [ | |
| 998 | + 'type' => Controls_Manager::DIVIDER, | |
| 999 | + ] | |
| 1000 | + ); | |
| 1001 | + if ($section) { | |
| 1002 | + $this->end_controls_section(); | |
| 1003 | + } | |
| 1004 | + } | |
| 1005 | + function TRAIT_register_fields_style_controls($section = true) | |
| 1006 | + { | |
| 1007 | + if ($section) { | |
| 1008 | + $this->start_controls_section( | |
| 1009 | + 'section_field_style', | |
| 1010 | + [ | |
| 1011 | + 'label' => esc_html__('Fields', 'uicore-elements'), | |
| 1012 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 1013 | + ] | |
| 1014 | + ); | |
| 1015 | + } | |
| 1016 | + | |
| 1017 | + $this->start_controls_tabs( | |
| 1018 | + 'field_style_tabs' | |
| 1019 | + ); | |
| 1020 | + | |
| 1021 | + $this->start_controls_tab( | |
| 1022 | + 'field_normal_tab', | |
| 1023 | + [ | |
| 1024 | + 'label' => esc_html__('Normal', 'uicore-elements'), | |
| 1025 | + ] | |
| 1026 | + ); | |
| 1027 | + | |
| 1028 | + $this->add_group_control( | |
| 1029 | + Group_Control_Typography::get_type(), | |
| 1030 | + [ | |
| 1031 | + 'name' => 'field_typography', | |
| 1032 | + 'selector' => '{{WRAPPER}} .ui-e-field-group .ui-e-field, {{WRAPPER}} .ui-e-field-subgroup label, {{WRAPPER}} .ui-e-field-group .ui-e-field-select select', | |
| 1033 | + 'global' => [ | |
| 1034 | + 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 1035 | + ], | |
| 1036 | + ] | |
| 1037 | + ); | |
| 1038 | + $this->add_control( | |
| 1039 | + 'field_text_color', | |
| 1040 | + [ | |
| 1041 | + 'label' => esc_html__('Text Color', 'uicore-elements'), | |
| 1042 | + 'type' => Controls_Manager::COLOR, | |
| 1043 | + 'selectors' => [ | |
| 1044 | + '{{WRAPPER}} .ui-e-field-group .ui-e-field, {{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'color: {{VALUE}};', | |
| 1045 | + ], | |
| 1046 | + 'default' => 'var(--e-global-color-uicore_body)', | |
| 1047 | + | |
| 1048 | + ] | |
| 1049 | + ); | |
| 1050 | + $this->add_control( | |
| 1051 | + 'field_placeholder_color', | |
| 1052 | + [ | |
| 1053 | + 'label' => esc_html__('Placeholder Color', 'uicore-elements'), | |
| 1054 | + 'type' => Controls_Manager::COLOR, | |
| 1055 | + 'selectors' => [ | |
| 1056 | + '{{WRAPPER}} .ui-e-field-group .ui-e-field::placeholder' => 'color: {{VALUE}};', | |
| 1057 | + ], | |
| 1058 | + 'default' => 'var(--e-global-color-uicore_body)', | |
| 1059 | + | |
| 1060 | + ] | |
| 1061 | + ); | |
| 1062 | + $this->add_control( | |
| 1063 | + 'field_background_color', | |
| 1064 | + [ | |
| 1065 | + 'label' => esc_html__('Background Color', 'uicore-elements'), | |
| 1066 | + 'type' => Controls_Manager::COLOR, | |
| 1067 | + 'default' => '#ffffff', | |
| 1068 | + 'selectors' => [ | |
| 1069 | + '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};', | |
| 1070 | + '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'background-color: {{VALUE}};', | |
| 1071 | + ], | |
| 1072 | + ] | |
| 1073 | + ); | |
| 1074 | + $this->add_group_control( | |
| 1075 | + Group_Control_Border::get_type(), | |
| 1076 | + [ | |
| 1077 | + 'name' => 'field_border', | |
| 1078 | + 'selector' => | |
| 1079 | + '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:not(.ui-e-field-select), | |
| 1080 | + {{WRAPPER}} .ui-e-field-group .ui-e-field-select select', | |
| 1081 | + ] | |
| 1082 | + ); | |
| 1083 | + $this->add_group_control( | |
| 1084 | + Group_Control_Box_Shadow::get_type(), | |
| 1085 | + [ | |
| 1086 | + 'name' => 'field_box_shadow', | |
| 1087 | + 'selector' => '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:not(.ui-e-field-select), | |
| 1088 | + {{WRAPPER}} .ui-e-field-group .ui-e-field-select select', | |
| 1089 | + ] | |
| 1090 | + ); | |
| 1091 | + | |
| 1092 | + $this->end_controls_tab(); | |
| 1093 | + | |
| 1094 | + $this->start_controls_tab( | |
| 1095 | + 'field_hover_tab', | |
| 1096 | + [ | |
| 1097 | + 'label' => esc_html__('Hover', 'uicore-elements'), | |
| 1098 | + ] | |
| 1099 | + ); | |
| 1100 | + | |
| 1101 | + $this->add_control( | |
| 1102 | + 'field_text_hover_color', | |
| 1103 | + [ | |
| 1104 | + 'label' => esc_html__('Text Color', 'uicore-elements'), | |
| 1105 | + 'type' => Controls_Manager::COLOR, | |
| 1106 | + 'selectors' => [ | |
| 1107 | + '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field, {{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select' => 'color: {{VALUE}};', | |
| 1108 | + ], | |
| 1109 | + 'default' => 'var(--e-global-color-uicore_body)', | |
| 1110 | + | |
| 1111 | + ] | |
| 1112 | + ); | |
| 1113 | + $this->add_control( | |
| 1114 | + 'field_placeholder_hover_color', | |
| 1115 | + [ | |
| 1116 | + 'label' => esc_html__('Placeholder Color', 'uicore-elements'), | |
| 1117 | + 'type' => Controls_Manager::COLOR, | |
| 1118 | + 'selectors' => [ | |
| 1119 | + '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field::placeholder' => 'color: {{VALUE}};', | |
| 1120 | + ], | |
| 1121 | + 'default' => 'var(--e-global-color-uicore_body)', | |
| 1122 | + | |
| 1123 | + ] | |
| 1124 | + ); | |
| 1125 | + $this->add_control( | |
| 1126 | + 'field_background_hover_color', | |
| 1127 | + [ | |
| 1128 | + 'label' => esc_html__('Background Color', 'uicore-elements'), | |
| 1129 | + 'type' => Controls_Manager::COLOR, | |
| 1130 | + 'default' => '#ffffff', | |
| 1131 | + 'selectors' => [ | |
| 1132 | + '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};', | |
| 1133 | + '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select' => 'background-color: {{VALUE}};', | |
| 1134 | + ], | |
| 1135 | + ] | |
| 1136 | + ); | |
| 1137 | + $this->add_group_control( | |
| 1138 | + Group_Control_Border::get_type(), | |
| 1139 | + [ | |
| 1140 | + 'name' => 'field_hover_border', | |
| 1141 | + 'selector' => | |
| 1142 | + '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:not(.ui-e-field-select), | |
| 1143 | + {{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select', | |
| 1144 | + ] | |
| 1145 | + ); | |
| 1146 | + $this->add_group_control( | |
| 1147 | + Group_Control_Box_Shadow::get_type(), | |
| 1148 | + [ | |
| 1149 | + 'name' => 'field_box_shadow_hover', | |
| 1150 | + 'selector' => '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:not(.ui-e-field-select), | |
| 1151 | + {{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select', | |
| 1152 | + ] | |
| 1153 | + ); | |
| 1154 | + | |
| 1155 | + $this->end_controls_tab(); | |
| 1156 | + | |
| 1157 | + $this->start_controls_tab( | |
| 1158 | + 'field_active_tab', | |
| 1159 | + [ | |
| 1160 | + 'label' => esc_html__('Active', 'uicore-elements'), | |
| 1161 | + ] | |
| 1162 | + ); | |
| 1163 | + | |
| 1164 | + $this->add_control( | |
| 1165 | + 'field_text_active_color', | |
| 1166 | + [ | |
| 1167 | + 'label' => esc_html__('Text Color', 'uicore-elements'), | |
| 1168 | + 'type' => Controls_Manager::COLOR, | |
| 1169 | + 'selectors' => [ | |
| 1170 | + '{{WRAPPER}} .ui-e-field-group .ui-e-field:focus, {{WRAPPER}} .ui-e-field-group .ui-e-field-select select:focus' => 'color: {{VALUE}};', | |
| 1171 | + ], | |
| 1172 | + 'default' => 'var(--e-global-color-uicore_body)', | |
| 1173 | + | |
| 1174 | + ] | |
| 1175 | + ); | |
| 1176 | + $this->add_control( | |
| 1177 | + 'field_background_active_color', | |
| 1178 | + [ | |
| 1179 | + 'label' => esc_html__('Background Color', 'uicore-elements'), | |
| 1180 | + 'type' => Controls_Manager::COLOR, | |
| 1181 | + 'default' => '#ffffff', | |
| 1182 | + 'selectors' => [ | |
| 1183 | + '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:focus:not(.ui-e-field-select)' => 'background-color: {{VALUE}};', | |
| 1184 | + '{{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select' => 'background-color: {{VALUE}};', | |
| 1185 | + ], | |
| 1186 | + ] | |
| 1187 | + ); | |
| 1188 | + $this->add_group_control( | |
| 1189 | + Group_Control_Border::get_type(), | |
| 1190 | + [ | |
| 1191 | + 'name' => 'field_active_border', | |
| 1192 | + 'selector' => | |
| 1193 | + '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:focus:not(.ui-e-field-select), | |
| 1194 | + {{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select', | |
| 1195 | + ] | |
| 1196 | + ); | |
| 1197 | + $this->add_group_control( | |
| 1198 | + Group_Control_Box_Shadow::get_type(), | |
| 1199 | + [ | |
| 1200 | + 'name' => 'field_box_shadow_active', | |
| 1201 | + 'selector' => '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:focus:not(.ui-e-field-select), | |
| 1202 | + {{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select', | |
| 1203 | + ] | |
| 1204 | + ); | |
| 1205 | + | |
| 1206 | + $this->end_controls_tab(); | |
| 1207 | + | |
| 1208 | + $this->end_controls_tabs(); | |
| 1209 | + | |
| 1210 | + $this->add_responsive_control( | |
| 1211 | + 'field_border_radius', | |
| 1212 | + [ | |
| 1213 | + 'label' => esc_html__('Border Radius', 'uicore-elements'), | |
| 1214 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 1215 | + 'size_units' => ['px', '%', 'em', 'rem', 'custom'], | |
| 1216 | + 'selectors' => [ | |
| 1217 | + '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:not(.ui-e-field-select)' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1218 | + '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1219 | + ], | |
| 1220 | + 'separator' => 'before' | |
| 1221 | + ] | |
| 1222 | + ); | |
| 1223 | + $this->add_responsive_control( | |
| 1224 | + 'field_padding', | |
| 1225 | + [ | |
| 1226 | + 'label' => esc_html__('Padding', 'uicore-elements'), | |
| 1227 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 1228 | + 'size_units' => ['px', '%', 'em', 'rem', 'custom'], | |
| 1229 | + 'selectors' => [ | |
| 1230 | + '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file, .ui-e-field-type-acceptance) .ui-e-field:not(.ui-e-field-select)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1231 | + '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1232 | + ], | |
| 1233 | + ] | |
| 1234 | + ); | |
| 1235 | + if ($section) { | |
| 1236 | + $this->end_controls_section(); | |
| 1237 | + } | |
| 1238 | + } | |
| 1239 | + function TRAIT_register_button_style_controls($section = true) | |
| 1240 | + { | |
| 1241 | + if ($section) { | |
| 1242 | + $this->start_controls_section( | |
| 1243 | + 'section_button_style', | |
| 1244 | + [ | |
| 1245 | + 'label' => esc_html__('Button', 'uicore-elements'), | |
| 1246 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 1247 | + ] | |
| 1248 | + ); | |
| 1249 | + } | |
| 1250 | + | |
| 1251 | + $this->add_group_control( | |
| 1252 | + Group_Control_Typography::get_type(), | |
| 1253 | + [ | |
| 1254 | + 'name' => 'button_typography', | |
| 1255 | + 'global' => [ | |
| 1256 | + 'default' => Global_Typography::TYPOGRAPHY_ACCENT, | |
| 1257 | + ], | |
| 1258 | + 'selector' => '{{WRAPPER}} .elementor-button', | |
| 1259 | + ] | |
| 1260 | + ); | |
| 1261 | + $this->add_group_control( | |
| 1262 | + Group_Control_Border::get_type(), | |
| 1263 | + [ | |
| 1264 | + 'name' => 'button_border', | |
| 1265 | + 'selector' => '{{WRAPPER}} .elementor-button', | |
| 1266 | + 'exclude' => [ | |
| 1267 | + 'color', | |
| 1268 | + ], | |
| 1269 | + ] | |
| 1270 | + ); | |
| 1271 | + | |
| 1272 | + $this->start_controls_tabs('tabs_button_style'); | |
| 1273 | + | |
| 1274 | + $this->start_controls_tab( | |
| 1275 | + 'tab_button_normal', | |
| 1276 | + [ | |
| 1277 | + 'label' => esc_html__('Normal', 'uicore-elements'), | |
| 1278 | + ] | |
| 1279 | + ); | |
| 1280 | + | |
| 1281 | + $this->add_control( | |
| 1282 | + 'button_background_color', | |
| 1283 | + [ | |
| 1284 | + 'label' => esc_html__('Background Color', 'uicore-elements'), | |
| 1285 | + 'type' => Controls_Manager::COLOR, | |
| 1286 | + 'selectors' => [ | |
| 1287 | + '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'background-color: {{VALUE}};', | |
| 1288 | + '{{WRAPPER}} .elementor-button[type="submit"]' => 'background-color: {{VALUE}};', | |
| 1289 | + ], | |
| 1290 | + ] | |
| 1291 | + ); | |
| 1292 | + $this->add_control( | |
| 1293 | + 'button_text_color', | |
| 1294 | + [ | |
| 1295 | + 'label' => esc_html__('Text Color', 'uicore-elements'), | |
| 1296 | + 'type' => Controls_Manager::COLOR, | |
| 1297 | + 'default' => '#ffffff', | |
| 1298 | + 'selectors' => [ | |
| 1299 | + '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'color: {{VALUE}};', | |
| 1300 | + '{{WRAPPER}} .elementor-button[type="submit"]' => 'color: {{VALUE}};', | |
| 1301 | + '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'fill: {{VALUE}};', | |
| 1302 | + ], | |
| 1303 | + ] | |
| 1304 | + ); | |
| 1305 | + $this->add_control( | |
| 1306 | + 'button_border_color', | |
| 1307 | + [ | |
| 1308 | + 'label' => esc_html__('Border Color', 'uicore-elements'), | |
| 1309 | + 'type' => Controls_Manager::COLOR, | |
| 1310 | + 'default' => '', | |
| 1311 | + 'selectors' => [ | |
| 1312 | + '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'border-color: {{VALUE}};', | |
| 1313 | + '{{WRAPPER}} .elementor-button[type="submit"]' => 'border-color: {{VALUE}};', | |
| 1314 | + ], | |
| 1315 | + 'condition' => [ | |
| 1316 | + 'button_border_border!' => '', | |
| 1317 | + ], | |
| 1318 | + ] | |
| 1319 | + ); | |
| 1320 | + | |
| 1321 | + $this->end_controls_tab(); | |
| 1322 | + | |
| 1323 | + $this->start_controls_tab( | |
| 1324 | + 'tab_button_hover', | |
| 1325 | + [ | |
| 1326 | + 'label' => esc_html__('Hover', 'uicore-elements'), | |
| 1327 | + ] | |
| 1328 | + ); | |
| 1329 | + | |
| 1330 | + $this->add_control( | |
| 1331 | + 'button_background_hover_color', | |
| 1332 | + [ | |
| 1333 | + 'label' => esc_html__('Background Color', 'uicore-elements'), | |
| 1334 | + 'type' => Controls_Manager::COLOR, | |
| 1335 | + 'default' => '', | |
| 1336 | + 'selectors' => [ | |
| 1337 | + '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'background-color: {{VALUE}};', | |
| 1338 | + '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'background-color: {{VALUE}};', | |
| 1339 | + ], | |
| 1340 | + ] | |
| 1341 | + ); | |
| 1342 | + $this->add_control( | |
| 1343 | + 'button_hover_color', | |
| 1344 | + [ | |
| 1345 | + 'label' => esc_html__('Text Color', 'uicore-elements'), | |
| 1346 | + 'type' => Controls_Manager::COLOR, | |
| 1347 | + 'default' => '#ffffff', | |
| 1348 | + 'selectors' => [ | |
| 1349 | + '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'color: {{VALUE}};', | |
| 1350 | + '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'color: {{VALUE}};', | |
| 1351 | + '{{WRAPPER}} .elementor-button[type="submit"]:hover svg *' => 'fill: {{VALUE}};', | |
| 1352 | + ], | |
| 1353 | + ] | |
| 1354 | + ); | |
| 1355 | + $this->add_control( | |
| 1356 | + 'button_hover_border_color', | |
| 1357 | + [ | |
| 1358 | + 'label' => esc_html__('Border Color', 'uicore-elements'), | |
| 1359 | + 'type' => Controls_Manager::COLOR, | |
| 1360 | + 'default' => '', | |
| 1361 | + 'selectors' => [ | |
| 1362 | + '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'border-color: {{VALUE}};', | |
| 1363 | + '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'border-color: {{VALUE}};', | |
| 1364 | + ], | |
| 1365 | + 'condition' => [ | |
| 1366 | + 'button_border_border!' => '', | |
| 1367 | + ], | |
| 1368 | + ] | |
| 1369 | + ); | |
| 1370 | + $this->add_control( | |
| 1371 | + 'hover_transition_duration', | |
| 1372 | + [ | |
| 1373 | + 'label' => esc_html__('Transition Duration', 'uicore-elements'), | |
| 1374 | + 'type' => Controls_Manager::SLIDER, | |
| 1375 | + 'size_units' => ['s', 'ms', 'custom'], | |
| 1376 | + 'default' => [ | |
| 1377 | + 'unit' => 'ms', | |
| 1378 | + ], | |
| 1379 | + 'selectors' => [ | |
| 1380 | + '{{WRAPPER}} .e-form__buttons__wrapper__button-previous' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 1381 | + '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 1382 | + '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 1383 | + '{{WRAPPER}} .elementor-button[type="submit"]' => 'transition-duration: {{SIZE}}{{UNIT}};', | |
| 1384 | + ], | |
| 1385 | + ] | |
| 1386 | + ); | |
| 1387 | + $this->add_control( | |
| 1388 | + 'button_hover_animation', | |
| 1389 | + [ | |
| 1390 | + 'label' => esc_html__('Animation', 'uicore-elements'), | |
| 1391 | + 'type' => Controls_Manager::HOVER_ANIMATION, | |
| 1392 | + ] | |
| 1393 | + ); | |
| 1394 | + | |
| 1395 | + $this->end_controls_tab(); | |
| 1396 | + | |
| 1397 | + $this->end_controls_tabs(); | |
| 1398 | + | |
| 1399 | + $this->add_responsive_control( | |
| 1400 | + 'button_border_radius', | |
| 1401 | + [ | |
| 1402 | + 'label' => esc_html__('Border Radius', 'uicore-elements'), | |
| 1403 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 1404 | + 'size_units' => ['px', '%', 'em', 'rem', 'custom'], | |
| 1405 | + 'selectors' => [ | |
| 1406 | + '{{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1407 | + ], | |
| 1408 | + 'separator' => 'before', | |
| 1409 | + ] | |
| 1410 | + ); | |
| 1411 | + | |
| 1412 | + $this->add_responsive_control( | |
| 1413 | + 'button_text_padding', | |
| 1414 | + [ | |
| 1415 | + 'label' => esc_html__('Text Padding', 'uicore-elements'), | |
| 1416 | + 'type' => Controls_Manager::DIMENSIONS, | |
| 1417 | + 'size_units' => ['px', '%', 'em', 'rem', 'custom'], | |
| 1418 | + 'selectors' => [ | |
| 1419 | + '{{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', | |
| 1420 | + ], | |
| 1421 | + ] | |
| 1422 | + ); | |
| 1423 | + | |
| 1424 | + if ($section) { | |
| 1425 | + $this->end_controls_section(); | |
| 1426 | + } | |
| 1427 | + } | |
| 1428 | + function TRAIT_register_messages_style_controls($section = true) | |
| 1429 | + { | |
| 1430 | + if ($section) { | |
| 1431 | + $this->start_controls_section( | |
| 1432 | + 'section_messages_style', | |
| 1433 | + [ | |
| 1434 | + 'label' => esc_html__('Messages', 'uicore-elements'), | |
| 1435 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 1436 | + ] | |
| 1437 | + ); | |
| 1438 | + } | |
| 1439 | + | |
| 1440 | + $this->add_control( | |
| 1441 | + 'show_messages', | |
| 1442 | + [ | |
| 1443 | + 'label' => esc_html__('Show/Hide messages', 'uicore-elements'), | |
| 1444 | + 'type' => Controls_Manager::BUTTON, | |
| 1445 | + 'separator' => 'before', | |
| 1446 | + 'text' => esc_html__('Toggle', 'uicore-elements'), | |
| 1447 | + 'event' => 'ui-e-form-show-messages', | |
| 1448 | + ] | |
| 1449 | + ); | |
| 1450 | + $this->add_group_control( | |
| 1451 | + Group_Control_Typography::get_type(), | |
| 1452 | + [ | |
| 1453 | + 'name' => 'message_typography', | |
| 1454 | + 'global' => [ | |
| 1455 | + 'default' => Global_Typography::TYPOGRAPHY_TEXT, | |
| 1456 | + ], | |
| 1457 | + 'selector' => '{{WRAPPER}} .ui-e-message', | |
| 1458 | + ] | |
| 1459 | + ); | |
| 1460 | + $this->add_control( | |
| 1461 | + 'success_message_color', | |
| 1462 | + [ | |
| 1463 | + 'label' => esc_html__('Success Message Color', 'uicore-elements'), | |
| 1464 | + 'type' => Controls_Manager::COLOR, | |
| 1465 | + 'default' => '#4CAF50', | |
| 1466 | + 'selectors' => [ | |
| 1467 | + '{{WRAPPER}} .ui-e-message span.success' => 'color: {{COLOR}};', | |
| 1468 | + ], | |
| 1469 | + ] | |
| 1470 | + ); | |
| 1471 | + $this->add_control( | |
| 1472 | + 'error_message_color', | |
| 1473 | + [ | |
| 1474 | + 'label' => esc_html__('Error Message Color', 'uicore-elements'), | |
| 1475 | + 'type' => Controls_Manager::COLOR, | |
| 1476 | + 'default' => '#F44336', | |
| 1477 | + 'selectors' => [ | |
| 1478 | + '{{WRAPPER}} .ui-e-message span.error' => 'color: {{COLOR}};', | |
| 1479 | + ], | |
| 1480 | + ] | |
| 1481 | + ); | |
| 1482 | + | |
| 1483 | + if ($section) { | |
| 1484 | + $this->end_controls_section(); | |
| 1485 | + } | |
| 1486 | + } | |
| 1487 | + function TRAIT_register_all_form_style_controls() | |
| 1488 | + { | |
| 1489 | + $this->TRAIT_register_form_style_controls(); | |
| 1490 | + $this->TRAIT_register_fields_style_controls(); | |
| 1491 | + $this->TRAIT_register_button_style_controls(); | |
| 1492 | + $this->TRAIT_register_messages_style_controls(); | |
| 1493 | + } | |
| 1494 | + | |
| 1495 | + // Helper and Utility Functions | |
| 1496 | + function TRAIT_get_width_values() | |
| 1497 | + { | |
| 1498 | + return [ | |
| 1499 | + '' => esc_html__('Default', 'uicore-elements'), | |
| 1500 | + '100' => '100%', | |
| 1501 | + '80' => '80%', | |
| 1502 | + '75' => '75%', | |
| 1503 | + '70' => '70%', | |
| 1504 | + '66' => '66%', | |
| 1505 | + '60' => '60%', | |
| 1506 | + '50' => '50%', | |
| 1507 | + '40' => '40%', | |
| 1508 | + '33' => '33%', | |
| 1509 | + '30' => '30%', | |
| 1510 | + '25' => '25%', | |
| 1511 | + '20' => '20%', | |
| 1512 | + ]; | |
| 1513 | + } | |
| 1514 | + function TRAIT_recaptcha_key_js() | |
| 1515 | + { | |
| 1516 | +?> | |
| 1517 | + <script> | |
| 1518 | + window.uicore_elements_recaptcha = '<?php echo esc_html(get_option('uicore_elements_recaptcha_site_key')); ?>'; | |
| 1519 | + </script> | |
| 1520 | +<?php | |
| 1521 | + } | |
| 1522 | +} | |