Making WordPress.org


Ignore:
Timestamp:
09/15/2022 03:13:17 PM (4 years ago)
Author:
amieiro
Message:

Translate. Add new status in the gp-translation-helpers plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/includes/class-gp-notifications.php

    r12003 r12063  
    3434                if ( ( '0' !== $comment->comment_parent ) ) { // Notify to the thread only if the comment is in a thread.
    3535                    self::send_emails_to_thread_commenters( $comment, $comment_meta );
    36                 }
    37                 if ( ( '0' === $comment->comment_parent ) && array_key_exists( 'reject_reason', $comment_meta ) && ( ! empty( $comment_meta['reject_reason'] ) ) ) {  // Notify a rejection without parent comments.
    38                     self::send_rejection_email_to_translator( $comment, $comment_meta );
    3936                }
    4037                $root_comment      = self::get_root_comment_in_a_thread( $comment );
     
    5047                            break;
    5148                    }
     49                } elseif ( ( '0' === $comment->comment_parent ) ) {  // Notify an approval, rejection or fuzzy without parent comments.
     50                    self::send_action_email_to_translator( $comment, $comment_meta );
    5251                }
    5352            }
     
    104103
    105104    /**
    106      * Sends the reject notification to the translator.
     105     * Sends the action notification (approval, rejection, fuzzy) to the translator.
    107106     *
    108107     * @since 0.0.2
     
    113112     * @return void
    114113     */
    115     public static function send_rejection_email_to_translator( WP_Comment $comment, array $comment_meta ) {
     114    public static function send_action_email_to_translator( WP_Comment $comment, array $comment_meta ) {
    116115        $translation_id = $comment_meta['translation_id'];
    117116        $translation    = GP::$translation->get( $translation_id );
    118         $translator     = get_user_by( 'id', $translation->user_id_last_modified );
     117        $translator     = get_user_by( 'id', $translation->user_id );
    119118        if ( false === $translator ) {
    120             $translator = get_user_by( 'id', $translation->user_id );
    121         }
    122         self::send_emails( $comment, $comment_meta, array( $translator->user_email ) );
     119            $translator = get_user_by( 'id', $translation->user_id_last_modified );
     120        }
     121        if ( false === $translator ) {
     122            self::send_emails( $comment, $comment_meta, array( $translator->user_email ) );
     123        }
    123124    }
    124125
     
    422423            }
    423424        }
     425        if ( isset( $comment_meta['reject_reason'][0] ) && ! empty( maybe_unserialize( $comment_meta['reject_reason'][0] ) ) ) {
     426            $reasons         = array();
     427            $comment_reasons = Helper_Translation_Discussion::get_comment_reasons();
     428            $reasons         = array_map(
     429                function( $reason ) use ( $comment_reasons ) {
     430                    if ( array_key_exists( $reason, $comment_reasons ) ) {
     431                        return $comment_reasons[ $reason ]['name'];
     432                    }
     433                },
     434                maybe_unserialize( $comment_meta['reject_reason'][0] )
     435            );
     436            /* translators: The reason(s) for rejection. */
     437            $output .= '- ' . wp_kses( sprintf( __( '<strong>Reason(s):</strong> %s', 'glotpress' ), implode( ', ', $reasons ) ), array( 'strong' => array() ) ) . '<br/>';
     438        }
    424439        /* translators: The comment made. */
    425440        $output .= '- ' . wp_kses( sprintf( __( '<strong>Comment:</strong> %s', 'glotpress' ), $comment->comment_content ), array( 'strong' => array() ) ) . '<br/>';
Note: See TracChangeset for help on using the changeset viewer.