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

git-svn-id: http://svn.automattic.com/wordpress/trunk@14426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32
2010-05-03 23:35:22 +00:00
parent 2c727e9442
commit 2bbdd19973
2 changed files with 16 additions and 5 deletions

View File

@@ -307,6 +307,10 @@ function post_categories_meta_box( $post, $box ) {
</div>
<div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
<?php
$name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy . ']';
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.
?>
<ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy?> categorychecklist form-no-clear">
<?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
</ul>