Make WordPress Core

Changeset 14426


Ignore:
Timestamp:
05/03/2010 11:35:22 PM (15 years ago)
Author:
dd32
Message:

Handle $_POST containing an empty term array, Fixes saving of deselecting all hierarchical terms. Fixes #10122

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/meta-boxes.php

    r14404 r14426  
    308308
    309309        <div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
     310            <?php
     311            $name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy . ']';
     312            echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
     313            ?>
    310314            <ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy?> categorychecklist form-no-clear">
    311315                <?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
  • trunk/wp-includes/post.php

    r14404 r14426  
    20712071    if ( empty($post_type) )
    20722072        $post_type = 'post';
     2073
     2074    if ( !empty($post_category) )
     2075        $post_category = array_filter($post_category); // Filter out empty terms
    20732076
    20742077    // Make sure we set a valid category.
     
    22262229    wp_set_post_categories( $post_ID, $post_category );
    22272230    // old-style tags_input
    2228     if ( isset( $tags_input ) )
     2231    if ( isset( $tags_input ) ) {
     2232        $tags_input = array_filter($tags_input);
    22292233        wp_set_post_tags( $post_ID, $tags_input );
    2230     // new-style support for all tag-like taxonomies
     2234    }
     2235    // new-style support for all custom taxonomies
    22312236    if ( !empty($tax_input) ) {
    22322237        foreach ( $tax_input as $taxonomy => $tags ) {
    22332238            $taxonomy_obj = get_taxonomy($taxonomy);
     2239            if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical.
     2240                $tags = array_filter($tags);
    22342241            if ( current_user_can($taxonomy_obj->assign_cap) )
    22352242                wp_set_post_terms( $post_ID, $tags, $taxonomy );
     
    27852792    $page_paths = explode('/', $page_paths);
    27862793    $full_path = '';
    2787     foreach( (array) $page_paths as $pathdir)
    2788         $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
     2794    foreach ( (array) $page_paths as $pathdir )
     2795        $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);
    27892796
    27902797    $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = %s OR post_type = 'attachment')", $leaf_path, $post_type ));
     
    36693676 */
    36703677function wp_check_for_changed_slugs($post_id) {
    3671     if ( !isset($_POST['wp-old-slug']) || !strlen($_POST['wp-old-slug']) )
     3678    if ( empty($_POST['wp-old-slug']) )
    36723679        return $post_id;
    36733680
Note: See TracChangeset for help on using the changeset viewer.