Changeset 12274
- Timestamp:
- 11/23/2022 06:22:00 PM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers
- Files:
-
- 5 edited
-
helpers-assets/templates/translation-discussion-comments.php (modified) (1 diff)
-
helpers/helper-translation-discussion.php (modified) (3 diffs)
-
includes/class-wporg-customizations.php (modified) (1 diff)
-
includes/class-wporg-notifications.php (modified) (2 diffs)
-
js/reject-feedback.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers-assets/templates/translation-discussion-comments.php
r12205 r12274 185 185 ?> 186 186 </div><!-- .discussion-wrapper --> 187 <script> 188 jQuery(function( e, mentions ) { 189 var mentionsList = '<?php echo wp_json_encode( $mentions_list ); ?>'; 190 var jetpackMentionsData = JSON.parse( mentionsList ); 191 if( jetpackMentionsData.length > 0 ) { 192 jQuery( 'textarea#comment' ).mentions( jetpackMentionsData ); 193 } 194 }); 195 </script> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers/helper-translation-discussion.php
r12205 r12274 267 267 } 268 268 269 // phpcs:ignore WordPress.Security.NonceVerification.Missing 270 $locale_exists = isset( $_POST['meta']['locale'] ) && ! empty( $this->sanitize_comment_locale( $_POST['meta']['locale'] ) ); 271 272 // phpcs:ignore WordPress.Security.NonceVerification.Missing 273 $locale_slug = $locale_exists ? $_POST['meta']['locale'] : null; 274 275 $set_slug = $locale_exists ? 'default' : null; 276 269 277 // We were able to gather all information, let's put it in the cache. 270 $cache[ $post->ID ] = GP_Route_Translation_Helpers::get_permalink( $project->path, $original_id );278 $cache[ $post->ID ] = GP_Route_Translation_Helpers::get_permalink( $project->path, $original_id, $set_slug, $locale_slug ); 271 279 272 280 return $cache[ $post->ID ]; … … 562 570 remove_action( 'comment_form_top', 'rosetta_comment_form_support_hint' ); 563 571 564 $post = self::maybe_get_temporary_post( self::get_shadow_post_id( $this->data['original_id'] ) ); 572 $post = self::maybe_get_temporary_post( self::get_shadow_post_id( $this->data['original_id'] ) ); 573 $mentions_list = apply_filters( 'gp_mentions_list', array(), $comments, $this->data['locale_slug'], $this->data['original_id'] ); 574 565 575 $output = gp_tmpl_get_output( 566 576 'translation-discussion-comments', … … 574 584 'project' => $this->data['project'], 575 585 'translation_set_slug' => $this->data['translation_set_slug'], 586 'mentions_list' => $mentions_list, 587 576 588 ), 577 589 $this->assets_dir . 'templates' -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/includes/class-wporg-customizations.php
r12003 r12274 44 44 2 45 45 ); 46 47 add_filter( 'jetpack_mentions_should_load_ui', '__return_true' ); 48 add_filter( 49 'jetpack_mentions_allowed_post_types', 50 function( $post_types ) { 51 $post_types[] = Helper_Translation_Discussion::POST_TYPE; 52 return $post_types; 53 } 54 ); 55 46 56 } 47 57 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/includes/class-wporg-notifications.php
r12063 r12274 95 95 2 96 96 ); 97 add_filter( 98 'gp_mentions_list', 99 function( $result, $comments, $locale, $original_id ) { 100 $validator_email_addresses = ( $locale && $original_id ) ? WPorg_GlotPress_Notifications::get_validator_details_for_original_id( $locale, $original_id ) : array(); 101 $commenters_email_addresses = array_values( GP_Notifications::get_commenters_email_addresses( $comments ) ); 102 103 // Remove commenter email if it already exists as a GTE. 104 $commenters_email_addresses = array_filter( 105 $commenters_email_addresses, 106 function( $commenter_email ) use ( $validator_email_addresses ) { 107 return ( ! in_array( $commenter_email, array_column( $validator_email_addresses, 'email' ) ) ); 108 } 109 ); 110 111 $commenters_email_role = array_map( 112 function( $commenter_email ) { 113 return( 114 array( 115 'role' => 'commenter', 116 'email' => $commenter_email, 117 ) 118 ); 119 }, 120 $commenters_email_addresses 121 ); 122 123 $all_email_addresses = array_merge( 124 $validator_email_addresses, 125 $commenters_email_role 126 ); 127 128 $current_user = wp_get_current_user(); 129 $current_user_email = $current_user->user_email; 130 131 // Find all instances of the logged_in user in the array 132 $user_search_result = array_keys( array_column( $all_email_addresses, 'email' ), $current_user_email ); 133 134 if ( false !== $user_search_result ) { 135 foreach ( $user_search_result as $index ) { 136 unset( $all_email_addresses[ $index ] ); 137 } 138 $all_email_addresses = array_values( $all_email_addresses ); 139 } 140 141 $users = array_map( 142 function( $mentionable_user ) { 143 $email = $mentionable_user; 144 $role = ''; 145 if ( is_array( $mentionable_user ) ) { 146 $email = $mentionable_user['email']; 147 $role = ! ( 'commenter' === $mentionable_user['role'] ) ? ' - ' . $mentionable_user['role'] : ''; 148 } 149 150 $user = get_user_by( 'email', $email ); 151 return array( 152 'ID' => $user->ID, 153 'user_login' => $user->user_login, 154 'user_nicename' => $user->user_nicename . $role, 155 'display_name' => '', 156 'source' => array( 'translators' ), 157 'image_URL' => get_avatar_url( $user->ID ), 158 ); 159 }, 160 $all_email_addresses 161 ); 162 return $users; 163 }, 164 10, 165 4 166 ); 97 167 } 98 168 } … … 118 188 return array_merge( $email_addresses, self::get_clpte_email_addresses_by_project( $original->id ) ); 119 189 } 190 191 /** 192 * Gets the email addresses and roles(GTE/PTE/CLPTE) of all project validators: GTE, PTE and CLPTE. 193 * 194 * @since 0.0.2 195 * 196 * @param string $locale The locale for the translation. 197 * @param int $original_id The original id for the string. 198 * 199 * @return array The emails and roles(GTE/PTE/CLPTE) of the validators. 200 */ 201 public static function get_validator_details_for_original_id( $locale, $original_id ): array { 202 $gtes_email_and_role = array_map( 203 function( $gte_email ) { 204 return array( 205 'role' => 'GTE', 206 'email' => $gte_email, 207 ); 208 }, 209 self::get_gte_email_addresses( $locale ) 210 ); 211 212 $ptes_email_and_role = array_map( 213 function( $pte_email ) { 214 return array( 215 'role' => 'GTE', 216 'email' => $pte_email, 217 ); 218 }, 219 self::get_pte_email_addresses_by_project_and_locale( $original_id, $locale ) 220 ); 221 222 $clptes_email_and_role = array_map( 223 function( $clpte_email ) { 224 return array( 225 'role' => 'GTE', 226 'email' => $clpte_email, 227 ); 228 }, 229 self::get_clpte_email_addresses_by_project( $original_id ) 230 ); 231 232 return array_merge( 233 array_merge( $gtes_email_and_role, $ptes_email_and_role ), 234 $clptes_email_and_role 235 ); 236 } 237 120 238 121 239 /** -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/js/reject-feedback.js
r12205 r12274 23 23 24 24 // Remove click event added to <summary> by wporg-gp-customizations plugin 25 $( $gp.editor.table ).off( 'click', 'summary ' );25 $( $gp.editor.table ).off( 'click', 'summary.feedback-summary' ); 26 26 27 27 $( '#bulk-actions-toolbar-top .button, #bulk-actions-toolbar-bottom .button' ).click(
Note: See TracChangeset
for help on using the changeset viewer.