diff --git a/classes/factories/FrmFieldFactory.php b/classes/factories/FrmFieldFactory.php
index c3850e7e1a..765469754c 100644
--- a/classes/factories/FrmFieldFactory.php
+++ b/classes/factories/FrmFieldFactory.php
@@ -91,24 +91,25 @@ public static function get_field_type( $field_type, $field = 0 ) {
*/
private static function get_field_type_class( $field_type ) {
$type_classes = array(
- 'text' => 'FrmFieldText',
- 'textarea' => 'FrmFieldTextarea',
- 'select' => 'FrmFieldSelect',
- 'radio' => 'FrmFieldRadio',
- 'checkbox' => 'FrmFieldCheckbox',
- 'number' => 'FrmFieldNumber',
- 'phone' => 'FrmFieldPhone',
- 'url' => 'FrmFieldUrl',
- 'website' => 'FrmFieldUrl',
- 'email' => 'FrmFieldEmail',
- 'user_id' => 'FrmFieldUserID',
- 'html' => 'FrmFieldHTML',
- 'hidden' => 'FrmFieldHidden',
- 'captcha' => 'FrmFieldCaptcha',
- 'name' => 'FrmFieldName',
- 'credit_card' => 'FrmFieldCreditCard',
+ 'text' => 'FrmFieldText',
+ 'textarea' => 'FrmFieldTextarea',
+ 'select' => 'FrmFieldSelect',
+ 'radio' => 'FrmFieldRadio',
+ 'checkbox' => 'FrmFieldCheckbox',
+ 'number' => 'FrmFieldNumber',
+ 'phone' => 'FrmFieldPhone',
+ 'url' => 'FrmFieldUrl',
+ 'website' => 'FrmFieldUrl',
+ 'email' => 'FrmFieldEmail',
+ 'user_id' => 'FrmFieldUserID',
+ 'html' => 'FrmFieldHTML',
+ 'hidden' => 'FrmFieldHidden',
+ 'captcha' => 'FrmFieldCaptcha',
+ 'name' => 'FrmFieldName',
+ 'credit_card' => 'FrmFieldCreditCard',
// Submit button field.
- FrmSubmitHelper::FIELD_TYPE => 'FrmFieldSubmit',
+ FrmSubmitHelper::FIELD_TYPE => 'FrmFieldSubmit',
+ FrmFieldGdprHelper::FIELD_TYPE => FrmFieldGdprHelper::get_gdpr_field_class( $field_type ),
);
$class = isset( $type_classes[ $field_type ] ) ? $type_classes[ $field_type ] : '';
diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php
index ef7d3a4e01..172e8de692 100644
--- a/classes/helpers/FrmAppHelper.php
+++ b/classes/helpers/FrmAppHelper.php
@@ -4444,4 +4444,28 @@ public static function print_setting_error( $args ) {
enable_gdpr || $frm_settings->no_ips || $frm_settings->custom_header_ip || $frm_settings->no_gdpr_cookies;
+ }
+
+ /**
+ * Check if GDPR cookies are disabled.
+ *
+ * @since x.x
+ *
+ * @return bool
+ */
+ public static function no_gdpr_cookies() {
+ $frm_settings = self::get_settings();
+ return $frm_settings->enable_gdpr && $frm_settings->no_gdpr_cookies;
+ }
}
diff --git a/classes/helpers/FrmFieldGdprHelper.php b/classes/helpers/FrmFieldGdprHelper.php
new file mode 100644
index 0000000000..2ee09d8c73
--- /dev/null
+++ b/classes/helpers/FrmFieldGdprHelper.php
@@ -0,0 +1,73 @@
+enable_gdpr;
+ }
+
+ /**
+ * Add GDPR field to form builder
+ *
+ * @since x.x
+ * @param array $fields
+ * @return array
+ */
+ public static function add_gdpr_field( $fields ) {
+ $fields[ self::FIELD_TYPE ] = array(
+ 'name' => __( 'GDPR', 'formidable' ),
+ 'icon' => 'frm_icon_font frm-gdpr-icon',
+ );
+ return $fields;
+ }
+
+ /**
+ * Initialize GDPR field Class name
+ *
+ * @since x.x
+ * @param string $field_type
+ * @return string
+ */
+ public static function get_gdpr_field_class( $field_type = '' ) {
+ if ( self::FIELD_TYPE === $field_type ) {
+ return self::FIELD_CLASS;
+ }
+ return '';
+ }
+}
diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php
index 92da9689c1..2f5fa1f3e8 100644
--- a/classes/helpers/FrmFieldsHelper.php
+++ b/classes/helpers/FrmFieldsHelper.php
@@ -1291,6 +1291,7 @@ public static function single_input_fields() {
'time',
'tag',
'password',
+ 'gdpr',
);
return apply_filters( 'frm_single_input_fields', $fields );
}
diff --git a/classes/models/FrmField.php b/classes/models/FrmField.php
index e7e62fbf1e..a6d12154fe 100644
--- a/classes/models/FrmField.php
+++ b/classes/models/FrmField.php
@@ -10,70 +10,75 @@ class FrmField {
public static function field_selection() {
$fields = array(
- 'text' => array(
+ 'text' => array(
'name' => __( 'Text', 'formidable' ),
'icon' => 'frm_icon_font frm_text2_icon',
),
- 'textarea' => array(
+ 'textarea' => array(
'name' => __( 'Paragraph', 'formidable' ),
'icon' => 'frm_icon_font frm_paragraph_icon',
),
- 'checkbox' => array(
+ 'checkbox' => array(
'name' => __( 'Checkboxes', 'formidable' ),
'icon' => 'frm_icon_font frm_check_square_icon',
),
- 'radio' => array(
+ 'radio' => array(
'name' => __( 'Radio Buttons', 'formidable' ),
'icon' => 'frm_icon_font frm_radio_checked_icon',
),
- 'select' => array(
+ 'select' => array(
'name' => __( 'Dropdown', 'formidable' ),
'icon' => 'frm_icon_font frm_caret_square_down_icon',
),
- 'email' => array(
+ 'email' => array(
'name' => __( 'Email', 'formidable' ),
'icon' => 'frm_icon_font frm_email_icon',
),
- 'url' => array(
+ 'url' => array(
'name' => __( 'Website/URL', 'formidable' ),
'icon' => 'frm_icon_font frm_link_icon',
),
- 'number' => array(
+ 'number' => array(
'name' => __( 'Number', 'formidable' ),
'icon' => 'frm_icon_font frm_hashtag_icon',
),
- 'name' => array(
+ 'name' => array(
'name' => __( 'Name', 'formidable' ),
'icon' => 'frm_icon_font frm_user_name_icon',
),
- 'phone' => array(
+ 'phone' => array(
'name' => __( 'Phone', 'formidable' ),
'icon' => 'frm_icon_font frm_phone_icon',
),
- 'html' => array(
+ 'html' => array(
'name' => __( 'HTML', 'formidable' ),
'icon' => 'frm_icon_font frm_code_icon',
),
- 'hidden' => array(
+ 'hidden' => array(
'name' => __( 'Hidden', 'formidable' ),
'icon' => 'frm_icon_font frm_eye_slash_icon',
),
- 'user_id' => array(
+ 'user_id' => array(
'name' => __( 'User ID', 'formidable' ),
'icon' => 'frm_icon_font frm_user_icon',
),
- 'captcha' => array(
+ 'captcha' => array(
'name' => self::get_captcha_field_name(),
'icon' => 'frm_icon_font frm_shield_check_icon',
),
- 'credit_card' => array(
+ 'credit_card' => array(
'name' => __( 'Payment', 'formidable' ),
'icon' => 'frm_icon_font frm_credit_card_icon',
),
- FrmSubmitHelper::FIELD_TYPE => array(
+ FrmSubmitHelper::FIELD_TYPE => array(
'name' => __( 'Submit', 'formidable' ),
'hide' => true,
),
+ FrmFieldGdprHelper::FIELD_TYPE => array(
+ 'name' => __( 'GDPR', 'formidable' ),
+ 'icon' => 'frm_icon_font frm-gdpr-icon',
+ 'hide' => FrmFieldGdprHelper::hide_gdpr_field(),
+ ),
);
/**
@@ -378,7 +383,9 @@ public static function create( $values, $return = true ) {
$values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) {
- $new_values[ $col ] = $values[ $col ];
+ if ( isset( $values[ $col ] ) ) {
+ $new_values[ $col ] = $values[ $col ];
+ }
}
$new_values['options'] = self::maybe_filter_options( $values['options'] );
diff --git a/classes/models/FrmSettings.php b/classes/models/FrmSettings.php
index 76f1f27283..2c7970d0ab 100644
--- a/classes/models/FrmSettings.php
+++ b/classes/models/FrmSettings.php
@@ -151,6 +151,8 @@ public function default_options() {
'new_tab_msg' => __( 'The page has been opened in a new tab.', 'formidable' ),
'email_to' => '[admin_email]',
+ 'enable_gdpr' => 0,
+ 'no_gdpr_cookies' => 0,
'no_ips' => 0,
'custom_header_ip' => 0,
'tracking' => FrmAppHelper::pro_is_installed(),
@@ -399,7 +401,7 @@ private function update_settings( $params ) {
$this->from_email = $params['frm_from_email'];
$this->currency = $params['frm_currency'];
- $checkboxes = array( 'mu_menu', 're_multi', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar', 'summary_emails' );
+ $checkboxes = array( 'mu_menu', 're_multi', 'fade_form', 'no_ips', 'no_gdpr_cookies', 'enable_gdpr', 'custom_header_ip', 'tracking', 'admin_bar', 'summary_emails' );
foreach ( $checkboxes as $set ) {
$this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
}
diff --git a/classes/models/fields/FrmFieldGdpr.php b/classes/models/fields/FrmFieldGdpr.php
new file mode 100644
index 0000000000..101023661d
--- /dev/null
+++ b/classes/models/fields/FrmFieldGdpr.php
@@ -0,0 +1,158 @@
+ false,
+ 'description' => false,
+ 'type' => $this->type,
+ 'options' => false,
+ 'required' => false,
+ 'field_options' => false,
+ );
+ }
+
+ return array(
+ 'name' => $this->get_new_field_name() . __( ' Consent', 'formidable' ),
+ 'description' => '',
+ 'type' => $this->type,
+ 'options' => '',
+ 'required' => true,
+ 'field_options' => $this->get_default_field_options(),
+ );
+ }
+
+ /**
+ * Get the field settings for the field type.
+ *
+ * @since x.x
+ * @return bool[]
+ */
+ protected function field_settings_for_type() {
+ if ( FrmFieldGdprHelper::hide_gdpr_field() ) {
+ return array(
+ 'size' => false,
+ 'clear_on_focus' => false,
+ 'default' => false,
+ 'invalid' => false,
+ 'max' => false,
+ 'required' => false,
+ 'label' => false,
+ 'css' => false,
+ 'label_position' => false,
+ 'description' => false,
+ );
+ }
+
+ return array(
+ 'size' => true,
+ 'clear_on_focus' => false,
+ 'default' => false,
+ 'invalid' => false,
+ 'max' => false,
+ 'readonly_required' => true,
+ 'required' => true,
+ );
+ }
+
+ /**
+ * Show the primary options for the field.
+ *
+ * @since x.x
+ * @param array $args The arguments.
+ */
+ public function show_primary_options( $args ) {
+ if ( FrmFieldGdprHelper::hide_gdpr_field() ) {
+ return;
+ }
+ $field = $args['field'];
+ include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/gdpr/primary-options.php';
+ }
+
+ public function show_label_on_form_builder() {
+ if ( FrmFieldGdprHelper::hide_gdpr_field() ) {
+ return;
+ }
+ parent::show_label_on_form_builder();
+ }
+
+ /**
+ * Gets extra field options.
+ *
+ * @since x.x
+ * @return string[]
+ */
+ protected function extra_field_opts() {
+ return array(
+ 'gdpr_agreement_text' => __( 'I consent to having this website store my submitted information so they can respond to my inquiry.', 'formidable' ),
+ );
+ }
+
+ /**
+ * Include the form builder file.
+ *
+ * @since x.x
+ * @return string
+ */
+ protected function include_form_builder_file() {
+ return FrmAppHelper::plugin_path() . self::VIEW_PATH;
+ }
+
+ /**
+ * Include the front form file.
+ *
+ * @since x.x
+ * @return string
+ */
+ protected function include_front_form_file() {
+ return FrmAppHelper::plugin_path() . self::VIEW_PATH;
+ }
+
+ /**
+ * Hide the field name/label if the GDPR field is disabled.
+ *
+ * @since x.x
+ *
+ * @param array $args The arguments.
+ * @param string $html The HTML.
+ * @return string
+ */
+ protected function before_replace_html_shortcodes( $args, $html ) {
+ if ( FrmFieldGdprHelper::hide_gdpr_field() && ! current_user_can( 'frm_edit_forms' ) ) {
+ return '';
+ }
+ return $html;
+ }
+}
diff --git a/classes/models/fields/FrmFieldType.php b/classes/models/fields/FrmFieldType.php
index 001a27a5b1..0a213a8100 100644
--- a/classes/models/fields/FrmFieldType.php
+++ b/classes/models/fields/FrmFieldType.php
@@ -338,27 +338,28 @@ public function display_field_settings() {
*/
protected function default_field_settings() {
return array(
- 'type' => $this->type,
- 'label' => true,
- 'required' => true,
- 'unique' => false,
- 'read_only' => false,
- 'description' => true,
- 'options' => true,
- 'label_position' => true,
- 'invalid' => false,
- 'size' => false,
+ 'type' => $this->type,
+ 'label' => true,
+ 'required' => true,
+ 'readonly_required' => false,
+ 'unique' => false,
+ 'read_only' => false,
+ 'description' => true,
+ 'options' => true,
+ 'label_position' => true,
+ 'invalid' => false,
+ 'size' => false,
// Shows the placeholder option.
- 'clear_on_focus' => false,
- 'css' => true,
- 'conf_field' => false,
- 'max' => true,
- 'range' => false,
- 'captcha_size' => false,
- 'captcha_theme' => false,
- 'format' => false,
- 'show_image' => false,
- 'default' => true,
+ 'clear_on_focus' => false,
+ 'css' => true,
+ 'conf_field' => false,
+ 'max' => true,
+ 'range' => false,
+ 'captcha_size' => false,
+ 'captcha_theme' => false,
+ 'format' => false,
+ 'show_image' => false,
+ 'default' => true,
);
}
diff --git a/classes/views/frm-fields/back-end/gdpr/primary-options.php b/classes/views/frm-fields/back-end/gdpr/primary-options.php
new file mode 100644
index 0000000000..dd62cc7299
--- /dev/null
+++ b/classes/views/frm-fields/back-end/gdpr/primary-options.php
@@ -0,0 +1,25 @@
+
+
+
+
+
diff --git a/classes/views/frm-fields/back-end/settings.php b/classes/views/frm-fields/back-end/settings.php
index ac540e1a5f..73c3479b08 100644
--- a/classes/views/frm-fields/back-end/settings.php
+++ b/classes/views/frm-fields/back-end/settings.php
@@ -53,6 +53,23 @@
}
}
?>
+
+
+
+ 'width:24px' ) ); ?>
+
+ ', '' );
+ ?>
+
+
+
+