@@ -22,6 +22,8 @@ public function __construct( $args = array() ) {
22
22
'default_entry_id ' => 1 ,
23
23
) );
24
24
25
+ $ this ->form_id = rgar ( $ args , 'form_id ' );
26
+
25
27
add_action ( 'init ' , array ( $ this , 'init ' ), 11 );
26
28
27
29
}
@@ -43,15 +45,23 @@ public function init() {
43
45
44
46
}
45
47
48
+ public function is_applicable_form ( $ form ) {
49
+ return empty ( $ this ->form_id ) || (int ) rgar ( $ form , 'id ' ) === (int ) $ this ->form_id ;
50
+ }
51
+
46
52
public function gpml_gflow_next_step ( $ step , $ current_step , $ entry , $ steps ) {
47
53
$ form = GFAPI ::get_form ( $ entry ['form_id ' ] );
54
+ if ( ! $ this ->is_applicable_form ( $ form ) ) {
55
+ return $ step ;
56
+ }
57
+
48
58
$ this ->update_entry_field_values ( $ entry , $ form );
49
59
return $ step ;
50
60
}
51
61
52
62
public function upload ( $ form , $ field , $ uploaded_filename , $ tmp_file_name , $ file_path ) {
53
63
54
- if ( ! gp_media_library ()->is_applicable_field ( $ field ) ) {
64
+ if ( ! gp_media_library ()->is_applicable_field ( $ field ) || ! $ this -> is_applicable_form ( $ form ) ) {
55
65
return ;
56
66
}
57
67
@@ -106,6 +116,10 @@ public function upload( $form, $field, $uploaded_filename, $tmp_file_name, $file
106
116
107
117
public function update_entry_field_values ( $ entry , $ form ) {
108
118
119
+ if ( ! $ this ->is_applicable_form ( $ form ) ) {
120
+ return $ entry ;
121
+ }
122
+
109
123
foreach ( $ form ['fields ' ] as $ field ) {
110
124
111
125
if ( $ field ->get_input_type () != 'fileupload ' || ! $ field ->multipleFiles ) {
@@ -151,5 +165,11 @@ public function update_entry_field_values( $entry, $form ) {
151
165
}
152
166
153
167
# Configuration
154
-
168
+ // Apply to All Forms.
155
169
new GPML_Ajax_Upload ();
170
+
171
+ // Apply to A Specific Form.
172
+ new GPML_Ajax_Upload ( array (
173
+ 'form_id ' => 292 ,
174
+ )
175
+ );
0 commit comments