PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / DonationForms / V2 / ServiceProvider.php

ServiceProvider.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/DonationForms/V2/ServiceProvider.php

65 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\V2;
4
5 use Give\DonationForms\V2\ListTable\DonationFormsListTable;
6 use Give\DonationForms\V2\Repositories\DonationFormsRepository;
7 use Give\Helpers\Hooks;
8 use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface;
9
10 /**
11 * @since 2.19.0
12 */
13 class ServiceProvider implements ServiceProviderInterface
14 {
15 /**
16 * @inheritDoc
17 */
18 public function register()
19 {
20 give()->singleton('donationForms', DonationFormsRepository::class);
21 give()->singleton(DonationFormsListTable::class, function () {
22 $listTable = new DonationFormsListTable();
23 Hooks::doAction('givewp_donation_forms_list_table', $listTable);
24
25 return $listTable;
26 });
27 }
28
29 /**
30 * @inheritDoc
31 */
32 public function boot()
33 {
34 $userId = get_current_user_id();
35 $showLegacy = get_user_meta($userId, '_give_donation_forms_archive_show_legacy', true);
36
37 Hooks::addAction('admin_menu', DonationFormsAdminPage::class, 'register', 0);
38
39 if (empty($showLegacy)) {
40 if (DonationFormsAdminPage::isShowing()) {
41 Hooks::addAction('admin_enqueue_scripts', DonationFormsAdminPage::class, 'loadScripts');
42 }
43 } elseif (DonationFormsAdminPage::isShowingLegacyPage()) {
44 Hooks::addAction('admin_head', DonationFormsAdminPage::class, 'renderReactSwitch');
45 }
46
47 // Onboarding
48 Hooks::addAction('submitpost_box', DonationFormsAdminPage::class, 'renderMigrationGuideBox');
49 Hooks::addAction('admin_enqueue_scripts', DonationFormsAdminPage::class, 'loadMigrationScripts');
50
51 // Dismiss notices
52 $noticeActions = [
53 'givewp_show_onboarding_banner' => 'show-onboarding-banner',
54 'givewp_show_upgraded_tooltip' => 'show-upgraded-tooltip',
55 'givewp_show_default_form_tooltip' => 'show-default-form-tooltip',
56 ];
57
58 foreach ($noticeActions as $action => $metaKey) {
59 add_action("wp_ajax_{$action}", static function () use ($metaKey) {
60 add_user_meta(get_current_user_id(), "givewp-{$metaKey}", time(), true);
61 });
62 }
63 }
64 }
65