PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / templates / fields / calculated-field.php

calculated-field.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at templates/fields/calculated-field.php

64 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Calculated field template
4 *
5 * @var Calculated_Field_Render $this
6 * @var $args
7 */
8
9 use Jet_Form_Builder\Blocks\Render\Calculated_Field_Render;
10
11 // If this file is called directly, abort.
12 if ( ! defined( 'WPINC' ) ) {
13 die;
14 }
15
16 $formula = $this->get_calculated_data( $args );
17
18 if ( empty( $formula ) ) {
19 return;
20 }
21
22 $name = $this->block_type->get_field_name( $args['name'] );
23 $id_attr = $this->block_type->get_field_id();
24 $default_value = ! empty( $args['default'] ) ? $args['default'] : '';
25 $prefix = ! empty( $args['calc_prefix'] ) ? $args['calc_prefix'] : false;
26 $suffix = ! empty( $args['calc_suffix'] ) ? $args['calc_suffix'] : false;
27 $precision = isset( $args['precision'] ) ? $args['precision'] : 0;
28 $is_hidden = isset( $args['calc_hidden'] ) ? filter_var( $args['calc_hidden'], defined( 'FILTER_VALIDATE_BOOL' ) ? FILTER_VALIDATE_BOOL : FILTER_VALIDATE_BOOLEAN ) : false;
29
30 $this->add_attribute( 'class', $args['class_name'] );
31 $this->add_attribute( 'data-formula', $formula );
32 $this->add_attribute( 'data-name', $args['name'] );
33 $this->add_attribute( 'data-precision', $precision );
34 $this->add_attribute( 'data-sep-decimal', $args['separate_decimals'] );
35 $this->add_attribute( 'data-sep-thousands', $args['separate_thousands'] );
36 $this->add_attribute( 'data-value-type', $this->args['value_type'] );
37 $this->add_attribute( 'data-date-format', ! empty( $args['date_format'] ) ? $args['date_format'] : 'YYYY-MM-DD' );
38
39 $this->add_attribute( 'class', 'jet-form-builder__calculated-field' );
40 $this->add_attribute( 'class', $is_hidden ? 'jet-form-builder__calculated-field--hidden' : '' );
41
42 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WhiteSpace.PrecisionAlignment.Found
43 ?>
44 <div <?php $this->render_attributes_string(); ?>>
45 <?php do_action( 'jet-form-builder/before-field', $this ); ?>
46 <?php if ( false !== $prefix ) : ?>
47 <div class="jet-form-builder__calculated-field-prefix"><?php echo wp_kses_post( $prefix ); ?></div>
48 <?php endif; ?>
49 <input type="hidden"
50 name="<?php echo esc_attr( $name ); ?>"
51 id="<?php echo esc_attr( $id_attr ); ?>"
52 value="<?php echo esc_attr( $default_value ); ?>"
53 class="jet-form-builder__calculated-field-input jet-form-builder__field"
54 data-field-name="<?php echo esc_attr( $args['name'] ); ?>"
55 data-jfb-sync
56 />
57 <div class="jet-form-builder__calculated-field-val"><?php echo wp_kses_post( $this->render_editor_placeholder() ); ?></div>
58 <?php if ( false !== $suffix ) : ?>
59 <div class="jet-form-builder__calculated-field-suffix"><?php echo wp_kses_post( $suffix ); ?></div>
60 <?php endif; ?>
61 <?php do_action( 'jet-form-builder/after-field', $this ); ?>
62 </div>
63 <?php
64