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-wporg-notifications.php

    r12003 r12063  
    326326                        }
    327327                }
     328                if ( isset( $comment_meta['reject_reason'][0] ) && ! empty( maybe_unserialize( $comment_meta['reject_reason'][0] ) ) ) {
     329                        $reasons         = array();
     330                        $comment_reasons = Helper_Translation_Discussion::get_comment_reasons();
     331                        $reasons         = array_map(
     332                                function( $reason ) use ( $comment_reasons ) {
     333                                        if ( array_key_exists( $reason, $comment_reasons ) ) {
     334                                                return $comment_reasons[ $reason ]['name'];
     335                                        }
     336                                },
     337                                maybe_unserialize( $comment_meta['reject_reason'][0] )
     338                        );
     339                        $output         .= '- <strong>' . esc_html__( 'Reason(s): ' ) . '</strong>' . esc_html( implode( ', ', $reasons ) ) . '<br>';
     340                }
    328341                $output .= '- <strong>' . esc_html__( 'Comment: ' ) . '</strong>' . esc_html( $comment->comment_content ) . '</pre>';
    329342                $output .= '<br><br>';
     
    430443         */
    431444        private static function get_opted_in_email_addresses( array $email_addresses ): array {
    432                 foreach ( $email_addresses as $email_address ) {
    433                         if ( self::is_global_optout_email_address( $email_address ) ) {
    434                                 $index = array_search( $email_address, $email_addresses, true );
    435                                 if ( false !== $index ) {
    436                                         unset( $email_addresses[ $index ] );
    437                                 }
     445                foreach ( $email_addresses as $index => $email_address ) {
     446                        if ( ! is_string( $email_address ) || empty( $email_address ) || self::is_global_optout_email_address( $email_address ) ) {
     447                                unset( $email_addresses[ $index ] );
    438448                        }
    439449                }
     
    451461         */
    452462        private static function is_global_optout_email_address( string $email_address ): bool {
     463                if ( empty( $email_address ) || ! is_email( $email_address ) ) {
     464                        return false;
     465                }
    453466                $user            = get_user_by( 'email', $email_address );
    454467                $gp_default_sort = get_user_option( 'gp_default_sort', $user->ID );
     
    602615                $user = wp_get_current_user();
    603616
     617                if ( ! $user->user_email ) {
     618                        return __( "You will not receive notifications because you don't have an e-mail address set." );
     619                }
    604620                if ( self::is_global_optout_email_address( $user->user_email ) ) {
    605                         $output  = __( 'You will not receive notifications because you have not yet opted-in. ' );
     621                        $output  = __( 'You will not receive notifications because you have not yet opted-in.' );
    606622                        $output .= ' <a href="https://translate.wordpress.org/settings/">' . __( 'Start receiving notifications.' ) . '</a>';
    607623                        return $output;
Note: See TracChangeset for help on using the changeset viewer.