Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions classes/factories/FrmFieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] : '';
Expand Down
24 changes: 24 additions & 0 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4444,4 +4444,28 @@ public static function print_setting_error( $args ) {
</span>
<?php
}

/**
* Check if GDPR is enabled.
*
* @since x.x
*
* @return bool
*/
public static function is_gdpr_enabled() {
$frm_settings = self::get_settings();
return $frm_settings->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;
}
}
73 changes: 73 additions & 0 deletions classes/helpers/FrmFieldGdprHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* GDPR field helper
*
* @since x.x
* @package Formidable
*/

if ( ! defined( 'ABSPATH' ) ) {
die( 'You are not allowed to call this page directly.' );
}

/**
* Class FrmFieldGdprHelper
*/
class FrmFieldGdprHelper {

/**
* Field type
*
* @since x.x
* @var string
*/
const FIELD_TYPE = 'gdpr';

/**
* Field class
*
* @since x.x
* @var string
*/
const FIELD_CLASS = 'FrmFieldGdpr';

/**
* Hide GDPR field
*
* @since x.x
* @return bool
*/
public static function hide_gdpr_field() {
$settings = FrmAppHelper::get_settings();
return ! $settings->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 '';
}
}
1 change: 1 addition & 0 deletions classes/helpers/FrmFieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,7 @@ public static function single_input_fields() {
'time',
'tag',
'password',
'gdpr',
);
return apply_filters( 'frm_single_input_fields', $fields );
}
Expand Down
41 changes: 24 additions & 17 deletions classes/models/FrmField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
);

/**
Expand Down Expand Up @@ -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 ] ) ) {
Comment thread
Crabcyborg marked this conversation as resolved.
$new_values[ $col ] = $values[ $col ];
}
}

$new_values['options'] = self::maybe_filter_options( $values['options'] );
Expand Down
4 changes: 3 additions & 1 deletion classes/models/FrmSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
}
Expand Down
Loading