Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group Settings in UI #761

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
136 changes: 90 additions & 46 deletions admin/class-convertkit-admin-settings-restrict-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ public function __construct() {
$this->title = __( 'Member Content', 'convertkit' );
$this->tab_text = __( 'Member Content', 'convertkit' );

// Define settings sections.
$this->settings_sections = array(
'general' => array(
'title' => $this->title,
'callback' => array( $this, 'print_section_info' ),
'wrap' => true,
),
'products' => array(
'title' => __( 'Products', 'convertkit' ),
'callback' => array( $this, 'print_section_info_products' ),
'wrap' => true,
),
'tags' => array(
'title' => __( 'Tags', 'convertkit' ),
'callback' => array( $this, 'print_section_info_tags' ),
'wrap' => true,
),
);

// Enqueue scripts.
add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) );

Expand Down Expand Up @@ -86,12 +105,12 @@ public function register_fields() {
__( 'reCAPTCHA: Site Key', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-tags',
array(
'name' => 'recaptcha_site_key',
'label_for' => 'recaptcha_site_key',
'description' => array(
__( 'Enter your Google reCAPTCHA v3 Site Key. When specified, this will be used in Member Content by Tag functionality to reduce spam signups.', 'convertkit' ),
__( 'Enter your Google reCAPTCHA v3 Site Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
),
)
);
Expand All @@ -100,12 +119,12 @@ public function register_fields() {
__( 'reCAPTCHA: Secret Key', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-tags',
array(
'name' => 'recaptcha_secret_key',
'label_for' => 'recaptcha_secret_key',
'description' => array(
__( 'Enter your Google reCAPTCHA v3 Secret Key. When specified, this will be used in Member Content by Tag functionality to reduce spam signups.', 'convertkit' ),
__( 'Enter your Google reCAPTCHA v3 Secret Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
),
)
);
Expand All @@ -114,7 +133,7 @@ public function register_fields() {
__( 'reCAPTCHA: Minimum Score', 'convertkit' ),
array( $this, 'number_callback' ),
$this->settings_key,
$this->name,
$this->name . '-tags',
array(
'name' => 'recaptcha_minimum_score',
'label_for' => 'recaptcha_minimum_score',
Expand All @@ -127,80 +146,80 @@ public function register_fields() {
)
);

// Restrict by Product.
// Restrict by Tag.
add_settings_field(
'subscribe_heading',
__( 'Product: Subscribe Heading', 'convertkit' ),
'subscribe_heading_tag',
__( 'Subscribe Heading', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-tags',
array(
'name' => 'subscribe_heading',
'label_for' => 'subscribe_heading',
'name' => 'subscribe_heading_tag',
'label_for' => 'subscribe_heading_tag',
'description' => array(
__( 'When a Page, Post or Custom Post\'s Member Content setting is set to a Kit Product, displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
__( 'Displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
),
)
);

add_settings_field(
'subscribe_text',
__( 'Product: Subscribe Text', 'convertkit' ),
'subscribe_text_tag',
__( 'Subscribe Text', 'convertkit' ),
array( $this, 'textarea_callback' ),
$this->settings_key,
$this->name,
$this->name . '-tags',
array(
'name' => 'subscribe_text',
'label_for' => 'subscribe_text',
'name' => 'subscribe_text_tag',
'label_for' => 'subscribe_text_tag',
'description' => array(
__( 'When a Page, Post or Custom Post\'s Member Content setting is set to a Kit Product, displays text explaining why the content is only available to subscribers.', 'convertkit' ),
__( 'Displays text explaining why the content is only available to subscribers.', 'convertkit' ),
),
)
);

// Restrict by Tag.
// All.
add_settings_field(
'subscribe_heading_tag',
__( 'Tag: Subscribe Heading', 'convertkit' ),
'subscribe_button_label',
__( 'Subscribe Button Label', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
array(
'name' => 'subscribe_heading_tag',
'label_for' => 'subscribe_heading_tag',
'name' => 'subscribe_button_label',
'label_for' => 'subscribe_button_label',
'description' => array(
__( 'When a Page, Post or Custom Post\'s Member Content setting is set to a Kit Tag, displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
__( 'The text to display for the call to action button to subscribe.', 'convertkit' ),
),
)
);

// Restrict by Product.
add_settings_field(
'subscribe_text_tag',
__( 'Tag: Subscribe Text', 'convertkit' ),
array( $this, 'textarea_callback' ),
'subscribe_heading',
__( 'Subscribe Heading', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'subscribe_text_tag',
'label_for' => 'subscribe_text_tag',
'name' => 'subscribe_heading',
'label_for' => 'subscribe_heading',
'description' => array(
__( 'When a Page, Post or Custom Post\'s Member Content setting is set to a Kit Tag, displays text explaining why the content is only available to subscribers.', 'convertkit' ),
__( 'Displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
),
)
);

// All.
add_settings_field(
'subscribe_button_label',
__( 'Subscribe Button Label', 'convertkit' ),
array( $this, 'text_callback' ),
'subscribe_text',
__( 'Subscribe Text', 'convertkit' ),
array( $this, 'textarea_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'subscribe_button_label',
'label_for' => 'subscribe_button_label',
'name' => 'subscribe_text',
'label_for' => 'subscribe_text',
'description' => array(
__( 'The text to display for the call to action button to subscribe.', 'convertkit' ),
__( 'Displays text explaining why the content is only available to subscribers.', 'convertkit' ),
),
)
);
Expand All @@ -210,7 +229,7 @@ public function register_fields() {
__( 'Email Text', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'email_text',
'label_for' => 'email_text',
Expand All @@ -225,7 +244,7 @@ public function register_fields() {
__( 'Email Heading', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'email_heading',
'label_for' => 'email_heading',
Expand All @@ -240,7 +259,7 @@ public function register_fields() {
__( 'Email Field Description', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'email_description_text',
'label_for' => 'email_description_text',
Expand All @@ -255,7 +274,7 @@ public function register_fields() {
__( 'Email Button Label', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'email_button_label',
'label_for' => 'email_button_label',
Expand All @@ -270,7 +289,7 @@ public function register_fields() {
__( 'Email Check Heading', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'email_check_heading',
'label_for' => 'email_check_heading',
Expand All @@ -285,7 +304,7 @@ public function register_fields() {
__( 'Email Check Text', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'email_check_text',
'label_for' => 'email_check_text',
Expand All @@ -300,7 +319,7 @@ public function register_fields() {
__( 'No Access Text', 'convertkit' ),
array( $this, 'text_callback' ),
$this->settings_key,
$this->name,
$this->name . '-products',
array(
'name' => 'no_access_text',
'label_for' => 'no_access_text',
Expand All @@ -325,6 +344,31 @@ public function print_section_info() {

}

/**
* Prints help info for the products section of the settings screen.
*
* @since 2.7.1
*/
public function print_section_info_products() {

?>
<p class="description"><?php esc_html_e( 'Defines settings when a Page, Post or Custom Post type has its member content setting set to a Kit product.', 'convertkit' ); ?></p>
<?php

}

/**
* Prints help info for the tags section of the settings screen.
*
* @since 2.7.1
*/
public function print_section_info_tags() {

?>
<p class="description"><?php esc_html_e( 'Defines settings when a Page, Post or Custom Post type has its member content setting set to a Kit tag.', 'convertkit' ); ?></p>
<?php

}

/**
* Returns the URL for the ConvertKit documentation for this setting section.
Expand Down
9 changes: 9 additions & 0 deletions admin/section/class-convertkit-admin-settings-broadcasts.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public function __construct() {
// Identify that this is beta functionality.
$this->is_beta = true;

// Define settings sections.
$this->settings_sections = array(
'general' => array(
'title' => $this->title,
'callback' => array( $this, 'print_section_info' ),
'wrap' => true,
),
);

// Register and maybe output notices for this settings screen.
if ( $this->on_settings_screen( $this->name ) ) {
add_filter( 'convertkit_settings_base_register_notices', array( $this, 'register_notices' ) );
Expand Down
Loading