Making WordPress.org


Ignore:
Timestamp:
11/04/2022 11:01:38 AM (2 years ago)
Author:
akirk
Message:

gp-translation-helpers: Update from Github

Changes:

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  
        1010phpunit.xml.dist
        1111tests
         12bin
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers/helper-translation-discussion.php

    r12071 r12205  
    161161                'show_in_rest'      => true,
    162162                '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' ),
    163175                'rewrite'           => false,
    164176            )
     
    550562        remove_action( 'comment_form_top', 'rosetta_comment_form_support_hint' );
    551563
    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'] ) );
    554565        $output = gp_tmpl_get_output(
    555566            'translation-discussion-comments',
     
    563574                'project'              => $this->data['project'],
    564575                'translation_set_slug' => $this->data['translation_set_slug'],
    565 
    566576            ),
    567577            $this->assets_dir . 'templates'
     
    666676        }
    667677        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
    668698    }
    669699
     
    863893
    864894    $comment_reason = get_comment_meta( $comment->comment_ID, 'reject_reason', true );
     895
     896    $_translation_status = get_comment_meta( $comment->comment_ID, 'translation_status', true );
    865897
    866898    $classes = array( 'comment-locale-' . $comment_locale );
     
    9951027            if ( ! $is_linking_comment ) :
    9961028                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 . ': ' );
    9981034                }
    9991035
Note: See TracChangeset for help on using the changeset viewer.