← All changes
|
app/Modules/Renderer/GlobalSettings/Settings.php
+27
-10
3.6.40
→
6.2.15
View file →
| @@ -1,14 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentForm\App\Modules\Renderer\GlobalSettings; |
| 4 | 4 | |
| 5 | +use FluentForm\App\Helpers\Helper; | |
| 5 | 6 | use FluentForm\App\Modules\Form\AkismetHandler; |
| 7 | +use FluentForm\App\Modules\Form\CleanTalkHandler; | |
| 8 | +use FluentForm\App\Modules\Registerer\TranslationString; | |
| 6 | 9 | use FluentForm\Framework\Foundation\Application; |
| 7 | 10 | |
| 8 | 11 | class Settings |
| 9 | 12 | { |
| 10 | 13 | /** |
| 14 | + * App instance | |
| 15 | + * | |
| 11 | 16 | * @var \FluentForm\Framework\Foundation\Application |
| 12 | 17 | */ |
| 13 | 18 | protected $app; |
| 14 | 19 | |
| @@ -24,29 +29,41 @@ | ||
| 24 | 29 | |
| 25 | 30 | /** |
| 26 | 31 | * Render the page for native global settings components |
| 27 | 32 | * |
| 33 | + * @param string $defaultComponent | |
| 28 | 34 | * @throws \Exception |
| 29 | 35 | */ |
| 30 | - public function render() | |
| 36 | + public function render($defaultComponent = 'settings') | |
| 31 | 37 | { |
| 32 | - $this->enqueue(); | |
| 38 | + $this->enqueue($defaultComponent); | |
| 33 | 39 | |
| 34 | - $this->app->view->render('admin.settings.settings'); | |
| 40 | + $this->app->view->render('admin.globalSettings.settings'); | |
| 35 | 41 | } |
| 36 | 42 | |
| 37 | 43 | /** |
| 38 | 44 | * Enqueue necessary resources. |
| 39 | 45 | * |
| 46 | + * @param string $defaultComponent | |
| 40 | 47 | * @throws \Exception |
| 41 | 48 | */ |
| 42 | - public function enqueue() | |
| 49 | + public function enqueue($defaultComponent = 'settings') | |
| 43 | 50 | { |
| 44 | 51 | wp_enqueue_script('fluentform-global-settings-js'); |
| 45 | - | |
| 46 | - wp_localize_script('fluentform-global-settings-js', 'FluentFormApp', [ | |
| 47 | - 'plugin' => $this->app->getSlug(), | |
| 48 | - 'akismet_activated' => AkismetHandler::isPluginEnabled(), | |
| 49 | - 'has_pro' => defined('FLUENTFORMPRO') | |
| 50 | - ]); | |
| 52 | + | |
| 53 | + $globalSettingAppData = [ | |
| 54 | + 'plugin' => $this->app->config->get('app.slug'), | |
| 55 | + 'akismet_activated' => AkismetHandler::isPluginEnabled(), | |
| 56 | + 'cleantalk_activated' => CleanTalkHandler::isPluginEnabled(), | |
| 57 | + 'has_pro' => Helper::hasPro(), | |
| 58 | + 'upgrade_url' => fluentform_upgrade_url(), | |
| 59 | + 'is_payment_compatible' => Helper::isPaymentCompatible(), | |
| 60 | + 'default_component' => sanitize_key($defaultComponent), | |
| 61 | + 'form_settings_str' => TranslationString::getGlobalSettingsI18n(), | |
| 62 | + 'ace_path_url' => fluentformMix('libs/ace'), | |
| 63 | + ]; | |
| 64 | + if (Helper::isPaymentCompatible()) { | |
| 65 | + $globalSettingAppData = apply_filters('fluentform/global_settings_component_settings_data', $globalSettingAppData); | |
| 66 | + } | |
| 67 | + wp_localize_script('fluentform-global-settings-js', 'FluentFormApp', $globalSettingAppData); | |
| 51 | 68 | } |
| 52 | 69 | } |