Changeset 13535 for trunk/wp-admin/includes/post.php
- Timestamp:
- 03/01/2010 03:48:01 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r13489 r13535 255 255 $post_IDs = array_map( 'intval', (array) $post_data['post'] ); 256 256 257 $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'ta gs_input', 'post_category', 'sticky' );257 $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tax_input', 'post_category', 'sticky' ); 258 258 foreach ( $reset as $field ) { 259 259 if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) … … 267 267 unset($post_data['post_category']); 268 268 } 269 270 if ( isset($post_data['tags_input']) ) { 271 $new_tags = preg_replace( '/\s*,\s*/', ',', rtrim( trim($post_data['tags_input']), ' ,' ) ); 272 $new_tags = explode(',', $new_tags); 269 270 $tax_input = array(); 271 if ( isset($post_data['tax_input'])) { 272 foreach ( $post_data['tax_input'] as $tax_name => $terms ) { 273 if ( empty($terms) ) 274 continue; 275 $taxonomy = get_taxonomy( $tax_name ); 276 if ( $taxonomy->hierarchical ) 277 $tax_input[$tax_name] = array_map( 'absint', $terms ); 278 else { 279 $tax_input[$tax_name] = preg_replace( '/\s*,\s*/', ',', rtrim( trim($terms), ' ,' ) ); 280 $tax_input[$tax_name] = explode(',', $tax_input[$tax_name]); 281 } 282 } 273 283 } 274 284 … … 301 311 continue; 302 312 } 303 304 if ( isset($new_cats) ) { 313 314 $tax_names = get_object_taxonomies( get_post($post_ID) ); 315 316 if ( isset($new_cats) && in_array( 'category', $tax_names ) ) { 305 317 $cats = (array) wp_get_post_categories($post_ID); 306 318 $post_data['post_category'] = array_unique( array_merge($cats, $new_cats) ); 307 319 } 308 309 if ( isset($new_tags) ) { 310 $tags = wp_get_post_tags($post_ID, array('fields' => 'names')); 311 $post_data['tags_input'] = array_unique( array_merge($tags, $new_tags) ); 320 321 foreach ( $tax_names as $tax_name ) { 322 if( isset( $tax_input[$tax_name]) ) { 323 $taxonomy = get_taxonomy( $tax_name ); 324 if( $taxonomy->hierarchical ) 325 $terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); 326 else 327 $terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); 328 $post_data['tax_input'][$tax_name] = array_merge( $terms, $tax_input[$tax_name] ); 329 } 312 330 } 313 331
Note: See TracChangeset
for help on using the changeset viewer.