Changeset 12205 for sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers/helper-translation-discussion.php
- Timestamp:
- 11/04/2022 11:01:38 AM (2 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers
- Property svn:ignore
-
old new 10 10 phpunit.xml.dist 11 11 tests 12 bin
-
- Property svn:ignore
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers/helper-translation-discussion.php
r12071 r12205 161 161 'show_in_rest' => true, 162 162 'sanitize_callback' => array( $this, 'sanitize_comment_locale' ), 163 'rewrite' => false, 164 ) 165 ); 166 167 register_meta( 168 'comment', 169 'translation_status', 170 array( 171 'description' => 'Translation status as at when the comment was made', 172 'single' => true, 173 'show_in_rest' => true, 174 'sanitize_callback' => array( $this, 'sanitize_comment_translation_status' ), 163 175 'rewrite' => false, 164 176 ) … … 550 562 remove_action( 'comment_form_top', 'rosetta_comment_form_support_hint' ); 551 563 552 $post = self::maybe_get_temporary_post( self::get_shadow_post_id( $this->data['original_id'] ) ); 553 564 $post = self::maybe_get_temporary_post( self::get_shadow_post_id( $this->data['original_id'] ) ); 554 565 $output = gp_tmpl_get_output( 555 566 'translation-discussion-comments', … … 563 574 'project' => $this->data['project'], 564 575 'translation_set_slug' => $this->data['translation_set_slug'], 565 566 576 ), 567 577 $this->assets_dir . 'templates' … … 666 676 } 667 677 return $translation_id; 678 } 679 680 /** 681 * Sets the translation_status meta_key as "unknown" if is not in the accepted values. 682 * 683 * Used as sanitize callback in the register_meta for the "comment" object type, 684 * 'translation_status' meta_key 685 * 686 * @since 0.0.2 687 * 688 * @param string $translation_status The meta_value for the meta_key "translation_status". 689 * 690 * @return string 691 */ 692 public function sanitize_translation_status( string $translation_status ): string { 693 if ( ! in_array( $translation_status, array( 'approved', 'rejected', 'waiting', 'current', 'fuzzy', 'changesrequested' ), true ) ) { 694 $translation_status = 'unknown'; 695 } 696 return $translation_status; 697 668 698 } 669 699 … … 863 893 864 894 $comment_reason = get_comment_meta( $comment->comment_ID, 'reject_reason', true ); 895 896 $_translation_status = get_comment_meta( $comment->comment_ID, 'translation_status', true ); 865 897 866 898 $classes = array( 'comment-locale-' . $comment_locale ); … … 995 1027 if ( ! $is_linking_comment ) : 996 1028 if ( $comment_translation_id && $comment_translation_id !== $current_translation_id ) { 997 gth_print_translation( $comment_translation_id, $args, 'Translation: ' ); 1029 $translation_status = ''; 1030 if ( $_translation_status ) { 1031 $translation_status = ' (' . $_translation_status . ')'; 1032 } 1033 gth_print_translation( $comment_translation_id, $args, 'Translation' . $translation_status . ': ' ); 998 1034 } 999 1035
Note: See TracChangeset
for help on using the changeset viewer.