Skip to content

Commit f09919a

Browse files
committed
Add last revision name & target languages
1 parent 97249d5 commit f09919a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

plugins/bcc-post-update-translations-notifier/bcc-post-update-translations-notifier.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,31 @@ public function maybe_notify_on_translate( $value, $post_id, $field ) {
8181
$message_lines[] = "The content of the following post was updated and the editor requested the translation to be reviewed again.";
8282
$message_lines[] = "";
8383
$message_lines[] = "Post: " . $title;
84+
85+
// Get the last revision author
86+
$revisions = wp_get_post_revisions( $post_id, array( 'numberposts' => 1 ) );
87+
if ( ! empty( $revisions ) ) {
88+
$last_revision = reset( $revisions );
89+
$author_name = get_the_author_meta( 'display_name', $last_revision->post_author );
90+
if ( $author_name ) {
91+
$message_lines[] = "Last edited by: " . $author_name;
92+
}
93+
}
94+
95+
// Get target languages
96+
$target_languages = get_field( 'target_languages', $post_id );
97+
if ( $target_languages ) {
98+
if ( is_array( $target_languages ) ) {
99+
$message_lines[] = "Translation languages: " . implode( ', ', $target_languages );
100+
} else {
101+
$message_lines[] = "Translation languages: " . $target_languages;
102+
}
103+
}
104+
84105
if ( $permalink ) {
85106
$message_lines[] = "URL: " . $permalink;
86107
}
108+
87109
$message_lines[] = "";
88110
$message_lines[] = "---";
89111
$message_lines[] = "This is an automated notification which is triggered whenever \"Translation stage\" is changed to \"Translate\".";

0 commit comments

Comments
 (0)