From 6009da91b3eb626e75155abc4cf557eb392357ab Mon Sep 17 00:00:00 2001 From: Morgan Kay Date: Fri, 27 Jan 2023 12:23:50 -0800 Subject: [PATCH 1/4] demonstrate problem with gform_form_settings_fields filter --- class-gfsimplefeedaddon.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/class-gfsimplefeedaddon.php b/class-gfsimplefeedaddon.php index 0eaef9f..b28ce68 100644 --- a/class-gfsimplefeedaddon.php +++ b/class-gfsimplefeedaddon.php @@ -42,6 +42,31 @@ public function init() { } + public function init_admin() { + parent::init_admin(); + + add_filter( 'gform_form_settings_fields', array( $this, 'form_settings_filter_test' ), 10, 2 ); + } + + public function form_settings_filter_test( $sections, $form ) { + $sections[] = array( + + 'title' => esc_html__( 'Simple Add-On Form', 'simplefeedaddon' ), + 'fields' => array( + array( + 'name' => 'textbox', + 'tooltip' => esc_html__( 'This is the tooltip', 'simplefeedaddon' ), + 'label' => esc_html__( 'This should only be on the Simple Feed add-on settings tab', 'simplefeedaddon' ), + 'type' => 'text', + 'class' => 'small', + ), + ), + + ); + + return $sections; + } + // # FEED PROCESSING ----------------------------------------------------------------------------------------------- From af43455732a2b383b012493622fae0acce850ca9 Mon Sep 17 00:00:00 2001 From: Morgan Kay Date: Fri, 27 Jan 2023 15:04:13 -0800 Subject: [PATCH 2/4] rename settings field --- class-gfsimplefeedaddon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class-gfsimplefeedaddon.php b/class-gfsimplefeedaddon.php index b28ce68..541c7eb 100644 --- a/class-gfsimplefeedaddon.php +++ b/class-gfsimplefeedaddon.php @@ -56,7 +56,7 @@ public function form_settings_filter_test( $sections, $form ) { array( 'name' => 'textbox', 'tooltip' => esc_html__( 'This is the tooltip', 'simplefeedaddon' ), - 'label' => esc_html__( 'This should only be on the Simple Feed add-on settings tab', 'simplefeedaddon' ), + 'label' => esc_html__( 'This should only be on main form settings tab', 'simplefeedaddon' ), 'type' => 'text', 'class' => 'small', ), From db20b12227cc68d04a9090ddf01a4d42a18a957c Mon Sep 17 00:00:00 2001 From: Emmanuel Laborin Date: Wed, 15 Mar 2023 01:49:09 -0700 Subject: [PATCH 3/4] Add dummy fields to test new filter --- class-gfsimplefeedaddon.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/class-gfsimplefeedaddon.php b/class-gfsimplefeedaddon.php index 541c7eb..43102c1 100644 --- a/class-gfsimplefeedaddon.php +++ b/class-gfsimplefeedaddon.php @@ -14,6 +14,7 @@ class GFSimpleFeedAddOn extends GFFeedAddOn { private static $_instance = null; + /** * Get an instance of this class. * @@ -40,12 +41,15 @@ public function init() { ) ); + + } public function init_admin() { parent::init_admin(); add_filter( 'gform_form_settings_fields', array( $this, 'form_settings_filter_test' ), 10, 2 ); + add_filter( 'gform_form_addon_settings_fields', array( $this, 'form_addon_settings_filter_test' ), 10, 2 ); } public function form_settings_filter_test( $sections, $form ) { @@ -67,6 +71,25 @@ public function form_settings_filter_test( $sections, $form ) { return $sections; } + public function form_addon_settings_filter_test( $sections, $form ) { + $sections[] = array( + + 'title' => esc_html__( 'Simple Add-On Form', 'simplefeedaddon' ), + 'fields' => array( + array( + 'name' => 'textbox', + 'tooltip' => esc_html__( 'This is the tooltip', 'simplefeedaddon' ), + 'label' => esc_html__( 'This will appear on all setting tabs for addons that override the form_settings_fields method.', 'simplefeedaddon' ), + 'type' => 'text', + 'class' => 'small', + ), + ), + + ); + + return $sections; + } + // # FEED PROCESSING ----------------------------------------------------------------------------------------------- From 375e80a8eadbeeb15a9d24fef7591786b2f55ec0 Mon Sep 17 00:00:00 2001 From: Emmanuel Laborin Date: Thu, 16 Mar 2023 08:37:11 -0700 Subject: [PATCH 4/4] Update to use the new filter name for gform_addon_form_settings_fields --- class-gfsimplefeedaddon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class-gfsimplefeedaddon.php b/class-gfsimplefeedaddon.php index 43102c1..5ea9a40 100644 --- a/class-gfsimplefeedaddon.php +++ b/class-gfsimplefeedaddon.php @@ -49,7 +49,7 @@ public function init_admin() { parent::init_admin(); add_filter( 'gform_form_settings_fields', array( $this, 'form_settings_filter_test' ), 10, 2 ); - add_filter( 'gform_form_addon_settings_fields', array( $this, 'form_addon_settings_filter_test' ), 10, 2 ); + add_filter( 'gform_addon_form_settings_fields', array( $this, 'form_addon_settings_filter_test' ), 10, 2 ); } public function form_settings_filter_test( $sections, $form ) {