Making WordPress.org

Changeset 11539


Ignore:
Timestamp:
02/10/2022 02:36:15 AM (4 years ago)
Author:
dd32
Message:

Trac: Don't alter the reporters ticket description/summary when a Gardener comments/edits a field.

Fixes #5866.

Location:
sites/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/trac.wordpress.org/templates/site.html

    r11538 r11539  
    55
    66<?python
    7     scripts_version = '159'
     7    scripts_version = '160'
    88    project_slug = req.environ['HTTP_HOST'].split(':')[0].split('.')[0]
    99    wporg_endpoint = 'https://make.wordpress.org/' + project_slug + '/'
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r11538 r11539  
    551551                var $summary     = $( '#field-summary' ),
    552552                    $description = $( '#field-description' ),
    553                     $comment     = $( '#comment' );
     553                    $comment     = $( '#comment' ),
     554                    isNewTicket  = wpTrac.isNewTicket();
    554555
    555556                // Simple replacement for ticket summary.
    556                 $summary.val( $summary.val().replace( 'Wordpress', 'WordPress' ) );
     557                if ( isNewTicket ) {
     558                    $summary.val( $summary.val().replaceAll( 'Wordpress', 'WordPress' ) );
     559                }
    557560
    558561                // Use the more judicious replacement for ticket description and comments.
    559562                $.each( [ ' Wordpress', '&#8216;Wordpress', '&#8220;Wordpress', '>Wordpress', '(Wordpress' ], function( index, value ) {
    560                     var replacement = value.replace( 'Wordpress', 'WordPress' );
    561 
    562                     if ( $description.length ) {
    563                         $description.val( $description.val().replace( value, replacement ) );
     563                    var replacement = value.replaceAll( 'Wordpress', 'WordPress' );
     564
     565                    if ( $description.length && isNewTicket ) {
     566                        $description.val( $description.val().replaceAll( value, replacement ) );
    564567                    }
    565568                    if ( $comment.length ) {
    566                         $comment.val( $comment.val().replace( value, replacement ) );
     569                        $comment.val( $comment.val().replaceAll( value, replacement ) );
    567570                    }
    568571                } );
     
    20592062
    20602063})(jQuery);
     2064
     2065/**
     2066 * String.prototype.replaceAll() polyfill. For Internet Explorer.
     2067 *
     2068 * https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/
     2069 * https://vanillajstoolkit.com/polyfills/stringreplaceall/
     2070 *
     2071 * @author Chris Ferdinandi
     2072 * @license MIT
     2073 */
     2074if ( ! String.prototype.replaceAll ) {
     2075    String.prototype.replaceAll = function(str, newStr) {
     2076
     2077        // If a regex pattern
     2078        if ( Object.prototype.toString.call(str).toLowerCase() === '[object regexp]' ) {
     2079            return this.replace(str, newStr);
     2080        }
     2081
     2082        // If a string
     2083        return this.replace(new RegExp(str, 'g'), newStr);
     2084
     2085    };
     2086}
Note: See TracChangeset for help on using the changeset viewer.