Admin
5 years ago
Exceptions
5 years ago
Factories
5 years ago
Helpers
5 years ago
Pipeline
5 years ago
Repositories
5 years ago
Routes
5 years ago
Tabs
5 years ago
resources
5 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
Block.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonorDashboards; |
| 4 | |
| 5 | use Give\DonorDashboards\App as DonorDashboard; |
| 6 | |
| 7 | class Block { |
| 8 | |
| 9 | protected $donorDashboard; |
| 10 | |
| 11 | public function __construct() { |
| 12 | $this->donorDashboard = give( DonorDashboard::class ); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Registers Donor Dashboard block |
| 17 | * |
| 18 | * @since 2.10.0 |
| 19 | **/ |
| 20 | public function addBlock() { |
| 21 | register_block_type( |
| 22 | 'give/donor-dashboard', |
| 23 | [ |
| 24 | 'render_callback' => [ $this, 'renderCallback' ], |
| 25 | 'attributes' => [ |
| 26 | 'align' => [ |
| 27 | 'type' => 'string', |
| 28 | 'default' => 'wide', |
| 29 | ], |
| 30 | 'accent_color' => [ |
| 31 | 'type' => 'string', |
| 32 | 'default' => '#68bb6c', |
| 33 | ], |
| 34 | ], |
| 35 | ] |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Returns Donor Profile block markup |
| 41 | * |
| 42 | * @since 2.10.0 |
| 43 | **/ |
| 44 | public function renderCallback( $attributes ) { |
| 45 | return $this->donorDashboard->getOutput( $attributes ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Load Donor Profile frontend assets |
| 50 | * |
| 51 | * @since 2.10.0 |
| 52 | **/ |
| 53 | public function loadFrontendAssets() { |
| 54 | if ( has_block( 'give/donor-dashboard' ) ) { |
| 55 | return $this->donorDashboard->loadAssets(); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Load Donor Profile block editor assets |
| 61 | * |
| 62 | * @since 2.10.0 |
| 63 | **/ |
| 64 | public function loadEditorAssets() { |
| 65 | wp_enqueue_script( |
| 66 | 'give-donor-dashboards-block', |
| 67 | GIVE_PLUGIN_URL . 'assets/dist/js/donor-dashboards-block.js', |
| 68 | [], |
| 69 | GIVE_VERSION, |
| 70 | true |
| 71 | ); |
| 72 | } |
| 73 | } |
| 74 |