| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Promotions; |
| 4 |
|
| 5 |
use Give\Helpers\Hooks; |
| 6 |
use Give\Promotions\BFCM\BFCM2025; |
| 7 |
use Give\Promotions\Campaigns\CampaignsWelcomeBanner; |
| 8 |
use Give\Promotions\FreeAddonModal\Controllers\CompleteRestApiEndpoint; |
| 9 |
use Give\Promotions\InPluginUpsells\AddonsAdminPage; |
| 10 |
use Give\Promotions\InPluginUpsells\Endpoints\HideSaleBannerRoute; |
| 11 |
use Give\Promotions\InPluginUpsells\Endpoints\ProductRecommendationsRoute; |
| 12 |
use Give\Promotions\InPluginUpsells\LegacyFormEditor; |
| 13 |
use Give\Promotions\InPluginUpsells\PaymentGateways; |
| 14 |
use Give\Promotions\InPluginUpsells\StellarSaleBanners; |
| 15 |
use Give\Promotions\ReportsWidgetBanner\ReportsWidgetBanner; |
| 16 |
use Give\Promotions\WelcomeBanner\Endpoints\DismissWelcomeBannerRoute; |
| 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 4.3.0 refactor to add conditional scripts inside admin_enqueue_scripts hook |
| 43 |
* @since 4.0.0 add CampaignWelcomeBanner |
| 44 |
* @since 3.13.0 add Stellar banner. |
| 45 |
* @since 2.27.1 Removed Recurring donations tab app. |
| 46 |
* @since 2.19.0 |
| 47 |
* |
| 48 |
* Boots the Plugin Upsell promotional page |
| 49 |
* |
| 50 |
*/ |
| 51 |
private function bootPluginUpsells() |
| 52 |
{ |
| 53 |
Hooks::addAction('admin_menu', AddonsAdminPage::class, 'register', 70); |
| 54 |
Hooks::addAction('rest_api_init', HideSaleBannerRoute::class, 'registerRoute'); |
| 55 |
Hooks::addAction('rest_api_init', ProductRecommendationsRoute::class, 'registerRoute'); |
| 56 |
Hooks::addAction('rest_api_init', DismissWelcomeBannerRoute::class, 'registerRoute'); |
| 57 |
|
| 58 |
add_action('admin_enqueue_scripts', static function (){ |
| 59 |
if (ReportsWidgetBanner::isShowing()) { |
| 60 |
give(ReportsWidgetBanner::class)->loadScripts(); |
| 61 |
} |
| 62 |
|
| 63 |
if (AddonsAdminPage::isShowing()) { |
| 64 |
give(AddonsAdminPage::class)->loadScripts(); |
| 65 |
} |
| 66 |
|
| 67 |
if (PaymentGateways::isShowing()) { |
| 68 |
give(PaymentGateways::class)->loadScripts(); |
| 69 |
} |
| 70 |
|
| 71 |
if (LegacyFormEditor::isShowing()) { |
| 72 |
give(LegacyFormEditor::class)->loadScripts(); |
| 73 |
} |
| 74 |
}); |
| 75 |
|
| 76 |
Hooks::addAction( |
| 77 |
'give_admin_field_enabled_gateways', |
| 78 |
PaymentGateways::class, |
| 79 |
'renderPaymentGatewayRecommendation' |
| 80 |
); |
| 81 |
|
| 82 |
Hooks::addAction( |
| 83 |
'give_post_form_field_options_settings', |
| 84 |
LegacyFormEditor::class, |
| 85 |
'renderDonationOptionsRecurringRecommendation' |
| 86 |
); |
| 87 |
|
| 88 |
Hooks::addAction('admin_init', CampaignsWelcomeBanner::class); |
| 89 |
Hooks::addAction('admin_init', BFCM2025::class); |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Boots the free addon modal promotion |
| 94 |
* |
| 95 |
* @since 2.19.0 |
| 96 |
*/ |
| 97 |
private function bootFreeAddonModal() |
| 98 |
{ |
| 99 |
if (is_admin()) { |
| 100 |
Hooks::addAction('rest_api_init', CompleteRestApiEndpoint::class); |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
|