Skip to content

Commit

Permalink
Merge pull request #761 from Kit/group-settings
Browse files Browse the repository at this point in the history
Group Settings in UI
  • Loading branch information
n7studios authored Jan 22, 2025
2 parents e436e9f + db76f6d commit 4488663
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 131 deletions.
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

0 comments on commit 4488663

Please sign in to comment.