PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.5.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 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / blocks / render / calculated-field-render.php
jetformbuilder / includes / blocks / render Last commit date
action-button-render.php 2 years ago base.php 2 years ago calculated-field-render.php 2 years ago date-field-render.php 2 years ago datetime-field-render.php 2 years ago form-builder.php 1 year ago form-hidden-fields.php 1 year ago group-break-field-render.php 2 years ago heading-field-render.php 2 years ago media-field-render.php 1 year ago number-field-render.php 2 years ago range-field-render.php 2 years ago textarea-field-render.php 2 years ago time-field-render.php 2 years ago
calculated-field-render.php
71 lines
1 <?php
2
3 namespace Jet_Form_Builder\Blocks\Render;
4
5 // If this file is called directly, abort.
6 use Jet_Form_Builder\Classes\Tools;
7 use Jet_Form_Builder\Live_Form;
8
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 /**
14 * Define text field renderer class
15 */
16 class Calculated_Field_Render extends Base {
17
18 public function get_name() {
19 return 'calculated-field';
20 }
21
22 public function render_editor_placeholder() {
23 return Tools::is_editor() ? '25.00' : '0.00';
24 }
25
26 /**
27 * We do not need a <label> tag in any case,
28 * because there is no visual field in this field
29 * that can be referenced through the "for" attribute.
30 *
31 * @see https://github.com/Crocoblock/jetformbuilder/issues/356
32 */
33 protected function get_fields_label_tag(): string {
34 return 'div';
35 }
36
37 /**
38 * Get calulation formula for calculated field
39 *
40 * @return [type] [description]
41 */
42 public function get_calculated_data( $args ) {
43
44 if ( empty( $args['calc_formula'] ) ) {
45 return '';
46 }
47
48 $formula = preg_replace_callback(
49 '/%([a-zA-Z-_]+)::([a-zA-Z0-9-_]+)%/',
50 function ( $matches ) {
51 switch ( strtolower( $matches[1] ) ) {
52 case 'field':
53 return '%' . $matches[2] . '%';
54
55 case 'meta':
56 return get_post_meta( Live_Form::instance()->post->ID, $matches[2], true );
57
58 default:
59 $macros_name = $matches[1];
60
61 return apply_filters( "jet-engine/calculated-data/$macros_name", $matches[0], $matches );
62 }
63 },
64 $args['calc_formula']
65 );
66
67 return str_replace( '^', '**', $formula );
68 }
69
70 }
71