Make WordPress Core

Ticket #31328: 31328.5.diff

File 31328.5.diff, 11.9 KB (added by pento, 9 years ago)
  • src/wp-admin/js/inline-edit-post.js

     
    117117        },
    118118
    119119        edit : function(id) {
    120                 var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, cur_format, f;
     120                var t = this, fields, editRow, rowData, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, cur_format, f, val;
    121121                t.revert();
    122122
    123123                if ( typeof(id) === 'object' ) {
     
    155155                });
    156156
    157157                for ( f = 0; f < fields.length; f++ ) {
    158                         $(':input[name="' + fields[f] + '"]', editRow).val( $('.'+fields[f], rowData).text() );
     158                        val = $('.'+fields[f], rowData);
     159                        // Deal with Twemoji
     160                        val.find( 'img' ).replaceWith( function() { return this.alt; } );
     161                        val = val.text();
     162                        $(':input[name="' + fields[f] + '"]', editRow).val( val );
    159163                }
    160164
    161165                if ( $( '.comment_status', rowData ).text() === 'open' ) {
     
    181185
    182186                //flat taxonomies
    183187                $('.tags_input', rowData).each(function(){
    184                         var terms = $(this).text(),
     188                        var terms = $(this),
    185189                                taxname = $(this).attr('id').replace('_' + id, ''),
    186190                                textarea = $('textarea.tax_input_' + taxname, editRow),
    187191                                comma = inlineEditL10n.comma;
    188192
     193                        terms.find( 'img' ).replaceWith( function() { return this.alt; } );
     194                        terms = terms.text();
     195
    189196                        if ( terms ) {
    190197                                if ( ',' !== comma ) {
    191198                                        terms = terms.replace(/,/g, comma);
     
    265272                                        if ( -1 !== r.indexOf( '<tr' ) ) {
    266273                                                $(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove();
    267274                                                $('#edit-'+id).before(r).remove();
     275                                                if ( WPEmoji ) {
     276                                                        WPEmoji.parse( $( inlineEditPost.what + id ).get( 0 ) );
     277                                                }
    268278                                                $(inlineEditPost.what+id).hide().fadeIn();
    269279                                        } else {
    270280                                                r = r.replace( /<.[^<>]*?>/g, '' );
  • src/wp-admin/js/inline-edit-tax.js

     
    4545        },
    4646
    4747        edit : function(id) {
    48                 var editRow, rowData,
     48                var editRow, rowData, val,
    4949                        t = this;
    5050                t.revert();
    5151
     
    5858
    5959                $(t.what+id).hide().before(editRow).before('<tr class="hidden"></tr>');
    6060
    61                 $(':input[name="name"]', editRow).val( $('.name', rowData).text() );
    62                 $(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
     61                val = $('.name', rowData);
     62                val.find( 'img' ).replaceWith( function() { return this.alt; } );
     63                val = val.text();
     64                $(':input[name="name"]', editRow).val( val );
    6365
     66                val = $('.slug', rowData);
     67                val.find( 'img' ).replaceWith( function() { return this.alt; } );
     68                val = val.text();
     69                $(':input[name="slug"]', editRow).val( val );
     70
    6471                $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
    6572                $('.ptitle', editRow).eq(0).focus();
    6673
     
    110117                                                // Update the value in the Parent dropdown.
    111118                                                $( '#parent' ).find( 'option[value=' + option_value + ']' ).text( row.find( '.row-title' ).text() );
    112119
     120                                                if ( WPEmoji ) {
     121                                                        WPEmoji.parse( row.get( 0 ) );
     122                                                }
     123
    113124                                                row.hide().fadeIn();
    114125                                        } else {
    115126                                                $('#edit-'+id+' .inline-edit-save .error').html(r).show();
  • src/wp-admin/js/post.js

     
    712712                        revert_slug = real_slug.val(),
    713713                        b = $('#edit-slug-buttons'),
    714714                        revert_b = b.html(),
    715                         full = $('#editable-post-name-full').html();
     715                        full = $('#editable-post-name-full');
    716716
     717                // Deal with Twemoji in the post-name
     718                full.find( 'img' ).replaceWith( function() { return this.alt; } );
     719                full = full.html();
     720
    717721                $('#view-post-btn').hide();
    718722                b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
    719723                b.children('.save').click(function() {
     
    736740                                                box.removeClass('hidden');
    737741                                        });
    738742                                }
     743
     744                                if ( WPEmoji ) {
     745                                        WPEmoji.parse( box.get( 0 ) );
     746                                }
     747
    739748                                b.html(revert_b);
    740749                                real_slug.val(new_slug);
    741750                                $('#view-post-btn').show();
  • src/wp-admin/js/tags.js

     
    4949                        else
    5050                                $( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
    5151
     52                        if ( WPEmoji ) {
     53                                WPEmoji.parse( $( '.tags' ).get( 0 ) );
     54                        }
     55
    5256                        $('.tags .no-items').remove();
    5357
    5458                        if ( form.find('select#parent') ) {
  • src/wp-includes/formatting.php

     
    785785                        $unicode .= chr($value);
    786786                        $unicode_length++;
    787787                } else {
    788                         if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
     788                        if ( count( $values ) == 0 ) {
     789                                if ( $value < 224 ) {
     790                                        $num_octets = 2;
     791                                } elseif ( $value < 240 ) {
     792                                        $num_octets = 3;
     793                                } else {
     794                                        $num_octets = 4;
     795                                }
     796                        }
    789797
    790798                        $values[] = $value;
    791799
     
    792800                        if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )
    793801                                break;
    794802                        if ( count( $values ) == $num_octets ) {
    795                                 if ($num_octets == 3) {
    796                                         $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
    797                                         $unicode_length += 9;
    798                                 } else {
    799                                         $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
    800                                         $unicode_length += 6;
     803                                for ( $j = 0; $j < $num_octets; $j++ ) {
     804                                        $unicode .= '%' . dechex( $values[ $j ] );
    801805                                }
    802806
     807                                $unicode_length += $num_octets * 3;
     808
    803809                                $values = array();
    804810                                $num_octets = 1;
    805811                        }
  • src/wp-includes/taxonomy.php

     
    28792879
    28802880        $slug_provided = ! empty( $args['slug'] );
    28812881        if ( ! $slug_provided ) {
    2882                 $_name = trim( $name );
    2883                 $existing_term = get_term_by( 'name', $_name, $taxonomy );
    2884                 if ( $existing_term ) {
    2885                         $slug = $existing_term->slug;
    2886                 } else {
    2887                         $slug = sanitize_title( $name );
    2888                 }
     2882                $slug = sanitize_title( $name );
    28892883        } else {
    28902884                $slug = $args['slug'];
    28912885        }
     
    29102904        }
    29112905
    29122906        // Terms with duplicate names are not allowed at the same level of a taxonomy hierarchy.
    2913         if ( $exists = term_exists( $slug, $taxonomy ) ) {
    2914                 $existing_term = get_term( $exists['term_id'], $taxonomy );
    2915 
    2916                 if ( $name === $existing_term->name ) {
    2917 
    2918                         if ( is_taxonomy_hierarchical( $taxonomy ) ) {
    2919                                 $siblings = get_terms( $taxonomy, array( 'fields' => 'names', 'get' => 'all', 'parent' => $parent ) );
    2920                                 if ( in_array( $name, $siblings ) ) {
    2921                                         return new WP_Error( 'term_exists', __( 'A term with the name and slug already exists with this parent.' ), $exists['term_id'] );
    2922                                 }
    2923 
    2924                         } else {
    2925                                 return new WP_Error( 'term_exists', __( 'A term with the name and slug already exists in this taxonomy.' ), $exists['term_id'] );
     2907        if ( $existing_term = get_term_by( 'name', $name, $taxonomy ) ) {
     2908                if ( is_taxonomy_hierarchical( $taxonomy ) ) {
     2909                        $siblings = get_terms( $taxonomy, array( 'fields' => 'names', 'get' => 'all', 'parent' => $parent ) );
     2910                        if ( in_array( $name, $siblings ) ) {
     2911                                return new WP_Error( 'term_exists', __( 'A term with the name already exists with this parent.' ), $existing_term->term_id );
    29262912                        }
     2913                } else {
     2914                        return new WP_Error( 'term_exists', __( 'A term with the name already exists in this taxonomy.' ), $existing_term->term_id );
    29272915                }
    29282916        }
    29292917
  • tests/phpunit/data/formatting/utf-8/entitized.txt

     
    22&#70;&#114;&#97;&#110;&#231;&#111;&#105;&#115;&#32;&#84;&#114;&#117;&#102;&#102;&#97;&#117;&#116;
    33&#4321;&#4304;&#4325;&#4304;&#4320;&#4311;&#4309;&#4308;&#4314;&#4317;
    44&#66;&#106;&#246;&#114;&#107;&#32;&#71;&#117;&#240;&#109;&#117;&#110;&#100;&#115;&#100;&#243;&#116;&#116;&#105;&#114;
    5 &#23470;&#23822;&#12288;&#39423;
    6  No newline at end of file
     5&#23470;&#23822;&#12288;&#39423;
     6&#128077;
     7 No newline at end of file
  • tests/phpunit/data/formatting/utf-8/u-urlencoded.txt

     
    1 %u7AE0%u5B50%u6021
    2 %u0046%u0072%u0061%u006E%u00E7%u006F%u0069%u0073%u0020%u0054%u0072%u0075%u0066%u0066%u0061%u0075%u0074
    3 %u10E1%u10D0%u10E5%u10D0%u10E0%u10D7%u10D5%u10D4%u10DA%u10DD
    4 %u0042%u006A%u00F6%u0072%u006B%u0020%u0047%u0075%u00F0%u006D%u0075%u006E%u0064%u0073%u0064%u00F3%u0074%u0074%u0069%u0072
    5 %u5BAE%u5D0E%u3000%u99FF
     1%u7AE0%u5B50%u6021
     2%u0046%u0072%u0061%u006E%u00E7%u006F%u0069%u0073%u0020%u0054%u0072%u0075%u0066%u0066%u0061%u0075%u0074
     3%u10E1%u10D0%u10E5%u10D0%u10E0%u10D7%u10D5%u10D4%u10DA%u10DD
     4%u0042%u006A%u00F6%u0072%u006B%u0020%u0047%u0075%u00F0%u006D%u0075%u006E%u0064%u0073%u0064%u00F3%u0074%u0074%u0069%u0072
     5%u5BAE%u5D0E%u3000%u99FF
     6%u1F44D
     7 No newline at end of file
  • tests/phpunit/data/formatting/utf-8/urlencoded.txt

     
    1 %e7%ab%a0%e5%ad%90%e6%80%a1
    2 Fran%c3%a7ois Truffaut
    3 %e1%83%a1%e1%83%90%e1%83%a5%e1%83%90%e1%83%a0%e1%83%97%e1%83%95%e1%83%94%e1%83%9a%e1%83%9d
    4 Bj%c3%b6rk Gu%c3%b0mundsd%c3%b3ttir
    5 %e5%ae%ae%e5%b4%8e%e3%80%80%e9%a7%bf
     1%e7%ab%a0%e5%ad%90%e6%80%a1
     2Fran%c3%a7ois Truffaut
     3%e1%83%a1%e1%83%90%e1%83%a5%e1%83%90%e1%83%a0%e1%83%97%e1%83%95%e1%83%94%e1%83%9a%e1%83%9d
     4Bj%c3%b6rk Gu%c3%b0mundsd%c3%b3ttir
     5%e5%ae%ae%e5%b4%8e%e3%80%80%e9%a7%bf
     6%f0%9f%91%8d
     7 No newline at end of file
  • tests/phpunit/data/formatting/utf-8/utf-8.txt

     
    33საქართველო
    44Björk Guðmundsdóttir
    55宮崎 駿
     6👍
  • tests/phpunit/tests/formatting/UrlEncodedToEntities.php

     
    88         * @dataProvider data
    99         */
    1010        function test_convert_urlencoded_to_entities( $u_urlencoded, $entity ) {
    11                 $this->assertEquals( $entity, preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $u_urlencoded ), $entity );
     11                $this->assertEquals( $entity, preg_replace_callback('/\%u([0-9A-F]{4,5})/', '_convert_urlencoded_to_entities', $u_urlencoded ), $entity );
    1212        }
    1313
    1414        function data() {
  • tests/phpunit/tests/term.php

     
    174174
    175175                // Test existing term name with unique slug
    176176                $term1 = $this->factory->tag->create( array( 'name' => 'Bozo', 'slug' => 'bozo1' ) );
    177                 $this->assertFalse( is_wp_error( $term1 ) );
    178                 $this->assertTrue( empty($term1->errors ) );
     177                $this->assertTrue( is_wp_error( $term1 ) );
     178                $this->assertSame( 'term_exists', $term1->get_error_code() );
     179                $this->assertEquals( $term->term_id, $term1->get_error_data() );
    179180
    180181                // Test an existing term name
    181182                $term2 = $this->factory->tag->create( array( 'name' => 'Bozo' ) );