PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.3
JetFormBuilder — Dynamic Blocks Form Builder v3.4.3
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 / modules / fields-render-validator / module.php
jetformbuilder / modules / fields-render-validator Last commit date
module.php 1 year ago
module.php
87 lines
1 <?php
2
3 namespace JFB_Modules\Fields_Render_Validator;
4
5 use JFB_Components\Module\Base_Module_Dir_It;
6 use JFB_Components\Module\Base_Module_Dir_Trait;
7 use JFB_Components\Module\Base_Module_Handle_It;
8 use JFB_Components\Module\Base_Module_Handle_Trait;
9 use JFB_Components\Module\Base_Module_It;
10 use JFB_Components\Module\Base_Module_Url_It;
11 use JFB_Components\Module\Base_Module_Url_Trait;
12 use JFB_Components\Module\Base_Module_After_Install_It;
13
14
15 // If this file is called directly, abort.
16 if ( ! defined( 'WPINC' ) ) {
17 die;
18 }
19
20 class Module implements
21 Base_Module_It,
22 Base_Module_Url_It,
23 Base_Module_Handle_It,
24 Base_Module_After_Install_It,
25 Base_Module_Dir_It {
26
27 use Base_Module_Handle_Trait;
28 use Base_Module_Url_Trait;
29 use Base_Module_Dir_Trait;
30
31 public function rep_item_id() {
32 return 'fields-render-validator';
33 }
34
35 public function condition(): bool {
36 return current_user_can( 'manage_options' );
37 }
38
39 protected $fields_stack = array();
40
41 public function init_hooks() {
42 add_filter( 'jet-form-builder/after-start-form', array( $this, 'reset_stack' ), 0 );
43 add_filter( 'jet-form-builder/after-render-field', array( $this, 'update_stack' ), 0, 5 );
44 }
45
46 public function reset_stack( string $html ): string {
47 $this->fields_stack = array();
48 return $html;
49 }
50
51 public function update_stack( $output, $field_name, $attrs, $content, $wp_block ): string {
52
53 if ( isset( $attrs['name'] ) && 'undefined' !== $attrs['name'] ) {
54 $name = $attrs['name'];
55
56 $context = $wp_block->context ?? '';
57 if ( $context ) {
58 $context_name = $context['jet-forms/repeater-field--name'] ?? '';
59 $context_index = $context['jet-forms/repeater-row--current-index'] ?? '';
60 if ( '' !== $context_name ) {
61 $name = $context_name . $context_index . $name;
62 }
63 }
64
65 if ( in_array( $name, $this->fields_stack ) ) {
66 $parent = $context ? 'repeater' : 'form';
67 $output .= "<div class='jet-form-builder__uniq-name-error' style='color:red;font-size: 12px;'>You already have field < " . esc_attr( $attrs['name'] ) . ' > in this ' . $parent . '. Please rename current field to avoid form processing errors.</div>';
68
69 } else {
70 $this->fields_stack[] = $name;
71 }
72 }
73
74 return $output;
75 }
76
77 public function on_install() {
78 }
79
80 public function on_uninstall() {
81 }
82
83 public function remove_hooks() {
84 }
85
86 }
87