Make WordPress Core

Ticket #31328: 31328.4.diff

File 31328.4.diff, 8.7 KB (added by boonebgorges, 9 years ago)
  • src/wp-admin/js/inline-edit-post.js

    diff --git a/src/wp-admin/js/inline-edit-post.js b/src/wp-admin/js/inline-edit-post.js
    index 9f1b13b..8683505 100644
    a b inlineEditPost = { 
    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' ) {
    inlineEditPost = { 
    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' ) {
    inlineEditPost = { 
    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);
    inlineEditPost = { 
    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

    diff --git a/src/wp-admin/js/inline-edit-tax.js b/src/wp-admin/js/inline-edit-tax.js
    index 7f3a5b3..dde6082 100644
    a b inlineEditTax = { 
    4545        },
    4646
    4747        edit : function(id) {
    48                 var editRow, rowData,
     48                var editRow, rowData, val,
    4949                        t = this;
    5050                t.revert();
    5151
    inlineEditTax = { 
    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 );
     65
     66                val = $('.slug', rowData);
     67                val.find( 'img' ).replaceWith( function() { return this.alt; } );
     68                val = val.text();
     69                $(':input[name="slug"]', editRow).val( val );
    6370
    6471                $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
    6572                $('.ptitle', editRow).eq(0).focus();
    inlineEditTax = { 
    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

    diff --git a/src/wp-admin/js/post.js b/src/wp-admin/js/post.js
    index 178deb3..7ab9e08 100644
    a b jQuery(document).ready( function($) { 
    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');
     716
     717                // Deal with Twemoji in the post-name
     718                full.find( 'img' ).replaceWith( function() { return this.alt; } );
     719                full = full.html();
    716720
    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>');
    jQuery(document).ready( 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

    diff --git a/src/wp-admin/js/tags.js b/src/wp-admin/js/tags.js
    index 333a2eb..4ac6f2e 100644
    a b jQuery(document).ready(function($) { 
    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

    diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
    index a18f796..ab13e7d 100644
    a b function utf8_uri_encode( $utf8_string, $length = 0 ) { 
    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

    diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php
    index f27b7b6..c7a923e 100644
    a b function wp_insert_term( $term, $taxonomy, $args = array() ) { 
    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        }
    function wp_insert_term( $term, $taxonomy, $args = array() ) { 
    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/tests/term.php

    diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php
    index 445713b..712663e 100644
    a b class Tests_Term extends WP_UnitTestCase { 
    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' ) );