public function init_options() { $session_name = wc2_get_option('session_name'); if (empty($session_name)) { $session_name = $this->plugin_slug . mt_rand(1000, 9999); wc2_update_option('session_name', $session_name); } /*------------------------------- 基本設定オプション初期値 ---------------------------------*/ $general = wc2_get_option('general'); if (!isset($general['campaign_category'])) { $general['campaign_category'] = 0; } if (!isset($general['campaign_privilege'])) { $general['campaign_privilege'] = ''; } if (!isset($general['privilege_point'])) { $general['privilege_point'] = ''; } if (!isset($general['privilege_discount'])) { $general['privilege_discount'] = ''; } if (!isset($general['company_name'])) { $general['company_name'] = ''; } if (!isset($general['zip_code'])) { $general['zip_code'] = ''; } if (!isset($general['address1'])) { $general['address1'] = ''; } if (!isset($general['address2'])) { $general['address2'] = ''; } if (!isset($general['tel_number'])) { $general['tel_number'] = ''; } if (!isset($general['fax_number'])) { $general['fax_number'] = ''; } if (!isset($general['order_mail'])) { $general['order_mail'] = ''; } if (!isset($general['inquiry_mail'])) { $general['inquiry_mail'] = ''; } if (!isset($general['sender_mail'])) { $general['sender_mail'] = ''; } if (!isset($general['error_mail'])) { $general['error_mail'] = ''; } if (!isset($general['copyright'])) { $general['copyright'] = ''; } if (!isset($general['postage_privilege'])) { $general['postage_privilege'] = ''; } if (!isset($general['purchase_limit'])) { $general['purchase_limit'] = ''; } if (!isset($general['shipping_rule'])) { $general['shipping_rule'] = ''; } if (!isset($general['tax_rate'])) { $general['tax_rate'] = ''; $general['tax_method'] = 'cutting'; $general['tax_mode'] = 'include'; $general['tax_target'] = 'products'; } else { if (!isset($general['tax_mode'])) { $general['tax_mode'] = empty($general['tax_rate']) ? 'include' : 'exclude'; } if (!isset($general['tax_target'])) { $general['tax_target'] = 'all'; } } if (!isset($general['add2cart'])) { $general['add2cart'] = '0'; } if (!isset($general['membersystem_state'])) { $general['membersystem_state'] = 'activate'; } if (!isset($general['membersystem_point'])) { $general['membersystem_point'] = 'activate'; } if (!isset($general['point_rate'])) { $general['point_rate'] = ''; } if (!isset($general['start_point'])) { $general['start_point'] = ''; } if (!isset($general['point_coverage'])) { $general['point_coverage'] = 1; } if (!isset($general['point_assign'])) { $general['point_assign'] = 1; } if (!isset($general['member_pass_rule_min']) || empty($general['member_pass_rule_min'])) { $general['member_pass_rule_min'] = 6; } if (!isset($general['member_pass_rule_max']) || empty($general['member_pass_rule_max'])) { $general['member_pass_rule_max'] = ''; } if (!isset($general['indi_item_name'])) { $general['indi_item_name']['item_name'] = 1; $general['indi_item_name']['item_code'] = 1; $general['indi_item_name']['sku_name'] = 1; $general['indi_item_name']['sku_code'] = 1; $general['pos_item_name']['item_name'] = 1; $general['pos_item_name']['item_code'] = 2; $general['pos_item_name']['sku_name'] = 3; $general['pos_item_name']['sku_code'] = 4; } wc2_update_option('general', $general); $cart_description = wc2_get_option('cart_description'); $member_description = wc2_get_option('member_description'); if (!isset($cart_description['cart_header'])) { $cart_description['cart_header'] = array('top' => '', 'customer' => '', 'delivery' => '', 'confirm' => '', 'complete' => ''); } if (!isset($cart_description['cart_footer'])) { $cart_description['cart_footer'] = array('top' => '', 'customer' => '', 'delivery' => '', 'confirm' => '', 'complete' => ''); } if (!isset($member_description['member_header'])) { $member_description['member_header'] = array('login' => '', 'newmemberform' => '', 'lostpassword' => '', 'changepassword' => '', 'memberform' => '', 'complete' => ''); } if (!isset($member_description['member_footer'])) { $member_description['member_footer'] = array('login' => '', 'newmemberform' => '', 'lostpassword' => '', 'changepassword' => '', 'memberform' => '', 'complete' => ''); } wc2_update_option('cart_description', $cart_description); wc2_update_option('member_description', $member_description); $this->check_display_mode(); /*--------------------------------- メール設定オプション初期値 ----------------------------------*/ $phrase = wc2_get_option('phrase'); $phrase_default = wc2_get_option('phrase_default'); if (!isset($phrase['title'])) { foreach ((array) $phrase_default['title'] as $key => $value) { $phrase['title'][$key] = $value; } } if (!isset($phrase['header'])) { foreach ((array) $phrase_default['header'] as $key => $value) { $phrase['header'][$key] = $value; } } if (!isset($phrase['footer'])) { foreach ((array) $phrase_default['footer'] as $key => $value) { $phrase['footer'][$key] = $value; } } wc2_update_option('phrase', $phrase); /*--------------------------------- 配送設定オプション初期値 -----------------------------------/ /*--------------------------------- システム設定オプション初期値 ----------------------------------*/ $system_options = wc2_get_option('system'); if (!isset($system_options['addressform'])) { $system_options['addressform'] = wc2_get_local_addressform(); } //住所様式 if (!isset($system_options['target_market'])) { $system_options['target_market'] = wc2_get_local_target_market(); } //販売対象国 if (!isset($system_options['mem_option_digit'])) { $system_options['mem_option_digit'] = 5; } //会員コード桁数 if (!isset($system_options['currency'])) { $system_options['currency'] = wc2_get_base_country(); } if (!isset($system_options['base_country'])) { $system_options['base_country'] = wc2_get_base_country(); } if (!isset($system_options['divide_item'])) { $system_options['divide_item'] = 0; } //表示モード if (!isset($system_options['itemimg_anchor_rel'])) { $system_options['itemimg_anchor_rel'] = ''; } //rel属性 if (!isset($system_options['composite_category_orderby'])) { $system_options['composite_category_orderby'] = 'ID'; } //複合カテゴリーソート項目 if (!isset($system_options['composite_category_order'])) { $system_options['composite_category_order'] = 'ASC'; } //複合カテゴリーソート順 if (!isset($system_options['use_ssl'])) { $system_options['use_ssl'] = 0; } //SSLを使用する if (!isset($system_options['ssl_url_admin'])) { $system_options['ssl_url_admin'] = ''; } //WordPress のアドレス (SSL) if (!isset($system_options['ssl_url'])) { $system_options['ssl_url'] = ''; } //ブログのアドレス (SSL) if (!isset($system_options['inquiry_id'])) { $system_options['inquiry_id'] = ''; } if (!isset($system_options['no_cart_css'])) { $system_options['no_cart_css'] = 0; } if (!isset($system_options['dec_orderID_flag'])) { $system_options['dec_orderID_flag'] = 0; } if (!isset($system_options['dec_orderID_prefix'])) { $system_options['dec_orderID_prefix'] = ''; } if (!isset($system_options['dec_orderID_digit'])) { $system_options['dec_orderID_digit'] = 8; } if (!isset($system_options['subimage_rule'])) { $system_options['subimage_rule'] = 1; } if (!isset($system_options['pdf_delivery'])) { $system_options['system']['pdf_delivery'] = 0; } if (!isset($system_options['csv_encode_type'])) { $system_options['csv_encode_type'] = 0; } //$system['currency'] = wc2_get_base_country(); //$system['base_country'] = wc2_get_base_country(); wc2_update_option('system', $system_options); /*------------------------------ 支払設定オプション初期値 -------------------------------*/ //$payment_method = wc2_get_option( 'payment_method' ); //if( !$payment_method ) $payment_method = array(); $settlement_types = wc2_get_option('settlement_types'); if (!$settlement_types) { $settlement_types = array('BT' => __('Bank transfer', 'wc2'), 'COD' => __('COD', 'wc2')); } wc2_update_option('settlement_types', $settlement_types); $payment_info = wc2_get_option('payment_info'); if (!isset($payment_info['cod_type'])) { $payment_info['cod_type'] = 'fix'; } wc2_update_option('payment_info', $payment_info); do_action('wc2_init_option'); }
<?php //選択可能な配送方法に設定されている配達日数 $script_days = ' var delivery_days = [];'; foreach( (array)$default_deli as $id ) { $index = wc2_get_delivery_method_index( $id ); if( 0 <= $index ) { $script_days .= ' delivery_days['.$id.'] = [];'; $script_days .= ' delivery_days['.$id.'].push("'.$delivery['delivery_method'][$index]['days'].'");'; } } //配達日数に設定されている県毎の日数 $target_market = ( isset($system['target_market']) && !empty($system['target_market']) ) ? $system['target_market'] : wc2_get_local_target_market(); $prefs = array(); foreach( (array)$target_market as $tm ) { $prefs[$tm] = $system['province'][$tm]; } $delivery_days = wc2_get_option( 'delivery_days' ); $script_days .= ' var delivery_days_value = [];'; foreach( (array)$default_deli as $id ) { $index = wc2_get_delivery_method_index( $id ); if( 0 <= $index ) { $days = (int)$delivery['delivery_method'][$index]['days']; if( 0 <= $days ) { for( $i = 0; $i < count((array)$delivery_days); $i++ ) { if( (int)$delivery_days[$i]['id'] == $days ) { $script_days .= '
public function system_setting_page() { if (!isset($this->plugin_screen_hook_suffix)) { return; } $screen = get_current_screen(); if ($this->plugin_screen_hook_suffix != $screen->id) { return; } $system_options = wc2_get_option('system'); $states = wc2_get_option('states_options'); $locale = wc2_get_option('locale_options'); if (array_key_exists('wc2_option_update', $_POST)) { $this->action_status = 'success'; $_POST = WC2_Utils::stripslashes_deep_post($_POST); $system_options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0; $system_options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : ''; $system_options['composite_category_orderby'] = isset($_POST['composite_category_orderby']) ? $_POST['composite_category_orderby'] : ''; $system_options['composite_category_order'] = isset($_POST['composite_category_order']) ? $_POST['composite_category_order'] : ''; $system_options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : ''; if (WC2_Utils::is_blank($system_options['settlement_path'])) { $system_options['settlement_path'] = WC2_PLUGIN_DIR . '/settlement/'; } $sl = substr($system_options['settlement_path'], -1); if ($sl != '/' && $sl != '\\') { $system_options['settlement_path'] .= '/'; } $system_options['logs_path'] = isset($_POST['logs_path']) ? $_POST['logs_path'] : ''; if (!WC2_Utils::is_blank($system_options['logs_path'])) { $sl = substr($system_options['logs_path'], -1); if ($sl == '/' || $sl == '\\') { $system_options['logs_path'] = substr($system_options['logs_path'], 0, -1); } } $system_options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0; $system_options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : ''; $system_options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : ''; if (WC2_Utils::is_blank($system_options['ssl_url']) || WC2_Utils::is_blank($system_options['ssl_url_admin'])) { $system_options['use_ssl'] = 0; } $system_options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : ''; $system_options['use_javascript'] = isset($_POST['use_javascript']) ? (int) $_POST['use_javascript'] : 1; $system_options['front_lang'] = isset($_POST['front_lang']) && 'others' != $_POST['front_lang'] ? $_POST['front_lang'] : wc2_get_local_language(); $system_options['currency'] = isset($_POST['currency']) && 'others' != $_POST['currency'] ? $_POST['currency'] : wc2_get_base_country(); $system_options['addressform'] = isset($_POST['addressform']) ? $_POST['addressform'] : wc2_get_local_addressform(); $system_options['target_market'] = isset($_POST['target_market']) ? $_POST['target_market'] : wc2_get_local_target_market(); $system_options['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0; $system_options['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int) $_POST['dec_orderID_flag'] : 0; $system_options['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : ''; $system_options['pdf_delivery'] = isset($_POST['pdf_delivery']) ? (int) $_POST['pdf_delivery'] : 0; $system_options['csv_encode_type'] = isset($_POST['csv_encode_type']) ? (int) $_POST['csv_encode_type'] : 0; if (isset($_POST['dec_orderID_digit'])) { $dec_orderID_digit = (int) rtrim($_POST['dec_orderID_digit']); if (6 > $dec_orderID_digit) { $system_options['dec_orderID_digit'] = 6; } else { $system_options['dec_orderID_digit'] = $dec_orderID_digit; } } else { $system_options['dec_orderID_digit'] = 6; } $system_options['subimage_rule'] = isset($_POST['subimage_rule']) ? (int) $_POST['subimage_rule'] : 0; unset($system_options['province']); foreach ((array) $system_options['target_market'] as $target_market) { $province = array(); if (!empty($_POST['province_' . $target_market])) { $temp_pref = explode("\n", $_POST['province_' . $target_market]); foreach ($temp_pref as $pref) { if (!WC2_Utils::is_blank($pref)) { $province[] = trim($pref); } } if (1 == count($province)) { $this->action_status = 'error'; } } else { if (isset($states[$target_market]) && is_array($states[$target_market])) { $province = $states[$target_market]; } else { $this->action_status = 'error'; } } $system_options['province'][$target_market] = $province; } if ($this->action_status != 'success') { $this->action_message = __('データに不備があります', 'wc2'); } else { wc2_update_option('system', $system_options); $this->action_message = __('Updated!'); } } else { if (!isset($system_options['province']) || empty($system_options['province'])) { $system_options['province'][$system_options['base_country']] = $states[$system_options['base_country']]; } $this->action_status = 'none'; $this->action_message = ''; } $status = $this->action_status; $message = $this->action_message; $divide_item = $system_options['divide_item']; $itemimg_anchor_rel = $system_options['itemimg_anchor_rel']; $composite_category_orderby = $system_options['composite_category_orderby']; $composite_category_order = $system_options['composite_category_order']; $logs_path = isset($system_options['logs_path']) ? $system_options['logs_path'] : ''; $use_ssl = $system_options['use_ssl']; $ssl_url = $system_options['ssl_url']; $ssl_url_admin = $system_options['ssl_url_admin']; $inquiry_id = $system_options['inquiry_id']; $orderby_itemsku = isset($system_options['orderby_itemsku']) ? $system_options['orderby_itemsku'] : 0; $orderby_itemopt = isset($system_options['orderby_itemopt']) ? $system_options['orderby_itemopt'] : 0; $system_front_lang = isset($system_options['front_lang']) && !empty($system_options['front_lang']) ? $system_options['front_lang'] : wc2_get_local_language(); $system_currency = isset($system_options['currency']) && !empty($system_options['currency']) ? $system_options['currency'] : wc2_get_base_country(); $system_addressform = isset($system_options['addressform']) && !empty($system_options['addressform']) ? $system_options['addressform'] : wc2_get_local_addressform(); $system_target_markets = isset($system_options['target_market']) && !empty($system_options['target_market']) ? $system_options['target_market'] : wc2_get_local_target_market(); $no_cart_css = isset($system_options['no_cart_css']) ? $system_options['no_cart_css'] : 0; $dec_orderID_flag = isset($system_options['dec_orderID_flag']) ? $system_options['dec_orderID_flag'] : 0; $dec_orderID_prefix = isset($system_options['dec_orderID_prefix']) ? $system_options['dec_orderID_prefix'] : ''; $dec_orderID_digit = isset($system_options['dec_orderID_digit']) ? $system_options['dec_orderID_digit'] : ''; $subimage_rule = isset($system_options['subimage_rule']) ? $system_options['subimage_rule'] : 0; $pdf_delivery = isset($system_options['pdf_delivery']) ? $system_options['pdf_delivery'] : 0; $csv_encode_type = isset($system_options['csv_encode_type']) ? $system_options['csv_encode_type'] : 0; require_once WC2_PLUGIN_DIR . '/admin/views/setting-system.php'; }