Add cli commands for settings

This commit is contained in:
Cooper Dalrymple
2026-06-09 16:29:06 -05:00
parent c37712d2b5
commit 97ec73035e
4 changed files with 280 additions and 4 deletions
+8 -1
View File
@@ -116,7 +116,7 @@ final class Addon extends GFAddOn {
}
public function is_enabled(array|null $form = null): bool {
$plugin_enabled = (bool) $this->get_plugin_setting('enabled');
$plugin_enabled = $this->get_plugin_setting('enabled') === '1';
if (is_null($form) || !$plugin_enabled) return $plugin_enabled;
$form_settings = $this->get_form_settings($form);
@@ -124,6 +124,13 @@ final class Addon extends GFAddOn {
return !$form_disabled;
}
public function set_enabled(bool $value): bool {
$settings = (array) $this->get_plugin_settings();
$settings['enabled'] = !!$value ? '1' : '0';
$this->update_plugin_settings($settings);
return true;
}
public function submit_button(string $button_input, array $form): string {
if (!Settings::is_connected() || !$this->is_enabled($form)) return $button_input;
if ((is_admin() && !defined('DOING_AJAX')) || GFCommon::is_form_editor()) return $button_input;