Add cli commands for settings
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user