From d8786605053a195a8fb306dcdd80347887358f1a Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 24 Feb 2026 08:00:57 +0800 Subject: [PATCH 1/5] =?UTF-8?q?Settings:=20Hide=20=E2=80=9CAdd=20New?= =?UTF-8?q?=E2=80=9D=20Button=20on=20Pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/class-convertkit-admin-landing-page.php | 5 ++++ ...lass-convertkit-admin-restrict-content.php | 5 ++++ ...class-convertkit-admin-section-general.php | 28 +++++++++++++++++++ includes/class-convertkit-settings.php | 14 ++++++++++ 4 files changed, 52 insertions(+) diff --git a/admin/class-convertkit-admin-landing-page.php b/admin/class-convertkit-admin-landing-page.php index f160cc1cc..e5afb8063 100644 --- a/admin/class-convertkit-admin-landing-page.php +++ b/admin/class-convertkit-admin-landing-page.php @@ -44,6 +44,11 @@ public function register_add_new_button( $buttons, $post_type ) { return $buttons; } + // If the Add New Landing Page / Member Content button is disabled, don't output the button. + if ( $settings->add_new_disabled() ) { + return $buttons; + } + // Bail if the Post Type isn't supported. if ( $post_type !== 'page' ) { return $buttons; diff --git a/admin/class-convertkit-admin-restrict-content.php b/admin/class-convertkit-admin-restrict-content.php index 2626e82e5..a81554d1b 100644 --- a/admin/class-convertkit-admin-restrict-content.php +++ b/admin/class-convertkit-admin-restrict-content.php @@ -241,6 +241,11 @@ public function register_add_new_button( $buttons, $post_type ) { return $buttons; } + // If the Add New Landing Page / Member Content button is disabled, don't output the button. + if ( $settings->add_new_disabled() ) { + return $buttons; + } + // Bail if the Post Type isn't supported. if ( ! in_array( $post_type, convertkit_get_supported_post_types(), true ) ) { return $buttons; diff --git a/admin/section/class-convertkit-admin-section-general.php b/admin/section/class-convertkit-admin-section-general.php index 7d65c5132..1fcef9d6d 100644 --- a/admin/section/class-convertkit-admin-section-general.php +++ b/admin/section/class-convertkit-admin-section-general.php @@ -461,6 +461,17 @@ public function register_fields() { ) ); + add_settings_field( + 'no_css', + __( 'Disable Add New Landing Page / Member Content Button', 'convertkit' ), + array( $this, 'no_add_new_callback' ), + $this->settings_key, + $this->name . '-advanced', + array( + 'label_for' => 'no_add_new', + ) + ); + add_settings_field( 'usage_tracking', __( 'Usage Tracking', 'convertkit' ), @@ -1015,6 +1026,23 @@ public function no_css_callback() { } + /** + * Renders the input for the Disable Add New Landing Page / Member Content setting. + * + * @since 3.2.0 + */ + public function no_add_new_callback() { + + // Output field. + $this->output_checkbox_field( + 'no_add_new', + 'on', + $this->settings->add_new_disabled(), + esc_html__( 'Hide the "Add New" button on Pages for creating Landing Pages and Member Content.', 'convertkit' ) + ); + + } + /** * Renders the input for the Usage Tracking setting. * diff --git a/includes/class-convertkit-settings.php b/includes/class-convertkit-settings.php index a714b5610..3fc2069fd 100644 --- a/includes/class-convertkit-settings.php +++ b/includes/class-convertkit-settings.php @@ -542,6 +542,19 @@ public function css_disabled() { } + /** + * Returns whether the Add New Landing Page / Member Content option is disabled in the Plugin settings. + * + * @since 3.2.0 + * + * @return bool + */ + public function add_new_disabled() { + + return ( $this->settings['no_add_new'] === 'on' ? true : false ); + + } + /** * Returns whether usage tracking is enabled in the Plugin settings. * @@ -589,6 +602,7 @@ public function get_defaults() { 'debug' => '', // blank|on. 'no_scripts' => '', // blank|on. 'no_css' => '', // blank|on. + 'no_add_new' => '', // blank|on. 'usage_tracking' => '', // blank|on. ); From 49e9b270af240971b6f16c97305fc82159ee8a33 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 24 Feb 2026 08:32:54 +0800 Subject: [PATCH 2/5] Settings: Disable Add New Button --- admin/class-convertkit-admin-landing-page.php | 2 +- ...lass-convertkit-admin-restrict-content.php | 2 +- ...class-convertkit-admin-section-general.php | 10 ++++---- includes/class-convertkit-settings.php | 8 +++---- tests/EndToEnd.suite.yml | 1 - .../PageLandingPageSetupWizardCest.php | 24 +++++++++++++++++++ .../general/RestrictContentSetupCest.php | 24 +++++++++++++++++++ tests/Support/Helper/KitPlugin.php | 1 + 8 files changed, 60 insertions(+), 12 deletions(-) diff --git a/admin/class-convertkit-admin-landing-page.php b/admin/class-convertkit-admin-landing-page.php index e5afb8063..24888f1e0 100644 --- a/admin/class-convertkit-admin-landing-page.php +++ b/admin/class-convertkit-admin-landing-page.php @@ -45,7 +45,7 @@ public function register_add_new_button( $buttons, $post_type ) { } // If the Add New Landing Page / Member Content button is disabled, don't output the button. - if ( $settings->add_new_disabled() ) { + if ( $settings->add_new_button_disabled() ) { return $buttons; } diff --git a/admin/class-convertkit-admin-restrict-content.php b/admin/class-convertkit-admin-restrict-content.php index a81554d1b..722885253 100644 --- a/admin/class-convertkit-admin-restrict-content.php +++ b/admin/class-convertkit-admin-restrict-content.php @@ -242,7 +242,7 @@ public function register_add_new_button( $buttons, $post_type ) { } // If the Add New Landing Page / Member Content button is disabled, don't output the button. - if ( $settings->add_new_disabled() ) { + if ( $settings->add_new_button_disabled() ) { return $buttons; } diff --git a/admin/section/class-convertkit-admin-section-general.php b/admin/section/class-convertkit-admin-section-general.php index 1fcef9d6d..b2df831aa 100644 --- a/admin/section/class-convertkit-admin-section-general.php +++ b/admin/section/class-convertkit-admin-section-general.php @@ -464,11 +464,11 @@ public function register_fields() { add_settings_field( 'no_css', __( 'Disable Add New Landing Page / Member Content Button', 'convertkit' ), - array( $this, 'no_add_new_callback' ), + array( $this, 'no_add_new_button_callback' ), $this->settings_key, $this->name . '-advanced', array( - 'label_for' => 'no_add_new', + 'label_for' => 'no_add_new_button', ) ); @@ -1031,13 +1031,13 @@ public function no_css_callback() { * * @since 3.2.0 */ - public function no_add_new_callback() { + public function no_add_new_button_callback() { // Output field. $this->output_checkbox_field( - 'no_add_new', + 'no_add_new_button', 'on', - $this->settings->add_new_disabled(), + $this->settings->add_new_button_disabled(), esc_html__( 'Hide the "Add New" button on Pages for creating Landing Pages and Member Content.', 'convertkit' ) ); diff --git a/includes/class-convertkit-settings.php b/includes/class-convertkit-settings.php index 3fc2069fd..56d799077 100644 --- a/includes/class-convertkit-settings.php +++ b/includes/class-convertkit-settings.php @@ -543,15 +543,15 @@ public function css_disabled() { } /** - * Returns whether the Add New Landing Page / Member Content option is disabled in the Plugin settings. + * Returns whether the Add New Landing Page / Member Content button is disabled in the Plugin settings. * * @since 3.2.0 * * @return bool */ - public function add_new_disabled() { + public function add_new_button_disabled() { - return ( $this->settings['no_add_new'] === 'on' ? true : false ); + return ( $this->settings['no_add_new_button'] === 'on' ? true : false ); } @@ -602,7 +602,7 @@ public function get_defaults() { 'debug' => '', // blank|on. 'no_scripts' => '', // blank|on. 'no_css' => '', // blank|on. - 'no_add_new' => '', // blank|on. + 'no_add_new_button' => '', // blank|on. 'usage_tracking' => '', // blank|on. ); diff --git a/tests/EndToEnd.suite.yml b/tests/EndToEnd.suite.yml index 7cf15b9ed..d8ef7596f 100644 --- a/tests/EndToEnd.suite.yml +++ b/tests/EndToEnd.suite.yml @@ -55,7 +55,6 @@ modules: capabilities: "goog:chromeOptions": args: - - "--headless" - "--disable-gpu" - "--disable-dev-shm-usage" - "--disable-software-rasterizer" diff --git a/tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php b/tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php index 65dd2a683..f4ecfd2e7 100644 --- a/tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php +++ b/tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php @@ -60,6 +60,30 @@ public function testAddNewLandingPageButtonNotDisplayedOnPosts(EndToEndTester $I $I->dontSeeElementInDOM('span.convertkit-action.page-title-action'); } + /** + * Test that the Add New Landing Page button does not display on the Pages screen when the Add New Landing Page / Member Content button is disabled. + * + * @since 3.2.0 + * + * @param EndToEndTester $I Tester. + */ + public function testAddNewLandingPageButtonNotDisplayedWhenDisabled(EndToEndTester $I) + { + // Setup Plugin, disabling the Add New Landing Page / Member Content button. + $I->setupKitPlugin( + $I, + [ + 'no_add_new_button' => 'on', + ] + ); + + // Navigate to Pages. + $I->amOnAdminPage('edit.php?post_type=page'); + + // Check the buttons are not displayed. + $I->dontSeeElementInDOM('span.convertkit-action.page-title-action'); + } + /** * Test that the Dashboard submenu item for this wizard does not display when a * third party Admin Menu editor type Plugin is installed and active. diff --git a/tests/EndToEnd/restrict-content/general/RestrictContentSetupCest.php b/tests/EndToEnd/restrict-content/general/RestrictContentSetupCest.php index a426035ef..bf88a0231 100644 --- a/tests/EndToEnd/restrict-content/general/RestrictContentSetupCest.php +++ b/tests/EndToEnd/restrict-content/general/RestrictContentSetupCest.php @@ -60,6 +60,30 @@ public function testAddNewMemberContentButtonNotDisplayedOnPosts(EndToEndTester $I->dontSeeElementInDOM('span.convertkit-action.page-title-action'); } + /** + * Test that the Add New Member Content button does not display on the Pages screen when the Add New Member Content button is disabled. + * + * @since 3.2.0 + * + * @param EndToEndTester $I Tester. + */ + public function testAddNewMemberContentButtonNotDisplayedWhenDisabled(EndToEndTester $I) + { + // Setup Plugin, disabling the Add New Landing Page / Member Content button. + $I->setupKitPlugin( + $I, + [ + 'no_add_new_button' => 'on', + ] + ); + + // Navigate to Pages. + $I->amOnAdminPage('edit.php?post_type=page'); + + // Check the buttons are not displayed. + $I->dontSeeElementInDOM('span.convertkit-action.page-title-action'); + } + /** * Test that the Dashboard submenu item for this wizard does not display when a * third party Admin Menu editor type Plugin is installed and active. diff --git a/tests/Support/Helper/KitPlugin.php b/tests/Support/Helper/KitPlugin.php index 326a84702..282d12184 100644 --- a/tests/Support/Helper/KitPlugin.php +++ b/tests/Support/Helper/KitPlugin.php @@ -72,6 +72,7 @@ public function setupKitPlugin($I, $options = false) 'debug' => 'on', 'no_scripts' => '', 'no_css' => '', + 'no_add_new_button' => '', 'usage_tracking' => '', 'post_form' => $_ENV['CONVERTKIT_API_FORM_ID'], 'page_form' => $_ENV['CONVERTKIT_API_FORM_ID'], From d7dfd4e87b7361ad56551f4b36f56a4bf0c1bddc Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 24 Feb 2026 09:00:52 +0800 Subject: [PATCH 3/5] Fix setting key --- admin/section/class-convertkit-admin-section-general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/section/class-convertkit-admin-section-general.php b/admin/section/class-convertkit-admin-section-general.php index b2df831aa..11efb8301 100644 --- a/admin/section/class-convertkit-admin-section-general.php +++ b/admin/section/class-convertkit-admin-section-general.php @@ -462,7 +462,7 @@ public function register_fields() { ); add_settings_field( - 'no_css', + 'no_add_new_button', __( 'Disable Add New Landing Page / Member Content Button', 'convertkit' ), array( $this, 'no_add_new_button_callback' ), $this->settings_key, From bae4365a7772045efe129104c9a1835b0659bca7 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 24 Feb 2026 09:01:20 +0800 Subject: [PATCH 4/5] Added tests --- .../PluginSettingsGeneralCest.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php b/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php index 171fcefd2..de70736ab 100644 --- a/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php +++ b/tests/EndToEnd/general/plugin-screens/PluginSettingsGeneralCest.php @@ -45,6 +45,7 @@ public function testAccessibilityAndUTMParameters(EndToEndTester $I) $I->seeInSource('