0 or set to '' if ( ! empty( $_POST[ $value['id'] ] ) ) { $option_value = absint( $_POST[ $value['id'] ] ); } else { $option_value = ''; } wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' ); if ( $option_value != '' ) wp_schedule_single_event( time() + ( absint( $option_value ) * 60 ), 'woocommerce_cancel_unpaid_orders' ); } else { if ( isset( $_POST[$value['id']] ) ) { $option_value = woocommerce_clean( stripslashes( $_POST[ $value['id'] ] ) ); } else { $option_value = ''; } } break; // Special types case "multiselect" : case "multi_select_countries" : // Get countries array if ( isset( $_POST[ $value['id'] ] ) ) $selected_countries = array_map( 'woocommerce_clean', array_map( 'stripslashes', (array) $_POST[ $value['id'] ] ) ); else $selected_countries = array(); $option_value = $selected_countries; break; case "image_width" : if ( isset( $_POST[$value['id'] ]['width'] ) ) { $update_options[ $value['id'] ]['width'] = woocommerce_clean( stripslashes( $_POST[ $value['id'] ]['width'] ) ); $update_options[ $value['id'] ]['height'] = woocommerce_clean( stripslashes( $_POST[ $value['id'] ]['height'] ) ); if ( isset( $_POST[ $value['id'] ]['crop'] ) ) $update_options[ $value['id'] ]['crop'] = 1; else $update_options[ $value['id'] ]['crop'] = 0; } else { $update_options[ $value['id'] ]['width'] = $value['default']['width']; $update_options[ $value['id'] ]['height'] = $value['default']['height']; $update_options[ $value['id'] ]['crop'] = $value['default']['crop']; } break; // Custom handling default : do_action( 'woocommerce_update_option_' . $type, $value ); break; } if ( ! is_null( $option_value ) ) { // Check if option is an array if ( strstr( $value['id'], '[' ) ) { parse_str( $value['id'], $option_array ); // Option name is first key $option_name = current( array_keys( $option_array ) ); // Get old option value if ( ! isset( $update_options[ $option_name ] ) ) $update_options[ $option_name ] = get_option( $option_name, array() ); if ( ! is_array( $update_options[ $option_name ] ) ) $update_options[ $option_name ] = array(); // Set keys and value $key = key( $option_array[ $option_name ] ); $update_options[ $option_name ][ $key ] = $option_value; // Single value } else { $update_options[ $value['id'] ] = $option_value; } } // Custom handling do_action( 'woocommerce_update_option', $value ); } // Now save the options foreach( $update_options as $name => $value ) update_option( $name, $value ); return true; }