Admin
4 years ago
Exceptions
4 years ago
Factories
4 years ago
Helpers
4 years ago
Pipeline
1 year ago
Repositories
3 years ago
Routes
2 years ago
Tabs
1 year ago
resources
1 year ago
App.php
1 year ago
Block.php
2 years ago
Helpers.php
1 year ago
Profile.php
1 year ago
RequestHandler.php
4 years ago
ServiceProvider.php
2 years ago
Shortcode.php
2 years ago
Shortcode.php
61 lines
| 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 |