Form builder to get in touch with visitors, grow your email list and collect payments — Happyforms - Version 1.11.0

Version Description

  • Improvement: Better support for 3rd party popup plugins.
  • Improvement: Better support for tab navigation in Dropdown field.
  • Bugfix: Dropdown field searchable functionality was misbehaving.
  • Bugfix: Form title "Display" control wasn't working.
  • Bugfix: Validation of optional Long Answer fields with character counting was misbehaving.
Download this release

Release Info

Developer happyforms
Plugin Icon 128x128 Form builder to get in touch with visitors, grow your email list and collect payments — Happyforms
Version 1.11.0
Comparing to
See all releases

Code changes from version 1.10.0 to 1.11.0

core/assets/css/no-interaction.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ .happyforms-button--submit,
2
+ [data-happyforms-type="attachment"] {
3
+ pointer-events: none;
4
+ }
core/assets/js/admin/block.js CHANGED
@@ -87,7 +87,7 @@
87
  }, el( 'p',
88
  null,
89
  settings.upgrade_notice.i18n.text,
90
- el( 'a', { href: 'https://happyforms.me/upgrade', target: '_blank' }, ' ' + settings.upgrade_notice.i18n.link_text )
91
  )
92
  ),
93
  ),
87
  }, el( 'p',
88
  null,
89
  settings.upgrade_notice.i18n.text,
90
+ el( 'a', { href: 'https://happyforms.io/upgrade', target: '_blank' }, ' ' + settings.upgrade_notice.i18n.link_text )
91
  )
92
  ),
93
  ),
core/assets/js/lib/happyforms-select.js CHANGED
@@ -143,6 +143,13 @@
143
  if ( $focusedItem.length ) {
144
  this.setValue( $focusedItem.data('value').toString() );
145
  }
 
 
 
 
 
 
 
146
  break;
147
  default:
148
  if ('autocomplete' === this.searchable) {
@@ -153,7 +160,7 @@
153
  }
154
 
155
  this.getSuggestions();
156
- } else {
157
  this.searchOptions();
158
  }
159
  break;
