Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions admin/class-convertkit-admin-landing-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions admin/class-convertkit-admin-restrict-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions admin/section/class-convertkit-admin-section-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down Expand Up @@ -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.
*
Expand Down
14 changes: 14 additions & 0 deletions includes/class-convertkit-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function testAccessibilityAndUTMParameters(EndToEndTester $I)
$I->seeInSource('<label for="debug">');
$I->seeInSource('<label for="no_scripts">');
$I->seeInSource('<label for="no_css">');
$I->seeInSource('<label for="no_add_new_button">');
$I->seeInSource('<label for="usage_tracking">');

// Confirm that the UTM parameters exist for the documentation links.
Expand Down Expand Up @@ -778,6 +779,48 @@ public function testEnableAndDisableCSSSetting(EndToEndTester $I)
$I->seeInSource('<link rel="stylesheet" id="convertkit-frontend-css" href="' . $_ENV['WORDPRESS_URL'] . '/wp-content/plugins/convertkit/resources/frontend/css/frontend.css');
}

/**
* Test that no PHP errors or notices are displayed on the Plugin's Setting screen
* when the Disable Add New Landing Page / Member Content button settings is unchecked, and that CSS is output
* on the frontend web site.
*
* @since 3.2.0
*
* @param EndToEndTester $I Tester.
*/
public function testEnableAndDisableAddNewLandingPageMemberContentButtonSetting(EndToEndTester $I)
{
// Setup Plugin.
$I->setupKitPlugin($I);

// Go to the Plugin's Settings Screen.
$I->loadKitSettingsGeneralScreen($I);

// Tick field.
$I->checkOption('#no_add_new_button');

// Click the Save Changes button.
$I->click('Save Changes');

// Check that no PHP warnings or notices were output.
$I->checkNoWarningsAndNoticesOnScreen($I);

// Check the field remains ticked.
$I->seeCheckboxIsChecked('#no_add_new_button');

// Untick field.
$I->uncheckOption('#no_add_new_button');

// Click the Save Changes button.
$I->click('Save Changes');

// Check that no PHP warnings or notices were output.
$I->checkNoWarningsAndNoticesOnScreen($I);

// Check the field remains unticked.
$I->dontSeeCheckboxIsChecked('#no_add_new_button');
}

/**
* Test that no PHP errors or notices are displayed on the Plugin's Setting screen
* when the Usage Tracking settings is unchecked, and that CSS is output
Expand Down
24 changes: 24 additions & 0 deletions tests/EndToEnd/landing-pages/PageLandingPageSetupWizardCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions tests/Support/Helper/KitPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down