From a4474adc664350638d7ac3d57f0f4528ad38fca5 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Fri, 25 Oct 2024 11:43:27 +0100 Subject: [PATCH 1/7] Adjust messaging for application emails --- .../wcpt-event/class-event-application.php | 23 +++++++++++++++---- .../wcpt-events/class-events-application.php | 4 ++-- .../wcpt-meetup/class-meetup-application.php | 4 ++-- .../class-wordcamp-application.php | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php index a156505088..375c5d90af 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php @@ -132,10 +132,15 @@ public function submit_application( $post_data ) { $message = $application_data->get_error_message(); $notice_classes = 'notice-error'; } else { - $this->create_post( $application_data ); + $application_post = $this->create_post( $application_data ); + if ( is_wp_error( $application_post ) ) { + // Set application post to an int, rather than wp_error. + $application_post = 0; + } $this->notify_applicant_application_received( $this->get_organizer_email(), - $this->get_event_location() + $this->get_event_location(), + $application_post ); $this->notify_new_application_in_slack(); @@ -253,8 +258,9 @@ public function display_notice( $message, $notice_classes ) { * * @param string $email_address * @param string $event_city + * @param int $application_post id of post created on WC Central. */ - public function notify_applicant_application_received( $email_address, $event_city ) { + public function notify_applicant_application_received( $email_address, $event_city, $application_post ) { //translators: Name of the event. E.g. WordCamp or meetup. $subject = sprintf( __( "We've received your %s application", 'wordcamporg' ), $this->get_event_label() ); $headers = array( @@ -265,12 +271,21 @@ public function notify_applicant_application_received( $email_address, $event_ci //translators: 1: Name of the event. 2: City of the event. $message = sprintf( __( - "Thank you for applying to organize a %1\$s in %2\$s! We'll send you a follow-up e-mail once we've had a chance to review your application.", + "Thank you for applying to organize a %1\$s in %2\$s! We'll send you a follow-up e-mail once we've had a chance to review your application.\n\n", 'wordcamporg' ), $this->get_event_label(), sanitize_text_field( $event_city ) ); + $message .= sprintf( + "---- Internal details for the Community Team ----\n\n + Name: %1\$s\n + Type: %2\$s\n + URL: : https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit", + $this->get_event_label(), + sanitize_text_field( $event_city ), + absint( $application_post ), + ); wp_mail( $email_address, $subject, $message, $headers ); } diff --git a/public_html/wp-content/plugins/wcpt/wcpt-events/class-events-application.php b/public_html/wp-content/plugins/wcpt/wcpt-events/class-events-application.php index 51cc7bb437..2619573d3c 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-events/class-events-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-events/class-events-application.php @@ -145,7 +145,7 @@ public function get_default_application_values() { * * @param array $data * - * @return bool|WP_Error + * @return int|WP_Error */ public function create_post( $data ) { // Create the post. @@ -201,7 +201,7 @@ public function create_post( $data ) { $this->post = get_post( $post_id ); - return true; + return $post_id; } /** diff --git a/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-application.php b/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-application.php index c2a81c0941..562edf64c3 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-application.php @@ -207,7 +207,7 @@ public function get_default_application_values() { * * @param array $data * - * @return bool|WP_Error + * @return int|WP_Error */ public function create_post( $data ) { // Create the post. @@ -264,7 +264,7 @@ public function create_post( $data ) { $this->post = get_post( $post_id ); - return true; + return $post_id; } /** diff --git a/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/class-wordcamp-application.php b/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/class-wordcamp-application.php index 38c10dfa89..71e5e470a1 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/class-wordcamp-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/class-wordcamp-application.php @@ -186,7 +186,7 @@ public static function get_application_report_url() { * * @param array $data * - * @return bool|\WP_Error + * @return int|\WP_Error */ public function create_post( $data ) { // Create the post. @@ -259,7 +259,7 @@ public function create_post( $data ) { ); $this->post = get_post( $post_id ); - return true; + return $post_id; } /** From b7140f7b42d887fe004f61cc9acf8113f569011d Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Fri, 25 Oct 2024 11:45:08 +0100 Subject: [PATCH 2/7] Fix tabs/spaces --- .../plugins/wcpt/wcpt-event/class-event-application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php index 375c5d90af..8d473aaa10 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php @@ -258,7 +258,7 @@ public function display_notice( $message, $notice_classes ) { * * @param string $email_address * @param string $event_city - * @param int $application_post id of post created on WC Central. + * @param int $application_post id of post created on WC Central. */ public function notify_applicant_application_received( $email_address, $event_city, $application_post ) { //translators: Name of the event. E.g. WordCamp or meetup. From 59767ebb6585a17dbb526b81a0cea9898a1ed4e6 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Fri, 25 Oct 2024 14:36:12 +0100 Subject: [PATCH 3/7] phpcs --- .../wcpt/wcpt-event/class-event-application.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php index 8d473aaa10..e7f1056125 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php @@ -258,7 +258,7 @@ public function display_notice( $message, $notice_classes ) { * * @param string $email_address * @param string $event_city - * @param int $application_post id of post created on WC Central. + * @param int $application_post id of post created on WC Central. */ public function notify_applicant_application_received( $email_address, $event_city, $application_post ) { //translators: Name of the event. E.g. WordCamp or meetup. @@ -278,10 +278,10 @@ public function notify_applicant_application_received( $email_address, $event_ci sanitize_text_field( $event_city ) ); $message .= sprintf( - "---- Internal details for the Community Team ----\n\n - Name: %1\$s\n - Type: %2\$s\n - URL: : https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit", + "---- Internal details for the Community Team ----\n\n + Name: %1\$s\n + Type: %2\$s\n + URL: : https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit", $this->get_event_label(), sanitize_text_field( $event_city ), absint( $application_post ), From 0fde6e2fde8e0224dd4c6029bfd92112615a7da1 Mon Sep 17 00:00:00 2001 From: Paul Kevan <2290623+pkevan@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:21:23 +0000 Subject: [PATCH 4/7] Update class-event-application.php remove extra colon --- .../plugins/wcpt/wcpt-event/class-event-application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php index e7f1056125..6e6f3d53fd 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php @@ -281,7 +281,7 @@ public function notify_applicant_application_received( $email_address, $event_ci "---- Internal details for the Community Team ----\n\n Name: %1\$s\n Type: %2\$s\n - URL: : https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit", + URL: https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit", $this->get_event_label(), sanitize_text_field( $event_city ), absint( $application_post ), From 3d9fa450f4cf922333561c2127479eeb37b390e0 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Mon, 28 Oct 2024 15:26:58 +0000 Subject: [PATCH 5/7] only show application url if value appears legitimate --- .../wcpt/wcpt-event/class-event-application.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php index 6e6f3d53fd..7e5288c416 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php @@ -260,7 +260,7 @@ public function display_notice( $message, $notice_classes ) { * @param string $event_city * @param int $application_post id of post created on WC Central. */ - public function notify_applicant_application_received( $email_address, $event_city, $application_post ) { + public function notify_applicant_application_received( $email_address, $event_city, $application_post = 0 ) { //translators: Name of the event. E.g. WordCamp or meetup. $subject = sprintf( __( "We've received your %s application", 'wordcamporg' ), $this->get_event_label() ); $headers = array( @@ -280,13 +280,18 @@ public function notify_applicant_application_received( $email_address, $event_ci $message .= sprintf( "---- Internal details for the Community Team ----\n\n Name: %1\$s\n - Type: %2\$s\n - URL: https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit", + Type: %2\$s\n", $this->get_event_label(), sanitize_text_field( $event_city ), - absint( $application_post ), ); + if ( 0 !== $application_post ) { + $message .= sprintf( + "URL: https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit", + absint( $application_post ) + ); + } + wp_mail( $email_address, $subject, $message, $headers ); } From 3581f3da79cb1a42964c9941ddf2bfece4b5f24a Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Mon, 28 Oct 2024 15:31:49 +0000 Subject: [PATCH 6/7] phpcs --- .../plugins/wcpt/wcpt-event/class-event-application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php index 7e5288c416..140b1a8897 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php @@ -287,7 +287,7 @@ public function notify_applicant_application_received( $email_address, $event_ci if ( 0 !== $application_post ) { $message .= sprintf( - "URL: https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit", + 'URL: https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit', absint( $application_post ) ); } From c24cae416a425dc2d213a49a71e25909351545aa Mon Sep 17 00:00:00 2001 From: Paul Kevan <2290623+pkevan@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:29:17 +0000 Subject: [PATCH 7/7] Format strings Alter string formation after changing logic. --- .../plugins/wcpt/wcpt-event/class-event-application.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php index 140b1a8897..3e620fc999 100644 --- a/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php +++ b/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php @@ -278,16 +278,16 @@ public function notify_applicant_application_received( $email_address, $event_ci sanitize_text_field( $event_city ) ); $message .= sprintf( - "---- Internal details for the Community Team ----\n\n + "---- Internal details for the Community Team ----\n Name: %1\$s\n - Type: %2\$s\n", + Type: %2\$s", $this->get_event_label(), sanitize_text_field( $event_city ), ); if ( 0 !== $application_post ) { $message .= sprintf( - 'URL: https://central.wordcamp.org/wp-admin/post.php?post=%3\$d&action=edit', + "\nURL: https://central.wordcamp.org/wp-admin/post.php?post=%1\$d&action=edit", absint( $application_post ) ); }