WordPress.org

Make WordPress Core

Changeset 14230


Ignore:
Timestamp:
04/25/2010 07:42:51 AM (10 years ago)
Author:
dd32
Message:

Allow edit posts page to save a empty set of terms for a custom hierarchical taxonomy. Props scribu for initial patch. See #10122

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r14219 r14230  
    21912191    $where = array( 'ID' => $post_ID );
    21922192
    2193     if ($update) {
     2193    if ( $update ) {
    21942194        do_action( 'pre_post_update', $post_ID );
    21952195        if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
     
    22302230    if ( isset( $tags_input ) )
    22312231        wp_set_post_tags( $post_ID, $tags_input );
    2232     // new-style support for all tag-like taxonomies
    2233     if ( !empty($tax_input) ) {
    2234         foreach ( $tax_input as $taxonomy => $tags ) {
    2235             $taxonomy_obj = get_taxonomy($taxonomy);
    2236             if ( current_user_can($taxonomy_obj->assign_cap) )
    2237                 wp_set_post_terms( $post_ID, $tags, $taxonomy );
    2238         }
     2232    // new-style support for all taxonomies
     2233    $tax_names = get_object_taxonomies( get_post($post_ID) );
     2234    foreach ( (array)$tax_names as $taxonomy ) {
     2235        if ( 'category' == $taxonomy ) // Handled seperately.
     2236            continue;
     2237        $taxonomy_obj = get_taxonomy($taxonomy);
     2238        if ( !current_user_can($taxonomy_obj->assign_cap) )
     2239            continue;
     2240        if ( !$taxonomy_obj->show_ui )
     2241            continue;
     2242
     2243        $tags = isset($tax_input[$taxonomy]) ? $tax_input[$taxonomy] : array();
     2244        wp_set_post_terms( $post_ID, $tags, $taxonomy );
    22392245    }
    22402246
     
    22662272    wp_transition_post_status($data['post_status'], $previous_status, $post);
    22672273
    2268     if ( $update)
     2274    if ( $update )
    22692275        do_action('edit_post', $post_ID, $post);
    22702276
     
    23212327    }
    23222328
    2323     if ($postarr['post_type'] == 'attachment')
     2329    if ( $postarr['post_type'] == 'attachment' )
    23242330        return wp_insert_attachment($postarr);
    23252331
Note: See TracChangeset for help on using the changeset viewer.