PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 3.21.1
GiveWP – Donation Plugin and Fundraising Platform v3.21.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 2.31.0 2.31.1 All 253 releases
give / src / DonorDashboards / Shortcode.php
Shortcode.php
61 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonorDashboards;
4
5 use Give\DonorDashboards\App as DonorDashboard;
6
7 class Shortcode
8 {
9
10 protected $donorDashboard;
11
12 public function __construct()
13 {
14 $this->donorDashboard = give(DonorDashboard::class);
15 }
16
17 /**
18 * Registers Donor Profile Shortcode
19 *
20 * @since 2.10.0
21 **/
22 public function addShortcode()
23 {
24 add_shortcode('give_donor_dashboard', [$this, 'renderCallback']);
25 }
26
27 /**
28 * Load Donor Profile frontend assets
29 *
30 * @since 2.9.0
31 **/
32 public function loadFrontendAssets()
33 {
34 global $post;
35 if (is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'give_donor_dashboard')) {
36 return $this->donorDashboard->loadAssets();
37 }
38 }
39
40 /**
41 * Returns Shortcode markup
42 *
43 * @since 3.6.0 Sanitize attributes
44 * @since 2.10.0
45 **/
46 public function renderCallback($attributes)
47 {
48 $attributes = give_clean($attributes);
49
50 $attributes = shortcode_atts(
51 [
52 'accent_color' => '#68bb6c',
53 ],
54 $attributes,
55 'give_donor_dashboard'
56 );
57
58 return $this->donorDashboard->getOutput($attributes);
59 }
60 }
61