PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / FormTaxonomies / Actions / EnqueueFormBuilderAssets.php

EnqueueFormBuilderAssets.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/FormTaxonomies/Actions/EnqueueFormBuilderAssets.php

62 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\FormTaxonomies\Actions;
4
5 use Give\FormTaxonomies\ViewModels\FormTaxonomyViewModel;
6 use Give\Framework\Support\Facades\Scripts\ScriptAsset;
7 use Give\Helpers\Language;
8
9 /**
10 * @since 3.16.0
11 */
12 class EnqueueFormBuilderAssets
13 {
14 /**
15 * @var FormTaxonomyViewModel
16 */
17 protected $viewModel;
18
19 /**
20 * @since 3.16.0
21 */
22 public function __construct(FormTaxonomyViewModel $viewModel)
23 {
24 $this->viewModel = $viewModel;
25 }
26
27 /**
28 * @since 4.10.0 use formTaxonomySettings.css instead of style-formTaxonomySettings.css
29 * @since 3.16.0
30 */
31 public function __invoke()
32 {
33 if($this->viewModel->isFormTagsEnabled() || $this->viewModel->isFormCategoriesEnabled()) {
34
35 $scriptAsset = ScriptAsset::get(GIVE_PLUGIN_DIR . 'build/formTaxonomySettings.asset.php');
36
37 wp_enqueue_script(
38 'givewp-builder-taxonomy-settings',
39 GIVE_PLUGIN_URL . 'build/formTaxonomySettings.js',
40 $scriptAsset['dependencies'],
41 $scriptAsset['version'],
42 true
43 );
44
45 Language::setScriptTranslations('givewp-builder-taxonomy-settings');
46
47 wp_enqueue_style(
48 'givewp-builder-taxonomy-settings',
49 GIVE_PLUGIN_URL . 'build/formTaxonomySettings.css'
50 );
51
52 wp_add_inline_script('givewp-builder-taxonomy-settings','var giveTaxonomySettings =' . json_encode([
53 'formTagsEnabled' => $this->viewModel->isFormTagsEnabled(),
54 'formCategoriesEnabled' => $this->viewModel->isFormCategoriesEnabled(),
55 'formTagsSelected' => $this->viewModel->getSelectedFormTags(),
56 'formCategoriesAvailable' => $this->viewModel->getFormCategories(),
57 'formCategoriesSelected' => $this->viewModel->getSelectedFormCategories(),
58 ]));
59 }
60 }
61 }
62