Ticket #55098: 55098.diff
File 55098.diff, 2.3 KB (added by , 3 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
108 108 wp_die( 0 ); 109 109 } 110 110 111 $taxonomy = sanitize_key( $_GET['tax'] );112 $tax 111 $taxonomy = sanitize_key( $_GET['tax'] ); 112 $taxonomy_object = get_taxonomy( $taxonomy ); 113 113 114 if ( ! $tax ) {114 if ( ! $taxonomy_object ) { 115 115 wp_die( 0 ); 116 116 } 117 117 118 if ( ! current_user_can( $tax ->cap->assign_terms ) ) {118 if ( ! current_user_can( $taxonomy_object->cap->assign_terms ) ) { 119 119 wp_die( -1 ); 120 120 } 121 121 122 $s = wp_unslash( $_GET['q'] );122 $search = wp_unslash( $_GET['q'] ); 123 123 124 124 $comma = _x( ',', 'tag delimiter' ); 125 125 if ( ',' !== $comma ) { 126 $s = str_replace( $comma, ',', $s);126 $search = str_replace( $comma, ',', $search ); 127 127 } 128 128 129 if ( false !== strpos( $s , ',' ) ) {130 $s = explode( ',', $s);131 $s = $s[ count( $s) - 1 ];129 if ( false !== strpos( $search, ',' ) ) { 130 $search = explode( ',', $search ); 131 $search = $search[ count( $search ) - 1 ]; 132 132 } 133 133 134 $s = trim( $s);134 $search = trim( $search ); 135 135 136 136 /** 137 137 * Filters the minimum number of characters required to fire a tag search via Ajax. … … 139 139 * @since 4.0.0 140 140 * 141 141 * @param int $characters The minimum number of characters required. Default 2. 142 * @param WP_Taxonomy $tax The taxonomy object.143 * @param string $s The search term.142 * @param WP_Taxonomy $taxonomy_object The taxonomy object. 143 * @param string $search The search term. 144 144 */ 145 $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax , $s);145 $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $taxonomy_object, $search ); 146 146 147 147 /* 148 148 * Require $term_search_min_chars chars for matching (default: 2) 149 149 * ensure it's a non-negative, non-zero integer. 150 150 */ 151 if ( ( 0 == $term_search_min_chars ) || ( strlen( $s ) < $term_search_min_chars ) ) {151 if ( ( 0 == $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) { 152 152 wp_die(); 153 153 } 154 154 … … 155 155 $results = get_terms( 156 156 array( 157 157 'taxonomy' => $taxonomy, 158 'name__like' => $s ,158 'name__like' => $search, 159 159 'fields' => 'names', 160 160 'hide_empty' => false, 161 161 )