public static function process_withdrawal() { $action = wskl_POST('action'); if ($action != 'dabory_members_withdrawal') { return; } self::evaluate_and_redirect_if_failed(is_user_logged_in(), __('먼저 로그인 하세요', 'wskl')); self::evaluate_and_redirect_if_failed(wp_verify_nonce($_POST['dabory_members_withdrawal'], 'dabory_members_withdrawal'), __('Nonce 인증에 실패했습니다.', 'wskl')); $user = wp_get_current_user(); $password = wskl_POST('password'); $reason = wskl_POST('reason', 'sanitize_text_field'); self::evaluate_and_redirect_if_failed(wp_check_password($password, $user->user_pass, $user->ID), __('비밀번호가 일치하지 않습니다.', 'wskl')); if (wskl_is_option_enabled('members_delete_after_withdrawal')) { if (!function_exists('wp_delete_user')) { include_once ABSPATH . 'wp-admin/includes/user.php'; } // 멤버 정말로 삭제 wp_logout(); wp_delete_user($user->ID); } else { // 역할을 바꿔 탈퇴 회원으로 간주 update_user_meta($user->ID, 'withdrawal_reason', $reason); $user->set_role('wskl_withdrawn'); wp_logout(); } // 탈퇴 완료 메시지 wp_redirect(add_query_arg(array('status' => 'complete'), $_SERVER['REQUEST_URI'])); exit; }
/** * @action woocommerce_checkout_order_processed * * @used-by init * * @param $order_id * @param $posted */ public static function add_name_to_postmeta($order_id, $posted) { $bacs_payer_name = wskl_POST('bacs_payer_name', 'sanitize_text_field'); $is_bacs = isset($posted['payment_method']) && $posted['payment_method'] == 'bacs'; if ($is_bacs && !empty($bacs_payer_name)) { update_post_meta($order_id, wskl_get_option_name('bacs_payer_name'), $bacs_payer_name); } }
/** * POST 데이터에서 값을 추출 * * @return array */ private static function extract_option_values() { $output = array(); // ranged numeric values $options = array(array('page_tos', 'intval', 0), array('page_privacy', 'intval', 0), array('page_3rd_party', 'intval', 0), array('page_delivery', 'intval', 0), array('page_refund', 'intval', 0), array('page_registration', 'intval', 0), array('page_registration_complete', 'intval', 0), array('page_withdrawal', 'intval', 0), array('show_terms', 'sanitize_text_field', 'no'), array('enable_postcode_button', 'sanitize_text_field', 'no'), array('password_mixed_chars', 'sanitize_text_field', 'no'), array('registration_custom_css', 'esc_textarea', ''), array('show_registration_complete', 'sanitize_text_field', 'no'), array('enable_withdrawal_shortcode', 'sanitize_text_field', 'no'), array('show_delivery', 'sanitize_text_field', 'no'), array('show_refund', 'sanitize_text_field', 'no'), array('enable_password_length', 'sanitize_text_field', 'no'), array('password_min_length', 'intval', 0), array('password_strength_meter', 'sanitize_text_field', 'no'), array('logged_in_after_registration', 'sanitize_text_field', 'no'), array('delete_after_withdrawal', 'sanitize_text_field', 'no')); foreach ($options as $elem) { $key = $elem[0]; $sanitize = $elem[1]; $fallback = $elem[2]; $option_name = self::get_option_name($key); $val = wskl_POST($option_name, $sanitize, $fallback); $output[$key] = $val; } return $output; }
public static function callback_save_post($post_id, \WP_Post $post, $update) { if (!$update || defined('DOING_AJAX') || defined('DOING_AUTOSAVE')) { return; } $is_export_allowed = filter_var(wskl_POST('allow-export'), FILTER_VALIDATE_BOOLEAN); if (!$is_export_allowed) { return; } $auth = new WSKL_Auth_Info('marketing'); if ($auth->is_verified()) { $key_type = $auth->get_key_type(); $key_value = $auth->get_key_value(); $user_id = $auth->get_oir()->get_user_id(); $site_url = site_url(); $remote_post_id = PostAPI::send_post($key_type, $key_value, $site_url, $user_id, $post_id); if ($remote_post_id) { $metadata = array('post_modified' => $post->post_modified, 'post_modified_gmt' => $post->post_modified_gmt, 'exported' => time(), 'remote_post_id' => $remote_post_id); update_post_meta($post_id, wskl_get_option_name('post_export_metadata'), $metadata); } else { error_log('callback_save_post() finished unsuccessfully!'); } } }
public function update_settings() { parent::update_settings(); if (wskl_GET('tab') !== $this->id || wskl_POST('action') != $this->action) { return; } $interval = $this->get_option('interval'); if ($interval) { $this->schedule_event(); } else { $this->cancel_event(); } }
/** * @used-by WSKL_Config_Editor::handle_form_submit() */ private static function update_wp_config_filter() { if (!wp_verify_nonce($_POST['wskl-config-filter-nonce'], 'wskl-config-filter-nonce')) { wp_die('Nonce verification error!'); } $values = array_map(function ($item) { return sanitize_text_field(trim($item)); }, explode("\n", wskl_POST('wskl-config-filter'))); wskl_update_option('config_editor_keys_to_filter', $values); self::$keys_to_filter = array_merge(self::$fixed_filtered_keys, $values); add_action('admin_notices', function () { echo '<div class="updated settings-error notice is-dismissible"><p><strong>' . __('Settings saved.') . '</strong></p></div>'; }); }
/** * 페이앱이 피드백 URL 에 대응하는 콜백. * 피드백 파라미터를 확인하고 올바른 경우에는 최종적으로 주문 내역을 결제된 것으로 업데이트한다. * * @action woocommerce_api_{wskl-payapp-feedback} */ public static function callback_payapp_feedback() { error_log('페이앱 피드백 URL 호출됨! 일시 (UTC time): ' . date('Y-m-d H:i:s')); $payapp_uid = wskl_POST('userid'); $link_key = wskl_POST('linkkey'); $link_val = wskl_POST('linkval'); $order_id = wskl_POST('var1', 'absint'); $order_key = wskl_POST('var2', 'sanitize_text_field'); $cst_url = wskl_POST('csturl', 'sanitize_text_field'); // 전표 주소 $pay_memo = wskl_POST('pay_memo', 'sanitize_text_field'); // 구매자가 기록한 메모 $mul_no = wskl_POST('mul_no', 'sanitize_text_field'); // 결제요청번호 $pay_state = wskl_POST('pay_state', 'absint'); // 결제요청상태 (1: 요청, 4: 결제완료, 8, 16, 32: 요청취소, 9, 64: 승인취소) $pay_type = wskl_POST('pay_type', 'absint'); // 결제수단 (1: 신용카드, 2: 휴대전화) $pay_date = wskl_POST('pay_date', 'sanitize_text_field'); // check payapp_uid if ($payapp_uid != wskl_get_option('payapp_user_id')) { error_log(__('페이앱 USER ID 에러', 'wskl')); return; } // check link key and link val if ($link_key != wskl_get_option('payapp_link_key') || $link_val != wskl_get_option('payapp_link_val')) { error_log(__('페이앱 연동 KEY, 혹은 연동 VALUE가 올바르지 않음', 'wskl')); return; } $order = wc_get_order($order_id); if (!$order) { error_log(__('잘못된 주문 ID', 'wskl') . ": {$order_id}"); return; } // check order key if ($order_key != $order->order_key) { error_log(__('잘못된 주문 KEY', 'wskl') . ": {$order_key}"); return; } // 승인 if ($pay_state == 4) { // 전표 기록 update_post_meta($order_id, 'wskl_payapp_cst_url', $cst_url); switch ($pay_type) { case 1: $card_name = wskl_POST('card_name', 'sanitize_text_field'); // 신용카드시 카드 이름 $order_note = sprintf(__('결제가 성공적으로 처리됨.<ul><li>결제방법: 신용카드</li><li>카드 이름: %s</li><li>페이앱 결제요청번호: %s</li><li>승인시각: %s</li><li>구매자의 결제창 메시지: %s</li></ul>', 'wskl'), $card_name, $mul_no, $pay_date, $pay_memo); break; case 2: $order_note = sprintf(__('결제가 성공적으로 처리됨.<ul><li>결제방법: 휴대전화</li><li>페이앱 결제요청번호: %s</li><li>승인시각: %s</li><li>구매자의 결제창 메시지: %s</li></ul>', 'wskl'), $mul_no, $pay_date, $pay_memo); break; default: $order_note = sprintf(__('결제가 성공적으로 처리됨.<ul><li>결제방법: 기타</li><li>페이앱 결제요청번호: %s</li><li>승인시각: %s</li><li>구매자의 결제창 메시지: %s</li></ul>', 'wskl'), $mul_no, $pay_date, $pay_memo); } $order->add_order_note($order_note); $order->payment_complete(); $order->reduce_order_stock(); wc_empty_cart(); } }
/** * 약관 페이지 필드 작성 * * @used-by WSKL_Dabory_Members_Registration::include_terms() * * @param string $key * @param bool $is_last * * @return string */ private static function get_tos_page_text($key, $is_last) { $post_id = intval(wskl_get_option('members_page_' . $key)); if ($post_id < 1) { return ''; } $post = WP_Post::get_instance($post_id); $title = esc_html($post->post_title); $content = wpautop(wptexturize($post->post_content)); $agreement_text = __('약관에 동의합니다.', 'wskl'); $last = $is_last ? 'last' : ''; $checked = wskl_POST('checkbox-' . $key) == 'yes' ? 'checked' : ''; if (isset(self::$validation_errors[$key])) { $validation_error_css_class = 'validation_error'; } else { $validation_error_css_class = ''; } $output = <<<PHP_EOD <div class="tos-wrapper {$last} {$validation_error_css_class}"> \t<h3 class="tos-title">{$title}</h3> \t<div class="text tos-content tos-content-{$key}"> \t\t{$content} \t</div> \t<label for="checkbox-{$key}"> \t\t<input type="checkbox" id="checkbox-{$key}" class="checkbox-agreement" name="checkbox-{$key}" value="yes" {$checked} /> \t\t{$agreement_text} \t</label> \t<span class="req">*</span> </div> PHP_EOD; return $output; }
/** * @return array|string */ public function extract_option_values() { $output = array('options' => array(), 'error' => NULL); $options = array(); $sections =& $this->fields['sections']; foreach ($sections as $section) { $fields =& $section['fields']; foreach ($fields as $field) { if (!isset($field['key'])) { continue; } $key = wskl_get_from_assoc($field, 'key'); $validate = wskl_get_from_assoc($field, 'validate'); $sanitize = wskl_get_from_assoc($field, 'sanitize'); $default = wskl_get_from_assoc($field, 'default'); $label = wskl_get_from_assoc($field, 'label'); $options[] = array($key, $validate, $sanitize, $default, $label); } } foreach ($options as $elem) { $key = $elem[0]; $validate = $elem[1]; $sanitize = $elem[2]; $default = $elem[3]; $label = $elem[4]; $opt_name = $this->get_option_name($key); $val = wskl_POST($opt_name, $sanitize, $default); if (is_callable($validate)) { /** @var true|string $validated */ $validated = call_user_func($validate, $val); if (TRUE !== $validated) { $output['error'] = sprintf(__('항목 \'%s\' 오류: ', 'wskl') . $validated, $label); return $output; } } $output['options'][$key] = $val; } return $output; }