Making WordPress.org

Changeset 11992


Ignore:
Timestamp:
07/22/2022 02:09:19 PM (4 years ago)
Author:
amieiro
Message:

Sync the gp-translation-helpers with GitHub, main branch

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/css/discussion.css

    r11909 r11992  
    55#original h1 {
    66        margin: .5em 14px;
    7         line-height: 34px;
     7        line-height: 45px;
    88}
    99
     
    6767.comment-content {
    6868        text-align: start;
     69}
     70.comment-content span.dashicons.dashicons-info,
     71.feedback-reason-list span.dashicons.dashicons-info,
     72#TB_window span.dashicons.dashicons-info {
     73        color: #D3D3D3;
     74        font-size:16px;
     75}
     76.feedback-reason-list li {
     77        white-space:nowrap;
     78        padding-right: 2px;
     79}
     80.ui-tooltip {
     81        z-index: 100051 !important;
    6982}
    7083.comment-form-comment label{
     
    210223        box-shadow: none;
    211224}
     225.hoverTooltip {
     226        position: fixed !important;
     227}
     228
     229a.comment-reply-link {
     230        margin: 2px !important;
     231}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers-assets/templates/translation-discussion-comments.php

    r11921 r11992  
    7373
    7474                        echo '<p class="comment-form-topic">
    75                                         <label for="comment_topic">Topic <span class="required" aria-hidden="true">*</span></label>
     75                                        <label for="comment_topic">Topic <span class="required" aria-hidden="true">*</span> (required)</label>
    7676                                        <select required name="comment_topic" id="comment_topic">
    7777                                                <option value="">Select topic</option>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers/helper-translation-discussion.php

    r11948 r11992  
    511511                        'comment_form_fields',
    512512                        function( $comment_fields ) {
    513                                 $comment_fields['comment'] = str_replace( '>Comment<', '>Please leave your comment about this string here:<', $comment_fields['comment'] );
     513                                $comment_fields['comment'] = str_replace( '</label>', ' (required)</label>', $comment_fields['comment'] );
    514514                                return $comment_fields;
    515515                        }
     
    664664
    665665                $link = sprintf(
    666                         "<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>",
     666                        "<a rel='nofollow' class='comment-reply-link button is-primary' href='%s' %s aria-label='%s'>%s</a>",
    667667                        esc_url(
    668668                                add_query_arg(
     
    719719
    720720        /**
    721          * Return an array of allowed rejection reasons
     721         * Return an array of allowed rejection reasons and explanation of each reason.
    722722         *
    723723         * @since 0.0.2
     
    725725         * @return array
    726726         */
    727         public static function get_reject_reasons() {
     727        public static function get_reject_reasons(): array {
    728728                return array(
    729                         'style'       => __( 'Style Guide' ),
    730                         'grammar'     => __( 'Grammar' ),
    731                         'branding'    => __( 'Branding' ),
    732                         'glossary'    => __( 'Glossary' ),
    733                         'punctuation' => __( 'Punctuation' ),
    734                         'typo'        => __( 'Typo' ),
    735                 );
    736         }
    737 
     729                        'style'       => array(
     730                                'name'        => __( 'Style Guide' ),
     731                                'explanation' => __( 'The translation is not following the style guide. It will be interesting to provide a link to the style guide for your locale in the comment.' ),
     732                        ),
     733                        'grammar'     => array(
     734                                'name'        => __( 'Grammar' ),
     735                                'explanation' => __( 'The translation has some grammar problems. It will be interesting to provide a link explaining the grammar issue for your locale in the comment.' ),
     736                        ),
     737                        'branding'    => array(
     738                                'name'        => __( 'Branding' ),
     739                                'explanation' => __( 'The translation is using incorrectly some brand. E.g. WordPress without the capital P.' ),
     740                        ),
     741                        'glossary'    => array(
     742                                'name'        => __( 'Glossary' ),
     743                                'explanation' => __( 'The translation is not using the glossary correctly. It will be interesting to provide some link to the glossary for your locale in the comment.' ),
     744                        ),
     745                        'punctuation' => array(
     746                                'name'        => __( 'Punctuation' ),
     747                                'explanation' =>
     748                                        __( 'The translation is not using the punctuation marks correctly.' ),
     749                        ),
     750                        'typo'        => array(
     751                                'name'        => __( 'Typo' ),
     752                                'explanation' => __( 'The translation has a typo. E.g., it is using the \'apostrope\' word instead of \'apostrophe\'.' ),
     753                        ),
     754                );
     755        }
    738756}
    739757
     
    869887                        <p>
    870888                                <?php echo esc_html( _n( 'Rejection Reason: ', 'Rejection Reasons: ', count( $reject_reason ) ) ); ?>
    871                                 <span><?php echo wp_kses( implode( '</span> | <span>', $reject_reason ), array( 'span' => array() ) ); ?></span>
     889                                <?php
     890                                $number_of_items = count( $reject_reason );
     891                                $counter         = 0;
     892                                $reject_reasons  = Helper_Translation_Discussion::get_reject_reasons();
     893                                foreach ( $reject_reason as $reason ) {
     894                                        echo wp_kses(
     895                                                sprintf(
     896                                                /* translators: 1: Title with the explanation of the reject reason , 2: The reject reason */
     897                                                        __( '<span title="%1$s" class="tooltip">%2$s</span> <span class="tooltip dashicons dashicons-info" title="%1$s"></span>', 'glotpress' ),
     898                                                        $reject_reasons[ $reason ]['explanation'],
     899                                                        $reject_reasons[ $reason ]['name'],
     900                                                ),
     901                                                array(
     902                                                        'span' => array(
     903                                                                'class' => array(),
     904                                                                'title' => array(),
     905                                                        ),
     906                                                )
     907                                        );
     908
     909                                        if ( ++$counter < $number_of_items ) {
     910                                                echo ', ';
     911                                        }
     912                                }
     913                                ?>
    872914                        </p>
    873915                        <?php endif; ?>
     
    929971                                                        'title_reply_before'  => '<h5 id="reply-title" class="discuss-title">',
    930972                                                        'title_reply_after'   => '</h5>',
     973                                                        'comment_field'       => '<p class="">',
    931974                                                        'id_form'             => 'commentform-' . $comment->comment_post_ID,
    932975                                                        'cancel_reply_link'   => '<span></span>',
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/includes/class-gp-notifications.php

    r11921 r11992  
    326326                 */
    327327                $email_addresses = apply_filters( 'gp_notification_before_send_emails', $email_addresses );
    328                 if ( ( null === $comment ) || ( null === $comment_meta ) || ( empty( $email_addresses ) ) ) {
     328                if ( null === $comment || null === $comment_meta || empty( $email_addresses ) ) {
    329329                        return false;
    330330                }
    331                 $original        = self::get_original( $comment );
     331                $original = self::get_original( $comment );
     332                if ( ! $original ) {
     333                        return false;
     334                }
    332335                $email_addresses = self::remove_commenter_email_address( $comment, $email_addresses );
    333336                $email_addresses = self::remove_optout_discussion_email_addresses( $original->id, $email_addresses );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/includes/class-gp-translation-helpers.php

    r11921 r11992  
    7373                add_filter( 'gp_translation_row_template_more_links', array( $this, 'translation_row_template_more_links' ), 10, 5 );
    7474                add_filter( 'preprocess_comment', array( $this, 'preprocess_comment' ) );
     75                add_filter(
     76                        'gp_tmpl_load_locations',
     77                        function( $locations, $template, $args, $template_path ) {
     78                                if ( 'translation-row-editor-meta-status' === $template ) {
     79                                        array_unshift( $locations, dirname( dirname( __FILE__ ) ) . '/templates/gp-templates-overrides/' );
     80                                } else {
     81                                        $locations[] = dirname( dirname( __FILE__ ) ) . '/templates/';
     82                                }
     83
     84                                return $locations;
     85                        },
     86                        60,
     87                        4
     88                );
    7589
    7690                $this->helpers = self::load_helpers();
     
    276290                );
    277291
    278                 gp_tmpl_load( 'translation-helpers', array( 'sections' => $sections ), dirname( __FILE__ ) . '/templates/' );
     292                gp_tmpl_load( 'translation-helpers', array( 'sections' => $sections ) );
    279293        }
    280294
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/js/reject-feedback.js

    r11909 r11992  
    66                        var translationIds = [];
    77                        var originalIds = [];
    8                         var feedbackForm = '<details><summary class="feedback-summary">Give feedback</summary>' +
    9                         '<div id="feedback-form">' +
    10                         '<form>' +
    11                         '<h3 class="feedback-reason-title">Reason</h3>' +
    12                         '<ul class="feedback-reason-list">' +
    13                         getReasonList( 'single' ) +
    14                         '</ul>' +
    15                         '<div class="feedback-comment">' +
    16                                 '<label>Comment </label>' +
    17                                 '<textarea name="feedback_comment"></textarea>' +
    18                         '</div>' +
    19                         '</form>' +
    20                         '</div>' +
    21                         '</details>';
    22 
    238                        var modalFeedbackForm =
    249                        '<div id="reject-feedback-form" style="display:none;">' +
    2510                        '<form>' +
    2611                        '<h3>Reason</h3>' +
    27                         getReasonList( 'bulk' ) +
     12                        getReasonList() +
    2813                        '<div class="modal-comment">' +
    2914                                        '<label>Comment </label>' +
     
    3823                        // Remove click event added to <summary> by wporg-gp-customizations plugin
    3924                        $( $gp.editor.table ).off( 'click', 'summary' );
    40 
    41                         $( 'button.reject' ).closest( 'dl,div.status-actions' ).prepend( feedbackForm );
    4225
    4326                        $( '#bulk-actions-toolbar-top .button, #bulk-actions-toolbar .button' ).click( function( e ) {
     
    10083                                rejectWithFeedback( rejectData );
    10184                                e.preventDefault();
     85                        } );
     86
     87                        $( '.tooltip' ).tooltip( {
     88                                tooltipClass: 'hoverTooltip',
    10289                        } );
    10390                }
     
    167154        }
    168155
    169         function getReasonList( displayType ) {
     156        function getReasonList( ) {
    170157                var rejectReasons = $gp_reject_feedback_settings.reject_reasons;
    171 
    172158                var rejectList = '';
    173159                var prefix = '';
    174160                var suffix = '';
    175161                var inputName = '';
    176                 if ( displayType === 'single' ) {
    177                         prefix = '<li><label>';
    178                         suffix = '</label></li>';
    179                         inputName = 'feedback_reason';
    180                 } else {
    181                         prefix = '<div class="modal-item"><label>';
    182                         suffix = '</div></label>';
    183                         inputName = 'modal_feedback_reason';
    184                 }
    185162
    186163                // eslint-disable-next-line vars-on-top
    187164                for ( var reason in rejectReasons ) {
    188                         rejectList += prefix + '<input type="checkbox" name="' + inputName + '" value="' + reason + '" />' + rejectReasons[ reason ] + suffix;
     165                        prefix = '<div class="modal-item"><label class="tooltip" title="' + rejectReasons[ reason ].explanation + '">';
     166                        suffix = '</label> <span class="tooltip dashicons dashicons-info" title="' + rejectReasons[ reason ].explanation + '"></span></div>';
     167                        inputName = 'modal_feedback_reason';
     168                        rejectList += prefix + '<input type="checkbox" name="' + inputName + '" value="' + reason + '" /> ' + rejectReasons[ reason ].name + suffix;
    189169                }
    190170                return rejectList;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/js/translation-helpers.js

    r11921 r11992  
    146146                };
    147147        }
     148
     149        $( '.tooltip' ).tooltip( {
     150                tooltipClass: 'hoverTooltip',
     151        } );
    148152} );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/templates/discussion.php

    r11837 r11992  
    2929                </h4>
    3030        <?php endif; ?>
    31         <?php gp_tmpl_load( 'comment-section', get_defined_vars(), dirname( __FILE__ ) ); ?>
     31        <?php gp_tmpl_load( 'comment-section', get_defined_vars() ); ?>
    3232</div>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/templates/original-permalink-template.php

    r11837 r11992  
    3030                                                                                </summary>
    3131
    32                                                                                 <?php gp_tmpl_load( 'comment-section', get_defined_vars(), dirname( __FILE__ ) ); ?>
     32                                                                                <?php gp_tmpl_load( 'comment-section', get_defined_vars() ); ?>
    3333
    3434                                                                        </details>
Note: See TracChangeset for help on using the changeset viewer.