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