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 / Campaigns / Shortcodes / CampaignGoalShortcode.php

CampaignGoalShortcode.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Campaigns/Shortcodes/CampaignGoalShortcode.php

79 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Campaigns\Shortcodes;
4
5 use Give\Campaigns\Actions\LoadCampaignPublicOptions;
6 use Give\Framework\Support\Facades\Scripts\ScriptAsset;
7 use Give\Helpers\Language;
8
9 /**
10 * @since 4.7.0
11 */
12 class CampaignGoalShortcode
13 {
14 /**
15 * @since 4.7.0
16 *
17 * @param array<string, mixed> $atts
18 *
19 * @return string
20 */
21 public function renderShortcode($atts): string
22 {
23 $this->loadAssets();
24 $attributes = $this->parseAttributes($atts);
25
26 $renderFile = GIVE_PLUGIN_DIR . 'src/Campaigns/Blocks/CampaignGoal/render.php';
27
28 return ShortcodeRenderController::renderWithBlockContext(
29 $renderFile,
30 'givewp/campaign-goal-block',
31 $attributes
32 );
33 }
34
35 /**
36 * @since 4.7.0
37 */
38 public function loadAssets(): void
39 {
40 give(LoadCampaignPublicOptions::class)();
41
42 $handleName = 'givewp-campaign-goal-block-app';
43 $asset = ScriptAsset::get(GIVE_PLUGIN_DIR . 'build/campaignGoalBlockApp.asset.php');
44
45 wp_enqueue_script(
46 $handleName,
47 GIVE_PLUGIN_URL . 'build/campaignGoalBlockApp.js',
48 $asset['dependencies'],
49 $asset['version'],
50 true
51 );
52
53 Language::setScriptTranslations($handleName);
54
55 wp_enqueue_style(
56 $handleName,
57 GIVE_PLUGIN_URL . 'build/campaignGoalBlockApp.css',
58 [],
59 $asset['version']
60 );
61
62 wp_enqueue_style('givewp-design-system-foundation');
63 }
64
65 /**
66 * @since 4.7.0
67 */
68 private function parseAttributes($atts): array
69 {
70 $atts = shortcode_atts([
71 'campaign_id' => 0,
72 ], $atts, 'givewp_campaign_goal');
73
74 return [
75 'campaignId' => (int) $atts['campaign_id'],
76 ];
77 }
78 }
79