@@ -22,6 +22,8 @@ public function __construct( $args = array() ) {
2222 'default_entry_id ' => 1 ,
2323 ) );
2424
25+ $ this ->form_id = rgar ( $ args , 'form_id ' );
26+
2527 add_action ( 'init ' , array ( $ this , 'init ' ), 11 );
2628
2729 }
@@ -43,15 +45,23 @@ public function init() {
4345
4446 }
4547
48+ public function is_applicable_form ( $ form ) {
49+ return empty ( $ this ->form_id ) || (int ) rgar ( $ form , 'id ' ) === (int ) $ this ->form_id ;
50+ }
51+
4652 public function gpml_gflow_next_step ( $ step , $ current_step , $ entry , $ steps ) {
4753 $ form = GFAPI ::get_form ( $ entry ['form_id ' ] );
54+ if ( ! $ this ->is_applicable_form ( $ form ) ) {
55+ return $ step ;
56+ }
57+
4858 $ this ->update_entry_field_values ( $ entry , $ form );
4959 return $ step ;
5060 }
5161
5262 public function upload ( $ form , $ field , $ uploaded_filename , $ tmp_file_name , $ file_path ) {
5363
54- if ( ! gp_media_library ()->is_applicable_field ( $ field ) ) {
64+ if ( ! gp_media_library ()->is_applicable_field ( $ field ) || ! $ this -> is_applicable_form ( $ form ) ) {
5565 return ;
5666 }
5767
@@ -106,6 +116,10 @@ public function upload( $form, $field, $uploaded_filename, $tmp_file_name, $file
106116
107117 public function update_entry_field_values ( $ entry , $ form ) {
108118
119+ if ( ! $ this ->is_applicable_form ( $ form ) ) {
120+ return $ entry ;
121+ }
122+
109123 foreach ( $ form ['fields ' ] as $ field ) {
110124
111125 if ( $ field ->get_input_type () != 'fileupload ' || ! $ field ->multipleFiles ) {
@@ -151,5 +165,11 @@ public function update_entry_field_values( $entry, $form ) {
151165}
152166
153167# Configuration
154-
168+ // Apply to All Forms.
155169new 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