Admin
5 years ago
Exceptions
5 years ago
Factories
5 years ago
Helpers
5 years ago
Pipeline
5 years ago
Repositories
4 years ago
Routes
5 years ago
Tabs
4 years ago
resources
4 years ago
App.php
5 years ago
Block.php
5 years ago
Helpers.php
5 years ago
Profile.php
5 years ago
RequestHandler.php
5 years ago
ServiceProvider.php
5 years ago
Shortcode.php
5 years ago
Shortcode.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonorDashboards; |
| 4 | |
| 5 | use Give\DonorDashboards\App as DonorDashboard; |
| 6 | |
| 7 | class Shortcode { |
| 8 | |
| 9 | protected $donorDashboard; |
| 10 | |
| 11 | public function __construct() { |
| 12 | $this->donorDashboard = give( DonorDashboard::class ); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Registers Donor Profile Shortcode |
| 17 | * |
| 18 | * @since 2.10.0 |
| 19 | **/ |
| 20 | public function addShortcode() { |
| 21 | add_shortcode( 'give_donor_dashboard', [ $this, 'renderCallback' ] ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Load Donor Profile frontend assets |
| 26 | * |
| 27 | * @since 2.9.0 |
| 28 | **/ |
| 29 | public function loadFrontendAssets() { |
| 30 | global $post; |
| 31 | if ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'give_donor_dashboard' ) ) { |
| 32 | return $this->donorDashboard->loadAssets(); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Returns Shortcode markup |
| 38 | * |
| 39 | * @since 2.10.0 |
| 40 | **/ |
| 41 | public function renderCallback( $attributes ) { |
| 42 | $attributes = shortcode_atts( |
| 43 | [ |
| 44 | 'accent_color' => '#68bb6c', |
| 45 | ], |
| 46 | $attributes, |
| 47 | 'give_donor_dashboard' |
| 48 | ); |
| 49 | return $this->donorDashboard->getOutput( $attributes ); |
| 50 | } |
| 51 | } |
| 52 |