Changeset 53801
- Timestamp:
- 07/30/2022 03:14:34 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r53781 r53801 109 109 } 110 110 111 $taxonomy = sanitize_key( $_GET['tax'] );112 $tax 113 114 if ( ! $tax ) {111 $taxonomy = sanitize_key( $_GET['tax'] ); 112 $taxonomy_object = get_taxonomy( $taxonomy ); 113 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);127 } 128 129 if ( false !== strpos( $s , ',' ) ) {130 $s = explode( ',', $s);131 $s = $s[ count( $s) - 1 ];132 } 133 134 $s = trim( $s);126 $search = str_replace( $comma, ',', $search ); 127 } 128 129 if ( false !== strpos( $search, ',' ) ) { 130 $search = explode( ',', $search ); 131 $search = $search[ count( $search ) - 1 ]; 132 } 133 134 $search = trim( $search ); 135 135 136 136 /** … … 139 139 * @since 4.0.0 140 140 * 141 * @param int $characters The minimum number of characters required. Default 2.142 * @param WP_Taxonomy $tax 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. 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 /* … … 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 } … … 156 156 array( 157 157 'taxonomy' => $taxonomy, 158 'name__like' => $s ,158 'name__like' => $search, 159 159 'fields' => 'names', 160 160 'hide_empty' => false, … … 168 168 * @since 6.1.0 169 169 * 170 * @param string[] $results Array of term names.171 * @param WP_Taxonomy $tax 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. 173 173 */ 174 $results = apply_filters( 'ajax_term_search_results', $results, $tax , $s);174 $results = apply_filters( 'ajax_term_search_results', $results, $taxonomy_object, $search ); 175 175 176 176 echo implode( "\n", $results ); … … 1022 1022 1023 1023 check_ajax_referer( $action ); 1024 $tax = get_taxonomy( 'link_category' ); 1025 1026 if ( ! current_user_can( $tax->cap->manage_terms ) ) { 1024 1025 $taxonomy_object = get_taxonomy( 'link_category' ); 1026 1027 if ( ! current_user_can( $taxonomy_object->cap->manage_terms ) ) { 1027 1028 wp_die( -1 ); 1028 1029 } … … 1068 1069 function wp_ajax_add_tag() { 1069 1070 check_ajax_referer( 'add-tag', '_wpnonce_add-tag' ); 1070 $taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag'; 1071 $tax = get_taxonomy( $taxonomy ); 1072 1073 if ( ! current_user_can( $tax->cap->edit_terms ) ) { 1071 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 ) ) { 1074 1076 wp_die( -1 ); 1075 1077 } … … 1123 1125 1124 1126 $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]; 1127 1129 } elseif ( isset( $messages['_item'][1] ) ) { 1128 1130 $message = $messages['_item'][1]; … … 1162 1164 } 1163 1165 1164 $taxonomy = sanitize_key( $_POST['tax'] );1165 $tax 1166 1167 if ( ! $tax ) {1166 $taxonomy = sanitize_key( $_POST['tax'] ); 1167 $taxonomy_object = get_taxonomy( $taxonomy ); 1168 1169 if ( ! $taxonomy_object ) { 1168 1170 wp_die( 0 ); 1169 1171 } 1170 1172 1171 if ( ! current_user_can( $tax ->cap->assign_terms ) ) {1173 if ( ! current_user_can( $taxonomy_object->cap->assign_terms ) ) { 1172 1174 wp_die( -1 ); 1173 1175 } … … 1183 1185 1184 1186 if ( empty( $tags ) ) { 1185 wp_die( $tax ->labels->not_found );1187 wp_die( $taxonomy_object->labels->not_found ); 1186 1188 } 1187 1189 … … 2144 2146 check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); 2145 2147 2146 $taxonomy = sanitize_key( $_POST['taxonomy'] );2147 $tax 2148 2149 if ( ! $tax ) {2148 $taxonomy = sanitize_key( $_POST['taxonomy'] ); 2149 $taxonomy_object = get_taxonomy( $taxonomy ); 2150 2151 if ( ! $taxonomy_object ) { 2150 2152 wp_die( 0 ); 2151 2153 } … … 2209 2211 unset( $post_types['attachment'] ); 2210 2212 2211 $s = wp_unslash( $_POST['ps'] );2212 2213 $args = array( 2213 2214 'post_type' => array_keys( $post_types ), … … 2216 2217 ); 2217 2218 2218 if ( '' !== $s ) { 2219 $args['s'] = $s; 2219 $search = wp_unslash( $_POST['ps'] ); 2220 2221 if ( '' !== $search ) { 2222 $args['s'] = $search; 2220 2223 } 2221 2224
Note: See TracChangeset
for help on using the changeset viewer.