diff --git a/projects/packages/forms/src/class-jetpack-forms.php b/projects/packages/forms/src/class-jetpack-forms.php index 60094e73e6b6..bcb438ccb298 100644 --- a/projects/packages/forms/src/class-jetpack-forms.php +++ b/projects/packages/forms/src/class-jetpack-forms.php @@ -38,6 +38,9 @@ public static function load_contact_form() { // Add hook to delete file attachments when a feedback post is deleted add_action( 'before_delete_post', array( '\Automattic\Jetpack\Forms\ContactForm\Contact_Form', 'delete_feedback_files' ) ); + + // Enforces the availability of block support controls in the UI for classic themes. + add_filter( 'wp_theme_json_data_default', array( '\Automattic\Jetpack\Forms\ContactForm\Contact_Form', 'add_theme_json_data_for_classic_themes' ) ); } /** diff --git a/projects/packages/forms/src/contact-form/class-contact-form.php b/projects/packages/forms/src/contact-form/class-contact-form.php index 3f99912c355d..df70e863a1a4 100644 --- a/projects/packages/forms/src/contact-form/class-contact-form.php +++ b/projects/packages/forms/src/contact-form/class-contact-form.php @@ -2065,4 +2065,68 @@ function ( $token ) { } return $files; } + + /** + * Enforce required block supports UIs for Classic themes. + * + * @param \WP_Theme_JSON_Data $theme_json_data Theme JSON data object. + * + * @return \WP_Theme_JSON_Data Updated theme JSON settings. + */ + public static function add_theme_json_data_for_classic_themes( $theme_json_data ) { + if ( wp_is_block_theme() ) { + return $theme_json_data; + } + + $data = $theme_json_data->get_data(); + + if ( ! isset( $data['settings']['blocks'] ) ) { + $data['settings']['blocks'] = array(); + } + + $data['settings']['blocks']['jetpack/input'] = array( + 'color' => array( + 'text' => true, + 'background' => true, + ), + 'border' => array( + 'color' => true, + 'radius' => true, + 'style' => true, + 'width' => true, + ), + 'typography' => array( + 'fontFamily' => true, + 'fontSize' => true, + 'fontStyle' => true, + 'fontWeight' => true, + 'letterSpacing' => true, + 'lineHeight' => true, + 'textDecoration' => true, + 'textTransform' => true, + ), + ); + + $shared_settings = array( + 'color' => array( + 'text' => true, + 'background' => false, + ), + 'typography' => array( + 'fontFamily' => true, + 'fontSize' => true, + 'fontStyle' => true, + 'fontWeight' => true, + 'letterSpacing' => true, + 'lineHeight' => true, + 'textDecoration' => true, + 'textTransform' => true, + ), + ); + $data['settings']['blocks']['jetpack/label'] = $shared_settings; + $data['settings']['blocks']['jetpack/option'] = $shared_settings; + + $theme_json_class = get_class( $theme_json_data ); + return new $theme_json_class( $data, 'default' ); + } }