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
← All changes | src/PaymentGateways/ServiceProvider.php +76 -9 2.30.04.16.9 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2
3 3 namespace Give\PaymentGateways;
4 4
5 -use Give\Framework\LegacyPaymentGateways\Adapters\LegacyPaymentGatewayRegisterAdapter;
6 5 use Give\Framework\Migrations\MigrationsRegister;
7 6 use Give\Framework\PaymentGateways\PaymentGatewayRegister;
8 7 use Give\Framework\PaymentGateways\Routes\GatewayRoute;
9 8 use Give\Helpers\Hooks;
@@ -13,8 +12,12 @@
13 12 use Give\PaymentGateways\Gateways\Stripe\CheckoutGateway;
14 13 use Give\PaymentGateways\Gateways\Stripe\Controllers\UpdateStatementDescriptorAjaxRequestController;
15 14 use Give\PaymentGateways\Gateways\Stripe\Migrations\AddMissingTransactionIdForUncompletedDonations;
16 15 use Give\PaymentGateways\Gateways\Stripe\Migrations\AddStatementDescriptorToStripeAccounts;
16 +use Give\PaymentGateways\Gateways\Stripe\Migrations\RemovePaymentIntentSecretMeta;
17 +use Give\PaymentGateways\Migrations\CopyV2GatewaysSettingsToV3;
18 +use Give\PaymentGateways\PayPalCommerce\Banners\GatewaySettingPageBanner;
19 +use Give\PaymentGateways\PayPalCommerce\Banners\PayPalStandardToDonationsMigrationGlobalBanner;
17 20 use Give\PaymentGateways\PayPalCommerce\Migrations\RegisterPayPalDonationsRefreshTokenCronJobByMode;
18 21 use Give\PaymentGateways\PayPalCommerce\Migrations\RemoveLogWithCardInfo;
19 22 use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface;
20 23
@@ -45,15 +48,8 @@
45 48 $this->registerMigrations();
46 49
47 50 Hooks::addFilter('give_register_gateway', RegisterPaymentGateways::class);
48 51 Hooks::addFilter('give_payment_gateways', RegisterPaymentGatewaySettingsList::class);
49 - Hooks::addFilter(
50 - 'give_payment_gateways_admin_label',
51 - LegacyPaymentGatewayRegisterAdapter::class,
52 - 'updatePaymentGatewayAdminLabelsWithSupportedFormVersions',
53 - 10,
54 - 2
55 - );
56 52
57 53 Hooks::addAction('template_redirect', GatewayRoute::class);
58 54 Hooks::addAction(
59 55 'wp_ajax_edit_stripe_account_statement_descriptor',
@@ -64,11 +60,16 @@
64 60 * Stripe Checkout Redirect Handler
65 61 */
66 62 Hooks::addAction('wp_footer', CheckoutGateway::class, 'maybeHandleRedirect', 99999);
67 63 Hooks::addAction('give_embed_footer', CheckoutGateway::class, 'maybeHandleRedirect', 99999);
64 +
65 + $this->registerPayPalDonationsMigrationBanners();
66 + $this->maybeHidePayPalStandard();
68 67 }
69 68
70 69 /**
70 + * @since 3.0.0 add CopyV2GatewaysSettingsToV3 migration
71 + * @since 2.33.0 add RemovePaymentIntentSecretMeta migration
71 72 * @since 2.19.6
72 73 */
73 74 private function registerMigrations()
74 75 {
@@ -75,8 +76,74 @@
75 76 give(MigrationsRegister::class)->addMigrations([
76 77 AddStatementDescriptorToStripeAccounts::class,
77 78 AddMissingTransactionIdForUncompletedDonations::class,
78 79 RemoveLogWithCardInfo::class,
79 - RegisterPayPalDonationsRefreshTokenCronJobByMode::class
80 + RemovePaymentIntentSecretMeta::class,
81 + RegisterPayPalDonationsRefreshTokenCronJobByMode::class,
82 + CopyV2GatewaysSettingsToV3::class,
80 83 ]);
84 + }
85 +
86 + /**
87 + * This method registers the banners.
88 + * @since 2.33.0
89 + * @return void
90 + */
91 + private function registerPayPalDonationsMigrationBanners()
92 + {
93 + if (! is_admin()) {
94 + return;
95 + }
96 +
97 + // Banner for the migration from PayPal Standard to PayPal Donations.
98 + give(GatewaySettingPageBanner::class)->setupHook();
99 + give(PayPalStandardToDonationsMigrationGlobalBanner::class)->setHook();
100 + }
101 +
102 + /**
103 + * @since 4.1.0
104 + */
105 + private function maybeHidePayPalStandard()
106 + {
107 + if ( ! is_admin()) {
108 + return;
109 + }
110 +
111 + $isPayPalStandardConnected = is_email(give_get_option('paypal_email', false));
112 + $alwaysShowPayPalStandardAdminOptions = defined('GIVE_ALWAYS_SHOW_PAYPAL_STANDARD_ADMIN_OPTIONS') && GIVE_ALWAYS_SHOW_PAYPAL_STANDARD_ADMIN_OPTIONS;
113 +
114 +
115 + add_filter('give_settings_payment_gateways_menu_groups',
116 + function ($groups) use ($isPayPalStandardConnected, $alwaysShowPayPalStandardAdminOptions) {
117 + if ($isPayPalStandardConnected || $alwaysShowPayPalStandardAdminOptions) {
118 + return $groups;
119 + }
120 +
121 + if (isset($groups['v2']['gateways']['paypal'])) {
122 + unset($groups['v2']['gateways']['paypal']);
123 + }
124 +
125 + if (isset($groups['v3']['gateways']['paypal'])) {
126 + unset($groups['v3']['gateways']['paypal']);
127 + }
128 +
129 + return $groups;
130 + },
131 + 999
132 + );
133 +
134 + add_filter('give_get_groups_paypal',
135 + function ($groups) use ($isPayPalStandardConnected, $alwaysShowPayPalStandardAdminOptions) {
136 + if ($isPayPalStandardConnected || $alwaysShowPayPalStandardAdminOptions) {
137 + return $groups;
138 + }
139 +
140 + if (isset($groups['paypal'])) {
141 + unset($groups['paypal']);
142 + }
143 +
144 + return $groups;
145 + },
146 + 999
147 + );
81 148 }
82 149 }