$data['post_name'
] =
wp_unique_post_slug( sanitize_title( $data['post_title'
],
$post_id ),
$post_id,
$data['post_status'
],
$post_type,
$post_parent );
$wpdb->
update( $wpdb->posts, array
( 'post_name' =>
$data['post_name'
] ),
$where );
clean_post_cache( $post_id );
} if ( is_object_in_taxonomy( $post_type, 'category'
) ) { wp_set_post_categories( $post_id,
$post_category );
} if ( isset( $postarr['tags_input'
] ) &&
is_object_in_taxonomy( $post_type, 'post_tag'
) ) { wp_set_post_tags( $post_id,
$postarr['tags_input'
] );
} // Add default term for all associated custom taxonomies.
if ( 'auto-draft' !==
$post_status ) { foreach ( get_object_taxonomies( $post_type, 'object'
) as $taxonomy =>
$tax_object ) { if ( !
empty( $tax_object->default_term
) ) { // Filter out empty terms.
if ( isset( $postarr['tax_input'
][ $taxonomy ] ) &&
is_array( $postarr['tax_input'
][ $taxonomy ] ) ) { $postarr['tax_input'
][ $taxonomy ] =
array_filter( $postarr['tax_input'
][ $taxonomy ] );
}