| Current Path : /home/bechata/mp/wp-content/uploads/2022/ejn73c/ |
| Current File : /home/bechata/mp/wp-content/uploads/2022/ejn73c/fields.tar |
class-evf-field-captcha.php 0000666 00000000773 15176450462 0011647 0 ustar 00 <?php
/**
* Captcha field
*
* @package EverestForms\Fields
* @since 1.6.5
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Captcha Class.
*/
class EVF_Field_Captcha extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Captcha', 'everest-forms' );
$this->type = 'captcha';
$this->icon = 'evf-icon evf-icon-captcha';
$this->order = 160;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-privacy-policy.php 0000666 00000001045 15176450462 0013207 0 ustar 00 <?php
/**
* Privacy Policy field
*
* @package EverestForms\Fields
* @since 1.7.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Privacy_Policy Class.
*/
class EVF_Field_Privacy_Policy extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Privacy Policy', 'everest-forms' );
$this->type = 'privacy-policy';
$this->icon = 'evf-icon evf-icon-privacy-policy';
$this->order = 180;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-image-upload.php 0000666 00000001016 15176450462 0012577 0 ustar 00 <?php
/**
* Image upload field
*
* @package EverestForms\Fields
* @since 1.3.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Image_Upload Class.
*/
class EVF_Field_Image_Upload extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = __( 'Image Upload', 'everest-forms' );
$this->type = 'image-upload';
$this->icon = 'evf-icon evf-icon-img-upload';
$this->order = 30;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-title.php 0000666 00000001011 15176450462 0011347 0 ustar 00 <?php
/**
* Section Title field.
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Title Class.
*/
class EVF_Field_Title extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Section Title', 'everest-forms' );
$this->type = 'title';
$this->icon = 'evf-icon evf-icon-section-divider';
$this->order = 90;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-country.php 0000666 00000000770 15176450462 0011744 0 ustar 00 <?php
/**
* Country field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Country Class.
*/
class EVF_Field_Country extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Country', 'everest-forms' );
$this->type = 'country';
$this->icon = 'evf-icon evf-icon-flag';
$this->order = 120;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-textarea.php 0000666 00000012524 15176450462 0012056 0 ustar 00 <?php
/**
* Textarea field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Textarea class.
*/
class EVF_Field_Textarea extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Paragraph Text', 'everest-forms' );
$this->type = 'textarea';
$this->icon = 'evf-icon evf-icon-paragraph';
$this->order = 40;
$this->group = 'general';
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'size',
'placeholder',
'label_hide',
'limit_length',
'default_value',
'css',
),
),
);
parent::__construct();
}
/**
* Hook in tabs.
*/
public function init_hooks() {
add_action( 'everest_forms_shortcode_scripts', array( $this, 'load_assets' ) );
}
/**
* Limit length field option.
*
* @param array $field Field settings.
*/
public function limit_length( $field ) {
// Limit length.
$args = array(
'slug' => 'limit_enabled',
'content' => $this->field_element(
'checkbox',
$field,
array(
'slug' => 'limit_enabled',
'value' => isset( $field['limit_enabled'] ),
'desc' => esc_html__( 'Limit Length', 'everest-forms' ),
'tooltip' => esc_html__( 'Check this option to limit text length by characters or words count.', 'everest-forms' ),
),
false
),
);
$this->field_element( 'row', $field, $args );
// Limit controls.
$count = $this->field_element(
'text',
$field,
array(
'type' => 'number',
'class' => 'small-text',
'slug' => 'limit_count',
'attrs' => array(
'min' => 1,
'step' => 1,
'pattern' => '[0-9]',
),
'value' => ! empty( $field['limit_count'] ) ? absint( $field['limit_count'] ) : 1,
),
false
);
$mode = $this->field_element(
'select',
$field,
array(
'slug' => 'limit_mode',
'class' => 'limit-select',
'value' => ! empty( $field['limit_mode'] ) ? esc_attr( $field['limit_mode'] ) : 'characters',
'options' => array(
'characters' => esc_html__( 'Characters', 'everest-forms' ),
'words' => esc_html__( 'Words Count', 'everest-forms' ),
),
),
false
);
$args = array(
'slug' => 'limit_controls',
'class' => ! isset( $field['limit_enabled'] ) ? 'everest-forms-hidden' : '',
'content' => $count . $mode,
);
$this->field_element( 'row', $field, $args );
}
/**
* Enqueue shortcode scripts.
*
* @param array $atts Shortcode Attributes.
*/
public function load_assets( $atts ) {
$form_id = isset( $atts['id'] ) ? wp_unslash( $atts['id'] ) : ''; // WPCS: CSRF ok, input var ok, sanitization ok.
$form_obj = evf()->form->get( $form_id );
$form_data = ! empty( $form_obj->post_content ) ? evf_decode( $form_obj->post_content ) : '';
// Leave only fields with limit.
if ( ! empty( $form_data['form_fields'] ) ) {
$form_fields = array_filter( $form_data['form_fields'], array( $this, 'field_is_limit' ) );
if ( count( $form_fields ) ) {
wp_enqueue_script( 'everest-forms-text-limit' );
}
}
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
$placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
// Label.
$this->field_preview_option( 'label', $field );
// Primary input.
echo '<textarea placeholder="' . esc_attr( $placeholder ) . '" class="widefat" disabled></textarea>';
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$value = '';
$primary = $field['properties']['inputs']['primary'];
if ( isset( $primary['attr']['value'] ) ) {
$value = evf_sanitize_textarea_field( $primary['attr']['value'] );
unset( $primary['attr']['value'] );
}
// Limit length.
if ( isset( $field['limit_enabled'] ) ) {
$limit_count = isset( $field['limit_count'] ) ? absint( $field['limit_count'] ) : 0;
$limit_mode = isset( $field['limit_mode'] ) ? sanitize_key( $field['limit_mode'] ) : 'characters';
$primary['data']['form-id'] = $form_data['id'];
$primary['data']['field-id'] = $field['id'];
if ( 'characters' === $limit_mode ) {
$primary['class'][] = 'everest-forms-limit-characters-enabled';
$primary['attr']['maxlength'] = $limit_count;
$primary['data']['text-limit'] = $limit_count;
} else {
$primary['class'][] = 'everest-forms-limit-words-enabled';
$primary['data']['text-limit'] = $limit_count;
}
}
// Primary field.
printf(
'<textarea %s %s>%s</textarea>',
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] ),
$value // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
class-evf-field-first-name.php 0000666 00000003636 15176450462 0012312 0 ustar 00 <?php
/**
* First name field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_First_Name class.
*/
class EVF_Field_First_Name extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'First Name', 'everest-forms' );
$this->type = 'first-name';
$this->icon = 'evf-icon evf-icon-first-name';
$this->order = 10;
$this->group = 'general';
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'placeholder',
'label_hide',
'default_value',
'css',
),
),
);
parent::__construct();
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
// Define data.
$placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
// Label.
$this->field_preview_option( 'label', $field );
// Primary input.
echo '<input type="text" placeholder="' . esc_attr( $placeholder ) . '" class="widefat" disabled>';
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$primary = $field['properties']['inputs']['primary'];
// Primary field.
printf(
'<input type="text" %s %s>',
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
}
}
class-evf-field-credit-card.php 0000666 00000001015 15176450462 0012413 0 ustar 00 <?php
/**
* Credit Card field
*
* @package EverestForms\Fields
* @since 1.4.9
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Credit_Card Class.
*/
class EVF_Field_Credit_Card extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Credit Card', 'everest-forms' );
$this->type = 'credit-card';
$this->icon = 'evf-icon evf-icon-payment';
$this->order = 50;
$this->group = 'payment';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-likert.php 0000666 00000000762 15176450462 0011534 0 ustar 00 <?php
/**
* Likert field
*
* @package EverestForms\Fields
* @since 1.4.3
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Likert Class.
*/
class EVF_Field_Likert extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Likert', 'everest-forms' );
$this->type = 'likert';
$this->icon = 'evf-icon evf-icon-likert';
$this->order = 20;
$this->group = 'survey';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-text.php 0000666 00000017104 15176450462 0011224 0 ustar 00 <?php
/**
* Text field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Text class.
*/
class EVF_Field_Text extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Single Line Text', 'everest-forms' );
$this->type = 'text';
$this->icon = 'evf-icon evf-icon-text';
$this->order = 30;
$this->group = 'general';
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'placeholder',
'label_hide',
'limit_length',
'default_value',
'css',
'input_mask',
),
),
);
parent::__construct();
}
/**
* Hook in tabs.
*/
public function init_hooks() {
add_action( 'everest_forms_shortcode_scripts', array( $this, 'load_assets' ) );
add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
}
/**
* Limit length field option.
*
* @param array $field Field settings.
*/
public function limit_length( $field ) {
// Limit length.
$args = array(
'slug' => 'limit_enabled',
'content' => $this->field_element(
'checkbox',
$field,
array(
'slug' => 'limit_enabled',
'value' => isset( $field['limit_enabled'] ),
'desc' => esc_html__( 'Limit Length', 'everest-forms' ),
'tooltip' => esc_html__( 'Check this option to limit text length by characters or words count.', 'everest-forms' ),
),
false
),
);
$this->field_element( 'row', $field, $args );
// Limit controls.
$count = $this->field_element(
'text',
$field,
array(
'type' => 'number',
'class' => 'small-text',
'slug' => 'limit_count',
'attrs' => array(
'min' => 1,
'step' => 1,
'pattern' => '[0-9]',
),
'value' => ! empty( $field['limit_count'] ) ? absint( $field['limit_count'] ) : 1,
),
false
);
$mode = $this->field_element(
'select',
$field,
array(
'slug' => 'limit_mode',
'class' => 'limit-select',
'value' => ! empty( $field['limit_mode'] ) ? esc_attr( $field['limit_mode'] ) : 'characters',
'options' => array(
'characters' => esc_html__( 'Characters', 'everest-forms' ),
'words' => esc_html__( 'Words Count', 'everest-forms' ),
),
),
false
);
$args = array(
'slug' => 'limit_controls',
'class' => ! isset( $field['limit_enabled'] ) ? 'everest-forms-hidden' : '',
'content' => $count . $mode,
);
$this->field_element( 'row', $field, $args );
}
/**
* Input mask field option.
*
* @param array $field Field settings.
*/
public function input_mask( $field ) {
// Input Mask.
$lbl = $this->field_element(
'label',
$field,
array(
'slug' => 'input_mask',
'value' => esc_html__( 'Input Mask', 'everest-forms' ),
'tooltip' => esc_html__( 'Enter your custom input mask.', 'everest-forms' ),
'after_tooltip' => '<a href="https://docs.wpeverest.com/docs/everest-forms/how-to-use-custom-input-mask/" class="after-label-description" target="_blank" rel="noopener noreferrer">' . esc_html__( 'See Examples & Docs', 'everest-forms' ) . '</a>',
),
false
);
$fld = $this->field_element(
'text',
$field,
array(
'slug' => 'input_mask',
'value' => ! empty( $field['input_mask'] ) ? esc_attr( $field['input_mask'] ) : '',
),
false
);
$this->field_element(
'row',
$field,
array(
'slug' => 'input_mask',
'content' => $lbl . $fld,
)
);
}
/**
* Enqueue shortcode scripts.
*
* @param array $atts Shortcode Attributes.
*/
public function load_assets( $atts ) {
$form_id = isset( $atts['id'] ) ? wp_unslash( $atts['id'] ) : ''; // WPCS: CSRF ok, input var ok, sanitization ok.
$form_obj = evf()->form->get( $form_id );
$form_data = ! empty( $form_obj->post_content ) ? evf_decode( $form_obj->post_content ) : '';
// Leave only fields with limit.
if ( ! empty( $form_data['form_fields'] ) ) {
$form_fields = array_filter( $form_data['form_fields'], array( $this, 'field_is_limit' ) );
if ( count( $form_fields ) ) {
wp_enqueue_script( 'everest-forms-text-limit' );
}
}
}
/**
* Define additional field properties.
*
* @since 1.0.0
*
* @param array $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array of additional field properties.
*/
public function field_properties( $properties, $field, $form_data ) {
// Input primary: Detect custom input mask.
if ( ! empty( $field['input_mask'] ) ) {
// Add class that will trigger custom mask.
$properties['inputs']['primary']['class'][] = 'evf-masked-input';
// Register string for translation.
$field['input_mask'] = evf_string_translation( $form_data['id'], $field['id'], $field['input_mask'], '-input-mask' );
if ( false !== strpos( $field['input_mask'], 'alias:' ) ) {
$mask = str_replace( 'alias:', '', $field['input_mask'] );
$properties['inputs']['primary']['data']['inputmask-alias'] = $mask;
} elseif ( false !== strpos( $field['input_mask'], 'regex:' ) ) {
$mask = str_replace( 'regex:', '', $field['input_mask'] );
$properties['inputs']['primary']['data']['inputmask-regex'] = $mask;
} elseif ( false !== strpos( $field['input_mask'], 'date:' ) ) {
$mask = str_replace( 'date:', '', $field['input_mask'] );
$properties['inputs']['primary']['data']['inputmask-alias'] = 'datetime';
$properties['inputs']['primary']['data']['inputmask-inputformat'] = $mask;
} else {
$properties['inputs']['primary']['data']['inputmask-mask'] = $field['input_mask'];
}
}
return $properties;
}
/**
* Field preview inside the builder.
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
// Define data.
$placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
// Label.
$this->field_preview_option( 'label', $field );
// Primary input.
echo '<input type="text" placeholder="' . esc_attr( $placeholder ) . '" class="widefat" disabled>';
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$primary = $field['properties']['inputs']['primary'];
// Limit length.
if ( isset( $field['limit_enabled'] ) ) {
$limit_count = isset( $field['limit_count'] ) ? absint( $field['limit_count'] ) : 0;
$limit_mode = isset( $field['limit_mode'] ) ? sanitize_key( $field['limit_mode'] ) : 'characters';
$primary['data']['form-id'] = $form_data['id'];
$primary['data']['field-id'] = $field['id'];
if ( 'characters' === $limit_mode ) {
$primary['class'][] = 'everest-forms-limit-characters-enabled';
$primary['attr']['maxlength'] = $limit_count;
$primary['data']['text-limit'] = $limit_count;
} else {
$primary['class'][] = 'everest-forms-limit-words-enabled';
$primary['data']['text-limit'] = $limit_count;
}
}
printf(
'<input type="text" %s %s>',
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
}
}
class-evf-field-hidden.php 0000666 00000000772 15176450462 0011476 0 ustar 00 <?php
/**
* Hidden field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Hidden Class.
*/
class EVF_Field_Hidden extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Hidden Field', 'everest-forms' );
$this->type = 'hidden';
$this->icon = 'evf-icon evf-icon-hidden';
$this->order = 50;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-payment-single.php 0000666 00000001042 15176450462 0013166 0 ustar 00 <?php
/**
* Payment Single Item field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Payment_Single Class.
*/
class EVF_Field_Payment_Single extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Single Item', 'everest-forms' );
$this->type = 'payment-single';
$this->icon = 'evf-icon evf-icon-single-item';
$this->order = 10;
$this->group = 'payment';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-range-slider.php 0000666 00000001031 15176450462 0012604 0 ustar 00 <?php
/**
* Range Slider field
*
* @package EverestForms\Fields
* @since 1.6.7
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Range_Slider Class.
*/
class EVF_Field_Range_Slider extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Range Slider', 'everest-forms' );
$this->type = 'range-slider';
$this->icon = 'evf-icon evf-icon-range-slider';
$this->order = 140;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-radio.php 0000666 00000030665 15176450462 0011345 0 ustar 00 <?php
/**
* Radio field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Radio class.
*/
class EVF_Field_Radio extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Multiple Choice', 'everest-forms' );
$this->type = 'radio';
$this->icon = 'evf-icon evf-icon-multiple-choices-radio';
$this->order = 60;
$this->group = 'general';
$this->defaults = array(
1 => array(
'label' => esc_html__( 'First Choice', 'everest-forms' ),
'value' => '',
'image' => '',
'default' => '',
),
2 => array(
'label' => esc_html__( 'Second Choice', 'everest-forms' ),
'value' => '',
'image' => '',
'default' => '',
),
3 => array(
'label' => esc_html__( 'Third Choice', 'everest-forms' ),
'value' => '',
'image' => '',
'default' => '',
),
);
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'choices',
'choices_images',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'randomize',
'show_values',
'input_columns',
'label_hide',
'css',
),
),
);
parent::__construct();
}
/**
* Hook in tabs.
*/
public function init_hooks() {
add_filter( 'everest_forms_html_field_value', array( $this, 'html_field_value' ), 10, 4 );
add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
}
/**
* Return images, if any, for HTML supported values.
*
* @since 1.6.0
*
* @param string $value Field value.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
* @param string $context Value display context.
*
* @return string
*/
public function html_field_value( $value, $field, $form_data = array(), $context = '' ) {
if ( is_serialized( $field ) || in_array( $context, array( 'email-html', 'export-pdf' ), true ) ) {
$field_value = maybe_unserialize( $field );
$field_type = isset( $field_value['type'] ) ? sanitize_text_field( $field_value['type'] ) : 'radio';
if ( $field_type === $this->type ) {
if (
'entry-table' !== $context
&& ! empty( $field_value['label'] )
&& ! empty( $field_value['image'] )
&& apply_filters( 'everest_forms_checkbox_field_html_value_images', true, $context )
) {
return sprintf(
'<span style="max-width:200px;display:block;margin:0 0 5px 0;"><img src="%s" style="max-width:100%%;display:block;margin:0;"></span>%s',
esc_url( $field_value['image'] ),
esc_html( $field_value['label'] )
);
} elseif ( isset( $field_value['label'] ) ) {
return esc_html( $field_value['label'] );
}
}
}
return $value;
}
/**
* Define additional field properties.
*
* @since 1.0.0
*
* @param array $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array of additional field properties.
*/
public function field_properties( $properties, $field, $form_data ) {
// Define data.
$form_id = absint( $form_data['id'] );
$field_id = $field['id'];
$choices = $field['choices'];
// Remove primary input.
unset( $properties['inputs']['primary'] );
// Set input container (ul) properties.
$properties['input_container'] = array(
'class' => array( ! empty( $field['random'] ) ? 'everest-forms-randomize' : '' ),
'data' => array(),
'attr' => array(),
'id' => "evf-{$form_id}-field_{$field_id}",
);
// Set input properties.
foreach ( $choices as $key => $choice ) {
$depth = isset( $choice['depth'] ) ? absint( $choice['depth'] ) : 1;
$properties['inputs'][ $key ] = array(
'container' => array(
'attr' => array(),
'class' => array( "choice-{$key}", "depth-{$depth}" ),
'data' => array(),
'id' => '',
),
'label' => array(
'attr' => array(
'for' => "evf-{$form_id}-field_{$field_id}_{$key}",
),
'class' => array( 'everest-forms-field-label-inline' ),
'data' => array(),
'id' => '',
'text' => evf_string_translation( $form_id, $field_id, $choice['label'], '-choice-' . $key ),
),
'attr' => array(
'name' => "everest_forms[form_fields][{$field_id}]",
'value' => isset( $field['show_values'] ) ? $choice['value'] : $choice['label'],
),
'class' => array( 'input-text' ),
'data' => array(),
'id' => "evf-{$form_id}-field_{$field_id}_{$key}",
'image' => isset( $choice['image'] ) ? $choice['image'] : '',
'required' => ! empty( $field['required'] ) ? 'required' : '',
'default' => isset( $choice['default'] ),
);
}
// Required class for validation.
if ( ! empty( $field['required'] ) ) {
$properties['input_container']['class'][] = 'evf-field-required';
}
// Custom properties if enabled image choices.
if ( ! empty( $field['choices_images'] ) ) {
$properties['input_container']['class'][] = 'everest-forms-image-choices';
foreach ( $properties['inputs'] as $key => $inputs ) {
$properties['inputs'][ $key ]['container']['class'][] = 'everest-forms-image-choices-item';
}
}
// Add selected class for choices with defaults.
foreach ( $properties['inputs'] as $key => $inputs ) {
if ( ! empty( $inputs['default'] ) ) {
$properties['inputs'][ $key ]['container']['class'][] = 'everest-forms-selected';
}
}
return $properties;
}
/**
* Randomize order of choices.
*
* @since 1.6.0
* @param array $field Field Data.
*/
public function randomize( $field ) {
$args = array(
'slug' => 'random',
'content' => $this->field_element(
'checkbox',
$field,
array(
'slug' => 'random',
'value' => isset( $field['random'] ) ? '1' : '0',
'desc' => esc_html__( 'Randomize Choices', 'everest-forms' ),
'tooltip' => esc_html__( 'Check this option to randomize the order of the choices.', 'everest-forms' ),
),
false
),
);
$this->field_element( 'row', $field, $args );
}
/**
* Show values field option.
*
* @param array $field Field Data.
*/
public function show_values( $field ) {
// Show Values toggle option. This option will only show if already used or if manually enabled by a filter.
if ( ! empty( $field['show_values'] ) || apply_filters( 'everest_forms_fields_show_options_setting', false ) ) {
$args = array(
'slug' => 'show_values',
'content' => $this->field_element(
'checkbox',
$field,
array(
'slug' => 'show_values',
'value' => isset( $field['show_values'] ) ? $field['show_values'] : '0',
'desc' => __( 'Show Values', 'everest-forms' ),
'tooltip' => __( 'Check this to manually set form field values.', 'everest-forms' ),
),
false
),
);
$this->field_element( 'row', $field, $args );
}
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
// Label.
$this->field_preview_option( 'label', $field );
// Choices.
$this->field_preview_option( 'choices', $field );
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$container = $field['properties']['input_container'];
$choices = $field['properties']['inputs'];
// List.
printf( '<ul %s>', evf_html_attributes( $container['id'], $container['class'], $container['data'], $container['attr'] ) );
foreach ( $choices as $choice ) {
if ( empty( $choice['container'] ) ) {
continue;
}
// Conditional logic.
if ( isset( $choices['primary'] ) ) {
$choice['attr']['conditional_id'] = $choices['primary']['attr']['conditional_id'];
if ( isset( $choices['primary']['attr']['conditional_rules'] ) ) {
$choice['attr']['conditional_rules'] = $choices['primary']['attr']['conditional_rules'];
}
}
printf( '<li %s>', evf_html_attributes( $choice['container']['id'], $choice['container']['class'], $choice['container']['data'], $choice['container']['attr'] ) );
if ( ! empty( $field['choices_images'] ) ) {
// Make image choices keyboard-accessible.
$choice['label']['attr']['tabindex'] = 0;
// Image choices.
printf( '<label %s>', evf_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ) );
if ( ! empty( $choice['image'] ) ) {
printf(
'<span class="everest-forms-image-choices-image"><img src="%s" alt="%s"%s></span>',
esc_url( $choice['image'] ),
esc_attr( $choice['label']['text'] ),
! empty( $choice['label']['text'] ) ? ' title="' . esc_attr( $choice['label']['text'] ) . '"' : ''
);
}
echo '<br>';
$choice['attr']['tabindex'] = '-1';
printf( '<input type="radio" %s %s %s>', evf_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ), esc_attr( $choice['required'] ), checked( '1', $choice['default'], false ) );
echo '<span class="everest-forms-image-choices-label">' . wp_kses_post( $choice['label']['text'] ) . '</span>';
echo '</label>';
} else {
// Normal display.
printf( '<input type="radio" %s %s %s>', evf_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ), esc_attr( $choice['required'] ), checked( '1', $choice['default'], false ) );
printf( '<label %s>%s</label>', evf_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ), wp_kses_post( $choice['label']['text'] ) );
}
echo '</li>';
}
echo '</ul>';
}
/**
* Edit form field display on the entry back-end.
*
* @since 1.7.0
*
* @param array $entry_field Entry field data.
* @param array $field Field data.
* @param array $form_data Form data and settings.
*/
public function edit_form_field_display( $entry_field, $field, $form_data ) {
$value = isset( $entry_field['value_raw'] ) ? $entry_field['value_raw'] : '';
$this->remove_field_choices_defaults( $field, $field['properties'] );
if ( '' !== $value ) {
$field['properties'] = $this->get_single_field_property_value( $value, 'primary', $field['properties'], $field );
}
$this->field_display( $field, null, $form_data );
}
/**
* Formats and sanitizes field.
*
* @since 1.0.0
*
* @param string $field_id Field Id.
* @param array $field_submit Submitted Field.
* @param array $form_data All Form Data.
* @param string $meta_key Field Meta Key.
*/
public function format( $field_id, $field_submit, $form_data, $meta_key ) {
$field = $form_data['form_fields'][ $field_id ];
$name = make_clickable( $field['label'] );
$value_raw = sanitize_text_field( $field_submit );
$choice_key = '';
$data = array(
'id' => $field_id,
'type' => $this->type,
'value' => array(
'name' => $name,
'type' => $this->type,
),
'meta_key' => $meta_key,
'value_raw' => $value_raw,
);
/*
* If show_values is true, that means values posted are the raw values
* and not the labels. So we need to get the label values.
*/
if ( ! empty( $field['show_values'] ) && '1' === $field['show_values'] ) {
foreach ( $field['choices'] as $key => $choice ) {
if ( $choice['value'] === $field_submit ) {
$data['value']['label'] = sanitize_text_field( $choice['label'] );
$choice_key = $key;
break;
}
}
} else {
$data['value']['label'] = $value_raw;
// Determine choice key, this is needed for image choices.
foreach ( $field['choices'] as $key => $choice ) {
if ( $choice['label'] === $field_submit ) {
$choice_key = $key;
break;
}
}
}
// Images choices are enabled, lookup and store image URL.
if ( ! empty( $choice_key ) && ! empty( $field['choices_images'] ) ) {
$data['value']['image'] = ! empty( $field['choices'][ $choice_key ]['image'] ) ? esc_url_raw( $field['choices'][ $choice_key ]['image'] ) : '';
}
// Push field details to be saved.
evf()->task->form_fields[ $field_id ] = $data;
}
}
class-evf-field-url.php 0000666 00000003600 15176450462 0011036 0 ustar 00 <?php
/**
* URL field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_URL class.
*/
class EVF_Field_URL extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Website / URL', 'everest-forms' );
$this->type = 'url';
$this->icon = 'evf-icon evf-icon-website';
$this->order = 10;
$this->group = 'advanced';
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'placeholder',
'label_hide',
'default_value',
'css',
),
),
);
parent::__construct();
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
// Define data.
$placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
// Label.
$this->field_preview_option( 'label', $field );
// Primary input.
echo '<input type="url" placeholder="' . esc_attr( $placeholder ) . '" class="widefat" disabled>';
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$primary = $field['properties']['inputs']['primary'];
// Primary field.
printf(
'<input type="url" %s %s>',
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
}
}
class-evf-field-payment-checkbox.php 0000666 00000001041 15176450462 0013472 0 ustar 00 <?php
/**
* Payment checkbox field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Payment_Checkbox Class.
*/
class EVF_Field_Payment_Checkbox extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Checkboxes', 'everest-forms' );
$this->type = 'payment-checkbox';
$this->icon = 'evf-icon evf-icon-checkbox';
$this->order = 30;
$this->group = 'payment';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-payment-quantity.php 0000666 00000001020 15176450462 0013557 0 ustar 00 <?php
/**
* Payment Quantity field
*
* @package EverestForms\Fields
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Payment_Quantity Class.
*/
class EVF_Field_Payment_Quantity extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Quantity', 'everest-forms' );
$this->type = 'payment-quantity';
$this->icon = 'evf-icon evf-icon-single-item';
$this->order = 40;
$this->group = 'payment';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-html.php 0000666 00000001001 15176450462 0011171 0 ustar 00 <?php
/**
* HTML block text field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_HTML Class.
*/
class EVF_Field_HTML extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Custom HTML', 'everest-forms' );
$this->type = 'html';
$this->icon = 'evf-icon evf-icon-custom-html';
$this->order = 80;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-signature.php 0000666 00000001011 15176450462 0012227 0 ustar 00 <?php
/**
* Signature field.
*
* @package EverestForms\Fields
* @since 1.4.7
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Signature Class.
*/
class EVF_Field_Signature extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Signature', 'everest-forms' );
$this->type = 'signature';
$this->icon = 'evf-icon evf-icon-signature';
$this->order = 100;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-email.php 0000666 00000032442 15176450462 0011331 0 ustar 00 <?php
/**
* Email field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Number class.
*/
class EVF_Field_Email extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Email', 'everest-forms' );
$this->type = 'email';
$this->icon = 'evf-icon evf-icon-email';
$this->order = 90;
$this->group = 'general';
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'description',
'required',
'required_field_message',
'confirmation',
),
),
'advanced-options' => array(
'field_options' => array(
'size',
'placeholder',
'confirmation_placeholder',
'label_hide',
'sublabel_hide',
'default_value',
'css',
),
),
);
parent::__construct();
}
/**
* Hook in tabs.
*/
public function init_hooks() {
add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
add_filter( 'everest_forms_field_new_required', array( $this, 'field_default_required' ), 5, 3 );
add_filter( 'everest_forms_builder_field_option_class', array( $this, 'field_option_class' ), 10, 2 );
}
/**
* Define additional field properties.
*
* @since 1.0.0
*
* @param array $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array of additional field properties.
*/
public function field_properties( $properties, $field, $form_data ) {
if ( empty( $field['confirmation'] ) ) {
return $properties;
}
$form_id = absint( $form_data['id'] );
$field_id = $field['id'];
$props = array(
'inputs' => array(
'primary' => array(
'block' => array(
'everest-forms-field-row-block',
'everest-forms-one-half',
'everest-forms-first',
),
'class' => array(
'everest-forms-field-email-primary',
),
'sublabel' => array(
'hidden' => ! empty( $field['sublabel_hide'] ),
'value' => esc_html__( 'Email', 'everest-forms' ),
),
),
'secondary' => array(
'attr' => array(
'name' => "everest_forms[form_fields][{$field_id}][secondary]",
'value' => '',
'placeholder' => ! empty( $field['confirmation_placeholder'] ) ? evf_string_translation( $form_id, $field_id, $field['confirmation_placeholder'], '-confirm-placeholder' ) : '',
),
'block' => array(
'everest-forms-field-row-block',
'everest-forms-one-half',
),
'class' => array(
'input-text',
'everest-forms-field-email-secondary',
),
'data' => array(
'rule-confirm' => '#' . $properties['inputs']['primary']['id'],
),
'id' => "evf-{$form_id}-field_{$field_id}-secondary",
'required' => ! empty( $field['required'] ) ? 'required' : '',
'sublabel' => array(
'hidden' => ! empty( $field['sublabel_hide'] ),
'value' => esc_html__( 'Confirm Email', 'everest-forms' ),
),
'value' => '',
),
),
);
$properties = array_merge_recursive( $properties, $props );
// Input Primary: adjust name.
$properties['inputs']['primary']['attr']['name'] = "everest_forms[form_fields][{$field_id}][primary]";
// Input Primary: remove error classes.
$properties['inputs']['primary']['class'] = array_diff(
$properties['inputs']['primary']['class'],
array(
'evf-error',
)
);
// Input Primary: add error class if needed.
if ( ! empty( $properties['error']['value']['primary'] ) ) {
$properties['inputs']['primary']['class'][] = 'evf-error';
}
// Input secondary: add error class if needed.
if ( ! empty( $properties['error']['value']['secondary'] ) ) {
$properties['inputs']['secondary']['class'][] = 'evf-error';
}
// Input Secondary: add required class if needed.
if ( ! empty( $field['required'] ) ) {
$properties['inputs']['secondary']['class'][] = 'evf-field-required';
}
return $properties;
}
/**
* Field should default to being required.
*
* @since 1.5.0
*
* @param bool $required Required status, true is required.
* @param array $field Field settings.
*
* @return bool
*/
public function field_default_required( $required, $field ) {
if ( 'email' === $field['type'] ) {
return true;
}
return $required;
}
/**
* Add class to field options wrapper to indicate if field confirmation is enabled.
*
* @param array $class Field class.
* @param array $field Field option data.
* @return array
*/
public function field_option_class( $class, $field ) {
if ( 'email' === $field['type'] ) {
if ( isset( $field['confirmation'] ) ) {
$class[] = 'everest-forms-confirm-enabled';
} else {
$class[] = 'everest-forms-confirm-disabled';
}
}
return $class;
}
/**
* Confirmation field option.
*
* @param array $field Field settings.
*/
public function confirmation( $field ) {
$fld = $this->field_element(
'checkbox',
$field,
array(
'slug' => 'confirmation',
'value' => isset( $field['confirmation'] ) ? '1' : '0',
'desc' => esc_html__( 'Enable Email Confirmation', 'everest-forms' ),
'tooltip' => esc_html__( 'Check to enable email confirmation.', 'everest-forms' ),
),
false
);
$args = array(
'slug' => 'confirmation',
'content' => $fld,
);
$this->field_element( 'row', $field, $args );
}
/**
* Confirmation Placeholder field option.
*
* @param array $field Field Data.
*/
public function confirmation_placeholder( $field ) {
$lbl = $this->field_element(
'label',
$field,
array(
'slug' => 'confirmation_placeholder',
'value' => esc_html__( 'Confirmation Placeholder Text', 'everest-forms' ),
'tooltip' => esc_html__( 'Enter text for the confirmation field placeholder.', 'everest-forms' ),
),
false
);
$fld = $this->field_element(
'text',
$field,
array(
'slug' => 'confirmation_placeholder',
'value' => ! empty( $field['confirmation_placeholder'] ) ? esc_attr( $field['confirmation_placeholder'] ) : '',
),
false
);
$args = array(
'slug' => 'confirmation_placeholder',
'content' => $lbl . $fld,
);
$this->field_element( 'row', $field, $args );
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
$placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
$confirm_placeholder = ! empty( $field['confirmation_placeholder'] ) ? esc_attr( $field['confirmation_placeholder'] ) : '';
$confirm = ! empty( $field['confirmation'] ) ? 'enabled' : 'disabled';
// Label.
$this->field_preview_option( 'label', $field );
?>
<div class="everest-forms-confirm everest-forms-confirm-<?php echo esc_attr( $confirm ); ?>">
<div class="everest-forms-confirm-primary">
<input type="email" placeholder="<?php echo esc_attr( $placeholder ); ?>" class="widefat primary-input" disabled>
<label class="everest-forms-sub-label"><?php esc_html_e( 'Email', 'everest-forms' ); ?></label>
</div>
<div class="everest-forms-confirm-confirmation">
<input type="email" placeholder="<?php echo esc_attr( $confirm_placeholder ); ?>" class="widefat secondary-input" disabled>
<label class="everest-forms-sub-label"><?php esc_html_e( 'Confirm Email', 'everest-forms' ); ?></label>
</div>
</div>
<?php
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$form_id = absint( $form_data['id'] );
$confirmation = ! empty( $field['confirmation'] );
$primary = $field['properties']['inputs']['primary'];
$secondary = ! empty( $field['properties']['inputs']['secondary'] ) ? $field['properties']['inputs']['secondary'] : '';
// Standard email field.
if ( ! $confirmation ) {
// Primary field.
printf(
'<input type="email" %s %s>',
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
// Confirmation email field configuration.
} else {
// Row wrapper.
echo '<div class="everest-forms-field-row everest-forms-field">';
// Primary field.
echo '<div ' . evf_html_attributes( false, $primary['block'] ) . '>';
printf(
'<input type="email" %s %s>',
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
$this->field_display_sublabel( 'primary', 'after', $field );
$this->field_display_error( 'primary', $field );
echo '</div>';
// Secondary field.
echo '<div ' . evf_html_attributes( false, $secondary['block'] ) . '>';
printf(
'<input type="email" %s %s>',
evf_html_attributes( $secondary['id'], $secondary['class'], $secondary['data'], $secondary['attr'] ),
esc_attr( $secondary['required'] )
);
$this->field_display_sublabel( 'secondary', 'after', $field );
$this->field_display_error( 'secondary', $field );
echo '</div>';
echo '</div>';
}
}
/**
* Edit form field display on the entry back-end.
*
* @since 1.7.0
*
* @param array $entry_field Entry field data.
* @param array $field Field data.
* @param array $form_data Form data and settings.
*/
public function edit_form_field_display( $entry_field, $field, $form_data ) {
$value = isset( $entry_field['value'] ) ? $entry_field['value'] : '';
// Unset confirmation.
unset( $field['confirmation'] );
if ( '' !== $value ) {
$field['properties'] = $this->get_single_field_property_value( $value, 'primary', $field['properties'], $field );
}
$this->field_display( $field, null, $form_data );
}
/**
* Validates field on form submit.
*
* @param int $field_id Field ID.
* @param array $field_submit Submitted data.
* @param array $form_data Form data.
*/
public function validate( $field_id, $field_submit, $form_data ) {
$form_id = (int) $form_data['id'];
$conditional_status = isset( $form_data['form_fields'][ $field_id ]['conditional_logic_status'] ) ? $form_data['form_fields'][ $field_id ]['conditional_logic_status'] : 0;
// Required check.
if ( ! empty( $form_data['form_fields'][ $field_id ]['required'] ) && '1' !== $conditional_status ) {
$required = evf_get_required_label();
// Standard configuration, confirmation disabled.
if ( empty( $form_data['form_fields'][ $field_id ]['confirmation'] ) ) {
if ( empty( $field_submit ) && '0' !== $field_submit ) {
evf()->task->errors[ $form_id ][ $field_id ] = $required;
update_option( 'evf_validation_error', 'yes' );
}
} else {
if ( empty( $field_submit['primary'] ) && '0' !== $field_submit ) {
evf()->task->errors[ $form_id ][ $field_id ]['primary'] = $required;
update_option( 'evf_validation_error', 'yes' );
}
if ( empty( $field_submit['secondary'] ) && '0' !== $field_submit ) {
evf()->task->errors[ $form_id ][ $field_id ]['secondary'] = $required;
update_option( 'evf_validation_error', 'yes' );
}
}
}
// If confirmation disabled, treat this way for primary email.
if ( ! is_array( $field_submit ) && ! empty( $field_submit ) ) {
$field_submit = array(
'primary' => $field_submit,
);
}
// Standard checks for valid email address and confirmation email match.
if ( ! empty( $field_submit['primary'] ) && ! is_email( $field_submit['primary'] ) ) {
$invalid_email = esc_html__( 'Please enter a valid email address.', 'everest-forms' );
if ( empty( $form_data['form_fields'][ $field_id ]['confirmation'] ) ) {
evf()->task->errors[ $form_id ][ $field_id ] = $invalid_email;
} else {
evf()->task->errors[ $form_id ][ $field_id ]['primary'] = $invalid_email;
}
update_option( 'evf_validation_error', 'yes' );
} elseif ( isset( $field_submit['primary'], $field_submit['secondary'] ) && $field_submit['secondary'] !== $field_submit['primary'] ) {
evf()->task->errors[ $form_id ][ $field_id ]['secondary'] = esc_html__( 'Confirmation Email do not match.', 'everest-forms' );
update_option( 'evf_validation_error', 'yes' );
}
}
/**
* Formats and sanitizes field.
*
* @param int $field_id Field ID.
* @param array $field_submit Submitted field value.
* @param array $form_data Form data and settings.
* @param string $meta_key Field meta key.
*/
public function format( $field_id, $field_submit, $form_data, $meta_key ) {
if ( is_array( $field_submit ) ) {
$value = ! empty( $field_submit['primary'] ) ? $field_submit['primary'] : '';
} else {
$value = ! empty( $field_submit ) ? $field_submit : '';
}
$name = ! empty( $form_data['form_fields'][ $field_id ]['label'] ) ? $form_data['form_fields'][ $field_id ]['label'] : '';
// Set final field details.
evf()->task->form_fields[ $field_id ] = array(
'name' => make_clickable( $name ),
'value' => sanitize_text_field( $value ),
'id' => $field_id,
'type' => $this->type,
'meta_key' => $meta_key,
);
}
}
class-evf-field-file-upload.php 0000666 00000001022 15176450462 0012431 0 ustar 00 <?php
/**
* File upload field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_File_Upload Class.
*/
class EVF_Field_File_Upload extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'File Upload', 'everest-forms' );
$this->type = 'file-upload';
$this->icon = 'evf-icon evf-icon-file-upload';
$this->order = 40;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-phone.php 0000666 00000000756 15176450462 0011356 0 ustar 00 <?php
/**
* Phone field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Phone Class.
*/
class EVF_Field_Phone extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Phone', 'everest-forms' );
$this->type = 'phone';
$this->icon = 'evf-icon evf-icon-phone';
$this->order = 60;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-divider.php 0000666 00000000773 15176450462 0011672 0 ustar 00 <?php
/**
* Divider field.
*
* @package EverestForms\Fields
* @since 1.7.5
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Divider Class.
*/
class EVF_Field_Divider extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Divider', 'everest-forms' );
$this->type = 'divider';
$this->icon = 'evf-icon evf-icon-divider';
$this->order = 87;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-rating.php 0000666 00000000760 15176450462 0011524 0 ustar 00 <?php
/**
* Rating field
*
* @package EverestForms\Fields
* @since 1.4.3
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Rating Class.
*/
class EVF_Field_Rating extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Rating', 'everest-forms' );
$this->type = 'rating';
$this->icon = 'evf-icon evf-icon-star';
$this->order = 10;
$this->group = 'survey';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-date-time.php 0000666 00000063402 15176450462 0012113 0 ustar 00 <?php
/**
* Date and Time field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Date_Time class.
*/
class EVF_Field_Date_Time extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Date / Time', 'everest-forms' );
$this->type = 'date-time';
$this->icon = 'evf-icon evf-icon-calendar';
$this->order = 20;
$this->group = 'advanced';
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'choose_format',
'choose_style',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'placeholder',
'datetime_options',
'label_hide',
'css',
),
),
);
parent::__construct();
}
/**
* Hook in tabs.
*/
public function init_hooks() {
add_action( 'everest_forms_shortcode_scripts', array( $this, 'load_assets' ) );
add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
}
/**
* Date field format option.
*
* @since 1.4.9
* @param array $field Field Data.
*/
public function choose_format( $field ) {
$format = ! empty( $field['datetime_format'] ) ? esc_attr( $field['datetime_format'] ) : 'date';
$format_label = $this->field_element(
'label',
$field,
array(
'slug' => 'datetime_format',
'value' => esc_html__( 'Format', 'everest-forms' ),
'tooltip' => esc_html__( 'Select a format for the date field.', 'everest-forms' ),
),
false
);
$format_select = $this->field_element(
'select',
$field,
array(
'slug' => 'datetime_format',
'value' => $format,
'options' => array(
'date' => esc_html__( 'Date', 'everest-forms' ),
'time' => esc_html__( 'Time', 'everest-forms' ),
'date-time' => esc_html__( 'Both', 'everest-forms' ),
),
),
false
);
$args = array(
'slug' => 'datetime_format',
'content' => $format_label . $format_select,
);
$this->field_element( 'row', $field, $args );
}
/**
* Date field style option.
*
* @since 1.7.5
* @param array $field Field Data.
*/
public function choose_style( $field ) {
$style = ! empty( $field['datetime_style'] ) ? esc_attr( $field['datetime_style'] ) : 'picker';
$style_label = $this->field_element(
'label',
$field,
array(
'slug' => 'datetime_style',
'value' => esc_html__( 'Style', 'everest-forms' ),
'tooltip' => esc_html__( 'Select a style for the date field.', 'everest-forms' ),
),
false
);
$style_select = $this->field_element(
'select',
$field,
array(
'slug' => 'datetime_style',
'value' => $style,
'options' => array(
'picker' => esc_html__( 'Date Picker', 'everest-forms' ),
'dropdown' => esc_html__( 'Date Dropdown', 'everest-forms' ),
),
),
false
);
$args = array(
'slug' => 'datetime_style',
'content' => $style_label . $style_select,
);
$this->field_element( 'row', $field, $args );
}
/**
* Date and time advanced field options.
*
* @since 1.4.9
* @param array $field Field Data.
*/
public function datetime_options( $field ) {
$format = ! empty( $field['datetime_format'] ) ? esc_attr( $field['datetime_format'] ) : 'date';
$class_name = isset( $field['enable_min_max'] ) && '1' === $field['enable_min_max'] ? '' : 'everest-forms-hidden';
$field['date_mode'] = isset( $field['date_mode'] ) ? $field['date_mode'] : 'single';
$field['date_mode'] = isset( $field['date_range'] ) && '1' === $field['date_range'] ? 'range' : $field['date_mode'];
$this->field_element(
'label',
$field,
array(
'slug' => 'datetime_advanced',
'value' => esc_html__( 'Date & Time Format', 'everest-forms' ),
'tooltip' => esc_html__( 'Advanced date and time formatting options.', 'everest-forms' ),
),
true
);
echo '<div class="format-selected-' . esc_attr( $format ) . ' format-selected">';
echo '<div class="everest-forms-border-container everest-forms-date">';
echo '<h4 class="everest-forms-border-container-title">' . esc_html__( 'Date', 'everest-forms' ) . '</h4>'; // phpcs:ignore WordPress.Security.NonceVerification
$date_format_label = $this->field_element(
'label',
$field,
array(
'slug' => 'date_format',
'value' => esc_html__( 'Date Format', 'everest-forms' ),
'tooltip' => esc_html__( 'Choose a desire date format to display.', 'everest-forms' ),
),
false
);
$date_format_select = $this->field_element(
'select',
$field,
array(
'slug' => 'date_format',
'value' => isset( $field['date_format'] ) ? $field['date_format'] : 'Y-m-d',
'class' => 'evf-date-format',
'options' => array(
'Y-m-d' => date_i18n( 'Y-m-d' ) . ' (Y-m-d)',
'F j, Y' => date_i18n( 'F j, Y' ) . ' (F j, Y)',
'm/d/Y' => date_i18n( 'm/d/Y' ) . ' (m/d/Y)',
'd/m/Y' => date_i18n( 'd/m/Y' ) . ' (d/m/Y)',
),
),
false
);
// Disable certain dates option.
$clear_disabled_dates_button = sprintf( '<a href="#" class="evf-clear-disabled-dates after-label-description">%s</a>', esc_html__( 'Clear', 'everest-forms' ) );
$disable_dates_label = $this->field_element(
'label',
$field,
array(
'slug' => 'disable_dates',
'value' => esc_html__( 'Disable Dates', 'everest-forms' ),
'tooltip' => esc_html__( 'Select which dates you want to disable.', 'everest-forms' ),
'after_tooltip' => $clear_disabled_dates_button,
),
false
);
$disable_dates = $this->field_element(
'text',
$field,
array(
'slug' => 'disable_dates',
'value' => isset( $field['disable_dates'] ) ? $field['disable_dates'] : '',
'class' => 'everest-forms-disable-dates',
'data' => array(
'date-format' => isset( $field['date_format'] ) ? $field['date_format'] : 'Y-m-d',
),
),
false
);
$current_date_mode = $this->field_element(
'radio',
$field,
array(
'slug' => 'date_mode',
'default' => isset( $field['date_mode'] ) ? $field['date_mode'] : 'single',
'desc' => esc_html__( 'Date Mode', 'everest-forms' ),
'tooltip' => esc_html__( 'Select your desire date mode.', 'everest-forms' ),
'options' => array(
'single' => 'Single',
'range' => 'Range',
'multiple' => 'Multiple',
),
),
false
);
$date_localization_label = $this->field_element(
'label',
$field,
array(
'slug' => 'date_localization',
'value' => esc_html__( 'Date Localization', 'everest-forms' ),
'tooltip' => esc_html__( 'Choose a desire date localization to display.', 'everest-forms' ),
),
false
);
$date_localization_select = $this->field_element(
'select',
$field,
array(
'slug' => 'date_localization',
'value' => isset( $field['date_localization'] ) ? $field['date_localization'] : 'en',
'options' => array(
'en' => 'English',
'ar' => 'Arabic',
'at' => 'Austria',
'az' => 'Azerbaijan',
'be' => 'Belarusian',
'bg' => 'Bulgarian',
'bn' => 'Bangla',
'bs' => 'Bosnian',
'cat' => 'Catalan',
'cs' => 'Czech',
'cy' => 'Welsh',
'da' => 'Danish',
'de' => 'German',
'eo' => 'Esperanto',
'es' => 'Spanish',
'et' => 'Estonian',
'fa' => 'Persian',
'fi' => 'Finnish',
'fo' => 'Faroese',
'fr' => 'French',
'ga' => 'Irish',
'gr' => 'Greek',
'he' => 'Hebrew',
'hi' => 'Hindi',
'hr' => 'Croatian',
'hu' => 'Hungarian',
'id' => 'Indonesian',
'is' => 'Icelandic',
'it' => 'Italian',
'ja' => 'Japanese',
'ka' => 'Georgian',
'ko' => 'Korean',
'km' => 'Khmer',
'kz' => 'Kazakh',
'lt' => 'Lithuanian',
'lv' => 'Latvian',
'mk' => 'Macedonian',
'mn' => 'Mongolian',
'ms' => 'Malaysian',
'my' => 'Burmese',
'nl' => 'Dutch',
'no' => 'Norwegian',
'pa' => 'Punjabi',
'pl' => 'Polish',
'pt' => 'Portuguese',
'ro' => 'Romanian',
'ru' => 'Russian',
'si' => 'Sinhala',
'sk' => 'Slovak',
'sl' => 'Slovenian',
'sq' => 'Albanian',
'sr' => 'Serbian',
'sv' => 'Swedish',
'th' => 'Thai',
'tr' => 'Turkish',
'uk' => 'Ukrainian',
'vn' => 'Vietnamese',
'zh' => 'Mandarin',
'zh_tw' => 'MandarinTraditional',
),
),
false
);
$current_date_default = $this->field_element(
'checkbox',
$field,
array(
'slug' => 'date_default',
'value' => isset( $field['date_default'] ) ? $field['date_default'] : '',
'desc' => esc_html__( 'Default to current date.', 'everest-forms' ),
'tooltip' => esc_html__( 'Check this option to set current date as default.', 'everest-forms' ),
),
false
);
$enable_min_max = $this->field_element(
'checkbox',
$field,
array(
'slug' => 'enable_min_max',
'value' => isset( $field['enable_min_max'] ) ? $field['enable_min_max'] : '',
'desc' => esc_html__( 'Enable Min Max date.', 'everest-forms' ),
'tooltip' => esc_html__( 'Check this option to set min max date.', 'everest-forms' ),
),
false
);
$min_date_label = $this->field_element(
'label',
$field,
array(
'slug' => 'min_date',
'value' => esc_html__( 'Minimum Date', 'everest-forms' ),
'tooltip' => esc_html__( 'Select minium date.', 'everest-forms' ),
),
false
);
$min_date = $this->field_element(
'text',
$field,
array(
'slug' => 'min_date',
'value' => isset( $field['min_date'] ) ? $field['min_date'] : '',
'class' => 'everest-forms-min-date',
),
false
);
$max_date_label = $this->field_element(
'label',
$field,
array(
'slug' => 'max_date',
'value' => esc_html__( 'Maximum Date', 'everest-forms' ),
'tooltip' => esc_html__( 'Select maximum date.', 'everest-forms' ),
),
false
);
$max_date = $this->field_element(
'text',
$field,
array(
'slug' => 'max_date',
'value' => isset( $field['max_date'] ) ? $field['max_date'] : '',
'class' => 'everest-forms-max-date',
),
false
);
$args = array(
'slug' => 'date_format',
'content' => $date_format_label . $date_format_select . $disable_dates_label . $disable_dates . $date_localization_label . $date_localization_select . '<div class="everest-forms-checklist everest-forms-checklist-inline">' . $current_date_mode . '</div><div class="everest-forms-current-date-format">' . $current_date_default . '</div><div class="everest-forms-min-max-date-format">' . $enable_min_max . '</div><div class="everest-forms-min-max-date-option ' . $class_name . '">' . $min_date_label . $min_date . $max_date_label . $max_date . '</div>',
);
$this->field_element( 'row', $field, $args );
echo '</div>';
echo '<div class="everest-forms-border-container everest-forms-time">';
echo '<h4 class="everest-forms-border-container-title">' . esc_html__( 'Time', 'everest-forms' ) . '</h4>'; // phpcs:ignore WordPress.Security.NonceVerification
$time_format_label = $this->field_element(
'label',
$field,
array(
'slug' => 'time_interval',
'value' => esc_html__( 'Time interval and format', 'everest-forms' ),
'tooltip' => esc_html__( 'Choose time interval and format to display.', 'everest-forms' ),
),
false
);
$time_interval_select = '<div class="input-group-col-2">';
$time_interval_select .= $this->field_element(
'select',
$field,
array(
'slug' => 'time_interval',
'value' => isset( $field['time_interval'] ) ? $field['time_interval'] : '',
'class' => 'time_interval',
'options' => array(
'15' => esc_html__( '15 minutes', 'everest-forms' ),
'30' => esc_html__( '30 minutes', 'everest-forms' ),
),
),
false
);
$time_format_select = $this->field_element(
'select',
$field,
array(
'slug' => 'time_format',
'value' => isset( $field['time_format'] ) ? $field['time_format'] : '',
'class' => 'time_format',
'options' => array(
'g:i A' => esc_html__( '12 H', 'everest-forms' ),
'H:i' => esc_html__( '24 H', 'everest-forms' ),
),
),
false
);
$time_format_select .= '</div>';
$min_time_select = '<div class="input-group-col-2">';
$min_time_select .= $this->field_element(
'select',
$field,
array(
'slug' => 'min_time_hour',
'value' => isset( $field['min_time_hour'] ) ? $field['min_time_hour'] : 9,
'class' => 'min_time_hour',
'options' => $this->get_minute_hours( $field, 'hours' ),
),
false
);
$min_time_select .= $this->field_element(
'select',
$field,
array(
'slug' => 'min_time_minute',
'value' => isset( $field['min_time_minute'] ) ? $field['min_time_minute'] : 30,
'class' => 'min_time_minute',
'options' => $this->get_minute_hours( $field, 'minutes' ),
),
false
);
$min_time_select .= '</div>';
$max_time_select = '<div class="input-group-col-2">';
$max_time_select .= $this->field_element(
'select',
$field,
array(
'slug' => 'max_time_hour',
'value' => isset( $field['max_time_hour'] ) ? $field['max_time_hour'] : 18,
'class' => 'max_time_hour',
'options' => $this->get_minute_hours( $field, 'hours' ),
),
false
);
$max_time_select .= $this->field_element(
'select',
$field,
array(
'slug' => 'max_time_minute',
'value' => isset( $field['max_time_minute'] ) ? $field['max_time_minute'] : 30,
'class' => 'max_time_minute',
'options' => $this->get_minute_hours( $field, 'minutes' ),
),
false
);
$max_time_select .= '</div>';
$enable_min_max_time = '<div class="input-group-col-2">';
$enable_min_max_time .= $this->field_element(
'checkbox',
$field,
array(
'slug' => 'enable_min_max_time',
'value' => isset( $field['enable_min_max_time'] ) ? $field['enable_min_max_time'] : '',
'desc' => esc_html__( 'Enable Min Max Time.', 'everest-forms' ),
'tooltip' => esc_html__( 'Check this option to set min max time.', 'everest-forms' ),
),
false
);
$enable_min_max_time .= '</div>';
$select_min_time = $this->field_element(
'label',
$field,
array(
'slug' => 'select_min_time',
'value' => esc_html__( 'Minimum Time', 'everest-forms' ),
'tooltip' => esc_html__( 'Select minium time.', 'everest-forms' ),
),
false
);
$select_max_time = $this->field_element(
'label',
$field,
array(
'slug' => 'select_max_time',
'value' => esc_html__( 'Maximum Time', 'everest-forms' ),
'tooltip' => esc_html__( 'Select maximum time.', 'everest-forms' ),
),
false
);
$args = array(
'slug' => 'time_interval_format',
'content' => $time_format_label . $time_interval_select . $time_format_select . $enable_min_max_time . $select_min_time . $min_time_select . $select_max_time . $max_time_select,
);
$this->field_element( 'row', $field, $args );
echo '</div>';
echo '</div>';
}
/**
* Time Hours/Minutes Provider.
*
* @since 1.7.5
* @param mixed $field field data.
* @param string $required required type.
*/
public function get_minute_hours( $field, $required = 'hours' ) {
$required_array = array();
if ( 'hours' === $required ) {
// Hours Array.
$period = '';
for ( $i = 0; $i <= 23; $i++ ) {
if ( isset( $field['time_format'] ) && 'H:i' === $field['time_format'] ) {
$required_array [] = ( $i < 10 ? '0' . $i : $i ) . $period;
} else {
if ( $i < 12 ) {
$period = ' AM';
} else {
$period = ' PM';
}
$hour = $i;
if ( 0 === $i ) {
$hour = 12;
}
if ( $hour > 12 ) {
$hour = $i - 12;
}
$required_array [] = $hour . $period;
}
}
} else {
// Minutes Array.
for ( $i = 0; $i <= 59; $i++ ) {
$required_array [] = ( $i < 10 ) ? '0' . $i : $i;
}
}
return $required_array;
}
/**
* Define additional field properties.
*
* @since 1.0.0
*
* @param array $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array of additional field properties.
*/
public function field_properties( $properties, $field, $form_data ) {
// Input primary: data-time-interval.
if ( ! empty( $field['time_interval'] ) ) {
$properties['inputs']['primary']['attr']['data-time-interval'] = esc_attr( $field['time_interval'] );
}
// Input primary: Disabled dates data.
if ( ! empty( $field['disable_dates'] ) ) {
$properties['inputs']['primary']['attr']['data-disable-dates'] = esc_attr( $field['disable_dates'] );
}
// Input primary: data-date-time.
if ( ! empty( $field['datetime_format'] ) ) {
$properties['inputs']['primary']['attr']['data-date-time'] = esc_attr( $field['datetime_format'] );
// Input primary: data-mode.
if ( 'time' !== $field['datetime_format'] ) {
if ( isset( $field['date_range'] ) && '1' === $field['date_range'] ) {
$properties['inputs']['primary']['attr']['data-mode'] = 'range';
} else {
$properties['inputs']['primary']['attr']['data-mode'] = isset( $field['date_mode'] ) ? $field['date_mode'] : 'single';
}
$properties['inputs']['primary']['attr']['data-locale'] = isset( $field['date_localization'] ) ? $field['date_localization'] : 'en';
$properties['inputs']['primary']['attr']['data-min-date'] = isset( $field['enable_min_max'], $field['min_date'] ) ? $field['min_date'] : '';
$properties['inputs']['primary']['attr']['data-max-date'] = isset( $field['enable_min_max'], $field['max_date'] ) ? $field['max_date'] : '';
}
if ( 'date' !== $field['datetime_format'] ) {
if ( isset( $field['enable_min_max_time'] ) ) {
$properties['inputs']['primary']['attr']['data-min-hour'] = isset( $field['min_time_hour'] ) ? $field['min_time_hour'] : '';
$properties['inputs']['primary']['attr']['data-min-minute'] = isset( $field['min_time_minute'] ) ? $field['min_time_minute'] : '';
$properties['inputs']['primary']['attr']['data-max-hour'] = isset( $field['max_time_hour'] ) ? $field['max_time_hour'] : '';
$properties['inputs']['primary']['attr']['data-max-minute'] = isset( $field['max_time_minute'] ) ? $field['max_time_minute'] : '';
}
}
// Input primary: data-date-format and value.
switch ( $field['datetime_format'] ) {
case 'date':
$properties['inputs']['primary']['attr']['value'] = isset( $field['date_default'] ) ? esc_attr( date_i18n( $field['date_format'] ) ) : '';
$properties['inputs']['primary']['attr']['data-date-format'] = ! empty( $field['date_format'] ) ? str_replace( 'g:i A', 'h:i K', esc_attr( $field['date_format'] ) ) : '';
break;
case 'time':
$properties['inputs']['primary']['attr']['value'] = '';
$properties['inputs']['primary']['attr']['data-date-format'] = ! empty( $field['time_format'] ) ? str_replace( 'g:i A', 'h:i K', esc_attr( $field['time_format'] ) ) : 'g:i A';
break;
case 'date-time':
if ( ! empty( $field['time_format'] ) ) {
$date_format = esc_attr( $field['date_format'] ) . ' ' . esc_attr( $field['time_format'] );
$properties['inputs']['primary']['attr']['value'] = isset( $field['date_default'] ) ? esc_attr( date_i18n( $date_format ) ) : '';
$properties['inputs']['primary']['attr']['data-date-format'] = ! empty( $field['date_format'] ) ? str_replace( 'g:i A', 'h:i K', esc_attr( $date_format ) ) : '';
} else {
$date_format = esc_attr( $field['date_format'] ) . ' g:i A';
$properties['inputs']['primary']['attr']['value'] = isset( $field['date_default'] ) ? esc_attr( date_i18n( $date_format ) ) : '';
$properties['inputs']['primary']['attr']['data-date-format'] = ! empty( $field['date_format'] ) ? str_replace( 'g:i A', 'h:i K', esc_attr( $date_format ) ) : '';
}
break;
}
}
return $properties;
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
// Define data.
$placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
// Label.
$this->field_preview_option( 'label', $field );
// Primary input.
echo '<input type="text" placeholder="' . esc_attr( $placeholder ) . '" class="widefat" disabled>';
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$primary = $field['properties']['inputs']['primary'];
$class = array_merge( array( 'flatpickr-field' ), $primary['class'] );
if ( ! array_key_exists( 'datetime_style', $field ) || 'picker' === $field['datetime_style'] ) {
$class = array_merge( array( 'flatpickr-field' ), $primary['class'] );
// Primary field.
printf(
'<input type="text" %s %s >',
evf_html_attributes( $primary['id'], $class, $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
} else {
$class = array_merge( array( 'date-dropdown-field' ), $primary['class'] );
echo '<div class="date-time-container">';
printf(
'<input type="text" %s %s >',
evf_html_attributes( $primary['id'], $class, $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
if ( 'date-time' === $field['datetime_format'] || 'date' === $field['datetime_format'] ) {
// For Years.
printf(
'<select value="%s" %s>',
esc_attr( gmdate( 'Y' ) ),
evf_html_attributes( 'year-select-' . $primary['id'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
// Build the select options.
$end_date = gmdate( 'Y' ) + 100;
$start_date = $end_date - 200;
for ( $i = $end_date; $i >= $start_date; $i-- ) {
printf(
'<option value="%s" %s>%s</option>',
esc_attr( $i ),
(int) gmdate( 'Y' ) === $i ? 'selected' : '',
esc_html( $i )
);
}
echo '</select>';
// For Months.
printf(
'<select value="%s" %s>',
esc_attr( gmdate( 'm' ) ),
evf_html_attributes( 'month-select-' . $primary['id'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
// Build the select options.
for ( $i = 1; $i <= 12; $i++ ) {
$month = ( $i < 10 ) ? '0' . $i : $i;
printf(
'<option value="%s" %s>%s</option>',
esc_attr( $i ),
(int) gmdate( 'm' ) === $i ? 'selected' : '',
esc_html( $month )
);
}
echo '</select>';
// For Days.
printf(
'<select value="%s" %s>',
esc_attr( gmdate( 'd' ) ),
evf_html_attributes( 'day-select-' . $primary['id'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
// Build the select options.
for ( $i = 1; $i <= 32; $i++ ) {
$day = $i < 10 ? '0' . $i : $i;
printf(
'<option value="%s" %s>%s</option>',
esc_attr( $i ),
(int) gmdate( 'd' ) === $i ? 'selected' : '',
esc_html( $day )
);
}
echo '</select>';
}
if ( 'date-time' === $field['datetime_format'] ) {
echo '<span class="date-time-space-filler"></span>';
}
if ( 'time' === $field['datetime_format'] || 'date-time' === $field['datetime_format'] ) {
$min_hour = isset( $field['min_time_hour'], $field['enable_min_max_time'] ) ? $field['min_time_hour'] : 0;
$max_hour = isset( $field['min_time_hour'], $field['enable_min_max_time'] ) ? $field['max_time_hour'] : 23;
// For Hours.
printf(
'<select value = "%s" %s>',
esc_attr( ( gmdate( 'H' ) >= $min_hour && ( gmdate( 'H' ) <= $max_hour ) ) ? gmdate( 'H' ) : $min_hour ),
evf_html_attributes( 'hour-select-' . $primary['id'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
for ( $i = $min_hour; $i <= $max_hour; $i++ ) {
printf(
'<option value="%s" %s>%s</option>',
esc_attr( $i ),
(int) gmdate( 'H' ) === $i ? 'selected' : '',
esc_html( $this->get_minute_hours( $field, 'hours' )[ $i ] )
);
}
echo '</select>';
$time_interval = isset( $field['time_interval'] ) ? $field['time_interval'] : 1;
// For Minutes.
printf(
'<select %s>',
evf_html_attributes( 'minute-select-' . $primary['id'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
echo '</select>';
}
echo '</div>';
}
}
/**
* Register/queue frontend scripts.
*
* @param array $atts Shortcode attributes.
*/
public static function load_assets( $atts ) {
$form_id = isset( $atts['id'] ) ? wp_unslash( $atts['id'] ) : ''; // WPCS: CSRF ok, input var ok, sanitization ok.
$form_obj = evf()->form->get( $form_id );
$form_data = ! empty( $form_obj->post_content ) ? evf_decode( $form_obj->post_content ) : '';
$data_i10n = 'en';
if ( ! empty( $form_data['form_fields'] ) ) {
foreach ( $form_data['form_fields'] as $form_field ) {
if ( 'date-time' === $form_field['type'] ) {
$data_i10n = isset( $form_field['date_localization'] ) ? $form_field['date_localization'] : 'en';
}
}
}
if ( wp_script_is( 'flatpickr' ) && 'en' !== $data_i10n ) {
wp_enqueue_script( 'flatpickr-localization', 'https://npmcdn.com/flatpickr/dist/l10n/' . $data_i10n . '.js', array(), EVF_VERSION, true );
}
}
}
class-evf-field-last-name.php 0000666 00000003630 15176450462 0012120 0 ustar 00 <?php
/**
* Last name field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Last_Name class.
*/
class EVF_Field_Last_Name extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Last Name', 'everest-forms' );
$this->type = 'last-name';
$this->icon = 'evf-icon evf-icon-last-name';
$this->order = 20;
$this->group = 'general';
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'placeholder',
'label_hide',
'default_value',
'css',
),
),
);
parent::__construct();
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
// Define data.
$placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
// Label.
$this->field_preview_option( 'label', $field );
// Primary input.
echo '<input type="text" placeholder="' . esc_attr( $placeholder ) . '" class="widefat" disabled>';
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$primary = $field['properties']['inputs']['primary'];
// Primary field.
printf(
'<input type="text" %s %s>',
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
}
}
class-evf-field-number.php 0000666 00000020464 15176450462 0011533 0 ustar 00 <?php
/**
* Number field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Number class.
*/
class EVF_Field_Number extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Number', 'everest-forms' );
$this->type = 'number';
$this->icon = 'evf-icon evf-icon-number';
$this->order = 80;
$this->group = 'general';
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'step',
'min_value',
'max_value',
'default_value',
'placeholder',
'label_hide',
'css',
),
),
);
parent::__construct();
}
/**
* Hook in tabs.
*/
public function init_hooks() {
add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
}
/**
* Step field option.
*
* @since 1.4.9
* @param array $field Field Data.
*/
public function step( $field ) {
$label = $this->field_element(
'label',
$field,
array(
'slug' => 'step',
'value' => esc_html__( 'Step', 'everest-forms' ),
'tooltip' => esc_html__( 'Allows users to enter specific legal number intervals.', 'everest-forms' ),
),
false
);
$input_field = $this->field_element(
'text',
$field,
array(
'type' => 'number',
'slug' => 'step',
'class' => 'evf-input-number-step',
'value' => isset( $field['step'] ) ? $field['step'] : 1,
),
false
);
$this->field_element(
'row',
$field,
array(
'slug' => 'step',
'content' => $label . $input_field,
)
);
}
/**
* Minimum value field option.
*
* @since 1.4.9
* @param array $field Field Data.
*/
public function min_value( $field ) {
$label = $this->field_element(
'label',
$field,
array(
'slug' => 'min_value',
'value' => esc_html__( 'Min Value', 'everest-forms' ),
'tooltip' => esc_html__( 'Minimum value user is allowed to enter.', 'everest-forms' ),
),
false
);
$input_field = $this->field_element(
'text',
$field,
array(
'type' => 'number',
'slug' => 'min_value',
'class' => 'evf-input-number',
'value' => isset( $field['min_value'] ) ? $field['min_value'] : '',
),
false
);
$this->field_element(
'row',
$field,
array(
'slug' => 'min_value',
'content' => $label . $input_field,
)
);
}
/**
* Maximum value field option.
*
* @since 1.4.9
* @param array $field Field Data.
*/
public function max_value( $field ) {
$label = $this->field_element(
'label',
$field,
array(
'slug' => 'max_value',
'value' => esc_html__( 'Max Value', 'everest-forms' ),
'tooltip' => esc_html__( 'Maximum value user is allowed to enter.', 'everest-forms' ),
),
false
);
$input_field = $this->field_element(
'text',
$field,
array(
'type' => 'number',
'slug' => 'max_value',
'class' => 'evf-input-number',
'value' => isset( $field['max_value'] ) ? $field['max_value'] : '',
),
false
);
$this->field_element(
'row',
$field,
array(
'slug' => 'max_value',
'content' => $label . $input_field,
)
);
}
/**
* Define additional field properties.
*
* @since 1.0.0
*
* @param array $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array of additional field properties.
*/
public function field_properties( $properties, $field, $form_data ) {
// Input primary: step interval.
if ( ! empty( $field['step'] ) ) {
$properties['inputs']['primary']['attr']['step'] = (float) $field['step'];
}
// Input primary: minimum value.
if ( ! empty( $field['min_value'] ) ) {
$properties['inputs']['primary']['attr']['min'] = (float) $field['min_value'];
}
// Input primary: maximum value.
if ( ! empty( $field['max_value'] ) ) {
$properties['inputs']['primary']['attr']['max'] = (float) $field['max_value'];
}
return $properties;
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
// Define data.
$placeholder = ! empty( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '';
// Label.
$this->field_preview_option( 'label', $field );
// Primary input.
echo '<input type="number" placeholder="' . $placeholder . '" class="widefat" disabled>'; // @codingStandardsIgnoreLine.
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$primary = $field['properties']['inputs']['primary'];
// Primary field.
printf(
'<input type="number" %s %s />',
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ),
esc_attr( $primary['required'] )
);
}
/**
* Formats and sanitizes field.
*
* @param string $field_id Field Id.
* @param array $field_submit Submitted Field.
* @param array $form_data All Form Data.
* @param string $meta_key Field Meta Key.
*/
public function format( $field_id, $field_submit, $form_data, $meta_key ) {
// Define data.
$name = ! empty( $form_data['form_fields'][ $field_id ]['label'] ) ? $form_data['form_fields'][ $field_id ]['label'] : '';
$value = preg_replace( '/[^0-9.]/', '', $field_submit );
// Set final field details.
evf()->task->form_fields[ $field_id ] = array(
'name' => make_clickable( $name ),
'value' => sanitize_text_field( $value ),
'id' => $field_id,
'type' => $this->type,
'meta_key' => $meta_key,
);
}
/**
* Validates field for minimum and maximum data input.
*
* @since 1.4.9
* @param string $field_id Field Id.
* @param array $field_submit Submitted Data.
* @param array $form_data All Form Data.
*/
public function validate( $field_id, $field_submit, $form_data ) {
$form_id = absint( $form_data['id'] );
$min_value = isset( $form_data['form_fields'][ $field_id ]['min_value'] ) ? floatval( $form_data['form_fields'][ $field_id ]['min_value'] ) : 0;
$max_value = isset( $form_data['form_fields'][ $field_id ]['max_value'] ) ? floatval( $form_data['form_fields'][ $field_id ]['max_value'] ) : 0;
$conditional_status = isset( $form_data['form_fields'][ $field_id ]['conditional_logic_status'] ) ? $form_data['form_fields'][ $field_id ]['conditional_logic_status'] : 0;
// Basic required check - If field is marked as required, check for entry data.
if ( ! empty( $form_data['form_fields'][ $field_id ]['required'] ) && '1' !== $conditional_status && empty( $field_submit ) && '0' !== $field_submit ) {
evf()->task->errors[ $form_id ][ $field_id ] = evf_get_required_label();
update_option( 'evf_validation_error', 'yes' );
}
// Check if value is numeric.
if ( ! empty( $field_submit ) && ! is_numeric( $field_submit ) ) {
evf()->task->errors[ $form_id ][ $field_id ] = apply_filters( 'everest_forms_valid_number_label', esc_html__( 'Please enter a valid number.', 'everest-forms' ) );
update_option( 'evf_validation_error', 'yes' );
}
// Check if minimum and maximum value is valid.
if ( ! empty( $form_data['form_fields'][ $field_id ]['min_value'] ) && floatval( $field_submit ) < $min_value ) {
/* translators: %s - minimum value. */
evf()->task->errors[ $form_id ][ $field_id ] = sprintf( esc_html__( 'Please enter a value greater than or equal to %s', 'everest-forms' ), absint( $min_value ) );
update_option( 'evf_validation_error', 'yes' );
} elseif ( ! empty( $form_data['form_fields'][ $field_id ]['max_value'] ) && floatval( $field_submit ) > $max_value ) {
/* translators: %s - maximum value. */
evf()->task->errors[ $form_id ][ $field_id ] = sprintf( esc_html__( 'Please enter a value less than or equal to %s', 'everest-forms' ), absint( $max_value ) );
update_option( 'evf_validation_error', 'yes' );
}
}
}
class-evf-field-checkbox.php 0000666 00000040122 15176450462 0012022 0 ustar 00 <?php
/**
* Checkbox field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Checkbox class.
*/
class EVF_Field_Checkbox extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Checkboxes', 'everest-forms' );
$this->type = 'checkbox';
$this->icon = 'evf-icon evf-icon-checkbox';
$this->order = 70;
$this->group = 'general';
$this->defaults = array(
1 => array(
'label' => esc_html__( 'First Choice', 'everest-forms' ),
'value' => '',
'image' => '',
'default' => '',
),
2 => array(
'label' => esc_html__( 'Second Choice', 'everest-forms' ),
'value' => '',
'image' => '',
'default' => '',
),
3 => array(
'label' => esc_html__( 'Third Choice', 'everest-forms' ),
'value' => '',
'image' => '',
'default' => '',
),
);
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'choices',
'choices_images',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'randomize',
'show_values',
'input_columns',
'choice_limit',
'label_hide',
'css',
),
),
);
parent::__construct();
}
/**
* Hook in tabs.
*/
public function init_hooks() {
add_filter( 'everest_forms_html_field_value', array( $this, 'html_field_value' ), 10, 4 );
add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
}
/**
* Return images, if any, for HTML supported values.
*
* @since 1.6.0
*
* @param string $value Field value.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
* @param string $context Value display context.
*
* @return string
*/
public function html_field_value( $value, $field, $form_data = array(), $context = '' ) {
if ( is_serialized( $field ) || in_array( $context, array( 'email-html', 'export-pdf' ), true ) ) {
$field_value = maybe_unserialize( $field );
$field_type = isset( $field_value['type'] ) ? sanitize_text_field( $field_value['type'] ) : 'checkbox';
if ( $field_type === $this->type ) {
if (
'entry-table' !== $context
&& ! empty( $field_value['label'] )
&& ! empty( $field_value['images'] )
&& apply_filters( 'everest_forms_checkbox_field_html_value_images', true, $context )
) {
$items = array();
if ( ! empty( $field_value['label'] ) ) {
foreach ( $field_value['label'] as $key => $value ) {
if ( ! empty( $field_value['images'][ $key ] ) ) {
$items[] = sprintf(
'<span style="max-width:200px;display:block;margin:0 0 5px 0;"><img src="%s" style="max-width:100%%;display:block;margin:0;"></span>%s',
esc_url( $field_value['images'][ $key ] ),
esc_html( $value )
);
} else {
$items[] = esc_html( $value );
}
}
}
return implode( 'export-csv' !== $context ? '<br><br>' : '|', $items );
}
}
}
return $value;
}
/**
* Define additional field properties.
*
* @since 1.0.0
*
* @param array $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array of additional field properties.
*/
public function field_properties( $properties, $field, $form_data ) {
// Define data.
$form_id = absint( $form_data['id'] );
$field_id = $field['id'];
$choices = $field['choices'];
// Remove primary input.
unset( $properties['inputs']['primary'] );
// Set input container (ul) properties.
$properties['input_container'] = array(
'class' => array( ! empty( $field['random'] ) ? 'everest-forms-randomize' : '' ),
'data' => array(),
'attr' => array(),
'id' => "evf-{$form_id}-field_{$field_id}",
);
// Set choice limit.
$field['choice_limit'] = empty( $field['choice_limit'] ) ? 0 : (int) $field['choice_limit'];
if ( $field['choice_limit'] > 0 ) {
$properties['input_container']['data']['choice-limit'] = $field['choice_limit'];
}
// Set input properties.
foreach ( $choices as $key => $choice ) {
$depth = isset( $choice['depth'] ) ? absint( $choice['depth'] ) : 1;
// Choice labels should not be left blank, but if they are we provide a basic value.
$value = isset( $field['show_values'] ) ? $choice['value'] : $choice['label'];
if ( '' === $value ) {
if ( 1 === count( $choices ) ) {
$value = esc_html__( 'Checked', 'everest-forms' );
} else {
/* translators: %s - Choice Number. */
$value = sprintf( esc_html__( 'Choice %s', 'everest-forms' ), $key );
}
}
$properties['inputs'][ $key ] = array(
'container' => array(
'attr' => array(),
'class' => array( "choice-{$key}", "depth-{$depth}" ),
'data' => array(),
'id' => '',
),
'label' => array(
'attr' => array(
'for' => "evf-{$form_id}-field_{$field_id}_{$key}",
),
'class' => array( 'everest-forms-field-label-inline' ),
'data' => array(),
'id' => '',
'text' => evf_string_translation( $form_id, $field_id, $choice['label'], '-choice-' . $key ),
),
'attr' => array(
'name' => "everest_forms[form_fields][{$field_id}][]",
'value' => $value,
),
'class' => array( 'input-text' ),
'data' => array(),
'id' => "evf-{$form_id}-field_{$field_id}_{$key}",
'image' => isset( $choice['image'] ) ? $choice['image'] : '',
'required' => ! empty( $field['required'] ) ? 'required' : '',
'default' => isset( $choice['default'] ),
);
// Rule for choice limit validator.
if ( $field['choice_limit'] > 0 ) {
$properties['inputs'][ $key ]['data']['rule-check-limit'] = 'true';
}
}
// Required class for validation.
if ( ! empty( $field['required'] ) ) {
$properties['input_container']['class'][] = 'evf-field-required';
}
// Custom properties if enabled image choices.
if ( ! empty( $field['choices_images'] ) ) {
$properties['input_container']['class'][] = 'everest-forms-image-choices';
foreach ( $properties['inputs'] as $key => $inputs ) {
$properties['inputs'][ $key ]['container']['class'][] = 'everest-forms-image-choices-item';
}
}
// Add selected class for choices with defaults.
foreach ( $properties['inputs'] as $key => $inputs ) {
if ( ! empty( $inputs['default'] ) ) {
$properties['inputs'][ $key ]['container']['class'][] = 'everest-forms-selected';
}
}
return $properties;
}
/**
* Randomize order of choices.
*
* @since 1.6.0
* @param array $field Field Data.
*/
public function randomize( $field ) {
$args = array(
'slug' => 'random',
'content' => $this->field_element(
'checkbox',
$field,
array(
'slug' => 'random',
'value' => isset( $field['random'] ) ? '1' : '0',
'desc' => esc_html__( 'Randomize Choices', 'everest-forms' ),
'tooltip' => esc_html__( 'Check this option to randomize the order of the choices.', 'everest-forms' ),
),
false
),
);
$this->field_element( 'row', $field, $args );
}
/**
* Choice limit field option.
*
* @since 1.6.0
* @param array $field Field data.
*/
public function choice_limit( $field ) {
$choice_limit_label = $this->field_element(
'label',
$field,
array(
'slug' => 'choice_limit',
'value' => esc_html__( 'Choice Limit', 'everest-forms' ),
'tooltip' => esc_html__( 'Check this option to limit the number of checkboxes a user can select.', 'everest-forms' ),
),
false
);
$choice_limit_input = $this->field_element(
'text',
$field,
array(
'slug' => 'choice_limit',
'value' => ( isset( $field['choice_limit'] ) && $field['choice_limit'] > 0 ) ? (int) $field['choice_limit'] : '',
'type' => 'number',
),
false
);
$args = array(
'slug' => 'choice_limit',
'content' => $choice_limit_label . $choice_limit_input,
);
$this->field_element( 'row', $field, $args );
}
/**
* Show values field option.
*
* @param array $field Field Data.
*/
public function show_values( $field ) {
// Show Values toggle option. This option will only show if already used or if manually enabled by a filter.
if ( ! empty( $field['show_values'] ) || apply_filters( 'everest_forms_fields_show_options_setting', false ) ) {
$args = array(
'slug' => 'show_values',
'content' => $this->field_element(
'checkbox',
$field,
array(
'slug' => 'show_values',
'value' => isset( $field['show_values'] ) ? $field['show_values'] : '0',
'desc' => __( 'Show Values', 'everest-forms' ),
'tooltip' => __( 'Check this to manually set form field values.', 'everest-forms' ),
),
false
),
);
$this->field_element( 'row', $field, $args );
}
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
// Label.
$this->field_preview_option( 'label', $field );
// Choices.
$this->field_preview_option( 'choices', $field );
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$container = $field['properties']['input_container'];
$choices = $field['properties']['inputs'];
// List.
printf( '<ul %s>', evf_html_attributes( $container['id'], $container['class'], $container['data'], $container['attr'] ) );
foreach ( $choices as $choice ) {
if ( empty( $choice['container'] ) ) {
continue;
}
// Conditional logic.
if ( isset( $choices['primary'] ) ) {
$choice['attr']['conditional_id'] = $choices['primary']['attr']['conditional_id'];
if ( isset( $choices['primary']['attr']['conditional_rules'] ) ) {
$choice['attr']['conditional_rules'] = $choices['primary']['attr']['conditional_rules'];
}
}
printf( '<li %s>', evf_html_attributes( $choice['container']['id'], $choice['container']['class'], $choice['container']['data'], $choice['container']['attr'] ) );
if ( ! empty( $field['choices_images'] ) ) {
// Make image choices keyboard-accessible.
$choice['label']['attr']['tabindex'] = 0;
// Image choices.
printf( '<label %s>', evf_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ) );
if ( ! empty( $choice['image'] ) ) {
printf(
'<span class="everest-forms-image-choices-image"><img src="%s" alt="%s"%s></span>',
esc_url( $choice['image'] ),
esc_attr( $choice['label']['text'] ),
! empty( $choice['label']['text'] ) ? ' title="' . esc_attr( $choice['label']['text'] ) . '"' : ''
);
}
echo '<br>';
$choice['attr']['tabindex'] = '-1';
printf( '<input type="checkbox" %s %s %s>', evf_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ), esc_attr( $choice['required'] ), checked( '1', $choice['default'], false ) );
echo '<span class="everest-forms-image-choices-label">' . wp_kses_post( $choice['label']['text'] ) . '</span>';
echo '</label>';
} else {
// Normal display.
printf( '<input type="checkbox" %s %s %s>', evf_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ), esc_attr( $choice['required'] ), checked( '1', $choice['default'], false ) );
printf( '<label %s>%s</label>', evf_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ), wp_kses_post( $choice['label']['text'] ) );
}
echo '</li>';
}
echo '</ul>';
}
/**
* Edit form field display on the entry back-end.
*
* @since 1.7.0
*
* @param array $entry_field Entry field data.
* @param array $field Field data.
* @param array $form_data Form data and settings.
*/
public function edit_form_field_display( $entry_field, $field, $form_data ) {
$value_choices = ! empty( $entry_field['value_raw'] ) ? $entry_field['value_raw'] : array();
$this->remove_field_choices_defaults( $field, $field['properties'] );
foreach ( $value_choices as $input => $single_value ) {
$field['properties'] = $this->get_single_field_property_value( $single_value, sanitize_key( $input ), $field['properties'], $field );
}
$this->field_display( $field, null, $form_data );
}
/**
* Validates field on form submit.
*
* @since 1.6.0
*
* @param int $field_id Field ID.
* @param array $field_submit Submitted data.
* @param array $form_data Form data.
*/
public function validate( $field_id, $field_submit, $form_data ) {
$field_submit = (array) $field_submit;
$form_id = $form_data['id'];
$fields = $form_data['form_fields'];
$choice_limit = empty( $fields[ $field_id ]['choice_limit'] ) ? 0 : (int) $fields[ $field_id ]['choice_limit'];
$conditional_status = isset( $form_data['form_fields'][ $field_id ]['conditional_logic_status'] ) ? $form_data['form_fields'][ $field_id ]['conditional_logic_status'] : 0;
// Generating the error.
if ( $choice_limit > 0 && $choice_limit < count( $field_submit ) ) {
$error = get_option( 'everest_forms_check_limit_validation', esc_html__( 'You have exceeded number of allowed selections: {#}.', 'everest-forms' ) );
$error = str_replace( '{#}', $choice_limit, $error );
}
// Basic required check.
if ( ! empty( $fields[ $field_id ]['required'] ) && '1' !== $conditional_status && ( empty( $field_submit ) || ( 1 === count( $field_submit ) && empty( $field_submit[0] ) ) ) ) {
$error = evf_get_required_label();
}
if ( ! empty( $error ) ) {
evf()->task->errors[ $form_id ][ $field_id ] = $error;
}
}
/**
* Formats and sanitizes field.
*
* @since 1.0.0
*
* @param string $field_id Field Id.
* @param array $field_submit Submitted Field.
* @param array $form_data All Form Data.
* @param string $meta_key Field Meta Key.
*/
public function format( $field_id, $field_submit, $form_data, $meta_key ) {
$field_submit = (array) $field_submit;
$field = $form_data['form_fields'][ $field_id ];
$name = make_clickable( $field['label'] );
$value_raw = evf_sanitize_array_combine( $field_submit );
$choice_keys = array();
$data = array(
'id' => $field_id,
'type' => $this->type,
'value' => array(
'name' => $name,
'type' => $this->type,
),
'meta_key' => $meta_key,
'value_raw' => $value_raw,
);
/*
* If show_values is true, that means values posted are the raw values
* and not the labels. So we need to get the label values.
*/
if ( ! empty( $field['show_values'] ) && '1' === $field['show_values'] ) {
foreach ( $field_submit as $item ) {
foreach ( $field['choices'] as $key => $choice ) {
if ( $item === $choice['value'] || ( empty( $choice['value']['label'] ) && (int) str_replace( 'Choice ', '', $item ) === $key ) ) {
$value[] = $choice['label'];
$choice_keys[] = $key;
break;
}
}
}
$data['value']['label'] = ! empty( $value ) ? evf_sanitize_array_combine( $value ) : '';
} else {
$data['value']['label'] = $value_raw;
// Determine choices keys, this is needed for image choices.
foreach ( $field_submit as $item ) {
foreach ( $field['choices'] as $key => $choice ) {
if ( $item === $choice['label'] ) {
$choice_keys[] = $key;
break;
}
}
}
}
// Images choices are enabled, lookup and store image URLs.
if ( ! empty( $choice_keys ) && ! empty( $field['choices_images'] ) ) {
$data['value']['images'] = array();
foreach ( $choice_keys as $key ) {
$data['value']['images'][] = ! empty( $field['choices'][ $key ]['image'] ) ? esc_url_raw( $field['choices'][ $key ]['image'] ) : '';
}
}
// Push field details to be saved.
evf()->task->form_fields[ $field_id ] = $data;
}
}
class-evf-field-payment-radio.php 0000666 00000001045 15176450462 0013006 0 ustar 00 <?php
/**
* Payment Radio field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Payment_Radio Class.
*/
class EVF_Field_Payment_Radio extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Multiple Choice', 'everest-forms' );
$this->type = 'payment-multiple';
$this->icon = 'evf-icon evf-icon-multiple-choices';
$this->order = 20;
$this->group = 'payment';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-password.php 0000666 00000001002 15176450462 0012070 0 ustar 00 <?php
/**
* Password field.
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Password Class.
*/
class EVF_Field_Password extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Password', 'everest-forms' );
$this->type = 'password';
$this->icon = 'evf-icon evf-icon-password';
$this->order = 70;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-payment-total.php 0000666 00000001015 15176450462 0013030 0 ustar 00 <?php
/**
* Payment Total field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Payment_Total Class.
*/
class EVF_Field_Payment_Total extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Total', 'everest-forms' );
$this->type = 'payment-total';
$this->icon = 'evf-icon evf-icon-total';
$this->order = 60;
$this->group = 'payment';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-scale-rating.php 0000666 00000001026 15176450462 0012605 0 ustar 00 <?php
/**
* Score Rating field
*
* @package EverestForms\Fields
* @since 1.4.3
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Scale_Rating Class.
*/
class EVF_Field_Scale_Rating extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Scale Rating', 'everest-forms' );
$this->type = 'scale-rating';
$this->icon = 'evf-icon evf-icon-scale-rating';
$this->order = 30;
$this->group = 'survey';
$this->is_pro = true;
parent::__construct();
}
}
class-evf-field-select.php 0000666 00000025706 15176450462 0011526 0 ustar 00 <?php
/**
* Select Dropdown field.
*
* @package EverestForms\Fields
* @since 1.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Select class.
*/
class EVF_Field_Select extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Dropdown', 'everest-forms' );
$this->type = 'select';
$this->icon = 'evf-icon evf-icon-dropdown';
$this->order = 50;
$this->group = 'general';
$this->defaults = array(
1 => array(
'label' => esc_html__( 'Option 1', 'everest-forms' ),
'value' => '',
'default' => '',
),
2 => array(
'label' => esc_html__( 'Option 2', 'everest-forms' ),
'value' => '',
'default' => '',
),
3 => array(
'label' => esc_html__( 'Option 3', 'everest-forms' ),
'value' => '',
'default' => '',
),
);
$this->settings = array(
'basic-options' => array(
'field_options' => array(
'label',
'meta',
'choices',
'enhanced_select',
'description',
'required',
'required_field_message',
),
),
'advanced-options' => array(
'field_options' => array(
'size',
'placeholder',
'label_hide',
'css',
),
),
);
parent::__construct();
}
/**
* Hook in tabs.
*/
public function init_hooks() {
add_action( 'everest_forms_shortcode_scripts', array( $this, 'load_assets' ) );
add_filter( 'everest_forms_field_properties_' . $this->type, array( $this, 'field_properties' ), 5, 3 );
}
/**
* Define additional field properties.
*
* @since 1.7.0
*
* @param array $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array of additional field properties.
*/
public function field_properties( $properties, $field, $form_data ) {
// Define data.
$form_id = absint( $form_data['id'] );
$field_id = $field['id'];
$choices = $field['choices'];
// Remove primary input.
unset( $properties['inputs']['primary'] );
// Set input container (<select>) properties.
$properties['input_container'] = array(
'class' => array( 'input-text' ),
'data' => array(),
'id' => "evf-{$form_id}-field_{$field_id}",
'attr' => array(
'name' => "everest_forms[form_fields][{$field_id}]",
),
);
// Set input properties.
foreach ( $choices as $key => $choice ) {
$depth = isset( $choice['depth'] ) ? absint( $choice['depth'] ) : 1;
$properties['inputs'][ $key ] = array(
'container' => array(
'attr' => array(),
'class' => array( "choice-{$key}", "depth-{$depth}" ),
'data' => array(),
'id' => '',
),
'label' => array(
'attr' => array(
'for' => "evf-{$form_id}-field_{$field_id}_{$key}",
),
'class' => array( 'everest-forms-field-label-inline' ),
'data' => array(),
'id' => '',
'text' => evf_string_translation( $form_id, $field_id, $choice['label'], '-choice-' . $key ),
),
'attr' => array(
'name' => "everest_forms[form_fields][{$field_id}][]",
'value' => isset( $field['show_values'] ) ? $choice['value'] : $choice['label'],
),
'class' => array(),
'data' => array(),
'id' => "evf-{$form_id}-field_{$field_id}_{$key}",
'required' => ! empty( $field['required'] ) ? 'required' : '',
'default' => isset( $choice['default'] ),
);
}
// Required class for validation.
if ( ! empty( $field['required'] ) ) {
$properties['input_container']['class'][] = 'evf-field-required';
}
return $properties;
}
/**
* Register/queue frontend scripts.
*
* @param array $atts Shortcode attributes.
*/
public static function load_assets( $atts ) {
$form_data = evf()->form->get( $atts['id'], array( 'content_only' => true ) );
if ( ! empty( $form_data['form_fields'] ) ) {
$is_enhanced_select = wp_list_filter(
$form_data['form_fields'],
array(
'type' => 'select',
'enhanced_select' => 1,
)
);
if ( ! empty( $is_enhanced_select ) ) {
wp_enqueue_style( 'select2' );
wp_enqueue_script( 'selectWoo' );
}
}
}
/**
* Enable enhanced select field option.
*
* @param array $field Field Data.
*/
public function enhanced_select( $field ) {
$plan = evf_get_license_plan();
$value = isset( $field['enhanced_select'] ) && false !== $plan ? $field['enhanced_select'] : '0';
$tooltip = esc_html__( 'Check this option to enable enhanced select. It enables you to search items in the dropdown field.', 'everest-forms' );
// Enable enhanced select toggle field.
$enhanced_select = $this->field_element(
'checkbox',
$field,
array(
'slug' => 'enhanced_select',
'value' => $value,
'class' => ( false === $plan ) ? 'disabled' : '',
'desc' => esc_html__( 'Enable Enhanced Select', 'everest-forms' ),
'tooltip' => $tooltip,
),
false
);
$this->field_element(
'row',
$field,
array(
'slug' => 'enhanced_select',
'content' => $enhanced_select,
'class' => ( false === $plan ) ? 'upgrade-modal' : '',
'data' => array(
'feature' => esc_html__( 'Enhanced select', 'everest-forms' ),
),
)
);
}
/**
* Field preview inside the builder.
*
* @since 1.0.0
*
* @param array $field Field data and settings.
*/
public function field_preview( $field ) {
$args = array();
if (
! empty( $field['enhanced_select'] )
&& ! empty( $field['multiple_choices'] ) && '1' === $field['multiple_choices']
) {
$args['class'] = 'evf-enhanced-select';
}
// Label.
$this->field_preview_option( 'label', $field );
// Choices.
$this->field_preview_option( 'choices', $field, $args );
// Description.
$this->field_preview_option( 'description', $field );
}
/**
* Field display on the form front-end.
*
* @since 1.0.0
*
* @param array $field Field Data.
* @param array $field_atts Field attributes.
* @param array $form_data All Form Data.
*/
public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$container = $field['properties']['input_container'];
$choices = $field['properties']['inputs'];
$field = apply_filters( 'everest_forms_select_field_display', $field, $field_atts, $form_data );
$field_placeholder = ! empty( $field['placeholder'] ) ? evf_string_translation( $form_data['id'], $field['id'], $field['placeholder'], '-placeholder' ) : '';
$plan = evf_get_license_plan();
$has_default = false;
$is_multiple = false;
if ( ! empty( $field['required'] ) ) {
$container['attr']['required'] = 'required';
}
// Enable enhanced select.
if ( false !== $plan && ! empty( $field['enhanced_select'] ) && '1' === $field['enhanced_select'] ) {
$container['class'][] = 'evf-enhanced-select';
if ( empty( $field_placeholder ) ) {
$first_choices = reset( $choices );
$field_placeholder = $first_choices['label']['text'];
}
// Set placeholder for select2.
$container['data']['placeholder'] = esc_attr( $field_placeholder );
}
// Enable multiple choices selection.
if ( false !== $plan && ! empty( $field['multiple_choices'] ) && '1' === $field['multiple_choices'] ) {
$is_multiple = true;
$container['attr']['multiple'] = 'multiple';
// Change a name attribute.
if ( ! empty( $container['attr']['name'] ) ) {
$container['attr']['name'] .= '[]';
}
}
// Check to see if any of the options have selected by default.
foreach ( $choices as $choice ) {
if ( ! empty( $choice['default'] ) ) {
$has_default = true;
break;
}
}
// Conditional logic.
if ( isset( $choices['primary'] ) ) {
$container['attr']['conditional_id'] = $choices['primary']['attr']['conditional_id'];
if ( isset( $choices['primary']['attr']['conditional_rules'] ) ) {
$container['attr']['conditional_rules'] = $choices['primary']['attr']['conditional_rules'];
}
}
// Primary select field.
printf(
'<select %s>',
evf_html_attributes( $container['id'], $container['class'], $container['data'], $container['attr'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
// Optional placeholder.
if ( ! empty( $field_placeholder ) ) {
printf( '<option value="" class="placeholder" disabled %s>%s</option>', selected( false, $has_default || $is_multiple, false ), esc_html( $field_placeholder ) );
}
// Build the select options.
foreach ( $choices as $choice ) {
if ( empty( $choice['container'] ) ) {
continue;
}
printf(
'<option value="%s" %s>%s</option>',
esc_attr( $choice['attr']['value'] ),
selected( true, ! empty( $choice['default'] ), false ),
esc_html( $choice['label']['text'] )
);
}
echo '</select>';
}
/**
* Edit form field display on the entry back-end.
*
* @since 1.7.0
*
* @param array $entry_field Entry field data.
* @param array $field Field data.
* @param array $form_data Form data and settings.
*/
public function edit_form_field_display( $entry_field, $field, $form_data ) {
$value_choices = ! empty( $entry_field['value_raw'] ) ? $entry_field['value_raw'] : array();
$this->remove_field_choices_defaults( $field, $field['properties'] );
if ( is_array( $value_choices ) ) {
foreach ( $value_choices as $input => $single_value ) {
$field['properties'] = $this->get_single_field_property_value( $single_value, sanitize_key( $input ), $field['properties'], $field );
}
}
$this->field_display( $field, null, $form_data );
}
/**
* Formats and sanitizes field.
*
* @since 1.0.0
*
* @param int $field_id Field ID.
* @param mixed $field_submit Submitted field value.
* @param array $form_data Form data and settings.
* @param string $meta_key Field meta key.
*/
public function format( $field_id, $field_submit, $form_data, $meta_key ) {
$field = $form_data['form_fields'][ $field_id ];
$name = make_clickable( $field['label'] );
$value = array();
// Convert field value into to array.
if ( ! is_array( $field_submit ) ) {
$field_submit = array( $field_submit );
}
$value_raw = evf_sanitize_array_combine( $field_submit );
$data = array(
'name' => $name,
'value' => '',
'value_raw' => $value_raw,
'id' => $field_id,
'type' => $this->type,
'meta_key' => $meta_key,
);
// Normal processing, dynamic population is off.
// If show_values is true, that means values posted are the raw values
// and not the labels. So we need to get the label values.
if ( ! empty( $field['show_values'] ) && '1' === $field['show_values'] ) {
foreach ( $field_submit as $item ) {
foreach ( $field['choices'] as $choice ) {
if ( $item === $choice['value'] ) {
$value[] = $choice['label'];
break;
}
}
}
$data['value'] = ! empty( $value ) ? evf_sanitize_array_combine( $value ) : '';
} else {
$data['value'] = $value_raw;
}
// Push field details to be saved.
evf()->task->form_fields[ $field_id ] = $data;
}
}
class-evf-field-address.php 0000666 00000000776 15176450462 0011674 0 ustar 00 <?php
/**
* Address field
*
* @package EverestForms\Fields
* @since 1.2.0
*/
defined( 'ABSPATH' ) || exit;
/**
* EVF_Field_Address Class.
*/
class EVF_Field_Address extends EVF_Form_Fields {
/**
* Constructor.
*/
public function __construct() {
$this->name = esc_html__( 'Address', 'everest-forms' );
$this->type = 'address';
$this->icon = 'evf-icon evf-icon-map-marker';
$this->order = 110;
$this->group = 'advanced';
$this->is_pro = true;
parent::__construct();
}
}