| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules\Renderer\GlobalSettings; |
| 4 |
|
| 5 |
use FluentForm\App\Helpers\Helper; |
| 6 |
use FluentForm\App\Modules\Form\AkismetHandler; |
| 7 |
use FluentForm\App\Modules\Form\CleanTalkHandler; |
| 8 |
use FluentForm\App\Modules\Registerer\TranslationString; |
| 9 |
use FluentForm\Framework\Foundation\Application; |
| 10 |
|
| 11 |
class Settings |
| 12 |
{ |
| 13 |
/** |
| 14 |
* App instance |
| 15 |
* |
| 16 |
* @var \FluentForm\Framework\Foundation\Application |
| 17 |
*/ |
| 18 |
protected $app; |
| 19 |
|
| 20 |
/** |
| 21 |
* GlobalSettings constructor. |
| 22 |
* |
| 23 |
* @param \FluentForm\Framework\Foundation\Application $app |
| 24 |
*/ |
| 25 |
public function __construct(Application $app) |
| 26 |
{ |
| 27 |
$this->app = $app; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Render the page for native global settings components |
| 32 |
* |
| 33 |
* @param string $defaultComponent |
| 34 |
* @throws \Exception |
| 35 |
*/ |
| 36 |
public function render($defaultComponent = 'settings') |
| 37 |
{ |
| 38 |
$this->enqueue($defaultComponent); |
| 39 |
|
| 40 |
$this->app->view->render('admin.globalSettings.settings'); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Enqueue necessary resources. |
| 45 |
* |
| 46 |
* @param string $defaultComponent |
| 47 |
* @throws \Exception |
| 48 |
*/ |
| 49 |
public function enqueue($defaultComponent = 'settings') |
| 50 |
{ |
| 51 |
wp_enqueue_script('fluentform-global-settings-js'); |
| 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); |
| 68 |
} |
| 69 |
} |
| 70 |
|