Skip to content

Commit 9d24a36

Browse files
committed
Fix fatal error on some new setups.
The `get_plugin_settings` function returns a default value of `false`, through WordPress' `get_option` call, while an array is expected. This change adds a check for a boolean `false` value, and sets the default value as an empty array in such cases. Fixes #3
1 parent 3af3549 commit 9d24a36

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

includes/class-addon.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,17 @@ public static function get_instance(): AddOn {
106106
public function init() {
107107
parent::init();
108108

109-
$this->controller = new Controller( $this->get_plugin_settings() );
109+
/**
110+
* Fallback handling of settings, as the base `GFAddOn` function `get_plugin_settings`
111+
* does not provide a default array value for its settings, so we need to do it, thus
112+
* avoiding our own fatal error when we expect settings to be in the form of an array in the Controller.
113+
*/
114+
$plugin_settings = $this->get_plugin_settings();
115+
if ( false === $plugin_settings ) {
116+
$plugin_settings = [];
117+
}
118+
119+
$this->controller = new Controller( $plugin_settings );
110120

111121
add_action( 'gform_after_submission', [ $this, 'after_submission' ], 10, 2 );
112122
}

0 commit comments

Comments
 (0)