CampaignsWelcomeBanner.php
69 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Promotions\Campaigns; |
| 4 | |
| 5 | namespace Give\Promotions\Campaigns; |
| 6 | |
| 7 | use Give\Framework\Views\View; |
| 8 | use Give\Vendors\StellarWP\AdminNotices\AdminNotice; |
| 9 | use Give\Vendors\StellarWP\AdminNotices\AdminNotices; |
| 10 | use Give\Vendors\StellarWP\AdminNotices\DataTransferObjects\NoticeElementProperties; |
| 11 | |
| 12 | /** |
| 13 | * @since 4.0.0 |
| 14 | */ |
| 15 | class CampaignsWelcomeBanner |
| 16 | { |
| 17 | /** |
| 18 | * @var string |
| 19 | */ |
| 20 | public $id = 'givewp-campaigns-welcome-banner-2025'; |
| 21 | |
| 22 | /** |
| 23 | * @since 4.0.0 |
| 24 | */ |
| 25 | public function __invoke() |
| 26 | { |
| 27 | $this->render(); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @since 4.0.0 |
| 32 | */ |
| 33 | public function render() |
| 34 | { |
| 35 | AdminNotices::show($this->id, [$this, 'renderCallback']) |
| 36 | ->custom() |
| 37 | ->location('below_header') |
| 38 | ->dismissible() |
| 39 | ->enqueueStylesheet(GIVE_PLUGIN_URL . 'build/campaignWelcomeBannerCss.css', [], '1.0.0') |
| 40 | ->enqueueScript(GIVE_PLUGIN_URL . 'build/campaignWelcomeBannerJs.js', [], '1.0.0') |
| 41 | ->on('plugins.php'); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @since 4.0.0 |
| 46 | */ |
| 47 | public function renderCallback(AdminNotice $notice, NoticeElementProperties $elements): string |
| 48 | { |
| 49 | $backgroundUrl = GIVE_PLUGIN_URL . 'build/assets/dist/images/admin/promotions/campaigns/welcome-banner-background.svg'; |
| 50 | $badgeIconUrl = GIVE_PLUGIN_URL . 'build/assets/dist/images/admin/promotions/campaigns/star-badge-icon.svg'; |
| 51 | $heartIconUrl = GIVE_PLUGIN_URL . 'build/assets/dist/images/admin/promotions/campaigns/heart-icon.svg'; |
| 52 | $exitIconUrl = GIVE_PLUGIN_URL . 'build/assets/dist/images/admin/promotions/campaigns/dismiss-icon.svg'; |
| 53 | $campaignsPageUrl = admin_url('admin.php?page=give-campaigns'); |
| 54 | |
| 55 | return View::load( |
| 56 | 'Promotions.CampaignWelcomeBanner', |
| 57 | [ |
| 58 | 'elements' => $elements, |
| 59 | 'backgroundUrl' => $backgroundUrl, |
| 60 | 'badgeIconUrl' => $badgeIconUrl, |
| 61 | 'heartIconUrl' => $heartIconUrl, |
| 62 | 'exitIconUrl' => $exitIconUrl, |
| 63 | 'campaignsPageUrl' => $campaignsPageUrl, |
| 64 | ], |
| 65 | false |
| 66 | ); |
| 67 | } |
| 68 | } |
| 69 |