100) $rate = 100; $rate = number_format($rate, 4, '.', ''); $class = woocommerce_clean($tax_classes[$i]); if (isset($tax_shipping[$i]) && $tax_shipping[$i]) $shipping = 'yes'; else $shipping = 'no'; // Handle countries $counties_array = array(); $countries = $tax_countries[$i]; if ($countries) foreach ($countries as $country) : $country = woocommerce_clean($country); $state = '*'; if (strstr($country, ':')) : $cr = explode(':', $country); $country = current($cr); $state = end($cr); endif; $counties_array[trim($country)][] = trim($state); endforeach; $tax_rates[] = array( 'countries' => $counties_array, 'rate' => $rate, 'shipping' => $shipping, 'class' => $class ); endif; endfor; update_option($value['id'], $tax_rates); elseif (isset($value['type']) && $value['type']=='multi_select_countries') : // Get countries array if (isset($_POST[$value['id']])) $selected_countries = $_POST[$value['id']]; else $selected_countries = array(); update_option($value['id'], $selected_countries); elseif ( isset($value['id']) && ( $value['id'] == 'woocommerce_price_thousand_sep' || $value['id'] == 'woocommerce_price_decimal_sep' ) ): // price separators get a special treatment as they should allow a spaces (don't trim) if( isset( $_POST[ $value['id'] ] ) ) { update_option($value['id'], $_POST[$value['id']] ); } else { delete_option($value['id']); } elseif (isset($value['type']) && $value['type']=='checkbox') : if(isset($value['id']) && isset($_POST[$value['id']])) { update_option($value['id'], 'yes'); } else { update_option($value['id'], 'no'); } elseif (isset($value['type']) && $value['type']=='image_width') : if(isset($value['id']) && isset($_POST[$value['id'].'_width'])) { update_option($value['id'].'_width', woocommerce_clean($_POST[$value['id'].'_width'])); update_option($value['id'].'_height', woocommerce_clean($_POST[$value['id'].'_height'])); if (isset($_POST[$value['id'].'_crop'])) : update_option($value['id'].'_crop', 1); else : update_option($value['id'].'_crop', 0); endif; } else { update_option($value['id'].'_width', $value['std']); update_option($value['id'].'_height', $value['std']); update_option($value['id'].'_crop', 1); } else : if(isset($value['id']) && isset($_POST[$value['id']])) { update_option($value['id'], woocommerce_clean($_POST[$value['id']])); } else { delete_option($value['id']); } endif; } return true; } /** * Admin fields * * Loops though the woocommerce options array and outputs each field. */ function woocommerce_admin_fields($options) { global $woocommerce; foreach ($options as $value) : if (!isset( $value['name'] ) ) $value['name'] = ''; if (!isset( $value['class'] )) $value['class'] = ''; if (!isset( $value['css'] )) $value['css'] = ''; if (!isset( $value['std'] )) $value['std'] = ''; switch($value['type']) : case 'title': if (isset($value['name']) && $value['name']) echo '

'.$value['name'].'

'; if (isset($value['desc']) && $value['desc']) echo wpautop(wptexturize($value['desc'])); echo ''. "\n\n"; if (isset($value['id']) && $value['id']) do_action('woocommerce_settings_'.sanitize_title($value['id'])); break; case 'sectionend': if (isset($value['id']) && $value['id']) do_action('woocommerce_settings_'.sanitize_title($value['id']).'_end'); echo '
'; if (isset($value['id']) && $value['id']) do_action('woocommerce_settings_'.sanitize_title($value['id']).'_after'); break; case 'text': ?>

$value['id'], 'id' => $value['id'], 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'show_option_none' => ' ', 'class' => $value['class'], 'echo' => false, 'selected' => $page_setting); if( isset($value['args']) ) $args = wp_parse_args($value['args'], $args); ?> countries->countries; $country_setting = (string) get_option($value['id']); if (strstr($country_setting, ':')) : $country = current(explode(':', $country_setting)); $state = end(explode(':', $country_setting)); else : $country = $country_setting; $state = '*'; endif; ?> countries->countries; asort($countries); $selections = (array) get_option($value['id']); ?> 0) foreach( $tax_rates as $rate ) : $i++; ?>
[?] [?]

% />
$value) : $country = woocommerce_clean($country); if (sizeof($value)>1) : $states_count+=sizeof($value); endif; if (!in_array($country, $counties_array)) $counties_array[] = $woocommerce->countries->countries[$country]; endforeach; $states_text = ''; $countries_text = implode(', ', $counties_array); // Show label if (sizeof($counties_array)==0) : $return .= __('No countries selected', 'woothemes'); elseif ( sizeof($counties_array) < 6 ) : if ($states_count>0) $states_text = sprintf(_n('(1 state)', '(%s states)', $states_count, 'woothemes'), $states_count); $return .= $countries_text . ' ' . $states_text; else : if ($states_count>0) $states_text = sprintf(_n('and 1 state', 'and %s states', $states_count, 'woothemes'), $states_count); $return .= sprintf(_n('1 country', '%1$s countries', sizeof($counties_array), 'woothemes'), sizeof($counties_array)) . ' ' . $states_text; endif; return $return; }