@@ -308,14 +315,17 @@
308
  $allItems.each( function( index, li ) {
309
  var $li = $( li );
310
  var liValue = $li.data( 'value' );
311
- var liLabel = ( $li.data( 'label' ).length ) ? $li.data( 'label' ).toLowerCase() : '';
312
-
313
- if ( liValue ) {
314
- liValue = liValue.toString().toLowerCase();
315
- value = value.toString().toLowerCase();
316
  }
317
 
318
- if ( liValue && -1 !== liValue.indexOf( value ) || liLabel && -1 !== liLabel.indexOf( value ) ) {
 
 
 
319
  $li.show();
320
  foundItems = foundItems + 1;
321
  }
143
  if ( $focusedItem.length ) {
144
  this.setValue( $focusedItem.data('value').toString() );
145
  }
146
+
147
+ this.handleBlur();
148
+ break;
149
+ case 9:
150
+ case 16:
151
+ e.preventDefault();
152
+
153
  break;
154
  default:
155
  if ('autocomplete' === this.searchable) {
160
  }
161
 
162
  this.getSuggestions();
163
+ } else if ( "true" === this.searchable ) {
164
  this.searchOptions();
165
  }
166
  break;
315
  $allItems.each( function( index, li ) {
316
  var $li = $( li );
317
  var liValue = $li.data( 'value' );
318
+ var labelValue = $li.data( 'label' );
319
+ if ( 'string' == typeof labelValue ) {
320
+ var liLabel = ( labelValue.length ) ? labelValue.toLowerCase() : '';
321
+ } else {
322
+ var liLabel = labelValue.toString();
323
  }
324
 
325
+ liValue = liValue.toString().toLowerCase();
326
+ value = value.toString().toLowerCase();
327
+
328
+ if ( -1 !== liLabel.indexOf( value ) ) {
329
  $li.show();
330
  foundItems = foundItems + 1;
331
  }
core/classes/class-form-assets.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class HappyForms_Form_Assets {
4
+
5
+ private static $instance;
6
+
7
+ const MODE_NONE = 0;
8
+ const MODE_ADMIN = 1;
9
+ const MODE_BLOCK = 2;
10
+ const MODE_CUSTOMIZER = 4;
11
+ const MODE_COMPLETE = 8;
12
+
13
+ public static function instance() {
14
+ if ( is_null( self::$instance ) ) {
15
+ self::$instance = new self();
16
+ }
17
+
18
+ return self::$instance;
19
+ }
20
+
21
+ public function output_frontend_styles( $form ) {
22
+ happyforms_the_form_styles( $form );
23
+ happyforms_additional_css( $form );
24
+ }
25
+
26
+ public function output_admin_styles( $form ) {
27
+ ?>
28
+ <link rel="stylesheet" type="text/css" href="<?php echo happyforms_get_plugin_url() . 'core/assets/css/no-interaction.css'; ?>">
29
+ <?php
30
+ }
31
+
32
+ public function output_frontend_scripts( $form ) {
33
+ wp_register_script(
34
+ 'happyforms-select',
35
+ happyforms_get_plugin_url() . 'core/assets/js/lib/happyforms-select.js',
36
+ array( 'jquery' ), HAPPYFORMS_VERSION, true
37
+ );
38
+
39
+ wp_register_script( 'happyforms-settings', '', array(), HAPPYFORMS_VERSION, true );
40
+
41
+ $settings = apply_filters( 'happyforms_frontend_settings', array(
42
+ 'ajaxUrl' => admin_url( 'admin-ajax.php' )
43
+ ) );
44
+
45
+ wp_localize_script( 'happyforms-settings', '_happyFormsSettings', $settings );
46
+
47
+ $dependencies = apply_filters(
48
+ 'happyforms_frontend_dependencies',
49
+ array( 'jquery', 'jquery-ui-core', 'jquery-ui-tooltip', 'happyforms-settings' ), [ $form ]
50
+ );
51
+
52
+ wp_register_script(
53
+ 'happyforms-frontend',
54
+ happyforms_get_plugin_url() . 'inc/assets/js/frontend.js',
55
+ $dependencies, HAPPYFORMS_VERSION, true
56
+ );
57
+
58
+ if ( wp_doing_ajax() ) {
59
+ global $wp_scripts;
60
+
61
+ add_filter( 'script_loader_tag', function( $tag, $handle, $src ) {
62
+ return '';
63
+ }, 10, 3 );
64
+
65
+ wp_scripts()->all_deps( 'happyforms-frontend' );
66
+
67
+ $queue = array();
68
+
69
+ foreach ( wp_scripts()->to_do as $handle ) {
70
+ $dep = wp_scripts()->registered[ $handle ];
71
+
72
+ if ( $dep->src ) {
73
+ $queue[] = array(
74
+ 'id' => $handle,
75
+ 'src' => $dep->src
76
+ );
77
+ }
78
+
79
+ wp_scripts()->print_extra_script( $handle );
80
+ }
81
+
82
+ wp_scripts()->print_extra_script( 'happyforms-frontend' );
83
+ ?>
84
+ <script type="text/javascript">
85
+ var queue = <?php echo json_encode( $queue ); ?>;
86
+ var loaded = 0;
87
+
88
+ queue = queue.filter( function( item ) {
89
+ if ( document.querySelector( 'script[id="' + item.id + '-js"]' ) ) {
90
+ return false;
91
+ }
92
+
93
+ return true;
94
+ } );
95
+
96
+ function enqueueNextScript() {
97
+ if ( queue.length === 0 ) {
98
+ jQuery( '.happyforms-form' ).happyForm();
99
+ return;
100
+ }
101
+
102
+ var item = queue.shift();
103
+ var script = document.createElement( 'script' );
104
+ script.id = item.id + '-js';
105
+ script.src = item.src;
106
+
107
+ script.addEventListener( 'load', function() {
108
+ enqueueNextScript();
109
+ } );
110
+
111
+ document.body.appendChild( script );
112
+ }
113
+
114
+ enqueueNextScript();
115
+ </script>
116
+ <?php
117
+ } else {
118
+ wp_scripts()->print_scripts( 'happyforms-frontend' );
119
+ }
120
+
121
+ wp_deregister_script( 'happyforms-frontend' );
122
+
123
+ do_action( 'happyforms_print_scripts', [ $form ] );
124
+ }
125
+
126
+ public function output( $form, $mode = self::MODE_COMPLETE ) {
127
+ switch( $mode ) {
128
+ case self::MODE_NONE:
129
+ break;
130
+ case self::MODE_ADMIN:
131
+ case self::MODE_BLOCK:
132
+ $this->output_frontend_styles( $form );
133
+ $this->output_admin_styles( $form );
134
+ break;
135
+ case self::MODE_CUSTOMIZER:
136
+ $this->output_frontend_styles( $form );
137
+ $this->output_admin_styles( $form );
138
+ $this->output_frontend_scripts( $form );
139
+ break;
140
+ case self::MODE_COMPLETE:
141
+ $this->output_frontend_styles( $form );
142
+ $this->output_frontend_scripts( $form );
143
+ break;
144
+ }
145
+ }
146
+
147
+ public function print_frontend_styles( $form ) {
148
+ wp_register_style(
149
+ 'happyforms-color',
150
+ happyforms_get_frontend_stylesheet_url( 'color.css' ),
151
+ array(), HAPPYFORMS_VERSION
152
+ );
153
+
154
+ $dependencies = apply_filters(
155
+ 'happyforms_style_dependencies',
156
+ array( 'happyforms-color' ), [ $form ]
157
+ );
158
+
159
+ wp_register_style(
160
+ 'happyforms-layout',
161
+ happyforms_get_frontend_stylesheet_url( 'layout.css' ),
162
+ $dependencies, HAPPYFORMS_VERSION
163
+ );
164
+
165
+ wp_styles()->do_items( 'happyforms-layout' );
166
+
167
+ wp_deregister_style( 'happyforms-layout' );
168
+
169
+ do_action( 'happyforms_print_frontend_styles', $form );
170
+ }
171
+ }
172
+
173
+ if ( ! function_exists( 'happyforms_get_form_assets' ) ):
174
+
175
+ function happyforms_get_form_assets() {
176
+ return HappyForms_Form_Assets::instance();
177
+ }
178
+
179
+ endif;
180
+
181
+ happyforms_get_form_assets();
core/classes/class-form-controller.php CHANGED
@@ -777,29 +777,27 @@ class HappyForms_Form_Controller {
777
  *
778
  * @return string
779
  */
780
- public function render( $form = array(), $render_styles = false ) {
781
- $form_markup = '';
782
 
783
  if ( empty( $form ) ) {
784
- return $form_markup;
785
  }
786
 
787
- if ( 'publish' === $form['post_status'] || happyforms_is_preview() ) {
788
- ob_start();
789
-
790
- if ( $render_styles ) {
791
- happyforms_the_form_styles( $form );
792
- }
793
 
794
- happyforms_additional_css( $form );
795
 
796
- $template_path = happyforms_get_core_folder() . '/templates/single-form.php';
797
- $template_path = apply_filters( 'happyforms_form_template_path', $template_path, $form );
798
- require( $template_path );
799
- $form_markup = ob_get_clean();
800
- }
 
801
 
802
- return $form_markup;
803
  }
804
 
805
  public function render_title( $form ) {
@@ -809,7 +807,7 @@ class HappyForms_Form_Controller {
809
  }
810
 
811
  public function the_form_title( $form_title, $before, $after, $form ) {
812
- if ( 'happyforms-form--hide-title' === happyforms_get_form_property( $form, 'form_title' ) ) {
813
  $form_title = '';
814
  }
815
 
777
  *
778
  * @return string
779
  */
780
+ public function render( $form = array(), $asset_mode = HappyForms_Form_Assets::MODE_NONE ) {
781
+ $html = '';
782
 
783
  if ( empty( $form ) ) {
784
+ return $html;
785
  }
786
 
787
+ if ( 'publish' !== $form['post_status'] && ! happyforms_is_preview() ) {
788
+ return $html;
789
+ }
 
 
 
790
 
791
+ ob_start();
792
 
793
+ happyforms_get_form_assets()->output( $form, $asset_mode );
794
+
795
+ $template_path = happyforms_get_core_folder() . '/templates/single-form.php';
796
+ $template_path = apply_filters( 'happyforms_form_template_path', $template_path, $form );
797
+ require( $template_path );
798
+ $html = ob_get_clean();
799
 
800
+ return $html;
801
  }
802
 
803
  public function render_title( $form ) {
807
  }
808
 
809
  public function the_form_title( $form_title, $before, $after, $form ) {
810
+ if ( 'happyforms-form--hide-title' === happyforms_get_form_property( $form, 'form_title' ) && ! happyforms_is_preview() ) {
811
  $form_title = '';
812
  }
813
 
core/classes/class-form-styles.php CHANGED
@@ -234,7 +234,7 @@ class HappyForms_Form_Styles {
234
  'standard' => __( 'Standard', 'happyforms' ),
235
  'tooltip' => __( 'Tooltip', 'happyforms' ),
236
  ),
237
- 'target' => 'form_class',
238
  'sanitize' => 'sanitize_text_field'
239
  ),
240
  'part_value_alignment' => array(
234
  'standard' => __( 'Standard', 'happyforms' ),
235
  'tooltip' => __( 'Tooltip', 'happyforms' ),
236
  ),
237
+ 'target' => '',
238
  'sanitize' => 'sanitize_text_field'
239
  ),
240
  'part_value_alignment' => array(
core/classes/class-happyforms-core.php CHANGED
@@ -30,16 +30,7 @@ class HappyForms_Core {
30
  *
31
  * @var string
32
  */
33
- private $landing_page_url = 'https://www.happyforms.me';
34
-
35
- /**
36
- * List of forms found on current page.
37
- *
38
- * @since 1.3
39
- *
40
- * @var array
41
- */
42
- private $current_forms = array();
43
 
44
  /**
45
  * Whether or not frontend styles were loaded.
@@ -51,8 +42,6 @@ class HappyForms_Core {
51
  */
52
  private $frontend_color_styles = false;
53
 
54
- private $dependencies = array();
55
-
56
  /**
57
  * Action: initialize admin and frontend logic.
58
  *
@@ -74,6 +63,7 @@ class HappyForms_Core {
74
  require_once( happyforms_get_core_folder() . '/classes/class-validation-messages.php' );
75
 
76
  require_once( happyforms_get_core_folder() . '/classes/class-tracking.php' );
 
77
  require_once( happyforms_get_core_folder() . '/classes/class-form-controller.php' );
78
  require_once( happyforms_get_include_folder() . '/classes/class-message-controller.php' );
79
  require_once( happyforms_get_core_folder() . '/classes/class-email-message.php' );
@@ -108,12 +98,13 @@ class HappyForms_Core {
108
  add_shortcode( $this->branded_shortcode, array( $this, 'handle_shortcode' ) );
109
  add_shortcode( $this->shortcode, array( $this, 'handle_shortcode' ) );
110
  add_action( 'wp_head', array( $this, 'wp_head' ) );
111
- add_action( 'wp_print_footer_scripts', array( $this, 'wp_print_footer_scripts' ), 0 );
112
- add_action( 'wp_print_scripts', array( $this, 'exclude_scripts' ), 9999 );
113
- add_action( 'wp_print_footer_scripts', array( $this, 'exclude_scripts' ), 9999 );
114
- add_action( 'admin_print_footer_scripts', array( $this, 'wp_print_footer_scripts' ), 0 );
115
  add_action( 'admin_print_footer_scripts', array( $this, 'print_shortcode_template' ) );
116
 
 
 
 
 
117
  // Preview scripts and styles
118
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_preview' ) );
119
  add_action( 'wp_footer', array( $this, 'enqueue_scripts_preview' ) );
@@ -374,19 +365,6 @@ class HappyForms_Core {
374
  return $buttons;
375
  }
376
 
377
- /**
378
- * Enqueue a form to load assets for.
379
- *
380
- * @since 1.0
381
- *
382
- * @param array $form The form to enqueue.
383
- *
384
- * @return void
385
- */
386
- public function enqueue_form( $form ) {
387
- $this->current_forms[$form['ID']] = $form;
388
- }
389
-
390
  /**
391
  * Render the HappyForms shortcode.
392
  *
@@ -413,8 +391,24 @@ class HappyForms_Core {
413
  return '';
414
  }
415
 
416
- $output = $form_controller->render( $form, true );
417
- $this->enqueue_form( $form );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
 
419
  return $output;
420
  }
@@ -456,7 +450,7 @@ class HappyForms_Core {
456
  return;
457
  }
458
 
459
- $button_html = '<a href="#" class="button happyforms-editor-button" data-title="' . __( 'Add form', 'happyforms' ) . '"><span class="dashicons dashicons-format-status"></span><span>'. __( 'Add form', 'happyforms' ) .'</span></a>';
460
 
461
  add_action( 'admin_footer', array( $this, 'output_happyforms_modal' ) );
462
 
@@ -467,7 +461,7 @@ class HappyForms_Core {
467
  if ( ! is_admin() ) {
468
  return $plugins;
469
  }
470
-
471
  $plugins['happyforms_shortcode'] = happyforms_get_plugin_url() . 'core/assets/js/admin/shortcode.js';
472
 
473
  return $plugins;
@@ -490,129 +484,6 @@ class HappyForms_Core {
490
  require_once( happyforms_get_core_folder() . '/templates/admin-form-modal.php' );
491
  }
492
 
493
- public function print_frontend_styles( $form ) {
494
-
495
- $output = apply_filters( 'happyforms_enqueue_style', true );
496
- $force_styles = apply_filters( 'happyforms_force_styles', false );
497
-
498
- if ( $output && ! $this->frontend_color_styles ) {
499
- $this->frontend_color_styles = ! $force_styles;
500
- $color_url = happyforms_get_frontend_stylesheet_url( 'color.css' );
501
- ?>
502
- <link rel="stylesheet" property="stylesheet" href="<?php echo $color_url; ?>" />
503
- <?php
504
- }
505
-
506
- if ( $output && ! $this->frontend_styles ) {
507
- $this->frontend_styles = ! $force_styles;
508
- $url = happyforms_get_frontend_stylesheet_url( 'layout.css' );
509
- ?>
510
- <link rel="stylesheet" property="stylesheet" href="<?php echo $url; ?>" />
511
- <?php
512
- }
513
-
514
- do_action( 'happyforms_print_frontend_styles', $form );
515
- }
516
-
517
- /**
518
- * Action: enqueue scripts and styles
519
- * for the frontend part of the plugin.
520
- *
521
- * @since 1.0
522
- *
523
- * @hooked action wp_print_footer_scripts
524
- *
525
- * @return void
526
- */
527
- public function wp_print_footer_scripts() {
528
- if ( happyforms_is_preview() ) {
529
- $form_controller = happyforms_get_form_controller();
530
- $form = $form_controller->get( get_the_ID() );
531
- $this->current_forms[] = $form;
532
- }
533
-
534
- // Return early if no current forms
535
- // are being displayed.
536
- if ( empty( $this->current_forms ) ) {
537
- return;
538
- }
539
-
540
- if ( is_admin() && happyforms_is_gutenberg() ) {
541
- return;
542
- }
543
-
544
- wp_register_script(
545
- 'happyforms-select',
546
- happyforms_get_plugin_url() . 'core/assets/js/lib/happyforms-select.js',
547
- array( 'jquery' ), HAPPYFORMS_VERSION, true
548
- );
549
-
550
- wp_register_script( 'happyforms-settings', '', array(), HAPPYFORMS_VERSION, true );
551
-
552
- $settings = apply_filters( 'happyforms_frontend_settings', array(
553
- 'ajaxUrl' => admin_url( 'admin-ajax.php' )
554
- ) );
555
-
556
- wp_localize_script( 'happyforms-settings', '_happyFormsSettings', $settings );
557
-
558
- $dependencies = apply_filters(
559
- 'happyforms_frontend_dependencies',
560
- array( 'jquery', 'jquery-ui-core', 'jquery-ui-tooltip', 'happyforms-settings' ), $this->current_forms
561
- );
562
-
563
- $this->dependencies = $dependencies;
564
-
565
- wp_enqueue_script(
566
- 'happyforms-frontend',
567
- happyforms_get_plugin_url() . 'inc/assets/js/frontend.js',
568
- $dependencies, HAPPYFORMS_VERSION, true
569
- );
570
-
571
- /**
572
- * Output form-specific scripts and styles.
573
- *
574
- * @since 1.1
575
- *
576
- * @param array $forms Array of forms found in page.
577
- *
578
- * @return void
579
- */
580
- do_action( 'happyforms_footer', $this->current_forms );
581
- }
582
-
583
- public function exclude_scripts() {
584
- if ( ! happyforms_is_preview() ) {
585
- return;
586
- }
587
-
588
- global $wp_scripts;
589
-
590
- $allowed_scripts = array(
591
- 'customize-preview-widgets',
592
- 'customize-preview-nav-menus',
593
- 'customize-selective-refresh',
594
- 'utils',
595
- 'moxiejs',
596
- );
597
-
598
- $allowed_scripts = array_merge( $allowed_scripts, $this->dependencies );
599
- $registered_scripts = $wp_scripts->registered;
600
-
601
- foreach ( $allowed_scripts as $handle ) {
602
- array_merge( $allowed_scripts, $registered_scripts[$handle]->deps );
603
- }
604
-
605
- foreach ( $wp_scripts->registered as $handle => $script ) {
606
- if ( ! wp_script_is( $handle, 'enqueued' ) ) {
607
- continue;
608
- }
609
-
610
- if ( ! in_array( $handle, $allowed_scripts ) ) {
611
- wp_dequeue_script( $handle );
612
- }
613
- }
614
- }
615
-
616
  public function print_shortcode_template() {
617
  require_once( happyforms_get_core_folder() . '/templates/admin-shortcode.php' );
618
  }
@@ -666,6 +537,36 @@ class HappyForms_Core {
666
  require_once( happyforms_get_core_folder() . '/templates/preview-form-pencil.php' );
667
  }
668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  /**
670
  * Action: register the HappyForms widget.
671
  *
30
  *
31
  * @var string
32
  */
33
+ private $landing_page_url = 'https://www.happyforms.io';
 
 
 
 
 
 
 
 
 
34
 
35
  /**
36
  * Whether or not frontend styles were loaded.
42
  */
43
  private $frontend_color_styles = false;
44
 
 
 
45
  /**
46
  * Action: initialize admin and frontend logic.
47
  *
63
  require_once( happyforms_get_core_folder() . '/classes/class-validation-messages.php' );
64
 
65
  require_once( happyforms_get_core_folder() . '/classes/class-tracking.php' );
66
+ require_once( happyforms_get_core_folder() . '/classes/class-form-assets.php' );
67
  require_once( happyforms_get_core_folder() . '/classes/class-form-controller.php' );
68
  require_once( happyforms_get_include_folder() . '/classes/class-message-controller.php' );
69
  require_once( happyforms_get_core_folder() . '/classes/class-email-message.php' );
98
  add_shortcode( $this->branded_shortcode, array( $this, 'handle_shortcode' ) );
99
  add_shortcode( $this->shortcode, array( $this, 'handle_shortcode' ) );
100
  add_action( 'wp_head', array( $this, 'wp_head' ) );
101
+
 
 
 
102
  add_action( 'admin_print_footer_scripts', array( $this, 'print_shortcode_template' ) );
103
 
104
+ // Exclude 3rd party assets
105
+ add_action( 'wp_print_scripts', array( $this, 'exclude_scripts' ), PHP_INT_MAX );
106
+ add_action( 'wp_print_footer_scripts', array( $this, 'exclude_scripts' ), PHP_INT_MAX );
107
+
108
  // Preview scripts and styles
109
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_preview' ) );
110
  add_action( 'wp_footer', array( $this, 'enqueue_scripts_preview' ) );
365
  return $buttons;
366
  }
367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  /**
369
  * Render the HappyForms shortcode.
370
  *
391
  return '';
392
  }
393
 
394
+ $asset_mode = HappyForms_Form_Assets::MODE_COMPLETE;
395
+
396
+ // Classic editor
397
+ if ( is_admin() ) {
398
+ $asset_mode = HappyForms_Form_Assets::MODE_ADMIN;
399
+ }
400
+
401
+ // Customize screen
402
+ if ( happyforms_is_preview() ) {
403
+ $asset_mode = HappyForms_Form_Assets::MODE_ADMIN;
404
+ }
405
+
406
+ // Block editor
407
+ if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
408
+ $asset_mode = HappyForms_Form_Assets::MODE_ADMIN;
409
+ }
410
+
411
+ $output = $form_controller->render( $form, $asset_mode );
412
 
413
  return $output;
414
  }
450
  return;
451
  }
452
 
453
+ $button_html = '<a href="#" class="button happyforms-editor-button" data-title="' . __( 'Add Form', 'happyforms' ) . '"><span class="dashicons dashicons-feedback"></span><span>'. __( 'Add Form', 'happyforms' ) .'</span></a>';
454
 
455
  add_action( 'admin_footer', array( $this, 'output_happyforms_modal' ) );
456
 
461
  if ( ! is_admin() ) {
462
  return $plugins;
463
  }
464
+
465
  $plugins['happyforms_shortcode'] = happyforms_get_plugin_url() . 'core/assets/js/admin/shortcode.js';
466
 
467
  return $plugins;
484
  require_once( happyforms_get_core_folder() . '/templates/admin-form-modal.php' );
485
  }
486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  public function print_shortcode_template() {
488
  require_once( happyforms_get_core_folder() . '/templates/admin-shortcode.php' );
489
  }
537
  require_once( happyforms_get_core_folder() . '/templates/preview-form-pencil.php' );
538
  }
539
 
540
+ public function exclude_scripts() {
541
+ if ( ! happyforms_is_preview() ) {
542
+ return;
543
+ }
544
+
545
+ global $wp_scripts;
546
+
547
+ $allowed_scripts = array(
548
+ 'customize-preview-widgets',
549
+ 'customize-preview-nav-menus',
550
+ 'customize-selective-refresh',
551
+ 'utils',
552
+ 'moxiejs',
553
+ );
554
+
555
+ foreach ( $allowed_scripts as $handle ) {
556
+ array_merge( $allowed_scripts, $wp_scripts->registered[$handle]->deps );
557
+ }
558
+
559
+ foreach ( $wp_scripts->registered as $handle => $script ) {
560
+ if ( ! wp_script_is( $handle, 'enqueued' ) ) {
561
+ continue;
562
+ }
563
+
564
+ if ( ! in_array( $handle, $allowed_scripts ) ) {
565
+ wp_dequeue_script( $handle );
566
+ }
567
+ }
568
+ }
569
+
570
  /**
571
  * Action: register the HappyForms widget.
572
  *
core/classes/class-wp-customize-form-manager.php CHANGED
@@ -175,7 +175,7 @@ class HappyForms_WP_Customize_Form_Manager {
175
  $notice_content .= '<li>' . __( 'Select a form in the Form dropdown.', 'happyforms' ) . '</li>';
176
  $notice_content .= '<li>' . __( 'All done!', 'happyforms' ) . '</li>';
177
  $notice_content .= '</ol>';
178
- $notice_content .= '<p>' . sprintf( __( 'Still have questions? Head over to our <a href="%s" target="_blank">help guide</a>.', 'happyforms' ), 'https://happyforms.me/help-guide' ) . '</p>';
179
  } else {
180
  $notice_name = 'happyforms_form_saved';
181
  $notice_type = 'success';
175
  $notice_content .= '<li>' . __( 'Select a form in the Form dropdown.', 'happyforms' ) . '</li>';
176
  $notice_content .= '<li>' . __( 'All done!', 'happyforms' ) . '</li>';
177
  $notice_content .= '</ol>';
178
+ $notice_content .= '<p>' . sprintf( __( 'Still have questions? Head over to our <a href="%s" target="_blank">help guide</a>.', 'happyforms' ), 'https://happyforms.io/help-guide' ) . '</p>';
179
  } else {
180
  $notice_name = 'happyforms_form_saved';
181
  $notice_type = 'success';
core/classes/parts/class-part-multi-line-text.php CHANGED
@@ -180,17 +180,19 @@ class HappyForms_Part_MultiLineText extends HappyForms_Form_Part {
180
  public function validate_value( $value, $part = array(), $form = array() ) {
181
  $validated_value = $value;
182
 
183
- if ( 1 === $part['required'] && empty( $validated_value ) ) {
184
  $validated_value = new WP_Error( 'error', happyforms_get_validation_message( 'field_empty' ) );
185
  return $validated_value;
 
 
186
  }
187
 
188
  $limit_input = intval( $part['limit_input'] );
189
  $character_limit = intval( $part['character_limit'] );
190
  $character_limit = $limit_input ? $character_limit : 0;
191
- $character_limit_mode = $part['character_limit_mode'];
192
 
193
  if ( $character_limit > 0 ) {
 
194
  $character_count = strlen( $validated_value );
195
  $word_count = str_word_count( $validated_value );
196
 
180
  public function validate_value( $value, $part = array(), $form = array() ) {
181
  $validated_value = $value;
182
 
183
+ if ( 1 === $part['required'] && '' === $validated_value ) {
184
  $validated_value = new WP_Error( 'error', happyforms_get_validation_message( 'field_empty' ) );
185
  return $validated_value;
186
+ } else if ( false == $part['required'] && '' === $validated_value ) {
187
+ return $validated_value;
188
  }
189
 
190
  $limit_input = intval( $part['limit_input'] );
191
  $character_limit = intval( $part['character_limit'] );
192
  $character_limit = $limit_input ? $character_limit : 0;
 
193
 
194
  if ( $character_limit > 0 ) {
195
+ $character_limit_mode = $part['character_limit_mode'];
196
  $character_count = strlen( $validated_value );
197
  $word_count = str_word_count( $validated_value );
198
 
core/helpers/helper-form-templates.php CHANGED
@@ -836,7 +836,7 @@ if ( ! function_exists( 'happyforms_the_form_styles' ) ):
836
  * @return array
837
  */
838
  function happyforms_the_form_styles( $form ) {
839
- HappyForms()->print_frontend_styles( $form );
840
  $styles = happyforms_get_form_styles( $form );
841
  ?>
842
  <!-- HappyForms CSS variables -->
836
  * @return array
837
  */
838
  function happyforms_the_form_styles( $form ) {
839
+ happyforms_get_form_assets()->print_frontend_styles( $form );
840
  $styles = happyforms_get_form_styles( $form );
841
  ?>
842
  <!-- HappyForms CSS variables -->
core/templates/customize-controls/setup/upsell.php CHANGED
@@ -1,3 +1,3 @@
1
  <div class="customize-control customize-control--upsell" id="<?php echo $control['id']; ?>">
2
- <a href="https://happyforms.me/upgrade" target="_blank" class="external"><?php echo $control['label']; ?></a>
3
  </div>
1
  <div class="customize-control customize-control--upsell" id="<?php echo $control['id']; ?>">
2
+ <a href="https://happyforms.io/upgrade" target="_blank" class="external"><?php echo $control['label']; ?></a>
3
  </div>
core/templates/customize-form-part-logic.php CHANGED
@@ -1,5 +1,5 @@
1
  <div class="no-parts no-parts--show no-parts--small">
2
  <h3><?php _e( 'Logic', 'happyforms' ); ?></h3>
3
 
4
- <p class="description"><a href="https://happyforms.me/upgrade" target="_blank" class="external"><?php _e( 'Upgrade to add logic rule', 'happyforms' ); ?></a></p>
5
  </div>
1
  <div class="no-parts no-parts--show no-parts--small">
2
  <h3><?php _e( 'Logic', 'happyforms' ); ?></h3>
3
 
4
+ <p class="description"><a href="https://happyforms.io/upgrade" target="_blank" class="external"><?php _e( 'Upgrade to add logic rule', 'happyforms' ); ?></a></p>
5
  </div>
core/templates/customize-form-parts-drawer.php CHANGED
@@ -35,7 +35,7 @@
35
  <div class="happyforms-parts-list-item-title">
36
  <h3><%= part.label %></h3>
37
  <% if ( isDummy ) { %>
38
- <a href="https://happyforms.me/upgrade" target="_blank"><?php _e( 'Upgrade', 'happyforms' ); ?></a>
39
  <% } %>
40
  </div>
41
  <div class="happyforms-parts-list-item-description"><%= part.description %></div>
35
  <div class="happyforms-parts-list-item-title">
36
  <h3><%= part.label %></h3>
37
  <% if ( isDummy ) { %>
38
+ <a href="https://happyforms.io/upgrade" target="_blank"><?php _e( 'Upgrade', 'happyforms' ); ?></a>
39
  <% } %>
40
  </div>
41
  <div class="happyforms-parts-list-item-description"><%= part.description %></div>
core/templates/customize-form-setup-logic.php CHANGED
@@ -1,5 +1,5 @@
1
  <div class="happyforms-setup-logic-wrap">
2
  <div class="happyforms-logic-view">
3
- <a href="https://happyforms.me/upgrade" class="external" target="_blank"><?php _e( 'Upgrade to add logic rule', 'happyforms' ); ?></a>
4
  </div>
5
  </div>
1
  <div class="happyforms-setup-logic-wrap">
2
  <div class="happyforms-logic-view">
3
+ <a href="https://happyforms.io/upgrade" class="external" target="_blank"><?php _e( 'Upgrade to add logic rule', 'happyforms' ); ?></a>
4
  </div>
5
  </div>
core/templates/parts/frontend-radio.php CHANGED
@@ -14,7 +14,7 @@
14
  $checked = false;
15
 
16
  if ( is_string( $value ) ) {
17
- $checked = ! empty( $option['label'] ) ? checked( $value, $o, false ) : false;
18
  }
19
 
20
  if ( false === $checked ) {
@@ -38,7 +38,7 @@
38
  <?php if ( 'tooltip' !== $part['description_mode'] ) : ?>
39
  <?php happyforms_print_part_description( $part ); ?>
40
  <?php endif; ?>
41
-
42
  <?php happyforms_part_error_message( happyforms_get_part_name( $part, $form ) ); ?>
43
  </div>
44
  </div>
14
  $checked = false;
15
 
16
  if ( is_string( $value ) ) {
17
+ $checked = checked( $value, $o, false );
18
  }
19
 
20
  if ( false === $checked ) {
38
  <?php if ( 'tooltip' !== $part['description_mode'] ) : ?>
39
  <?php happyforms_print_part_description( $part ); ?>
40
  <?php endif; ?>
41
+
42
  <?php happyforms_part_error_message( happyforms_get_part_name( $part, $form ) ); ?>
43
  </div>
44
  </div>
core/templates/preview-form-edit.php CHANGED
@@ -9,10 +9,8 @@
9
  </head>
10
  <body class="happyforms-preview">
11
  <?php global $post; $form = happyforms_get_form_controller()->get( $post->ID ); ?>
12
- <?php happyforms_the_form_styles( $form ); ?>
13
- <?php happyforms_additional_css( $form ); ?>
14
  <?php include( happyforms_get_core_folder() . '/templates/single-form.php' ); ?>
15
-
16
  <?php wp_footer(); ?>
17
  </body>
18
  </html>
9
  </head>
10
  <body class="happyforms-preview">
11
  <?php global $post; $form = happyforms_get_form_controller()->get( $post->ID ); ?>
12
+ <?php happyforms_get_form_assets()->output( $form, HappyForms_Form_Assets::MODE_CUSTOMIZER ); ?>
 
13
  <?php include( happyforms_get_core_folder() . '/templates/single-form.php' ); ?>
 
14
  <?php wp_footer(); ?>
15
  </body>
16
  </html>
happyforms.php CHANGED
@@ -2,18 +2,18 @@
2
 
3
  /**
4
  * Plugin Name: Happyforms (free)
5
- * Plugin URI: https://happyforms.me
6
  * Description: We're changin' WordPress forms.
7
  * Author: Happyforms
8
- * Version: 1.10.0
9
- * Author URI: https://happyforms.me
10
- * Upgrade URI: https://happyforms.me/upgrade
11
  */
12
 
13
  /**
14
  * The current version of the plugin.
15
  */
16
- define( 'HAPPYFORMS_VERSION', '1.10.0' );
17
 
18
  if ( ! function_exists( 'happyforms_plugin_file' ) ):
19
  /**
2
 
3
  /**
4
  * Plugin Name: Happyforms (free)
5
+ * Plugin URI: https://happyforms.io
6
  * Description: We're changin' WordPress forms.
7
  * Author: Happyforms
8
+ * Version: 1.11.0
9
+ * Author URI: https://happyforms.io
10
+ * Upgrade URI: https://happyforms.io/upgrade
11
  */
12
 
13
  /**
14
  * The current version of the plugin.
15
  */
16
+ define( 'HAPPYFORMS_VERSION', '1.11.0' );
17
 
18
  if ( ! function_exists( 'happyforms_plugin_file' ) ):
19
  /**
languages/happyforms.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Happyforms (free) package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Happyforms (free) 1.10.0\n"
6
  "Report-Msgid-Bugs-To: https://thethemefoundry.com/support/\n"
7
- "POT-Creation-Date: 2021-02-16 14:03:18+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -14,8 +14,8 @@ msgstr ""
14
  "X-Generator: grunt-wp-i18n 0.4.9\n"
15
 
16
  #: core/classes/class-block.php:49 core/classes/class-form-controller.php:68
17
- #: core/classes/class-happyforms-core.php:174
18
- #: core/classes/class-happyforms-core.php:175
19
  #: core/classes/class-happyforms-widget.php:13
20
  msgid "Forms"
21
  msgstr ""
@@ -166,8 +166,8 @@ msgid "Form"
166
  msgstr ""
167
 
168
  #: core/classes/class-form-controller.php:70
169
- #: core/classes/class-happyforms-core.php:190
170
- #: core/classes/class-happyforms-core.php:191
171
  msgid "Add New"
172
  msgstr ""
173
 
@@ -198,8 +198,8 @@ msgstr ""
198
 
199
  #: core/classes/class-form-controller.php:79
200
  #: core/classes/class-form-controller.php:80
201
- #: core/classes/class-happyforms-core.php:182
202
- #: core/classes/class-happyforms-core.php:183
203
  msgid "All Forms"
204
  msgstr ""
205
 
@@ -891,28 +891,28 @@ msgstr ""
891
  msgid "Additional CSS"
892
  msgstr ""
893
 
 
 
 
 
 
894
  #: core/classes/class-happyforms-core.php:198
895
  #: core/classes/class-happyforms-core.php:199
896
- msgid "Activity"
897
  msgstr ""
898
 
899
  #: core/classes/class-happyforms-core.php:207
900
  #: core/classes/class-happyforms-core.php:208
901
- msgid "Integrations"
902
  msgstr ""
903
 
904
  #: core/classes/class-happyforms-core.php:216
905
  #: core/classes/class-happyforms-core.php:217
906
- msgid "Settings"
907
- msgstr ""
908
-
909
- #: core/classes/class-happyforms-core.php:225
910
- #: core/classes/class-happyforms-core.php:226
911
  msgid "Welcome"
912
  msgstr ""
913
 
914
- #: core/classes/class-happyforms-core.php:459
915
- msgid "Add form"
916
  msgstr ""
917
 
918
  #: core/classes/class-happyforms-widget.php:79
@@ -3513,7 +3513,7 @@ msgid "Happyforms (free)"
3513
  msgstr ""
3514
 
3515
  #. Author URI of the plugin/theme
3516
- msgid "https://happyforms.me"
3517
  msgstr ""
3518
 
3519
  #. Description of the plugin/theme
2
  # This file is distributed under the same license as the Happyforms (free) package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Happyforms (free) 1.11.0\n"
6
  "Report-Msgid-Bugs-To: https://thethemefoundry.com/support/\n"
7
+ "POT-Creation-Date: 2021-03-03 15:42:35+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
14
  "X-Generator: grunt-wp-i18n 0.4.9\n"
15
 
16
  #: core/classes/class-block.php:49 core/classes/class-form-controller.php:68
17
+ #: core/classes/class-happyforms-core.php:165
18
+ #: core/classes/class-happyforms-core.php:166
19
  #: core/classes/class-happyforms-widget.php:13
20
  msgid "Forms"
21
  msgstr ""
166
  msgstr ""
167
 
168
  #: core/classes/class-form-controller.php:70
169
+ #: core/classes/class-happyforms-core.php:181
170
+ #: core/classes/class-happyforms-core.php:182
171
  msgid "Add New"
172
  msgstr ""
173
 
198
 
199
  #: core/classes/class-form-controller.php:79
200
  #: core/classes/class-form-controller.php:80
201
+ #: core/classes/class-happyforms-core.php:173
202
+ #: core/classes/class-happyforms-core.php:174
203
  msgid "All Forms"
204
  msgstr ""
205
 
891
  msgid "Additional CSS"
892
  msgstr ""
893
 
894
+ #: core/classes/class-happyforms-core.php:189
895
+ #: core/classes/class-happyforms-core.php:190
896
+ msgid "Activity"
897
+ msgstr ""
898
+
899
  #: core/classes/class-happyforms-core.php:198
900
  #: core/classes/class-happyforms-core.php:199
901
+ msgid "Integrations"
902
  msgstr ""
903
 
904
  #: core/classes/class-happyforms-core.php:207
905
  #: core/classes/class-happyforms-core.php:208
906
+ msgid "Settings"
907
  msgstr ""
908
 
909
  #: core/classes/class-happyforms-core.php:216
910
  #: core/classes/class-happyforms-core.php:217
 
 
 
 
 
911
  msgid "Welcome"
912
  msgstr ""
913
 
914
+ #: core/classes/class-happyforms-core.php:453
915
+ msgid "Add Form"
916
  msgstr ""
917
 
918
  #: core/classes/class-happyforms-widget.php:79
3513
  msgstr ""
3514
 
3515
  #. Author URI of the plugin/theme
3516
+ msgid "https://happyforms.io"
3517
  msgstr ""
3518
 
3519
  #. Description of the plugin/theme
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: contact form, contact form plugin, forms, form builder, custom form, intak
5
  Requires at least: 4.8
6
  Tested up to: 5.6
7
  Requires PHP: 5.3
8
- Stable tag: 1.10.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -15,9 +15,9 @@ The WordPress form builder you need to manage and respond to conversations with
15
 
16
  https://www.youtube.com/watch?v=X1snk2vJbXI
17
 
18
- [HappyForms](https://happyforms.me/) is the simplest way for you to manage and respond to conversations with your website visitors. With over 10 years of experience here at The Theme Foundry, we've heard from nearly 1,000,000 business what they need from a form builder! We've heard about the wasted time trying to set up tricky forms; the frustration of emails not being delivered; and the let down of not hearing from leads. That’s why we created HappyForms: Your free and friendly drag and drop form builder for creating contact forms, lead generation forms, feedback forms, quote forms, survey forms and more! HappyForms is optimized to increase conversations with your website visitors. Have peace of mind knowing messages to-and-from are getting delivered without the hassle of spam. You'll be set up and going in 5 minutes or less.
19
 
20
- [Discover all the benefits of upgrading.](https://happyforms.me/upgrade) 🚀
21
 
22
  = HappyForms solves these struggles: =
23
 
@@ -78,7 +78,7 @@ https://www.youtube.com/watch?v=X1snk2vJbXI
78
  * Get access to our growing Slack community.
79
  * Unlimited personal and client use plans.
80
 
81
- [Discover all the benefits of upgrading.](https://happyforms.me/upgrade) 🚀
82
 
83
  == Frequently Asked Questions ==
84
 
@@ -144,6 +144,13 @@ Note: you'll need to upgrade to our paid contact form builder plugin to get some
144
 
145
  == Changelog ==
146
 
 
 
 
 
 
 
 
147
  = 1.10.0 =
148
  * New feature: Messages tab in Edit Form screen allows for complete language customization.
149
  * New feature: Prefill control for setting a default value on Short Text, Long Text, Email Address and Number fields.
@@ -750,6 +757,9 @@ Note: you'll need to upgrade to our paid contact form builder plugin to get some
750
 
751
  == Upgrade Notice ==
752
 
 
 
 
753
  = 1.10.0 =
754
  * New Messages tab, Prefill control, miscellaneous bugfixes.
755
 
5
  Requires at least: 4.8
6
  Tested up to: 5.6
7
  Requires PHP: 5.3
8
+ Stable tag: 1.11.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
15
 
16
  https://www.youtube.com/watch?v=X1snk2vJbXI
17
 
18
+ [HappyForms](https://happyforms.io/) is the simplest way for you to manage and respond to conversations with your website visitors. With over 10 years of experience here at The Theme Foundry, we've heard from nearly 1,000,000 business what they need from a form builder! We've heard about the wasted time trying to set up tricky forms; the frustration of emails not being delivered; and the let down of not hearing from leads. That’s why we created HappyForms: Your free and friendly drag and drop form builder for creating contact forms, lead generation forms, feedback forms, quote forms, survey forms and more! HappyForms is optimized to increase conversations with your website visitors. Have peace of mind knowing messages to-and-from are getting delivered without the hassle of spam. You'll be set up and going in 5 minutes or less.
19
 
20
+ [Discover all the benefits of upgrading.](https://happyforms.io/upgrade) 🚀
21
 
22
  = HappyForms solves these struggles: =
23
 
78
  * Get access to our growing Slack community.
79
  * Unlimited personal and client use plans.
80
 
81
+ [Discover all the benefits of upgrading.](https://happyforms.io/upgrade) 🚀
82
 
83
  == Frequently Asked Questions ==
84
 
144
 
145
  == Changelog ==
146
 
147
+ = 1.11.0 =
148
+ * Improvement: Better support for 3rd party popup plugins.
149
+ * Improvement: Better support for tab navigation in Dropdown field.
150
+ * Bugfix: Dropdown field searchable functionality was misbehaving.
151
+ * Bugfix: Form title "Display" control wasn't working.
152
+ * Bugfix: Validation of optional Long Answer fields with character counting was misbehaving.
153
+
154
  = 1.10.0 =
155
  * New feature: Messages tab in Edit Form screen allows for complete language customization.
156
  * New feature: Prefill control for setting a default value on Short Text, Long Text, Email Address and Number fields.
757
 
758
  == Upgrade Notice ==
759
 
760
+ = 1.11.0 =
761
+ * Better support for 3rd party popup plugins, miscellaneous improvements and bugfixes.
762
+
763
  = 1.10.0 =
764
  * New Messages tab, Prefill control, miscellaneous bugfixes.
765