static function get_addressform($data, $type) { if (empty($data)) { return; } $system_options = wc2_get_option('system'); $applyform = wc2_get_apply_addressform($system_options['addressform']); if (is_admin()) { switch ($type) { case 'member': case 'customer': $values = $data; break; case 'delivery': $values = $data['delivery'][0]; break; } $essential_mark_off = $type == 'member' ? false : true; } else { switch ($type) { case 'member': $values = $data; break; case 'customer': $values = $data['customer']; break; case 'delivery': $values = $data['delivery']; break; } $essential_mark_off = false; } $values['country'] = !empty($values['country']) ? $values['country'] : wc2_get_local_addressform(); $values = wc2_stripslashes_deep_post($values); $essential_mark = wc2_get_option('essential_mark'); if ($essential_mark_off) { foreach ($essential_mark as $key => $value) { $essential_mark[$key] = ''; } } $formtag = ''; switch ($applyform) { case 'JP': $formtag .= self::get_custom_field_input($values, $type, 'head'); if (is_admin() && ($type == 'member' || $type == 'customer')) { $get_member = $type == 'customer' ? '<input type="button" id="get-member" class="button" value="' . __('会員情報取込', 'wc2') . '" />' : ''; $formtag .= ' <tr class="' . $type . '-mail"> <th>' . $essential_mark['email'] . 'e-mail</th> <td><input name="' . $type . '[email]" type="text" class="text long" value="' . esc_attr($values['email']) . '" />' . $get_member . apply_filters('wc2_filter_after_email', NULL, $values, $type) . '</td> </tr>'; } $formtag .= self::get_custom_field_input($values, $type, 'beforename'); $formtag .= ' <tr class="' . $type . '-name"> <th>' . $essential_mark['name1'] . __('Name', 'wc2') . '</th> <td> <input name="' . $type . '[name1]" type="text" class="text short" value="' . esc_attr($values['name1']) . '" placeholder="' . __('Last name', 'wc2') . '" /> <input name="' . $type . '[name2]" type="text" class="text short" value="' . esc_attr($values['name2']) . '" placeholder="' . __('First name', 'wc2') . '" />' . apply_filters('wc2_filter_after_name2', NULL, $values, $type) . ' </td> </tr> <tr class="' . $type . '-phonetic"> <th>' . $essential_mark['name3'] . __('Kana', 'wc2') . '</th> <td> <input name="' . $type . '[name3]" type="text" class="text short" value="' . esc_attr($values['name3']) . '" placeholder="' . __('セイ', 'wc2') . '" /> <input name="' . $type . '[name4]" type="text" class="text short" value="' . esc_attr($values['name4']) . '" placeholder="' . __('メイ', 'wc2') . '" />' . apply_filters('wc2_filter_after_name4', NULL, $values, $type) . ' </td> </tr>'; $formtag .= self::get_custom_field_input($values, $type, 'aftername'); if (count($system_options['target_market']) == 1) { $formtag .= '<input name="' . $type . '[country]" type="hidden" value="' . $system_options['target_market'][0] . '" />'; } else { $formtag .= ' <tr class="' . $type . '-country"> <th>' . $essential_mark['country'] . __('国', 'wc2') . '</th> <td>' . wc2_get_target_market_form($type, $values['country']) . apply_filters('wc2_filter_after_country', NULL, $values, $type) . '</td> </tr>'; } $formtag .= ' <tr class="' . $type . '-zipcode"> <th>' . $essential_mark['zipcode'] . __('郵便番号', 'wc2') . '</th> <td> <input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr($values['zipcode']) . '" /> <input id="search-zipcode-' . $type . '" type="button" class="search-zipcode button" value="住所検索" />' . apply_filters('wc2_filter_after_zipcode', NULL, $values, $type) . ' </td> </tr> <tr class="' . $type . '-pref"> <th>' . $essential_mark['pref'] . __('都道府県', 'wc2') . '</th> <td>' . wc2_get_pref_select($type, $values) . apply_filters('wc2_filter_after_pref', NULL, $values, $type) . '</td> </tr> <tr class="' . $type . '-address1"> <th>' . $essential_mark['address1'] . __('City/Ward/Town/Village/Street name, street number', 'wc2') . '</th> <td><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr($values['address1']) . '" />' . apply_filters('wc2_filter_after_address1', NULL, $values, $type) . '</td> </tr> <tr class="' . $type . '-address2"> <th>' . $essential_mark['address2'] . __('Building name, floor, room number', 'wc2') . '</th> <td><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr($values['address2']) . '" />' . apply_filters('wc2_filter_after_address2', NULL, $values, $type) . '</td> </tr> <tr class="' . $type . '-tel"> <th>' . $essential_mark['tel'] . __('電話番号', 'wc2') . '</th> <td><input name="' . $type . '[tel]" type="text" class="text short" value="' . esc_attr($values['tel']) . '" />' . apply_filters('wc2_filter_after_tel', NULL, $values, $type) . '</td>'; $formtag .= ' </td> </tr> <tr class="' . $type . '-fax"> <th>' . $essential_mark['fax'] . __('FAX番号', 'wc2') . '</th> <td><input name="' . $type . '[fax]" type="text" class="text short" value="' . esc_attr($values['fax']) . '" />' . apply_filters('wc2_filter_after_fax', NULL, $values, $type) . '</td> </tr>'; $formtag .= self::get_custom_field_input($values, $type, 'bottom'); break; } return $formtag; }
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'); }
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'; }