From 1870aaadbc87804339e900ca226752aaba99cc2f Mon Sep 17 00:00:00 2001 From: lezama Date: Fri, 24 Jan 2025 18:38:00 +0000 Subject: [PATCH] use postAuthorEmail (#41290) Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12955311033 Upstream-Ref: Automattic/jetpack@32de098e394596db7144f08332fdcd746d978c46 --- CHANGELOG.md | 1 + src/blocks/contact-form/class-contact-form-block.php | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d44a7b..c8325be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This is an alpha version! The changes listed here are not final. - Adds missing deprecation for checkboxes and radio fields - Form: fix the default checkstate for admins - Forms: Add unique ids to each form +- Forms: fix send to settings for multiple authors - Updates the icon colours to the new standard ## [0.35.0] - 2025-01-20 diff --git a/src/blocks/contact-form/class-contact-form-block.php b/src/blocks/contact-form/class-contact-form-block.php index 6a77ca2..a1bdb1a 100644 --- a/src/blocks/contact-form/class-contact-form-block.php +++ b/src/blocks/contact-form/class-contact-form-block.php @@ -156,7 +156,6 @@ public static function gutenblock_render_form( $atts, $content ) { * Loads scripts */ public static function load_editor_scripts() { - global $post; $handle = 'jp-forms-blocks'; @@ -171,10 +170,14 @@ public static function load_editor_scripts() { ) ); + // Create a Contact_Form instance to get the default values + $contact_form = new Contact_Form( array() ); + $defaults = $contact_form->defaults; + $data = array( 'defaults' => array( - 'to' => wp_get_current_user()->user_email, - 'subject' => '[' . get_bloginfo( 'name' ) . ']' . ( isset( $post ) ? ' ' . esc_html( $post->post_title ) : '' ), + 'to' => $defaults['to'], + 'subject' => $defaults['subject'], ), );