| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\FeatureFlags\OptionBasedFormEditor; |
| 4 |
|
| 5 |
use Give\FeatureFlags\OptionBasedFormEditor\Settings\Advanced as AdvancedSettings; |
| 6 |
use Give\FeatureFlags\OptionBasedFormEditor\Settings\DefaultOptions as DefaultOptionsSettings; |
| 7 |
use Give\FeatureFlags\OptionBasedFormEditor\Settings\General as GeneralSettings; |
| 8 |
use Give\Helpers\Hooks; |
| 9 |
use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface; |
| 10 |
|
| 11 |
/** |
| 12 |
* @since 3.18.0 |
| 13 |
*/ |
| 14 |
class ServiceProvider implements ServiceProviderInterface |
| 15 |
{ |
| 16 |
/** |
| 17 |
* @since 3.18.0 |
| 18 |
*/ |
| 19 |
public function register() |
| 20 |
{ |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* @since 3.18.0 |
| 25 |
*/ |
| 26 |
public function boot() |
| 27 |
{ |
| 28 |
$this->maybeDisableOptionBasedFormEditorSettings(); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* @return void |
| 33 |
*/ |
| 34 |
private function maybeDisableOptionBasedFormEditorSettings() |
| 35 |
{ |
| 36 |
// General Tab |
| 37 |
Hooks::addFilter('give_get_settings_general', GeneralSettings::class, 'maybeDisableOptions', 999); |
| 38 |
|
| 39 |
// Payment Gateways Tab |
| 40 |
add_filter('give_settings_payment_gateways_menu_groups', function ($groups) { |
| 41 |
if ( ! OptionBasedFormEditor::isEnabled() && isset($groups['v2'])) { |
| 42 |
unset($groups['v2']); |
| 43 |
} |
| 44 |
|
| 45 |
return $groups; |
| 46 |
}); |
| 47 |
|
| 48 |
// Default Options Tab |
| 49 |
Hooks::addFilter('give_get_settings_display', DefaultOptionsSettings::class, 'maybeDisableOptions', 999); |
| 50 |
|
| 51 |
// Advance Tab |
| 52 |
Hooks::addFilter('give_get_settings_advanced', AdvancedSettings::class, 'maybeDisableOptions', 999); |
| 53 |
} |
| 54 |
} |
| 55 |
|