Ticket #38922: 38922-2.diff
File 38922-2.diff, 5.1 KB (added by , 8 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
139 139 * @param string $s The search term. 140 140 */ 141 141 $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $s ); 142 143 /*144 * Require $term_search_min_chars chars for matching (default: 2)145 * ensure it's a non-negative, non-zero integer.146 */147 142 if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ){ 148 143 wp_die(); 149 144 } 150 145 151 $results = get_terms( $taxonomy, array( 'name__like' => $s, 'fields' => 'names', 'hide_empty' => false ) ); 152 153 echo join( $results, "\n" ); 146 echo $term_search_min_chars; 154 147 wp_die(); 155 148 } 156 149 … … 177 170 $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."'; 178 171 179 172 if ( 1 == $_GET['test'] ) { 180 181 173 echo $test_str; 174 wp_die(); 182 175 } elseif ( 2 == $_GET['test'] ) { 183 176 if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) 184 177 wp_die( -1 ); -
wp-admin/js/tags-suggest.js
1 1 /** 2 2 * Default settings for jQuery UI Autocomplete for use with non-hierarchical taxonomies. 3 3 */ 4 ( function( $ ) {4 ( function( $, window ) { 5 5 if ( typeof window.tagsSuggestL10n === 'undefined' || typeof window.uiAutocompleteL10n === 'undefined' ) { 6 6 return; 7 7 } … … 45 45 options = $.extend( { 46 46 source: function( request, response ) { 47 47 var term; 48 var minLength; 48 49 49 50 if ( last === request.term ) { 50 51 response( cache ); … … 54 55 term = getLast( request.term ); 55 56 56 57 $.get( window.ajaxurl, { 58 tax: taxonomy, 59 q: term, 57 60 action: 'ajax-tag-search', 58 tax: taxonomy,59 q: term60 } ).always( function(){61 $element.removeClass( 'ui-autocomplete-loading' ); // UI fails to remove this sometimes?62 } ).done( function( data ) {63 var tagName;64 var tags = [];61 } ).done( function( limit ) { 62 minLength = limit; 63 if ( minLength == 0 || term.length < minLength ){ 64 $element.removeClass( 'ui-autocomplete-loading' ); // If under limit hide auto-complete 65 response( cache ); 66 return; 67 } 65 68 66 if ( data ) { 67 data = data.split( '\n' ); 69 $.get( window.tagsSuggestL10n.rest_url, { 70 taxonomy: taxonomy, 71 search: term 72 } ).always( function() { 73 $element.removeClass( 'ui-autocomplete-loading' ); // UI fails to remove this sometimes? 74 } ).done( function( data ) { 75 response( data ); 76 } ); 68 77 69 for ( tagName in data ) { 70 var id = ++tempID; 71 72 tags.push({ 73 id: id, 74 name: data[tagName] 75 }); 76 } 77 78 cache = tags; 79 response( tags ); 80 } else { 81 response( tags ); 82 } 78 last = request.term; 83 79 } ); 84 85 last = request.term;86 80 }, 87 81 focus: function( event, ui ) { 88 82 $element.attr( 'aria-activedescendant', 'wp-tags-autocomplete-' + ui.item.id ); … … 118 112 close: function() { 119 113 $element.attr( 'aria-expanded', 'false' ); 120 114 }, 121 minLength: 2,122 115 position: { 123 116 my: 'left top+2' 124 117 }, 118 minLength: 2, 125 119 messages: { 126 120 noResults: window.uiAutocompleteL10n.noResults, 127 121 results: function( number ) { … … 180 174 return this; 181 175 }; 182 176 183 }( jQuery ) );177 }( jQuery, window ) ); -
wp-includes/script-loader.php
547 547 'termSelected' => __( 'Term selected.' ), 548 548 'termAdded' => __( 'Term added.' ), 549 549 'termRemoved' => __( 'Term removed.' ), 550 'rest_url' => rest_url( '/wp/v2/tags' ) 550 551 ) ); 551 552 552 553 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y' ), false, 1 );