diff --git a/admin/class-convertkit-admin-legacy-resource-notice.php b/admin/class-convertkit-admin-legacy-resource-notice.php
index 547ca151c..d1b7e1821 100644
--- a/admin/class-convertkit-admin-legacy-resource-notice.php
+++ b/admin/class-convertkit-admin-legacy-resource-notice.php
@@ -216,6 +216,49 @@ public function get_legacy_warnings_for_settings( $settings ) {
}
+ /**
+ * Returns an array of warning strings for the Plugin's General Settings,
+ * when one or more Default Form settings reference Legacy Forms.
+ *
+ * @since 3.3.9
+ *
+ * @param array $settings Plugin settings array.
+ * @return array
+ */
+ public function get_legacy_warnings_for_plugin_settings( $settings ) {
+
+ // Get Forms resource.
+ $forms = new ConvertKit_Resource_Forms();
+
+ // Initialize warnings array.
+ $warnings = array();
+
+ // Check each supported Post Type's Default Form setting.
+ foreach ( convertkit_get_supported_post_types() as $supported_post_type ) {
+ // Get Post Type object.
+ $post_type = get_post_type_object( $supported_post_type );
+ if ( ! $post_type ) {
+ continue;
+ }
+
+ // Get Default Form setting.
+ $setting_key = $supported_post_type . '_form';
+ if ( empty( $settings[ $setting_key ] ) || ! $forms->is_legacy( $settings[ $setting_key ] ) ) {
+ continue;
+ }
+
+ $warnings[] = sprintf(
+ /* translators: 1: Post Type name, plural; 2: Form name */
+ __( 'Default Form (%1$s): %2$s', 'convertkit' ),
+ $post_type->label,
+ $this->get_form_display_name( $settings[ $setting_key ], $forms )
+ );
+ }
+
+ return $warnings;
+
+ }
+
/**
* Resolves the form ID to a human-readable "Form Name" string, falling
* back to "a Legacy Form" when the resource isn't cached.
diff --git a/admin/section/class-convertkit-admin-section-general.php b/admin/section/class-convertkit-admin-section-general.php
index 17a4ec3a6..5ee1063e9 100644
--- a/admin/section/class-convertkit-admin-section-general.php
+++ b/admin/section/class-convertkit-admin-section-general.php
@@ -78,6 +78,7 @@ public function __construct() {
if ( $this->on_settings_screen( $this->name ) ) {
add_filter( 'convertkit_settings_base_register_notices', array( $this, 'register_notices' ) );
add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_notices' ) );
+ add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_legacy_form_notice' ) );
}
// Enqueue scripts and CSS.
@@ -110,6 +111,41 @@ public function register_notices( $notices ) {
}
+ /**
+ * Outputs a non-dismissible warning when one or more Default Form settings
+ * reference Legacy Forms.
+ *
+ * @since 3.3.9
+ */
+ public function maybe_output_legacy_form_notice() {
+
+ // Get warnings.
+ $warnings = WP_ConvertKit()->get_class( 'admin_legacy_resource_notice' )->get_legacy_warnings_for_plugin_settings( $this->settings->get() );
+
+ // Bail if no warnings are found.
+ if ( empty( $warnings ) ) {
+ return;
+ }
+
+ // Output warnings.
+ ?>
+
+
+ :
+
+
+
+ ' . esc_html( $warning ) . '';
+ }
+ ?>
+
+
+ Kit > General when one or
+ * more Default Form settings reference a Legacy Form.
+ *
+ * @since 3.3.9
+ *
+ * @param EndToEndTester $I Tester.
+ */
+ public function testWarningDisplayedForLegacyDefaultFormsSetting(EndToEndTester $I)
+ {
+ // Setup Plugin with a legacy form pre-assigned as the Default Form for
+ // both Pages and Posts, as would be the case for an upgraded install.
+ $I->setupKitPlugin(
+ $I,
+ [
+ 'page_form' => (string) $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'],
+ 'post_form' => (string) $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'],
+ ]
+ );
+ $I->setupKitPluginResources($I);
+
+ // Go to the Plugin's Settings Screen.
+ $I->loadKitSettingsGeneralScreen($I);
+
+ // Confirm the warning identifies each affected Default Form setting.
+ $I->seeElementInDOM('#convertkit-legacy-settings-warning');
+ $I->see('Default Form (Pages): ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'], '#convertkit-legacy-settings-warning');
+ $I->see('Default Form (Posts): ' . $_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'], '#convertkit-legacy-settings-warning');
+
+ // Replace the Legacy Forms with a current Kit Form and save the settings.
+ $I->fillSelect2Field(
+ $I,
+ container: '#select2-_wp_convertkit_settings_page_form-container',
+ value: $_ENV['CONVERTKIT_API_FORM_NAME']
+ );
+ $I->fillSelect2Field(
+ $I,
+ container: '#select2-_wp_convertkit_settings_post_form-container',
+ value: $_ENV['CONVERTKIT_API_FORM_NAME']
+ );
+ $I->click('Save Changes');
+
+ // Confirm the warning is no longer displayed.
+ $I->waitForElementNotVisible('#convertkit-legacy-settings-warning');
+ }
+
/**
* Test that a previously-saved legacy Form ID assigned to a Category
* term continues to render as the selected option in the term edit
diff --git a/tests/Integration/AdminLegacyResourceNoticeTest.php b/tests/Integration/AdminLegacyResourceNoticeTest.php
index 6b1240b04..e4cbba2ac 100644
--- a/tests/Integration/AdminLegacyResourceNoticeTest.php
+++ b/tests/Integration/AdminLegacyResourceNoticeTest.php
@@ -97,6 +97,42 @@ public function testWarningForLegacyForm()
$this->assertStringContainsString($_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'], $warnings[0]);
}
+ /**
+ * Test that a legacy Default Form setting produces a warning containing
+ * the Post Type label and Form name.
+ *
+ * @since 3.3.9
+ */
+ public function testWarningForLegacyPluginDefaultForm()
+ {
+ $warnings = $this->notice->get_legacy_warnings_for_plugin_settings(
+ [
+ 'page_form' => $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'],
+ ]
+ );
+
+ $this->assertCount(1, $warnings);
+ $this->assertStringContainsString('Default Form (Pages):', $warnings[0]);
+ $this->assertStringContainsString($_ENV['CONVERTKIT_API_LEGACY_FORM_NAME'], $warnings[0]);
+ }
+
+ /**
+ * Test that Plugin settings with no Legacy Forms do not produce warnings.
+ *
+ * @since 3.3.7
+ */
+ public function testNoWarningForPluginSettingsWithoutLegacyForms()
+ {
+ $warnings = $this->notice->get_legacy_warnings_for_plugin_settings(
+ [
+ 'page_form' => $_ENV['CONVERTKIT_API_FORM_ID'],
+ 'post_form' => 0,
+ ]
+ );
+
+ $this->assertSame([], $warnings);
+ }
+
/**
* Test that a legacy landing page assignment (by numeric ID) produces
* a landing-page-scoped warning containing the landing page's name.