stripslashes_deep_post($newvalue); $option_value = get_option($option_name); if( !empty($option_value) ){ $option_num = count($option_value); $unique = true; $sortnull = true; foreach( (array)$option_value as $value ){ if( $value['name'] == $newvalue['name'] ) $unique = false; if( !isset($value['sort']) ) $sortnull = false; $sort[] = $value['sort']; } if( !$unique ) return -1; rsort($sort); $next_number = reset($sort) + 1; $unique_sort = array_unique($sort); if( $option_num !== count($unique_sort) || $option_num !== $next_number || !$sortnull){ //To repair the sort data $i = 0; foreach( $option_value as $opkey => $opvalue ){ $option_value[$opkey]['sort'] = $i; $i++; } } } $newvalue['sort'] = !empty($option_num) ? $option_num : 0; $option_value[] = $newvalue; update_option($option_name, $option_value); krsort($option_value); $key_arr = each($option_value); $last_index = $key_arr['key']; return $last_index; } function usces_update_system_option( $option_name, $index, $newvalue ){ global $usces; $newvalue = $usces->stripslashes_deep_post($newvalue); $option_value = get_option($option_name); if( !empty($option_value) ){ $unique = true; foreach( (array)$option_value as $value_id => $value ){ if( $value['name'] == $newvalue['name'] && $value_id != $index ){ $unique = false; break; } } if( !$unique ) return -1; $option_value[$index] = $newvalue; update_option($option_name, $option_value); $lid = $index; }else{ $lid = -1; } return $lid; } function usces_get_system_option( $option_name, $keyflag = 'sort' ) { $sysopts = array(); $option_value = get_option($option_name); if( !is_array($option_value) ) return $sysopts; foreach( $option_value as $id => $value ){ $key = isset($value[$keyflag]) ? $value[$keyflag] : $value['sort']; switch( $option_name ){ case 'usces_payment_method': $sysopts[$key] = array( 'id' => $id, 'name' => $value['name'], 'explanation' => $value['explanation'], 'settlement' => $value['settlement'], 'module' => $value['module'], 'sort' => $value['sort'], 'use' => isset( $value['use'] ) ? $value['use'] : 'activate' ); break; } } ksort($sysopts); return $sysopts; } function usces_sort_system_option( $option_name, $idstr ) { global $usces; $option_value = get_option($option_name); if( !empty($option_value) ){ $ids = explode(',', $idstr); $c = 0; foreach( (array)$ids as $id ){ // usces_log('ids : '.$id.$c, 'acting_transaction.log'); $option_value[$id]['sort'] = $c; $c++; // usces_log('options : '.print_r($option_value,true), 'acting_transaction.log'); } update_option( $option_name, $option_value ); } return; } function usces_del_system_option( $option_name, $id ) { global $usces; $option_value = get_option($option_name); if( !empty($option_value) && isset($option_value[$id]) && !empty($option_value)){ unset($option_value[$id]); $op = array(); foreach( (array)$option_value as $opkey => $opvalue ){ $op[$opvalue['sort']] = $opkey; } ksort($op); $c = 0; foreach( $op as $opid ){ $option_value[$opid]['sort'] = $c; $c++; } update_option( $option_name, $option_value ); } return; } /** * payment_list */ function payment_list( $option_value ) { // Exit if no meta if ( empty($option_value) ) { ?>
 
 
/>  />
' onclick="payment.post('del', );" /> ' onclick="payment.post('update', );" />

:

\"ソリューション画像\"
PayPal について
"; } if ( !empty( $newvalue['name'] ) ) { $lid = usces_add_system_option( 'usces_payment_method', $newvalue ); return $lid; } return false; } // add_meta /** * update_payment */ function up_payment_method() { global $usces; $value = array(); //$id = isset($_POST['id']) ? (int)$_POST['id'] : ''; $id = $_POST['id']; $value['name'] = isset($_POST['name']) ? trim( $_POST['name'] ) : ''; $value['explanation'] = isset($_POST['explanation']) ? trim( $_POST['explanation'] ) : ''; $value['settlement'] = isset($_POST['settlement']) ? $_POST['settlement'] : ''; $value['module'] = isset($_POST['module']) ? trim( $_POST['module'] ) : ''; $value['sort'] = isset($_POST['sort']) ?(int)$_POST['sort'] : 0; $value['use'] = isset($_POST['use']) ? $_POST['use'] : 'activate'; if ( !empty( $value['name'] ) && !WCUtils::is_blank($id) ) { $id = usces_update_system_option( 'usces_payment_method', $id, $value ); return $id; } return -2; } // add_meta /** * delete_payment */ function del_payment_method() { global $usces; $id = $_POST['id']; if ( !WCUtils::is_blank($id) ) { usces_del_system_option( 'usces_payment_method', $id ); return $id; } return false; } function sort_payment_method(){ return usces_sort_system_option( 'usces_payment_method', $_POST['idstr'] ); } function add_delivery_method() { $options = get_option('usces'); $name = trim($_POST['name']); foreach((array)$options['delivery_method'] as $deli){ $ids[] = (int)$deli['id']; } if(isset($ids)){ rsort($ids); $newid = $ids[0]+1; }else{ $newid = 0; } $index = isset($options['delivery_method']) ? count($options['delivery_method']) : 0; $options['delivery_method'][$index]['id'] = $newid; $options['delivery_method'][$index]['name'] = $name; $options['delivery_method'][$index]['time'] = str_replace("\r\n", "\n", $_POST['time']); $options['delivery_method'][$index]['time'] = str_replace("\r", "\n", $options['delivery_method'][$index]['time']); $options['delivery_method'][$index]['charge'] = (int)$_POST['charge']; //20101208ysk start $options['delivery_method'][$index]['days'] = (int)$_POST['days']; //20101208ysk end //20101119ysk start $options['delivery_method'][$index]['nocod'] = $_POST['nocod']; //20101119ysk end //20110317ysk start $options['delivery_method'][$index]['intl'] = $_POST['intl']; //20110317ysk end update_option('usces', $options); //20101208ysk start //20101119ysk start //$res = $newid . '#usces#' . $name . '#usces#' . $options['delivery_method'][$index]['time'] . '#usces#' . $options['delivery_method'][$index]['charge']; //$res = $newid . '#usces#' . $name . '#usces#' . $options['delivery_method'][$index]['time'] . '#usces#' . $options['delivery_method'][$index]['charge'] . '#usces#' . $options['delivery_method'][$index]['nocod']; //20101119ysk end //20110317ysk start //$res = $newid . '#usces#' . $name . '#usces#' . $options['delivery_method'][$index]['time'] . '#usces#' . $options['delivery_method'][$index]['charge'] . '#usces#' . $options['delivery_method'][$index]['days'] . '#usces#' . $options['delivery_method'][$index]['nocod']; $res = $newid . '#usces#' . stripslashes($name) . '#usces#' . stripslashes($options['delivery_method'][$index]['time']) . '#usces#' . $options['delivery_method'][$index]['charge'] . '#usces#' . $options['delivery_method'][$index]['days'] . '#usces#' . $options['delivery_method'][$index]['nocod'] . '#usces#' . $options['delivery_method'][$index]['intl']; //20110317ysk end //20101208ysk end return $res; } function update_delivery_method() { $options = get_option('usces'); $name = trim($_POST['name']); $id = (int)$_POST['id']; $charge = (int)$_POST['charge']; for($i=0; $ioptions['province']; //20110331ysk start //$prefs = $usces_states[$country]; //20120710ysk start 0000472 //$prefs = get_usces_states($country); //20110331ysk end //20110317ysk end //array_shift($prefs); $target_market = ( isset($options['system']['target_market']) && !empty($options['system']['target_market']) ) ? $options['system']['target_market'] : usces_get_local_target_market(); foreach( (array)$target_market as $tm ) { $prefs = get_usces_states($tm); array_shift($prefs); $value = $_POST['value_'.$tm]; //20120710ysk end $options['shipping_charge'][$index]['id'] = $newid; $options['shipping_charge'][$index]['name'] = $name; //20110317ysk start //20120710ysk start 0000472 //$options['shipping_charge'][$index]['country'] = $country; //20110317ysk end //$options['shipping_charge'][$index]["value"] = array(); //for($i=0; $ioptions['province']; //20110331ysk start //$prefs = $usces_states[$country]; //20120710ysk start 0000472 //$prefs = get_usces_states($country); //20110331ysk end //20110317ysk end //array_shift($prefs); //20120710ysk end for($i=0; $ioptions['province']; //20110331ysk start //$prefs = $usces_states[$country]; //20120710ysk start 0000472 //$prefs = get_usces_states($country); //20110331ysk end //20110317ysk end //array_shift($prefs); $target_market = ( isset($options['system']['target_market']) && !empty($options['system']['target_market']) ) ? $options['system']['target_market'] : usces_get_local_target_market(); foreach( (array)$target_market as $tm ) { $prefs = get_usces_states($tm); array_shift($prefs); $value = $_POST['value_'.$tm]; //20120710ysk end $options['delivery_days'][$index]['id'] = $newid; $options['delivery_days'][$index]['name'] = $name; //20110317ysk start //20120710ysk start 0000472 //$options['delivery_days'][$index]['country'] = $country; //20110317ysk end //for($i=0; $ioptions['province']; //20110331ysk start //$prefs = $usces_states[$country]; //20120710ysk start 0000472 //$prefs = get_usces_states($country); //20110331ysk end //20110317ysk end //array_shift($prefs); //20120710ysk end for($i=0; $i