FreeAddonModal
4 years ago
InPluginUpsells
2 years ago
WelcomeBanner
2 years ago
sharedResources
3 years ago
ServiceProvider.php
2 years ago
ServiceProvider.php
98 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Promotions; |
| 4 | |
| 5 | use Give\Helpers\Hooks; |
| 6 | use Give\Promotions\FreeAddonModal\Controllers\CompleteRestApiEndpoint; |
| 7 | use Give\Promotions\InPluginUpsells\AddonsAdminPage; |
| 8 | use Give\Promotions\InPluginUpsells\Endpoints\HideSaleBannerRoute; |
| 9 | use Give\Promotions\InPluginUpsells\Endpoints\ProductRecommendationsRoute; |
| 10 | use Give\Promotions\InPluginUpsells\LegacyFormEditor; |
| 11 | use Give\Promotions\InPluginUpsells\PaymentGateways; |
| 12 | use Give\Promotions\InPluginUpsells\SaleBanners; |
| 13 | use Give\Promotions\WelcomeBanner\Endpoints\DismissWelcomeBannerRoute; |
| 14 | use Give\Promotions\WelcomeBanner\WelcomeBanner; |
| 15 | use Give\ServiceProviders\ServiceProvider as ServiceProviderContract; |
| 16 | |
| 17 | class ServiceProvider implements ServiceProviderContract |
| 18 | { |
| 19 | /** |
| 20 | * @since 2.19.0 |
| 21 | * |
| 22 | * @inheritDoc |
| 23 | */ |
| 24 | public function register() |
| 25 | { |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @since 2.19.0 |
| 30 | * |
| 31 | * @inheritDoc |
| 32 | */ |
| 33 | public function boot() |
| 34 | { |
| 35 | $this->bootPluginUpsells(); |
| 36 | $this->bootFreeAddonModal(); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @since 2.27.1 Removed Recurring donations tab app. |
| 41 | * |
| 42 | * Boots the Plugin Upsell promotional page |
| 43 | * |
| 44 | * @since 2.19.0 |
| 45 | */ |
| 46 | private function bootPluginUpsells() |
| 47 | { |
| 48 | Hooks::addAction('admin_menu', AddonsAdminPage::class, 'register', 70); |
| 49 | Hooks::addAction('rest_api_init', HideSaleBannerRoute::class, 'registerRoute'); |
| 50 | Hooks::addAction('rest_api_init', ProductRecommendationsRoute::class, 'registerRoute'); |
| 51 | Hooks::addAction('rest_api_init', DismissWelcomeBannerRoute::class, 'registerRoute'); |
| 52 | |
| 53 | if (AddonsAdminPage::isShowing()) { |
| 54 | Hooks::addAction('admin_enqueue_scripts', AddonsAdminPage::class, 'loadScripts'); |
| 55 | } |
| 56 | |
| 57 | if (SaleBanners::isShowing()) { |
| 58 | Hooks::addAction('admin_notices', SaleBanners::class, 'render'); |
| 59 | Hooks::addAction('admin_enqueue_scripts', SaleBanners::class, 'loadScripts'); |
| 60 | } |
| 61 | |
| 62 | if (PaymentGateways::isShowing()) { |
| 63 | Hooks::addAction('admin_enqueue_scripts', PaymentGateways::class, 'loadScripts'); |
| 64 | Hooks::addAction( |
| 65 | 'give_admin_field_enabled_gateways', |
| 66 | PaymentGateways::class, |
| 67 | 'renderPaymentGatewayRecommendation' |
| 68 | ); |
| 69 | } |
| 70 | |
| 71 | if (LegacyFormEditor::isShowing()) { |
| 72 | Hooks::addAction('admin_enqueue_scripts', LegacyFormEditor::class, 'loadScripts'); |
| 73 | Hooks::addAction( |
| 74 | 'give_post_form_field_options_settings', |
| 75 | LegacyFormEditor::class, |
| 76 | 'renderDonationOptionsRecurringRecommendation' |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | if (WelcomeBanner::isShowing()) { |
| 81 | Hooks::addAction('admin_notices', WelcomeBanner::class, 'render'); |
| 82 | Hooks::addAction('admin_enqueue_scripts', WelcomeBanner::class, 'loadScripts'); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Boots the free addon modal promotion |
| 88 | * |
| 89 | * @since 2.19.0 |
| 90 | */ |
| 91 | private function bootFreeAddonModal() |
| 92 | { |
| 93 | if (is_admin()) { |
| 94 | Hooks::addAction('rest_api_init', CompleteRestApiEndpoint::class); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 |