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..5f319715b 100644 --- a/includes/plugin-sidebars/class-convertkit-plugin-sidebar-post-settings.php +++ b/includes/plugin-sidebars/class-convertkit-plugin-sidebar-post-settings.php @@ -157,12 +157,16 @@ public function get_fields() { // Get Products. $restrict_content = array( - '0' => esc_html__( 'Don\'t restrict content to member-only', 'convertkit' ), + '0' => esc_html__( 'Do not 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..3b1047548 100644 --- a/resources/backend/js/gutenberg.js +++ b/resources/backend/js/gutenberg.js @@ -1003,13 +1003,77 @@ function convertKitGutenbergRegisterPluginSidebar(sidebar) { }, }; - const fieldOptions = []; - // Define additional Field Properties and the Field Element, // depending on the Field Type (select, textarea, text etc). switch (field.type) { case 'select': - // Build options for