FreeAddonModal
4 years ago
InPluginUpsells
3 years ago
sharedResources
4 years ago
ServiceProvider.php
3 years ago
ServiceProvider.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Promotions; |
| 4 | |
| 5 | use Give\Helpers\Hooks; |
| 6 | use Give\Promotions\FreeAddonModal\Controllers\DisplaySettingsButton; |
| 7 | use Give\Promotions\FreeAddonModal\Controllers\EnqueueModal; |
| 8 | use Give\Promotions\FreeAddonModal\Controllers\CompleteRestApiEndpoint; |
| 9 | use Give\Promotions\FreeAddonModal\Controllers\PreventFreshInstallPromotion; |
| 10 | use Give\Promotions\InPluginUpsells\AddonsAdminPage; |
| 11 | use Give\Promotions\InPluginUpsells\HideSaleBannerRoute; |
| 12 | use Give\Promotions\InPluginUpsells\RecurringDonationsTab; |
| 13 | use Give\Promotions\InPluginUpsells\SaleBanners; |
| 14 | use Give\ServiceProviders\ServiceProvider as ServiceProviderContract; |
| 15 | |
| 16 | class ServiceProvider implements ServiceProviderContract |
| 17 | { |
| 18 | /** |
| 19 | * @since 2.19.0 |
| 20 | * |
| 21 | * @inheritDoc |
| 22 | */ |
| 23 | public function register() |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @since 2.19.0 |
| 29 | * |
| 30 | * @inheritDoc |
| 31 | */ |
| 32 | public function boot() |
| 33 | { |
| 34 | $this->bootPluginUpsells(); |
| 35 | $this->bootFreeAddonModal(); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Boots the Plugin Upsell promotional page |
| 40 | * |
| 41 | * @since 2.19.0 |
| 42 | */ |
| 43 | private function bootPluginUpsells() |
| 44 | { |
| 45 | Hooks::addAction('admin_menu', AddonsAdminPage::class, 'register', 70); |
| 46 | Hooks::addAction('rest_api_init', HideSaleBannerRoute::class, 'registerRoute'); |
| 47 | |
| 48 | if (AddonsAdminPage::isShowing()) { |
| 49 | Hooks::addAction('admin_enqueue_scripts', AddonsAdminPage::class, 'loadScripts'); |
| 50 | } |
| 51 | |
| 52 | if (RecurringDonationsTab::isShowing()) { |
| 53 | Hooks::addAction('admin_enqueue_scripts', RecurringDonationsTab::class, 'loadScripts'); |
| 54 | } |
| 55 | |
| 56 | if (SaleBanners::isShowing()) { |
| 57 | Hooks::addAction('admin_notices', SaleBanners::class, 'render'); |
| 58 | Hooks::addAction('admin_enqueue_scripts', SaleBanners::class, 'loadScripts'); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Boots the free addon modal promotion |
| 64 | * |
| 65 | * @since 2.19.0 |
| 66 | */ |
| 67 | private function bootFreeAddonModal() |
| 68 | { |
| 69 | if (is_admin()) { |
| 70 | Hooks::addAction('rest_api_init', CompleteRestApiEndpoint::class); |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 |