mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
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:
parent
2c727e9442
commit
2bbdd19973
@ -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>
|
||||
|
@ -2071,6 +2071,9 @@ function wp_insert_post($postarr = array(), $wp_error = false) {
|
||||
if ( empty($post_type) )
|
||||
$post_type = 'post';
|
||||
|
||||
if ( !empty($post_category) )
|
||||
$post_category = array_filter($post_category); // Filter out empty terms
|
||||
|
||||
// Make sure we set a valid category.
|
||||
if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
|
||||
// 'post' requires at least one category.
|
||||
@ -2225,12 +2228,16 @@ function wp_insert_post($postarr = array(), $wp_error = false) {
|
||||
|
||||
wp_set_post_categories( $post_ID, $post_category );
|
||||
// old-style tags_input
|
||||
if ( isset( $tags_input ) )
|
||||
if ( isset( $tags_input ) ) {
|
||||
$tags_input = array_filter($tags_input);
|
||||
wp_set_post_tags( $post_ID, $tags_input );
|
||||
// new-style support for all tag-like taxonomies
|
||||
}
|
||||
// new-style support for all custom taxonomies
|
||||
if ( !empty($tax_input) ) {
|
||||
foreach ( $tax_input as $taxonomy => $tags ) {
|
||||
$taxonomy_obj = get_taxonomy($taxonomy);
|
||||
if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical.
|
||||
$tags = array_filter($tags);
|
||||
if ( current_user_can($taxonomy_obj->assign_cap) )
|
||||
wp_set_post_terms( $post_ID, $tags, $taxonomy );
|
||||
}
|
||||
@ -2784,8 +2791,8 @@ function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
||||
$leaf_path = sanitize_title(basename($page_paths));
|
||||
$page_paths = explode('/', $page_paths);
|
||||
$full_path = '';
|
||||
foreach( (array) $page_paths as $pathdir)
|
||||
$full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
|
||||
foreach ( (array) $page_paths as $pathdir )
|
||||
$full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);
|
||||
|
||||
$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 ));
|
||||
|
||||
@ -3668,7 +3675,7 @@ function wp_mime_type_icon( $mime = 0 ) {
|
||||
* @return int Same as $post_id
|
||||
*/
|
||||
function wp_check_for_changed_slugs($post_id) {
|
||||
if ( !isset($_POST['wp-old-slug']) || !strlen($_POST['wp-old-slug']) )
|
||||
if ( empty($_POST['wp-old-slug']) )
|
||||
return $post_id;
|
||||
|
||||
$post = &get_post($post_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user