@@ -843,36 +843,36 @@ public function populate_related_items_tooltip( $tooltips ) {
843843 }
844844
845845 /**
846- *
846+ * Init integration.
847847 */
848848 public function init () {
849-
850849 parent ::init ();
851850
852- if ( $ this ->is_gravityforms_supported () ) {
853- // Handle normal forms.
854- add_filter ( 'gform_pre_render ' , array ( $ this , '_gf_pre_render ' ), 9 , 2 );
855- add_filter ( 'gform_admin_pre_render ' , array ( $ this , '_gf_pre_render ' ), 9 , 1 );
856- add_filter ( 'gform_pre_process ' , array ( $ this , '_gf_pre_process ' ) );
851+ if ( ! $ this ->is_gravityforms_supported () ) {
852+ return ;
853+ }
857854
858- // Handle merge tags
859- add_filter ( 'gform_custom_merge_tags ' , array ( $ this , '_gf_custom_merge_tags ' ), 10 , 2 );
860- add_filter ( 'gform_merge_tag_data ' , array ( $ this , '_gf_add_merge_tags ' ), 10 , 3 );
861- add_filter ( 'gform_replace_merge_tags ' , array ( $ this , '_gf_replace_merge_tags ' ), 10 , 2 );
855+ // Handle normal forms.
856+ add_filter ( 'gform_pre_render ' , array ( $ this , '_gf_pre_render ' ), 9 , 3 );
857+ add_filter ( 'gform_admin_pre_render ' , array ( $ this , '_gf_pre_render ' ), 9 , 1 );
858+ add_filter ( 'gform_pre_process ' , array ( $ this , '_gf_pre_process ' ) );
862859
863- // Handle entry detail edits.
864- add_action ( 'gform_pre_entry_detail ' , array ( $ this , '_gf_pre_entry_detail ' ), 10 , 2 );
865- add_action ( 'check_admin_referer ' , array ( $ this , '_check_admin_referer ' ), 10 , 2 );
866- add_action ( 'gform_entry_detail_content_before ' , array ( $ this , '_gf_entry_detail_content_before ' ), 10 , 2 );
860+ // Handle merge tags
861+ add_filter ( 'gform_custom_merge_tags ' , array ( $ this , '_gf_custom_merge_tags ' ), 10 , 2 );
862+ add_filter ( 'gform_merge_tag_data ' , array ( $ this , '_gf_add_merge_tags ' ), 10 , 3 );
863+ add_filter ( 'gform_replace_merge_tags ' , array ( $ this , '_gf_replace_merge_tags ' ), 10 , 2 );
867864
868- // Handle entry updates.
869- add_action ( 'gform_post_update_entry ' , array ( $ this , '_gf_post_update_entry ' ), 9 , 2 );
870- add_action ( 'gform_after_update_entry ' , array ( $ this , '_gf_after_update_entry ' ), 9 , 3 );
865+ // Handle entry detail edits.
866+ add_action ( 'gform_pre_entry_detail ' , array ( $ this , '_gf_pre_entry_detail ' ), 10 , 2 );
867+ add_action ( 'check_admin_referer ' , array ( $ this , '_check_admin_referer ' ), 10 , 2 );
868+ add_action ( 'gform_entry_detail_content_before ' , array ( $ this , '_gf_entry_detail_content_before ' ), 10 , 2 );
871869
872- // Handle Payment Add-on callbacks .
873- add_action ( 'gform_action_pre_payment_callback ' , array ( $ this , '_gf_action_pre_payment_callback ' ), 10 , 2 );
874- }
870+ // Handle entry updates .
871+ add_action ( 'gform_post_update_entry ' , array ( $ this , '_gf_post_update_entry ' ), 9 , 2 );
872+ add_action ( ' gform_after_update_entry ' , array ( $ this , ' _gf_after_update_entry ' ), 9 , 3 );
875873
874+ // Handle Payment Add-on callbacks.
875+ add_action ( 'gform_action_pre_payment_callback ' , array ( $ this , '_gf_action_pre_payment_callback ' ), 10 , 2 );
876876 }
877877
878878 /**
@@ -893,7 +893,7 @@ public function process_feed( $feed, $entry, $form ) {
893893 return null ;
894894 }
895895
896- $ form = $ this ->_gf_pre_render ( $ form , $ entry );
896+ $ form = $ this ->_gf_pre_render ( $ form , false , $ entry );
897897
898898 /** @var Pods_GF $pods_gf */
899899 $ pods_gf = $ this ->pods_gf [ $ feed ['id ' ] ];
@@ -974,7 +974,7 @@ public function _gf_pre_entry_detail( $form, $entry ) {
974974 remove_action ( 'check_admin_referer ' , array ( $ this , '_check_admin_referer ' ) );
975975 remove_action ( 'gform_entry_detail_content_before ' , array ( $ this , '_gf_entry_detail_content_before ' ) );
976976
977- $ this ->_gf_pre_render ( $ form , $ entry , true );
977+ $ this ->_gf_pre_render ( $ form , false , $ entry , true );
978978
979979 }
980980
@@ -1004,7 +1004,7 @@ public function _check_admin_referer( $action, $result ) {
10041004 */
10051005 public function _gf_entry_detail_content_before ( $ form , $ entry ) {
10061006
1007- $ this ->_gf_pre_render ( $ form , $ entry , true );
1007+ $ this ->_gf_pre_render ( $ form , false , $ entry , true );
10081008
10091009 }
10101010
@@ -1013,7 +1013,11 @@ public function _gf_entry_detail_content_before( $form, $entry ) {
10131013 *
10141014 * @return mixed
10151015 */
1016- public function _gf_pre_render ( $ form , $ entry = null , $ admin_edit = false ) {
1016+ public function _gf_pre_render ( $ form , $ ajax = false , $ entry = null , $ admin_edit = false ) {
1017+ // Bad form / form ID.
1018+ if ( empty ( $ form ) ) {
1019+ return $ form ;
1020+ }
10171021
10181022 static $ setup = array ();
10191023
@@ -1071,52 +1075,58 @@ public function _gf_pre_render( $form, $entry = null, $admin_edit = false ) {
10711075 * @var GF_Field $gf_field
10721076 */
10731077 foreach ( $ form ['fields ' ] as $ gf_field ) {
1074- if ( ! empty ( $ gf_field ->pods_populate_related_items ) ) {
1075- $ pod_field = null ;
1078+ if ( empty ( $ gf_field ->pods_populate_related_items ) ) {
1079+ //continue;
1080+ }
10761081
1077- foreach ( $ pod_fields as $ k => $ field_options ) {
1078- if ( (string ) $ gf_field ->id === (string ) $ field_options ['gf_field ' ] ) {
1079- $ pod_field = $ field_options ['field ' ];
1080- }
1081- }
1082+ $ pod_field = null ;
10821083
1083- if ( empty ( $ pod_field ) ) {
1084- continue ;
1084+ foreach ( $ pod_fields as $ k => $ field_options ) {
1085+ if ( (string ) $ gf_field ->id === (string ) $ field_options ['gf_field ' ] ) {
1086+ $ pod_field = $ field_options ['field ' ];
10851087 }
1088+ }
10861089
1087- $ pod_field_options = $ pod_obj ->fields ( $ pod_field );
1090+ if ( empty ( $ pod_field ) ) {
1091+ continue ;
1092+ }
10881093
1089- // Override limit for autocomplete
1090- $ object_params = array (
1091- 'limit ' => -1 ,
1092- );
1094+ $ pod_field_options = $ pod_obj ->fields ( $ pod_field );
10931095
1094- $ data = PodsForm::field_method ( $ pod_field_options ['type ' ], 'get_field_data ' , $ pod_field_options , array (), $ object_params );
1096+ if ( empty ( $ pod_field_options ) ) {
1097+ continue ;
1098+ }
10951099
1096- if ( empty ( $ data ) ) {
1097- continue ;
1098- }
1100+ // Override limit for autocomplete
1101+ $ object_params = array (
1102+ 'limit ' => -1 ,
1103+ );
10991104
1100- if ( isset ( $ data ['' ] ) ) {
1101- unset( $ data ['' ] );
1102- }
1105+ $ data = PodsForm::field_method ( $ pod_field_options ['type ' ], 'get_field_data ' , $ pod_field_options , array (), $ object_params );
1106+
1107+ if ( empty ( $ data ) ) {
1108+ continue ;
1109+ }
11031110
1104- $ select_text = pods_v ( $ pod_field_options ['type ' ] . '_select_text ' , $ pod_field_options ['options ' ], __ ( '-- Select One -- ' , 'pods ' ), true );
1111+ if ( isset ( $ data ['' ] ) ) {
1112+ unset( $ data ['' ] );
1113+ }
11051114
1106- $ options = array (
1107- 'options ' => $ data ,
1108- );
1115+ $ select_text = pods_v ( $ pod_field_options ['type ' ] . '_select_text ' , $ pod_field_options ['options ' ], __ ( '-- Select One -- ' , 'pods ' ), true );
11091116
1110- if ( $ select_text ) {
1111- $ options[ ' select_text ' ] = $ select_text ;
1112- }
1117+ $ options = array (
1118+ ' options ' => $ data ,
1119+ );
11131120
1114- $ dynamic_selects [ $ gf_field ->id ] = $ options ;
1121+ if ( $ select_text ) {
1122+ $ options ['select_text ' ] = $ select_text ;
11151123 }
1124+
1125+ $ dynamic_selects [ $ gf_field ->id ] = $ options ;
11161126 }
11171127
11181128 if ( ! empty ( $ dynamic_selects ) ) {
1119- $ form = Pods_GF::gf_dynamic_select ( $ form , $ dynamic_selects );
1129+ $ form = Pods_GF::gf_dynamic_select ( $ form , false , $ dynamic_selects );
11201130 }
11211131 }
11221132
0 commit comments