From b65aa79c95d2236402de09de105ae73491218825 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 15 Apr 2026 19:18:28 +0800 Subject: [PATCH 1/2] Block Editor: Settings Sidebar: Support `optgroup` for Member Content --- ...onvertkit-plugin-sidebar-post-settings.php | 18 +++- resources/backend/js/gutenberg.js | 91 +++++++++++++++++-- 2 files changed, 100 insertions(+), 9 deletions(-) diff --git a/includes/plugin-sidebars/class-convertkit-plugin-sidebar-post-settings.php b/includes/plugin-sidebars/class-convertkit-plugin-sidebar-post-settings.php index c84121cee..e504bad9a 100644 --- a/includes/plugin-sidebars/class-convertkit-plugin-sidebar-post-settings.php +++ b/includes/plugin-sidebars/class-convertkit-plugin-sidebar-post-settings.php @@ -160,9 +160,13 @@ public function get_fields() { '0' => esc_html__( 'Don\'t restrict content to member-only', 'convertkit' ), ); if ( $convertkit_forms->exist() ) { + $restrict_content['forms'] = array( + 'label' => esc_html__( 'Forms', 'convertkit' ), + 'values' => array(), + ); foreach ( $convertkit_forms->get() as $form ) { // Legacy forms don't include a `format` key, so define them as inline. - $restrict_content[ 'form_' . absint( $form['id'] ) ] = sprintf( + $restrict_content['forms']['values'][ 'form_' . absint( $form['id'] ) ] = sprintf( '%s [%s]', sanitize_text_field( $form['name'] ), ( ! empty( $form['format'] ) ? sanitize_text_field( $form['format'] ) : 'inline' ) @@ -170,13 +174,21 @@ public function get_fields() { } } if ( $convertkit_tags->exist() ) { + $restrict_content['tags'] = array( + 'label' => esc_html__( 'Tags', 'convertkit' ), + 'values' => array(), + ); foreach ( $convertkit_tags->get() as $tag ) { - $restrict_content[ 'tag_' . absint( $tag['id'] ) ] = sanitize_text_field( $tag['name'] ); + $restrict_content['tags']['values'][ 'tag_' . absint( $tag['id'] ) ] = sanitize_text_field( $tag['name'] ); } } if ( $convertkit_products->exist() ) { + $restrict_content['products'] = array( + 'label' => esc_html__( 'Products', 'convertkit' ), + 'values' => array(), + ); foreach ( $convertkit_products->get() as $product ) { - $restrict_content[ 'product_' . $product['id'] ] = sanitize_text_field( $product['name'] ); + $restrict_content['products']['values'][ 'product_' . $product['id'] ] = sanitize_text_field( $product['name'] ); } } diff --git a/resources/backend/js/gutenberg.js b/resources/backend/js/gutenberg.js index 1e617cbbb..24965b7ad 100644 --- a/resources/backend/js/gutenberg.js +++ b/resources/backend/js/gutenberg.js @@ -1009,25 +1009,104 @@ function convertKitGutenbergRegisterPluginSidebar(sidebar) { // depending on the Field Type (select, textarea, text etc). switch (field.type) { case 'select': - // Build options for