Fix removing attributes

This commit is contained in:
Mike Jolley 2012-05-07 14:09:09 +01:00
parent 6a40ee9ef4
commit 95e041214b
3 changed files with 26 additions and 21 deletions

View File

@ -595,8 +595,9 @@ function woocommerce_process_product_meta( $post_id, $post ) {
$is_taxonomy = ($attribute_is_taxonomy[$i]) ? 1 : 0;
if ( $is_taxonomy ) {
if ( isset( $attribute_values[$i] ) ) {
// Format values
if ( is_array( $attribute_values[$i] ) ) {
$values = array_map('htmlspecialchars', array_map('stripslashes', $attribute_values[$i]));
@ -606,28 +607,32 @@ function woocommerce_process_product_meta( $post_id, $post ) {
$values = explode('|', $values);
$values = array_map('trim', $values);
}
// Remove empty items in the array
$values = array_filter( $values );
// Update post terms
if ( taxonomy_exists( $attribute_names[$i] ) )
wp_set_object_terms( $post_id, $values, $attribute_names[$i] );
if ( $values ) {
// Add attribute to array, but don't set values
$attributes[ sanitize_title( $attribute_names[$i] ) ] = array(
'name' => htmlspecialchars(stripslashes($attribute_names[$i])),
'value' => '',
'position' => $attribute_position[$i],
'is_visible' => $is_visible,
'is_variation' => $is_variation,
'is_taxonomy' => $is_taxonomy
);
}
} else {
$values = array();
}
// Update post terms
if ( taxonomy_exists( $attribute_names[$i] ) )
wp_set_object_terms( $post_id, $values, $attribute_names[$i] );
if ( $values ) {
// Add attribute to array, but don't set values
$attributes[ sanitize_title( $attribute_names[$i] ) ] = array(
'name' => htmlspecialchars(stripslashes($attribute_names[$i])),
'value' => '',
'position' => $attribute_position[$i],
'is_visible' => $is_visible,
'is_variation' => $is_variation,
'is_taxonomy' => $is_taxonomy
);
}
} else {
if (!$attribute_values[$i]) continue;
if ( ! $attribute_values[$i] ) continue;
// Format values
$values = esc_html(stripslashes($attribute_values[$i]));
// Text based, separate by pipe

File diff suppressed because one or more lines are too long

View File

@ -1558,11 +1558,11 @@ img.help_tip {
}
.expand_all {
padding-left: 14px;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAARklEQVQYGWP8//8/AzGACV3Rnj17/oMwujiGQnQFMD7RChlBbsRmFcwkEO3i4sJImonIumGmg0xBFifaRKIVgj2DbAUuNgCfThpracSKqwAAAABJRU5ErkJggg==) no-repeat left;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAI0lEQVQYV2PcvXv3fwY8gJEoBa6urozYDAFpBpswGBTg8yYA3kYtiYVhDhIAAAAASUVORK5CYII=) no-repeat left;
}
.close_all {
padding-left: 14px;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAKUlEQVQYlWP8//8/Az7AhFeWGAUsDAwMDHv27MFqj4uLCyNBExhp70gAohwKC5KJ+HQAAAAASUVORK5CYII=) no-repeat left;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAHUlEQVQYV2NkIAAYd+/e/R+fGsIKCFpBUAHt3QAASf0MyQbFJwoAAAAASUVORK5CYII=) no-repeat left;
}
.toolbar {
margin: 0 !important;