diff --git a/admin/class-convertkit-admin-settings-restrict-content.php b/admin/class-convertkit-admin-settings-restrict-content.php index 57f524fe..28fd282a 100644 --- a/admin/class-convertkit-admin-settings-restrict-content.php +++ b/admin/class-convertkit-admin-settings-restrict-content.php @@ -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' ) ); @@ -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' ), ), ) ); @@ -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' ), ), ) ); @@ -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', @@ -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' ), ), ) ); @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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() { + + ?> +
+ + + 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' ) ); diff --git a/admin/section/class-convertkit-settings-base.php b/admin/section/class-convertkit-settings-base.php index e3adc8d0..e0b994c8 100644 --- a/admin/section/class-convertkit-settings-base.php +++ b/admin/section/class-convertkit-settings-base.php @@ -51,6 +51,15 @@ abstract class ConvertKit_Settings_Base { */ public $settings; + /** + * Holds the settings sections for a settings screen. + * + * @since 2.7.1 + * + * @var array + */ + public $settings_sections = array(); + /** * Holds whether this settings section is for beta functionality. * @@ -121,15 +130,30 @@ public function on_settings_screen( $tab ) { */ public function register_section() { - add_settings_section( - $this->name, - $this->title, - array( $this, 'print_section_info' ), - $this->settings_key - ); + // Register settings sections. + foreach ( $this->settings_sections as $name => $settings_section ) { + // Determine if this settings section needs to be wrapped in its own container. + $wrap = array(); + if ( $settings_section['wrap'] ) { + $wrap = array( + 'before_section' => $this->get_render_container_start(), + 'after_section' => $this->get_render_container_end(), + ); + } + + add_settings_section( + ( $name === 'general' ? $this->name : $this->name . '-' . $name ), + $settings_section['title'], + $settings_section['callback'], + $this->settings_key, + $wrap + ); + } + // Register settings fields. $this->register_fields(); + // Register setting to store data in options table. register_setting( $this->settings_key, $this->settings_key, @@ -141,7 +165,8 @@ public function register_section() { /** * Register fields for this section */ - abstract public function register_fields(); + public function register_fields() { + } /** * Prints help info for this section @@ -202,8 +227,6 @@ public function render() { */ do_action( 'convertkit_settings_base_render_before' ); - $this->render_container_start(); - do_settings_sections( $this->settings_key ); settings_fields( $this->settings_key ); @@ -212,10 +235,8 @@ public function render() { submit_button(); } - $this->render_container_end(); - /** - * Performs actions after rendering of the settings form. + * Performs actions after rendering of the settings form. * * @since 1.9.6 */ @@ -224,17 +245,14 @@ public function render() { } /** - * Outputs .metabox-holder and .postbox container div elements, + * Outputs opening .metabox-holder and .postbox container div elements, * used before beginning a setting screen's output. * * @since 2.0.0 */ public function render_container_start() { - ?> - - get_render_container_end(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + + } + + /** + * Returns opening .metabox-holder and .postbox container div elements, + * used before beginning a section of a settings screen output. + * + * @since 2.7.1 + */ + public function get_render_container_start() { + + return ' '; } diff --git a/admin/section/class-convertkit-settings-general.php b/admin/section/class-convertkit-settings-general.php index fd7cb834..21cc03cc 100644 --- a/admin/section/class-convertkit-settings-general.php +++ b/admin/section/class-convertkit-settings-general.php @@ -57,6 +57,20 @@ public function __construct() { $this->title = __( 'General Settings', 'convertkit' ); $this->tab_text = __( 'General', 'convertkit' ); + // Define settings sections. + $this->settings_sections = array( + 'general' => array( + 'title' => $this->title, + 'callback' => array( $this, 'print_section_info' ), + 'wrap' => true, + ), + 'advanced' => array( + 'title' => __( 'Advanced', 'convertkit' ), + 'callback' => array( $this, 'print_section_info_advanced' ), + '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' ) ); @@ -346,12 +360,13 @@ public function register_fields() { ) ); + // Advanced. add_settings_field( 'debug', __( 'Debug', 'convertkit' ), array( $this, 'debug_callback' ), $this->settings_key, - $this->name, + $this->name . '-advanced', array( 'label_for' => 'debug', ) @@ -362,7 +377,7 @@ public function register_fields() { __( 'Disable JavaScript', 'convertkit' ), array( $this, 'no_scripts_callback' ), $this->settings_key, - $this->name, + $this->name . '-advanced', array( 'label_for' => 'no_scripts', ) @@ -373,7 +388,7 @@ public function register_fields() { __( 'Disable CSS', 'convertkit' ), array( $this, 'no_css_callback' ), $this->settings_key, - $this->name, + $this->name . '-advanced', array( 'label_for' => 'no_css', ) @@ -387,13 +402,13 @@ public function register_fields() { public function print_section_info() { ?> - +
tags */
- esc_html__( 'The default form can be inserted into the middle of post or page content by using the %s shortcode.', 'convertkit' ),
+ esc_html__( 'The default form can be inserted into the middle of post or page content by using either the %s shortcode or block.', 'convertkit' ),
'[convertkit]
'
);
?>
@@ -402,6 +417,19 @@ public function print_section_info() {
}
+ /**
+ * Prints help info for the advanced section of the settings screen.
+ *
+ * @since 2.7.1
+ */
+ public function print_section_info_advanced() {
+
+ ?>
+