Changeset 31359 for trunk/src/wp-admin/includes/post.php
- Timestamp:
- 02/06/2015 08:31:37 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r31323 r31359 313 313 /** This filter is documented in wp-admin/includes/media.php */ 314 314 $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data ); 315 } 316 317 // Convert taxonomy input to term IDs, to avoid ambiguity. 318 if ( isset( $post_data['tax_input'] ) ) { 319 foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) { 320 // Hierarchical taxonomy data is already sent as term IDs, so no conversion is necessary. 321 if ( is_taxonomy_hierarchical( $taxonomy ) ) { 322 continue; 323 } 324 325 /* 326 * Assume that a 'tax_input' string is a comma-separated list of term names. 327 * Some languages may use a character other than a comma as a delimiter, so we standardize on 328 * commas before parsing the list. 329 */ 330 if ( ! is_array( $terms ) ) { 331 $comma = _x( ',', 'tag delimiter' ); 332 if ( ',' !== $comma ) { 333 $terms = str_replace( $comma, ',', $terms ); 334 } 335 $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); 336 } 337 338 $clean_terms = array(); 339 foreach ( $terms as $term ) { 340 $_term = get_terms( $taxonomy, array( 341 'name' => $term, 342 'fields' => 'ids', 343 'hide_empty' => false, 344 ) ); 345 346 if ( ! empty( $_term ) ) { 347 $clean_terms[] = intval( $_term[0] ); 348 } else { 349 // No existing term was found, so pass the string. A new term will be created. 350 $clean_terms[] = $term; 351 } 352 } 353 354 $post_data['tax_input'][ $taxonomy ] = $clean_terms; 355 } 315 356 } 316 357
Note: See TracChangeset
for help on using the changeset viewer.