Changeset 12405
- Timestamp:
- 02/20/2023 02:50:11 PM (2 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers
- Files:
-
- 5 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/css/discussion.css
r12205 r12405 298 298 } 299 299 ul#glossary-item-list { 300 300 list-style-type: none; 301 301 border: #bcc3c3 thin solid; 302 303 304 302 padding: 10px; 303 border-radius: 3px; 304 background: #f2f2f2; 305 305 } 306 306 ul#glossary-item-list h6 { 307 307 margin-top: 3px; 308 308 margin-bottom: 8px 309 309 } 310 310 ul#glossary-item-list li label { 311 311 margin-left: 5px; 312 312 } 313 313 #glossary-item-list li label input[type="checkbox"].glossary-word-item { 314 margin-right: 5px; 315 } 314 margin-right: 5px; 315 } 316 td.gtes-involved a{ 317 text-decoration: none; 318 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/gp-translation-helpers.php
r12074 r12405 31 31 32 32 require_once __DIR__ . '/includes/class-gp-route-translation-helpers.php'; 33 require_once __DIR__ . '/includes/class-gp-sidebar.php'; 33 34 require_once __DIR__ . '/includes/class-gp-translation-helpers.php'; 34 35 require_once __DIR__ . '/includes/class-gth-temporary-post.php'; … … 36 37 require_once __DIR__ . '/includes/class-wporg-notifications.php'; 37 38 require_once __DIR__ . '/includes/class-wporg-customizations.php'; 39 require_once __DIR__ . '/includes/class-gp-custom-locale-reasons.php'; 38 40 39 add_action( 'gp_init', array( 'GP_Translation_Helpers', 'init' ) ); 41 add_action( 'gp_init', array( 'GP_Translation_Helpers', 'init' ) ); // todo: remove this when this plugin will be merged in the GlotPress core. 42 add_action( 'gp_init', array( 'GP_Sidebar', 'init' ) ); // todo: remove this when this plugin will be merged in the GlotPress core. 40 43 add_action( 'gp_init', array( 'WPorg_GlotPress_Notifications', 'init' ) ); // todo: include this class in a different plugin. 41 44 add_action( 'gp_init', array( 'WPorg_GlotPress_Customizations', 'init' ) ); // todo: include this class in a different plugin. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers/helper-translation-discussion.php
r12274 r12405 805 805 * @return array 806 806 */ 807 public static function get_comment_reasons( ): array {808 returnarray(807 public static function get_comment_reasons( $locale = null ): array { 808 $default_reasons = array( 809 809 'style' => array( 810 810 'name' => __( 'Style Guide' ), … … 825 825 'punctuation' => array( 826 826 'name' => __( 'Punctuation' ), 827 'explanation' => 828 __( 'The translation is not using the punctuation marks correctly.' ), 827 'explanation' => __( 'The translation is not using the punctuation marks correctly.' ), 829 828 ), 830 829 'typo' => array( … … 833 832 ), 834 833 ); 834 $reasons = apply_filters( 'gp_custom_reasons', $default_reasons, $locale ); 835 return $reasons; 835 836 } 836 837 } … … 898 899 $is_linking_comment = preg_match( '!^' . home_url( gp_url() ) . '[a-z0-9_/#-]+$!i', $comment->comment_content ); 899 900 900 $comment_locale = get_comment_meta( $comment->comment_ID, 'locale', true ); 901 $current_locale = $args['locale_slug']; 902 901 $comment_locale = get_comment_meta( $comment->comment_ID, 'locale', true ); 902 $current_locale = $args['locale_slug']; 903 903 $current_translation_id = $args['translation_id']; 904 904 $comment_translation_id = get_comment_meta( $comment->comment_ID, 'translation_id', true ); … … 960 960 if ( $comment_reason ) : 961 961 ?> 962 The translation <?php gth_print_translation( $comment_translation_id, $args ); ?> <a href="<?php echo esc_url( $linked_comment ); ?>"><?php esc_html_e( 'is being discussed here' ); ?></a>.962 <p>The translation <?php gth_print_translation( $comment_translation_id, $args ); ?> <a href="<?php echo esc_url( $linked_comment ); ?>"><?php esc_html_e( 'is being discussed here' ); ?></a>.</p> 963 963 <?php else : ?> 964 964 <a href="<?php echo esc_url( $linked_comment ); ?>"><?php esc_html_e( 'Please continue the discussion here' ); ?></a> … … 1037 1037 } 1038 1038 1039 if ( $comment_translation_id && $comment_translation_id !== $current_translation_id ) { 1040 $translation_status = ''; 1041 if ( $_translation_status ) { 1042 1043 $translation_status = ( is_array( $_translation_status ) && array_key_exists( $comment_translation_id, $_translation_status ) ) ? '(' . $_translation_status[ $comment_translation_id ] . ')' : ' (' . $_translation_status[0] . ')'; 1044 } 1045 gth_print_translation( $comment_translation_id, $args, 'Translation' . $translation_status . ': ' ); 1046 } 1039 1047 if ( ! $is_linking_comment ) : 1040 if ( $comment_translation_id && $comment_translation_id !== $current_translation_id ) {1041 $translation_status = '';1042 if ( $_translation_status ) {1043 $translation_status = ' (' . $_translation_status . ')';1044 }1045 gth_print_translation( $comment_translation_id, $args, 'Translation' . $translation_status . ': ' );1046 }1047 1048 1048 1049 ?> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/includes/class-gp-translation-helpers.php
r12205 r12405 75 75 ); 76 76 gp_enqueue_style( 'gp-discussion-css' ); 77 78 wp_register_style( // todo: these CSS should be integrated in GlotPress. 79 'gp-translation-helpers-editor', 80 plugins_url( 'css/editor.css', __DIR__ ), 81 array(), 82 filemtime( plugin_dir_path( __DIR__ ) . 'css/editor.css' ) 83 ); 84 gp_enqueue_style( 'gp-translation-helpers-editor' ); 77 85 78 86 add_filter( 'gp_translation_row_template_more_links', array( $this, 'translation_row_template_more_links' ), 10, 5 ); … … 371 379 * 372 380 * @param string $template Template of the current page. 373 * @param string $translation_set Current translation set381 * @param array $translation_set Current translation set. 374 382 * 375 383 * @return void … … 396 404 'nonce' => wp_create_nonce( 'gp_comment_feedback' ), 397 405 'locale_slug' => $translation_set['locale_slug'], 398 'comment_reasons' => Helper_Translation_Discussion::get_comment_reasons(), 406 'comment_reasons' => Helper_Translation_Discussion::get_comment_reasons( $translation_set['locale_slug'] ), 407 ) 408 ); 409 410 wp_register_script( 411 'gp-translation-helpers-editor', 412 plugins_url( 'js/editor.js', __DIR__ ), 413 array( 'gp-editor' ), 414 filemtime( plugin_dir_path( __DIR__ ) . 'js/editor.js' ), 415 true 416 ); 417 gp_enqueue_scripts( array( 'gp-translation-helpers-editor' ) ); 418 419 wp_localize_script( 420 'gp-translation-helpers-editor', 421 '$gp_translation_helpers_editor', 422 array( 423 'translation_helper_url' => gp_url_project( $translation_set['project']->path, gp_url_join( $translation_set['locale_slug'], $translation_set['translation_set']->slug, '-get-translation-helpers' ) ), 424 'reply_text' => esc_attr__( 'Reply' ), 425 'cancel_reply_text' => esc_html__( 'Cancel reply' ), 426 ) 427 ); 428 wp_localize_script( 429 'gp-translation-helpers-editor', 430 'wpApiSettings', 431 array( 432 'root' => esc_url_raw( rest_url() ), 433 'nonce' => wp_create_nonce( 'wp_rest' ), 434 'admin_ajax_url' => admin_url( 'admin-ajax.php' ), 399 435 ) 400 436 ); … … 413 449 $helper_discussion = new Helper_Translation_Discussion(); 414 450 $locale_slug = $helper_discussion->sanitize_comment_locale( sanitize_text_field( $_POST['data']['locale_slug'] ) ); 415 $translation_status = $helper_discussion->sanitize_translation_status( sanitize_text_field( $_POST['data']['translation_status'] ) );451 $translation_status = ! empty( $_POST['data']['translation_status'] ) ? array_map( array( $helper_discussion, 'sanitize_translation_status' ), $_POST['data']['translation_status'] ) : null; 416 452 $translation_id_array = ! empty( $_POST['data']['translation_id'] ) ? array_map( array( $helper_discussion, 'sanitize_translation_id' ), $_POST['data']['translation_id'] ) : null; 417 453 $original_id_array = ! empty( $_POST['data']['original_id'] ) ? array_map( array( $helper_discussion, 'sanitize_original_id' ), $_POST['data']['original_id'] ) : null; … … 451 487 foreach ( $original_id_array as $index => $single_original_id ) { 452 488 $comment_id = $this->insert_comment( $comment, $single_original_id, $comment_reason, $translation_id_array[ $index ], $locale_slug, $_SERVER, $translation_status ); 453 $ comment= get_comment( $comment_id );454 GP_Notifications::add_related_comment( $ comment );489 $_comment = get_comment( $comment_id ); 490 GP_Notifications::add_related_comment( $_comment ); 455 491 } 456 492 } … … 461 497 } 462 498 463 wp_send_json_success( );499 wp_send_json_success( 'success' ); 464 500 } 465 501 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/includes/class-wporg-customizations.php
r12274 r12405 45 45 ); 46 46 47 add_filter( 48 'gp_custom_reasons', 49 function ( $default_reasons, $locale ) { 50 return array_merge( $default_reasons, GP_Custom_Locale_Reasons::get_custom_reasons( $locale ) ); 51 }, 52 10, 53 2 54 ); 55 47 56 add_filter( 'jetpack_mentions_should_load_ui', '__return_true' ); 48 57 add_filter( … … 54 63 ); 55 64 65 add_filter( 66 'gp_validators_involved', 67 function ( $gtes_involved, $locale_slug, $original_id, $comment_authors ) { 68 $gte_emails = WPorg_GlotPress_Notifications::get_gte_email_addresses( $locale_slug ); 69 $pte_emails = WPorg_GlotPress_Notifications::get_pte_email_addresses_by_project_and_locale( $original_id, $locale_slug ); 70 $clpte_emails = WPorg_GlotPress_Notifications::get_clpte_email_addresses_by_project( $original_id ); 71 return array_intersect( array_merge( $gte_emails, $pte_emails, $clpte_emails ), $comment_authors ); 72 73 }, 74 10, 75 4 76 ); 77 78 add_filter( 79 'gp_involved_table_heading', 80 function () { 81 return __( 'GTEs/PTEs/CLPTEs Involved' ); 82 } 83 ); 56 84 } 57 85 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/js/reject-feedback.js
r12274 r12405 6 6 var translationIds = []; 7 7 var originalIds = []; 8 var bulkTranslationStatus = []; 9 var translationStatuses = {}; 10 var statusIndex = 0; 8 11 var modalFeedbackForm = 9 12 '<div id="reject-feedback-form" style="display:none;">' + … … 30 33 function() { 31 34 var selectedRow = $( this ).parents( 'tr.preview' ); 35 var translationStatus = ''; 36 32 37 if ( ! selectedRow.hasClass( 'untranslated' ) ) { 38 translationStatus = selectedRow.attr( 'class' ).split( ' ' )[ 1 ].substring( 7 ); 39 bulkTranslationStatus.push( translationStatus ); 33 40 return selectedRow.attr( 'row' ); 34 41 } … … 46 53 originalIds.push( originalId ); 47 54 translationIds.push( translationId ); 55 translationStatuses[ translationId ] = bulkTranslationStatus[ statusIndex ]; 48 56 } 57 statusIndex++; 49 58 } 50 59 ); … … 105 114 commentData.translation_id = translationIds; 106 115 commentData.is_bulk_reject = true; 116 commentData.translation_status = translationStatuses; 117 107 118 commentWithFeedback( commentData, false, 'rejected' ); 108 119 e.preventDefault(); … … 283 294 feedbackData.original_id = [ $gp.editor.current.original_id ]; 284 295 feedbackData.translation_id = [ $gp.editor.current.translation_id ]; 285 feedbackData.translation_status = status;296 feedbackData.translation_status = [ status ]; 286 297 287 298 commentWithFeedback( feedbackData, button, status ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/templates/discussions-dashboard.php
r12275 r12405 104 104 <th>Author</th> 105 105 <th>Submitted on</th> 106 <th><?php echo esc_html( apply_filters( 'gp_involved_table_heading', __( 'Validators Involved' ) ) ); ?></th> 106 107 </tr> 107 108 </thead> … … 119 120 $project_name = ( $parent_project ) ? $parent_project->name : $project->name; 120 121 $project_link = gp_link_project_get( $project, esc_html( $project_name ) ); 122 123 $comment_authors = array_unique( array_column( $post_comments, 'comment_author_email' ) ); 124 $validator_emails = GP_Notifications::get_validators_email_addresses( $project->path ); 125 $validators_involved_emails = array_intersect( $validator_emails, $comment_authors ); 126 127 $validators_involved_emails = apply_filters( 'gp_validators_involved', $validators_involved_emails, $locale_slug, $original_id, $comment_authors ); 128 129 $validator_involved_names = array_map( 130 function( $validator ) { 131 $validator_user = get_user_by( 'email', $validator ); 132 return '<a href="' . esc_url( gp_url_profile( $validator_user->user_nicename ) ) . '">' . esc_html( $validator_user->display_name ) . '</a>'; 133 }, 134 $validators_involved_emails 135 ); 121 136 122 137 $first_comment = reset( $post_comments ); … … 201 216 <td><?php echo get_comment_author_link( $first_comment ); ?></td> 202 217 <td><?php echo esc_html( $first_comment->comment_date ); ?></td> 218 <td class="gtes-involved"> 219 <?php 220 echo wp_kses( 221 implode( ', ', $validator_involved_names ), 222 array( 223 'a' => array( 224 'href' => array(), 225 'class' => array(), 226 ), 227 ) 228 ); 229 ?> 230 </td> 203 231 </tr> 204 232 <?php -
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/templates/translation-row-editor-meta-feedback.php
r12205 r12405 9 9 <ul class="feedback-reason-list"> 10 10 <?php 11 $comment_reasons = Helper_Translation_Discussion::get_comment_reasons( );11 $comment_reasons = Helper_Translation_Discussion::get_comment_reasons( $locale_slug ); 12 12 foreach ( $comment_reasons as $key => $reason ) : 13 13 ?> … … 18 18 </ul> 19 19 <div class="feedback-comment"> 20 <label><?php esc_html_e( 'Comment (Optional)', 'glotpress' ); ?> 21 <textarea name="feedback_comment"></textarea> 20 <label for="feedback_comment"><?php esc_html_e( 'Comment (Optional)', 'glotpress' ); ?> 22 21 </label> 22 <textarea name="feedback_comment"></textarea> 23 23 24 <label class="note">Please note that all feedback is visible to the public.</label> 24 25 </div>
Note: See TracChangeset
for help on using the changeset viewer.