From c617c1dc97096535a27c1fdf5b03462a406c2463 Mon Sep 17 00:00:00 2001 From: "Kyle B. Johnson" Date: Wed, 23 Aug 2023 11:46:05 -0400 Subject: [PATCH 1/2] Feature: Auto-deactivate the feature plugin (#6896) * Deactivate the Next Gen feature plugin --------- Co-authored-by: Ben Meredith Co-authored-by: Angela Blake --- give.php | 24 ++++++++++++++++++++++ src/FormMigration/functions.php | 6 +++--- tests/Unit/FormMigration/FunctionsTest.php | 12 +++++------ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/give.php b/give.php index 4180202bd8..c805b7fe8a 100644 --- a/give.php +++ b/give.php @@ -74,6 +74,7 @@ use Give\Log\LogServiceProvider; use Give\MigrationLog\MigrationLogServiceProvider; use Give\MultiFormGoals\ServiceProvider as MultiFormGoalsServiceProvider; +use Give\PaymentGateways\Gateways\TestOffsiteGateway\TestOffsiteGateway; use Give\PaymentGateways\ServiceProvider as PaymentGatewaysServiceProvider; use Give\Promotions\ServiceProvider as PromotionsServiceProvider; use Give\Revenue\RevenueServiceProvider; @@ -257,6 +258,8 @@ public function boot() { $this->setup_constants(); + $this->disableVisualDonationFormBuilderFeaturePlugin(); + // Add compatibility notice for recurring and stripe support with Give 2.5.0. add_action('admin_notices', [$this, 'display_old_recurring_compatibility_notice']); @@ -515,6 +518,27 @@ private function setupExceptionHandler() $handler = new UncaughtExceptionLogger(); $handler->setupExceptionHandler(); } + + protected function disableVisualDonationFormBuilderFeaturePlugin() + { + // Include plugin.php to use is_plugin_active() below. + include_once ABSPATH . 'wp-admin/includes/plugin.php'; + + // Prevent fatal error due to a renamed class. + class_alias(TestOffsiteGateway::class, 'Give\PaymentGateways\Gateways\TestGateway\TestGatewayOffsite', true); + + if ( is_plugin_active('givewp-next-gen/give-visual-form-builder.php' )) { + deactivate_plugins(['givewp-next-gen/give-visual-form-builder.php']); + + add_action('admin_notices', function() { + Give()->notices->register_notice([ + 'id' => 'give-visual-donation-form-builder-feature-plugin-deactivated', + 'description' => __('The Visual Form Builder Beta plugin is no longer needed, since the form builder is included in your current version of GiveWP. To prevent conflicts, the Beta plugin has been deactivated and can be safely deleted.', 'give'), + 'type' => 'info', + ]); + }); + } + } } /** diff --git a/src/FormMigration/functions.php b/src/FormMigration/functions.php index 27141e56bc..b4e04793d0 100644 --- a/src/FormMigration/functions.php +++ b/src/FormMigration/functions.php @@ -16,7 +16,7 @@ * * @return void Note: $formId is an "output argument" - not a return value. */ -function give_redirect_form_id(&$formId, &...$extraReference) { +function _give_redirect_form_id(&$formId, &...$extraReference) { global $wpdb; $formId = absint(DB::get_var( @@ -40,7 +40,7 @@ function give_redirect_form_id(&$formId, &...$extraReference) { * * @return bool */ -function give_is_form_migrated($formId) { +function _give_is_form_migrated($formId) { global $wpdb; return (bool) DB::get_var( @@ -63,7 +63,7 @@ function give_is_form_migrated($formId) { * * @return bool */ -function give_is_form_donations_transferred($formId) { +function _give_is_form_donations_transferred($formId) { global $wpdb; return (bool) DB::get_var( diff --git a/tests/Unit/FormMigration/FunctionsTest.php b/tests/Unit/FormMigration/FunctionsTest.php index ffe043a5d8..c7bd3c2fe6 100644 --- a/tests/Unit/FormMigration/FunctionsTest.php +++ b/tests/Unit/FormMigration/FunctionsTest.php @@ -20,7 +20,7 @@ public function testIsFormRedirected() $formId = $donationFormV2->id; - give_redirect_form_id($formId); + _give_redirect_form_id($formId); $this->assertEquals($donationFormV3->id, $formId); } @@ -34,7 +34,7 @@ public function testIsFormRedirectedWithAdditionalReference() $formId = $donationFormV2->id; $atts['id'] = $donationFormV2->id; - give_redirect_form_id($formId, $atts['id']); + _give_redirect_form_id($formId, $atts['id']); $this->assertEquals($donationFormV3->id, $formId); $this->assertEquals($donationFormV3->id, $atts['id']); @@ -46,14 +46,14 @@ public function testIsFormMigrated() $donationFormV3 = DonationForm::factory()->create(); give_update_meta($donationFormV3->id, 'migratedFormId', $donationFormV2->id); - $this->assertTrue(give_is_form_migrated($donationFormV2->id)); + $this->assertTrue(_give_is_form_migrated($donationFormV2->id)); } public function testIsFormNotMigrated() { $donationFormV2 = $this->createSimpleDonationForm(); - $this->assertFalse(give_is_form_migrated($donationFormV2->id)); + $this->assertFalse(_give_is_form_migrated($donationFormV2->id)); } public function testIsFormDonationsTransferred() @@ -62,13 +62,13 @@ public function testIsFormDonationsTransferred() $donationFormV3 = DonationForm::factory()->create(); give_update_meta($donationFormV3->id, 'transferredFormId', $donationFormV2->id); - $this->assertTrue(give_is_form_donations_transferred($donationFormV2->id)); + $this->assertTrue(_give_is_form_donations_transferred($donationFormV2->id)); } public function testIsFormDonationsNotTransferred() { $donationFormV2 = $this->createSimpleDonationForm(); - $this->assertFalse(give_is_form_donations_transferred($donationFormV2->id)); + $this->assertFalse(_give_is_form_donations_transferred($donationFormV2->id)); } } From f5138cbc6bcbed67d20d0474cadb077e097f5b15 Mon Sep 17 00:00:00 2001 From: Jon Waldstein Date: Wed, 23 Aug 2023 12:06:25 -0400 Subject: [PATCH 2/2] fix: subscriptionPeriod is already being exported --- .../templates/groups/DonationAmount/subscriptionPeriod.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DonationForms/resources/registrars/templates/groups/DonationAmount/subscriptionPeriod.ts b/src/DonationForms/resources/registrars/templates/groups/DonationAmount/subscriptionPeriod.ts index 858ee9e996..bb095870dd 100644 --- a/src/DonationForms/resources/registrars/templates/groups/DonationAmount/subscriptionPeriod.ts +++ b/src/DonationForms/resources/registrars/templates/groups/DonationAmount/subscriptionPeriod.ts @@ -1,4 +1,4 @@ -import {__} from '@wordpress/i18n'; +import { __ } from "@wordpress/i18n"; /** * @since 3.0.0 @@ -50,7 +50,7 @@ const subscriptionPeriodLabelLookup = { /** * @since 3.0.0 */ -export type subscriptionPeriod = keyof typeof subscriptionPeriodLabelLookup; +type subscriptionPeriod = keyof typeof subscriptionPeriodLabelLookup; /** * @since 3.0.0