API - Default display type is blank string

Fixes #10986 @claudiosmweb
This commit is contained in:
Mike Jolley 2016-05-25 12:19:55 +01:00
parent 62712c1648
commit 7cacd678cf
2 changed files with 3 additions and 3 deletions

View File

@ -105,7 +105,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Terms_Controller {
protected function update_term_meta_fields( $term, $request ) {
$id = (int) $term->term_id;
update_woocommerce_term_meta( $id, 'display_type', $request['display'] );
update_woocommerce_term_meta( $id, 'display_type', 'default' === $request['display'] ? '' : $request['display'] );
update_woocommerce_term_meta( $id, 'order', $request['menu_order'] );
if ( ! empty( $request['image'] ) ) {

View File

@ -701,7 +701,7 @@ class WC_API_Products extends WC_API_Resource {
$id = $insert['term_id'];
update_woocommerce_term_meta( $id, 'display_type', esc_attr( $data['display'] ) );
update_woocommerce_term_meta( $id, 'display_type', 'default' === $data['display'] ? '' : sanitize_text_field( $data['display'] ) );
// Check if image_id is a valid image attachment before updating the term meta.
if ( $image_id && wp_attachment_is_image( $image_id ) ) {
@ -774,7 +774,7 @@ class WC_API_Products extends WC_API_Resource {
}
if ( ! empty( $data['display'] ) ) {
update_woocommerce_term_meta( $id, 'display_type', sanitize_text_field( $data['display'] ) );
update_woocommerce_term_meta( $id, 'display_type', 'default' === $data['display'] ? '' : sanitize_text_field( $data['display'] ) );
}
if ( isset( $image_id ) ) {