Ticket #31328: 31328.4.diff
File 31328.4.diff, 8.7 KB (added by , 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 = { 117 117 }, 118 118 119 119 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; 121 121 t.revert(); 122 122 123 123 if ( typeof(id) === 'object' ) { … … inlineEditPost = { 155 155 }); 156 156 157 157 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 ); 159 163 } 160 164 161 165 if ( $( '.comment_status', rowData ).text() === 'open' ) { … … inlineEditPost = { 181 185 182 186 //flat taxonomies 183 187 $('.tags_input', rowData).each(function(){ 184 var terms = $(this) .text(),188 var terms = $(this), 185 189 taxname = $(this).attr('id').replace('_' + id, ''), 186 190 textarea = $('textarea.tax_input_' + taxname, editRow), 187 191 comma = inlineEditL10n.comma; 188 192 193 terms.find( 'img' ).replaceWith( function() { return this.alt; } ); 194 terms = terms.text(); 195 189 196 if ( terms ) { 190 197 if ( ',' !== comma ) { 191 198 terms = terms.replace(/,/g, comma); … … inlineEditPost = { 265 272 if ( -1 !== r.indexOf( '<tr' ) ) { 266 273 $(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove(); 267 274 $('#edit-'+id).before(r).remove(); 275 if ( WPEmoji ) { 276 WPEmoji.parse( $( inlineEditPost.what + id ).get( 0 ) ); 277 } 268 278 $(inlineEditPost.what+id).hide().fadeIn(); 269 279 } else { 270 280 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 = { 45 45 }, 46 46 47 47 edit : function(id) { 48 var editRow, rowData, 48 var editRow, rowData, val, 49 49 t = this; 50 50 t.revert(); 51 51 … … inlineEditTax = { 58 58 59 59 $(t.what+id).hide().before(editRow).before('<tr class="hidden"></tr>'); 60 60 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 ); 63 70 64 71 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); 65 72 $('.ptitle', editRow).eq(0).focus(); … … inlineEditTax = { 110 117 // Update the value in the Parent dropdown. 111 118 $( '#parent' ).find( 'option[value=' + option_value + ']' ).text( row.find( '.row-title' ).text() ); 112 119 120 if ( WPEmoji ) { 121 WPEmoji.parse( row.get( 0 ) ); 122 } 123 113 124 row.hide().fadeIn(); 114 125 } else { 115 126 $('#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($) { 712 712 revert_slug = real_slug.val(), 713 713 b = $('#edit-slug-buttons'), 714 714 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(); 716 720 717 721 $('#view-post-btn').hide(); 718 722 b.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>'); … … jQuery(document).ready( function($) { 736 740 box.removeClass('hidden'); 737 741 }); 738 742 } 743 744 if ( WPEmoji ) { 745 WPEmoji.parse( box.get( 0 ) ); 746 } 747 739 748 b.html(revert_b); 740 749 real_slug.val(new_slug); 741 750 $('#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($) { 49 49 else 50 50 $( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm 51 51 52 if ( WPEmoji ) { 53 WPEmoji.parse( $( '.tags' ).get( 0 ) ); 54 } 55 52 56 $('.tags .no-items').remove(); 53 57 54 58 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 ) { 785 785 $unicode .= chr($value); 786 786 $unicode_length++; 787 787 } 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 } 789 797 790 798 $values[] = $value; 791 799 792 800 if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length ) 793 801 break; 794 802 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 ] ); 801 805 } 802 806 807 $unicode_length += $num_octets * 3; 808 803 809 $values = array(); 804 810 $num_octets = 1; 805 811 } -
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() ) { 2879 2879 2880 2880 $slug_provided = ! empty( $args['slug'] ); 2881 2881 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 ); 2889 2883 } else { 2890 2884 $slug = $args['slug']; 2891 2885 } … … function wp_insert_term( $term, $taxonomy, $args = array() ) { 2910 2904 } 2911 2905 2912 2906 // 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 ); 2926 2912 } 2913 } else { 2914 return new WP_Error( 'term_exists', __( 'A term with the name already exists in this taxonomy.' ), $existing_term->term_id ); 2927 2915 } 2928 2916 } 2929 2917 -
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 { 174 174 175 175 // Test existing term name with unique slug 176 176 $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() ); 179 180 180 181 // Test an existing term name 181 182 $term2 = $this->factory->tag->create( array( 'name' => 'Bozo' ) );