diff --git a/admin/class-convertkit-admin-landing-page.php b/admin/class-convertkit-admin-landing-page.php index f160cc1cc..24888f1e0 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_button_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..722885253 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_button_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..11efb8301 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_add_new_button', + __( 'Disable Add New Landing Page / Member Content Button', 'convertkit' ), + array( $this, 'no_add_new_button_callback' ), + $this->settings_key, + $this->name . '-advanced', + array( + 'label_for' => 'no_add_new_button', + ) + ); + 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_button_callback() { + + // Output field. + $this->output_checkbox_field( + 'no_add_new_button', + 'on', + $this->settings->add_new_button_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..56d799077 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 button is disabled in the Plugin settings. + * + * @since 3.2.0 + * + * @return bool + */ + public function add_new_button_disabled() { + + return ( $this->settings['no_add_new_button'] === '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_button' => '', // blank|on. 'usage_tracking' => '', // blank|on. ); 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('