Ticket #33902: 33902.3.patch
File 33902.3.patch, 15.4 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/class-wp-posts-list-table.php
1550 1550 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?> 1551 1551 1552 1552 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> 1553 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> 1553 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : 1554 $taxonomy_name = esc_attr( $taxonomy->name ); 1555 1556 ?> 1554 1557 <label class="inline-edit-tags"> 1555 1558 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span> 1556 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>1559 <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea> 1557 1560 </label> 1558 1561 <?php endif; ?> 1559 1562 -
src/wp-admin/includes/meta-boxes.php
431 431 <?php if ( $user_can_assign_terms ) : ?> 432 432 <div class="ajaxtag hide-if-no-js"> 433 433 <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> 434 <p><input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-<?php echo $tax_name; ?>-desc" value="" />434 <p><input data-wp-taxonomy="<?php echo $tax_name; ?>" type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-<?php echo $tax_name; ?>-desc" value="" /> 435 435 <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" /></p> 436 436 </div> 437 437 <p class="howto" id="new-tag-<?php echo $tax_name; ?>-desc"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p> -
src/wp-admin/js/inline-edit-post.js
114 114 115 115 // enable autocomplete for tags 116 116 if ( 'post' === type ) { 117 // support multi taxonomies?118 tax = 'post_tag';119 $('tr.inline-editor textarea[name="tax_input['+tax+']"]').suggest( ajaxurl + '?action=ajax-tag-search&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: inlineEditL10n.comma} );117 $( 'tr.inline-editor textarea[data-wp-taxonomy]' ).each( function ( i, element ) { 118 $( element ).wpTagsSuggest(); 119 } ); 120 120 } 121 121 $('html, body').animate( { scrollTop: 0 }, 'fast' ); 122 122 }, … … 196 196 textarea.val(terms); 197 197 } 198 198 199 textarea. suggest( ajaxurl + '?action=ajax-tag-search&tax=' + taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: inlineEditL10n.comma });199 textarea.wpTagsSuggest(); 200 200 }); 201 201 202 202 // handle the post status -
src/wp-admin/js/tags-box.js
4 4 var tagBox, array_unique_noempty; 5 5 6 6 ( function( $ ) { 7 var tagDelimiter = ( window.tagsSuggestL10n && window.tagsSuggestL10n.tagDelimiter ) || ','; 8 7 9 // Return an array with any duplicate, whitespace or empty values removed 8 10 array_unique_noempty = function( array ) { 9 11 var out = []; … … 20 22 }; 21 23 22 24 tagBox = { 23 clean : function(tags) { 24 var comma = window.tagsBoxL10n.tagDelimiter; 25 if ( ',' !== comma ) 26 tags = tags.replace(new RegExp(comma, 'g'), ','); 25 clean : function( tags ) { 26 if ( ',' !== tagDelimiter ) { 27 tags = tags.replace( new RegExp( tagDelimiter, 'g' ), ',' ); 28 } 29 27 30 tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, ''); 28 if ( ',' !== comma ) 29 tags = tags.replace(/,/g, comma); 31 32 if ( ',' !== tagDelimiter ) { 33 tags = tags.replace( /,/g, tagDelimiter ); 34 } 35 30 36 return tags; 31 37 }, 32 38 … … 35 41 num = id.split('-check-num-')[1], 36 42 taxbox = $(el).closest('.tagsdiv'), 37 43 thetags = taxbox.find('.the-tags'), 38 comma = window.tagsBoxL10n.tagDelimiter, 39 current_tags = thetags.val().split( comma ), 44 current_tags = thetags.val().split( tagDelimiter ), 40 45 new_tags = []; 41 46 42 47 delete current_tags[num]; … … 48 53 } 49 54 }); 50 55 51 thetags.val( this.clean( new_tags.join( comma) ) );56 thetags.val( this.clean( new_tags.join( tagDelimiter ) ) ); 52 57 53 58 this.quickClicks( taxbox ); 54 59 return false; … … 65 70 66 71 disabled = thetags.prop('disabled'); 67 72 68 current_tags = thetags.val().split( window.tagsBoxL10n.tagDelimiter );73 current_tags = thetags.val().split( tagDelimiter ); 69 74 tagchecklist.empty(); 70 75 71 76 $.each( current_tags, function( key, val ) { … … 106 111 flushTags : function( el, a, f ) { 107 112 var tagsval, newtags, text, 108 113 tags = $( '.the-tags', el ), 109 newtag = $( 'input.newtag', el ), 110 comma = window.tagsBoxL10n.tagDelimiter; 114 newtag = $( 'input.newtag', el ); 111 115 112 116 a = a || false; 113 117 … … 118 122 } 119 123 120 124 tagsval = tags.val(); 121 newtags = tagsval ? tagsval + comma+ text : text;125 newtags = tagsval ? tagsval + tagDelimiter + text : text; 122 126 123 127 newtags = this.clean( newtags ); 124 newtags = array_unique_noempty( newtags.split( comma ) ).join( comma);128 newtags = array_unique_noempty( newtags.split( tagDelimiter ) ).join( tagDelimiter ); 125 129 tags.val( newtags ); 126 130 this.quickClicks( el ); 127 131 … … 153 157 }, 154 158 155 159 init : function() { 156 var t = this, ajaxtag = $('div.ajaxtag'); 160 var t = this; 161 var ajaxtag = $('div.ajaxtag'); 157 162 158 163 $('.tagsdiv').each( function() { 159 tagBox.quickClicks( this);164 tagBox.quickClicks( this ); 160 165 }); 161 166 162 $( '.tagadd', ajaxtag).click(function(){163 t .flushTags( $(this).closest('.tagsdiv') );167 $( '.tagadd', ajaxtag ).click( function() { 168 tagBox.flushTags( $( this ).closest( '.tagsdiv' ) ); 164 169 }); 165 170 166 $('input.newtag', ajaxtag).keyup(function(e){ 167 if ( 13 == e.which ) { 168 tagBox.flushTags( $(this).closest('.tagsdiv') ); 169 return false; 171 $( 'input.newtag', ajaxtag ).keyup( function( event ) { 172 if ( 13 == event.which ) { 173 tagBox.flushTags( $( this ).closest( '.tagsdiv' ) ); 174 event.preventDefault(); 175 event.stopPropagation(); 170 176 } 171 }).keypress( function(e){172 if ( 13 == e .which ) {173 e .preventDefault();174 return false;177 }).keypress( function( event ) { 178 if ( 13 == event.which ) { 179 event.preventDefault(); 180 event.stopPropagation(); 175 181 } 176 }).each( function() { 177 var tax = $(this).closest('div.tagsdiv').attr('id'); 178 $(this).suggest( 179 ajaxurl + '?action=ajax-tag-search&tax=' + tax, 180 { delay: 500, minchars: 2, multiple: true, multipleSep: window.tagsBoxL10n.tagDelimiter } 181 ); 182 }).each( function( i, element ) { 183 $( element ).wpTagsSuggest(); 182 184 }); 183 185 184 186 // save tags on post save/publish -
src/wp-admin/js/tags-suggest.js
1 ( function( $ ) { 2 var tempID = 0; 3 var separator = ( window.tagsSuggestL10n && window.tagsSuggestL10n.tagDelimiter ) || ','; 4 5 function split( val ) { 6 return val.split( new RegExp( separator + '\\s*' ) ); 7 } 8 9 function getLast( term ) { 10 return split( term ).pop(); 11 } 12 13 $.fn.wpTagsSuggest = function( options ) { 14 var cache; 15 var last; 16 var $element = $( this ); 17 18 options = options || {}; 19 20 var taxonomy = options.taxonomy || $element.attr( 'data-wp-taxonomy' ) || 'post_tag'; 21 22 delete( options.taxonomy ); 23 24 options = $.extend( { 25 source: function( request, response ) { 26 var term; 27 28 if ( last === request.term ) { 29 response( cache ); 30 return; 31 } 32 33 term = getLast( request.term ); 34 35 $.get( window.ajaxurl, { 36 action: 'ajax-tag-search', 37 tax: taxonomy, 38 q: term 39 } ).always( function() { 40 $element.removeClass( 'ui-autocomplete-loading' ); // UI fails to remove this sometimes? 41 } ).done( function( data ) { 42 var value; 43 var terms = []; 44 45 if ( data ) { 46 data = data.split( '\n' ); 47 48 for ( value in data ) { 49 var id = ++tempID; 50 51 terms.push({ 52 id: id, 53 name: data[value] 54 }); 55 } 56 57 cache = terms; 58 response( terms ); 59 } else { 60 response( terms ); 61 } 62 } ); 63 64 last = request.term; 65 }, 66 focus: function( event, ui ) { 67 $element.attr( 'aria-activedescendant', 'wp-tags-autocomplete-' + ui.item.id ); 68 69 // Don't empty the input field when using the arrow keys to 70 // highlight items. See api.jqueryui.com/autocomplete/#event-focus 71 event.preventDefault(); 72 }, 73 select: function( event, ui ) { 74 var tags = split( $element.val() ); 75 // Remove the last user input. 76 tags.pop(); 77 // Append the new tag and an empty element to get one more separator at the end. 78 tags.push( ui.item.name, '' ); 79 80 $element.val( tags.join( separator + ' ' ) ); 81 82 if ( 9 === event.keyCode && typeof window.uiAutocompleteL10n !== 'undefined' ) { 83 // Audible confirmation message when a tag has been selected. 84 speak( window.uiAutocompleteL10n.itemSelected ); 85 } 86 87 return false; 88 }, 89 open: function() { 90 $element.attr( 'aria-expanded', 'true' ); 91 }, 92 close: function() { 93 $element.attr( 'aria-expanded', 'false' ); 94 }, 95 minLength: 2, 96 position: { 97 my: 'left top+2' 98 }, 99 messages: { 100 noResults: ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.noResults : '', 101 results: function( number ) { 102 if ( typeof window.uiAutocompleteL10n !== 'undefined' ) { 103 if ( number > 1 ) { 104 return window.uiAutocompleteL10n.manyResults.replace( '%d', number ); 105 } 106 107 return window.uiAutocompleteL10n.oneResult; 108 } 109 } 110 } 111 }, options ); 112 113 $element.on( 'keydown', function() { 114 $element.removeAttr( 'aria-activedescendant' ); 115 } ) 116 .autocomplete( options ) 117 .autocomplete( 'instance' )._renderItem = function( ul, item ) { 118 return $( '<li role="option" id="wp-tags-autocomplete-' + item.id + '">' ) 119 .text( item.name ) 120 .appendTo( ul ); 121 }; 122 123 $element.attr( { 124 'role': 'combobox', 125 'aria-autocomplete': 'list', 126 'aria-expanded': 'false', 127 'aria-owns': $element.autocomplete( 'widget' ).attr( 'id' ) 128 } ) 129 .on( 'focus', function() { 130 var inputValue = split( $element.val() ).pop(); 131 132 // Don't trigger a search if the field is empty. 133 // Also, avoids screen readers announce `No search results`. 134 if ( inputValue ) { 135 $element.autocomplete( 'search' ); 136 } 137 } ) 138 // Returns a jQuery object containing the menu element. 139 .autocomplete( 'widget' ) 140 .addClass( 'wplink-autocomplete' ) 141 .attr( 'role', 'listbox' ) 142 .removeAttr( 'tabindex' ) // Remove the `tabindex=0` attribute added by jQuery UI. 143 144 // Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301. 145 // The `menufocus` and `menublur` events are the same events used to add and remove 146 // the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget. 147 .on( 'menufocus', function( event, ui ) { 148 ui.item.attr( 'aria-selected', 'true' ); 149 }) 150 .on( 'menublur', function() { 151 // The `menublur` event returns an object where the item is `null` 152 // so we need to find the active item with other means. 153 $( this ).find( '[aria-selected="true"]' ).removeAttr( 'aria-selected' ); 154 }); 155 156 return this; 157 } 158 159 }( jQuery ) ); -
src/wp-includes/script-loader.php
Property changes on: src/wp-admin/js/tags-suggest.js ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
234 234 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ), 235 235 /* translators: %d: Number of results found when using jQuery UI Autocomplete */ 236 236 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ), 237 'itemSelected' => __( 'Item selected.' ), 237 238 ) ); 238 239 239 240 // deprecated, not used in core, most functionality is included in jQuery 1.3 … … 241 242 242 243 // jQuery plugins 243 244 $scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color.min.js", array('jquery'), '2.1.1', 1 ); 244 $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1 );245 245 $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m', 1 ); 246 246 $scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7', 1 ); 247 247 $scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2', 1 ); … … 249 249 $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1 ); 250 250 $scripts->add( 'jquery-touch-punch', "/wp-includes/js/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1 ); 251 251 252 // Not used any more, registered for backwards compatibility. 253 $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113', 1 ); 254 252 255 // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv. 253 256 // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way. 254 257 $scripts->add( 'imagesloaded', "/wp-includes/js/imagesloaded.min.js", array(), '3.2.0', 1 ); … … 523 526 'postBoxEmptyString' => __( 'Drag boxes here' ), 524 527 ) ); 525 528 526 $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'suggest' ), false, 1 ); 527 did_action( 'init' ) && $scripts->localize( 'tags-box', 'tagsBoxL10n', array( 529 $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 ); 530 531 $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 ); 532 did_action( 'init' ) && $scripts->localize( 'tags-suggest', 'tagsSuggestL10n', array( 528 533 'tagDelimiter' => _x( ',', 'tag delimiter' ), 529 534 ) ); 530 535 … … 584 589 585 590 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 ); 586 591 587 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', ' suggest', 'wp-a11y' ), false, 1 );592 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 ); 588 593 did_action( 'init' ) && $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( 589 594 'error' => __( 'Error while saving the changes.' ), 590 595 'ntdeltitle' => __( 'Remove From Bulk Edit' ),