USCES_ITEM_CAT_PARENT_ID) );
?>
post_type && $res = usces_is_same_itemcode($post->ID, $itemCode)) {
// $usces->action_message .= 'post_ID ';
// foreach( $res as $postid )
// $usces->action_message .= $postid . ', ';
// $usces->action_message .= 'に同じ商品コードが登録されています。' . "
";
// }
//}
//
//function usces_filter_redirect_post_location( $location, $post_id ){
// global $usces;
//// usces_log('usces_filter_redirect_post_location : '.print_r($location,true), 'acting_transaction.log');
// if( !empty($usces->action_message) )
// $location = add_query_arg( 'usces_notice', urlencode($usces->action_message), $location );
// return $location;
//}
//
//function usces_action_updated_messages(){
// global $notice;
//
// if( isset($_GET['usces_notice']) ){
// $notice = urldecode($_GET['usces_notice']) . $notice;
// }
//}
function usces_item_duplicate($post_id){
global $wpdb;
if ( !current_user_can( 'edit_posts' ) )
wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
if( empty($post_id) )
wp_die( __( 'Data does not exist.', 'usces' ) );
//if ( !$post_data = wp_get_single_post($post_id, ARRAY_A) )
if ( !$post_data = get_post($post_id, ARRAY_A) )
wp_die( __( 'Data does not exist.', 'usces' ) );
$datas = array();
foreach($post_data as $key => $value){
switch( $key ){
case 'ID':
break;
case 'post_date':
case 'post_modified':
//$datas[$key] = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
break;
case 'post_date_gmt':
case 'post_modified_gmt':
//$datas[$key] = gmdate('Y-m-d H:i:s');
break;
case 'post_status':
$datas[$key] = 'draft';
break;
case 'post_name':
case 'guid':
//$datas[$key] = '';
break;
case 'menu_order':
case 'post_parent':
case 'comment_count':
$datas[$key] = 0;
break;
default:
$datas[$key] = $value;
}
}
$datas['post_category'] = wp_get_post_categories( $post_id );
$newpost_id = wp_insert_post( $datas );
$query = $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post_id);
$meta_data = $wpdb->get_results( $query );
if(!$meta_data) return;
$valstr = '';
foreach($meta_data as $data){
$prefix = substr($data->meta_key, 0, 5);
$prefix1 = substr($data->meta_key, 0, 1);
$prefix2 = substr($data->meta_key, 0, 11);
if( $prefix == '_item' ){
switch( $data->meta_key ){
case '_itemCode':
$value = $data->meta_value . '(copy)';
break;
default:
$value = $data->meta_value;
}
$key = $data->meta_key;
//$valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
$valstr .= '(' . $newpost_id . ", '" . esc_sql($key) . "','" . esc_sql($value) . "'),";
}else if( $prefix == '_isku' || $prefix == '_iopt' ){
$value = $data->meta_value;
$key = $data->meta_key;
//$valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
$valstr .= '(' . $newpost_id . ", '" . esc_sql($key) . "','" . esc_sql($value) . "'),";
}
if( $prefix1 != '_' ){
$value = $data->meta_value;
$key = $data->meta_key;
//$valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
$valstr .= '(' . $newpost_id . ", '" . esc_sql($key) . "','" . esc_sql($value) . "'),";
}
}
$valstr = rtrim($valstr, ',');
$query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES $valstr", $post_id);
$res = $wpdb->query($query);
if(!$res ) return;
do_action('usces_action_item_dupricate', $post_id, $newpost_id);
return $newpost_id;
}
function usces_item_dupricate($post_id){
return usces_item_duplicate($post_id);
}
function usces_all_delete_itemdata(&$obj){
global $wpdb;
if ( !current_user_can( 'edit_posts' ) )
wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
$ids = $_POST['listcheck'];
$status = true;
foreach ( (array)$ids as $post_id ){
if ( !wp_delete_post($post_id, true) ){
$status = false;
}
}
if ( true === $status ) {
$obj->set_action_status('success', __('I completed collective operation.','usces'));
} elseif ( false === $status ) {
$obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
} else {
$obj->set_action_status('none', '');
}
}
function usces_typenow(){
global $typenow;
if( isset($_GET['page']) && ('usces_itemedit' == $_GET['page'] || 'usces_itemnew' == $_GET['page']) )
$typenow = '';
}
function usces_admin_notices(){
global $usces;
if( 'on' == $usces->options['acting_settings']['zeus']['activate'] ){
$options = get_option('usces');
if(!isset($options['acting_settings']['zeus']['vercheck']) || '115' != $options['acting_settings']['zeus']['vercheck'] ){
$msg = '
決済に「ゼウス」をご利用の場合は、「セキュリティーコード」の設定内容を確認して更新ボタンを押して下さい。設定を更新するとこのメッセージは表示されなくなります。