@@ -108,54 +108,54 @@ function wp_ajax_ajax_tag_search() {
108108 wp_die ( 0 );
109109 }
110110
111- $ taxonomy = sanitize_key ( $ _GET ['tax ' ] );
112- $ tax = get_taxonomy ( $ taxonomy );
111+ $ taxonomy = sanitize_key ( $ _GET ['tax ' ] );
112+ $ taxonomy_object = get_taxonomy ( $ taxonomy );
113113
114- if ( ! $ tax ) {
114+ if ( ! $ taxonomy_object ) {
115115 wp_die ( 0 );
116116 }
117117
118- if ( ! current_user_can ( $ tax ->cap ->assign_terms ) ) {
118+ if ( ! current_user_can ( $ taxonomy_object ->cap ->assign_terms ) ) {
119119 wp_die ( -1 );
120120 }
121121
122- $ s = wp_unslash ( $ _GET ['q ' ] );
122+ $ search = wp_unslash ( $ _GET ['q ' ] );
123123
124124 $ comma = _x ( ', ' , 'tag delimiter ' );
125125 if ( ', ' !== $ comma ) {
126- $ s = str_replace ( $ comma , ', ' , $ s );
126+ $ search = str_replace ( $ comma , ', ' , $ search );
127127 }
128128
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 ];
132132 }
133133
134- $ s = trim ( $ s );
134+ $ search = trim ( $ search );
135135
136136 /**
137137 * Filters the minimum number of characters required to fire a tag search via Ajax.
138138 *
139139 * @since 4.0.0
140140 *
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.
141+ * @param int $characters The minimum number of characters required. Default 2.
142+ * @param WP_Taxonomy $taxonomy_object The taxonomy object.
143+ * @param string $search The search term.
144144 */
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 );
146146
147147 /*
148148 * Require $term_search_min_chars chars for matching (default: 2)
149149 * ensure it's a non-negative, non-zero integer.
150150 */
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 ) ) {
152152 wp_die ();
153153 }
154154
155155 $ results = get_terms (
156156 array (
157157 'taxonomy ' => $ taxonomy ,
158- 'name__like ' => $ s ,
158+ 'name__like ' => $ search ,
159159 'fields ' => 'names ' ,
160160 'hide_empty ' => false ,
161161 'number ' => isset ( $ _GET ['number ' ] ) ? (int ) $ _GET ['number ' ] : 0 ,
@@ -167,11 +167,11 @@ function wp_ajax_ajax_tag_search() {
167167 *
168168 * @since 6.1.0
169169 *
170- * @param string[] $results Array of term names.
171- * @param WP_Taxonomy $tax The taxonomy object.
172- * @param string $s The search term.
170+ * @param string[] $results Array of term names.
171+ * @param WP_Taxonomy $taxonomy_object The taxonomy object.
172+ * @param string $search The search term.
173173 */
174- $ results = apply_filters ( 'ajax_term_search_results ' , $ results , $ tax , $ s );
174+ $ results = apply_filters ( 'ajax_term_search_results ' , $ results , $ taxonomy_object , $ search );
175175
176176 echo implode ( "\n" , $ results );
177177 wp_die ();
@@ -1021,9 +1021,10 @@ function wp_ajax_add_link_category( $action ) {
10211021 }
10221022
10231023 check_ajax_referer ( $ action );
1024- $ tax = get_taxonomy ( 'link_category ' );
10251024
1026- if ( ! current_user_can ( $ tax ->cap ->manage_terms ) ) {
1025+ $ taxonomy_object = get_taxonomy ( 'link_category ' );
1026+
1027+ if ( ! current_user_can ( $ taxonomy_object ->cap ->manage_terms ) ) {
10271028 wp_die ( -1 );
10281029 }
10291030
@@ -1067,10 +1068,11 @@ function wp_ajax_add_link_category( $action ) {
10671068 */
10681069function wp_ajax_add_tag () {
10691070 check_ajax_referer ( 'add-tag ' , '_wpnonce_add-tag ' );
1070- $ taxonomy = ! empty ( $ _POST ['taxonomy ' ] ) ? $ _POST ['taxonomy ' ] : 'post_tag ' ;
1071- $ tax = get_taxonomy ( $ taxonomy );
10721071
1073- if ( ! current_user_can ( $ tax ->cap ->edit_terms ) ) {
1072+ $ taxonomy = ! empty ( $ _POST ['taxonomy ' ] ) ? $ _POST ['taxonomy ' ] : 'post_tag ' ;
1073+ $ taxonomy_object = get_taxonomy ( $ taxonomy );
1074+
1075+ if ( ! current_user_can ( $ taxonomy_object ->cap ->edit_terms ) ) {
10741076 wp_die ( -1 );
10751077 }
10761078
@@ -1122,8 +1124,8 @@ function wp_ajax_add_tag() {
11221124 require ABSPATH . 'wp-admin/includes/edit-tag-messages.php ' ;
11231125
11241126 $ message = '' ;
1125- if ( isset ( $ messages [ $ tax ->name ][1 ] ) ) {
1126- $ message = $ messages [ $ tax ->name ][1 ];
1127+ if ( isset ( $ messages [ $ taxonomy_object ->name ][1 ] ) ) {
1128+ $ message = $ messages [ $ taxonomy_object ->name ][1 ];
11271129 } elseif ( isset ( $ messages ['_item ' ][1 ] ) ) {
11281130 $ message = $ messages ['_item ' ][1 ];
11291131 }
@@ -1161,14 +1163,14 @@ function wp_ajax_get_tagcloud() {
11611163 wp_die ( 0 );
11621164 }
11631165
1164- $ taxonomy = sanitize_key ( $ _POST ['tax ' ] );
1165- $ tax = get_taxonomy ( $ taxonomy );
1166+ $ taxonomy = sanitize_key ( $ _POST ['tax ' ] );
1167+ $ taxonomy_object = get_taxonomy ( $ taxonomy );
11661168
1167- if ( ! $ tax ) {
1169+ if ( ! $ taxonomy_object ) {
11681170 wp_die ( 0 );
11691171 }
11701172
1171- if ( ! current_user_can ( $ tax ->cap ->assign_terms ) ) {
1173+ if ( ! current_user_can ( $ taxonomy_object ->cap ->assign_terms ) ) {
11721174 wp_die ( -1 );
11731175 }
11741176
@@ -1182,7 +1184,7 @@ function wp_ajax_get_tagcloud() {
11821184 );
11831185
11841186 if ( empty ( $ tags ) ) {
1185- wp_die ( $ tax ->labels ->not_found );
1187+ wp_die ( $ taxonomy_object ->labels ->not_found );
11861188 }
11871189
11881190 if ( is_wp_error ( $ tags ) ) {
@@ -2143,10 +2145,10 @@ function wp_ajax_inline_save() {
21432145function wp_ajax_inline_save_tax () {
21442146 check_ajax_referer ( 'taxinlineeditnonce ' , '_inline_edit ' );
21452147
2146- $ taxonomy = sanitize_key ( $ _POST ['taxonomy ' ] );
2147- $ tax = get_taxonomy ( $ taxonomy );
2148+ $ taxonomy = sanitize_key ( $ _POST ['taxonomy ' ] );
2149+ $ taxonomy_object = get_taxonomy ( $ taxonomy );
21482150
2149- if ( ! $ tax ) {
2151+ if ( ! $ taxonomy_object ) {
21502152 wp_die ( 0 );
21512153 }
21522154
@@ -2208,15 +2210,16 @@ function wp_ajax_find_posts() {
22082210 $ post_types = get_post_types ( array ( 'public ' => true ), 'objects ' );
22092211 unset( $ post_types ['attachment ' ] );
22102212
2211- $ s = wp_unslash ( $ _POST ['ps ' ] );
22122213 $ args = array (
22132214 'post_type ' => array_keys ( $ post_types ),
22142215 'post_status ' => 'any ' ,
22152216 'posts_per_page ' => 50 ,
22162217 );
22172218
2218- if ( '' !== $ s ) {
2219- $ args ['s ' ] = $ s ;
2219+ $ search = wp_unslash ( $ _POST ['ps ' ] );
2220+
2221+ if ( '' !== $ search ) {
2222+ $ args ['s ' ] = $ search ;
22202223 }
22212224
22222225 $ posts = get_posts ( $ args );
0 commit comments