PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
← All changes | functions/admin_func.php +692 -548 1.3.92.12.4 View file →
@@ -1,14 +1,26 @@
1 1 <?php
2 -function usces_states_form_js(){
2 +/**
3 + * Admin Page functions.
4 + *
5 + * @package Welcart
6 + */
7 +
8 +// phpcs:disable WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL
9 +// phpcs:disable WordPress.PHP.DevelopmentFunctions, WordPress.PHP.NoSilencedErrors
10 +
11 +/**
12 + * Front scripts.
13 + */
14 +function usces_states_form_js() {
3 15 global $usces;
4 -
16 +
5 17 $js = '';
6 - if( $usces->use_js
7 - && (( (is_page(USCES_MEMBER_NUMBER) || $usces->is_member_page($_SERVER['REQUEST_URI'])) && ((true === $usces->is_member_logged_in() && WCUtils::is_blank($usces->page)) || 'member' == $usces->page || 'editmemberform' == $usces->page || 'newmemberform' == $usces->page) )
8 - || ( (is_page(USCES_CART_NUMBER) || $usces->is_cart_page($_SERVER['REQUEST_URI'])) && ('customer' == $usces->page || 'delivery' == $usces->page) )
9 - )) {
10 -
18 + if ( $usces->use_js
19 + && ( ( ( is_page( USCES_MEMBER_NUMBER ) || $usces->is_member_page( $_SERVER['REQUEST_URI'] ) ) && ( ( true === $usces->is_member_logged_in() && WCUtils::is_blank( $usces->page ) ) || 'member' === $usces->page || 'editmemberform' === $usces->page || 'newmemberform' === $usces->page ) )
20 + || ( ( is_page( USCES_CART_NUMBER ) || $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) ) && ( 'customer' === $usces->page || 'delivery' === $usces->page ) )
21 + ) ) {
22 +
11 23 $js .= '<script type="text/javascript">
12 24 (function($) {
13 25 uscesForm = {
14 26 settings: {
@@ -13,15 +25,9 @@
13 25 uscesForm = {
14 26 settings: {
15 27 url: uscesL10n.ajaxurl,
16 28 type: "POST",
17 - cache: false,
18 - success: function(data, dataType){
19 - //$("tbody#item-opt-list").html( data );
20 - },
21 - error: function(msg){
22 - //$("#ajax-response").html(msg);
23 - }
29 + cache: false
24 30 },
25 31
26 32 changeStates : function( country, type ) {
27 33
@@ -27,32 +33,30 @@
27 33
28 34 var s = this.settings;
29 35 s.url = "' . USCES_SSL_URL . '/";
30 36 s.data = "usces_ajax_action=change_states&country=" + country;
31 - s.success = function(data, dataType){
37 + $.ajax( s ).done(function( data ){
32 38 if( "error" == data ){
33 39 alert("error");
34 40 }else{
35 41 $("select#" + type + "_pref").html( data );
36 42 if( customercountry == country && "customer" == type ){
37 - $("#" + type + "_pref").attr({selectedIndex:customerstate});
43 + $("#" + type + "_pref").prop({selectedIndex:customerstate});
38 44 }else if( deliverycountry == country && "delivery" == type ){
39 - $("#" + type + "_pref").attr({selectedIndex:deliverystate});
45 + $("#" + type + "_pref").prop({selectedIndex:deliverystate});
40 46 }else if( customercountry == country && "member" == type ){
41 - $("#" + type + "_pref").attr({selectedIndex:customerstate});
47 + $("#" + type + "_pref").prop({selectedIndex:customerstate});
42 48 }
43 49 }
44 - };
45 - s.error = function(msg){
50 + }).fail(function( msg ){
46 51 alert("error");
47 - };
48 - $.ajax( s );
52 + });
49 53 return false;
50 54 }
51 55 };';
52 -
53 - if( 'customer' == $usces->page ){
54 -
56 +
57 + if ( 'customer' === $usces->page ) {
58 +
55 59 $js .= 'var customerstate = $("#customer_pref").get(0).selectedIndex;
56 60 var customercountry = $("#customer_country").val();
57 61 var deliverystate = "";
58 62 var deliverycountry = "";
@@ -59,13 +63,13 @@
59 63 var memberstate = "";
60 64 var membercountry = "";
61 65 $("#customer_country").change(function () {
62 66 var country = $("#customer_country option:selected").val();
63 - uscesForm.changeStates( country, "customer" );
67 + uscesForm.changeStates( country, "customer" );
64 68 });';
65 -
66 - }elseif( 'delivery' == $usces->page ){
67 -
69 +
70 + } elseif ( 'delivery' === $usces->page ) {
71 +
68 72 $js .= 'var customerstate = "";
69 73 var customercountry = "";
70 74 var deliverystate = $("#delivery_pref").get(0).selectedIndex;
71 75 var deliverycountry = $("#delivery_country").val();
@@ -72,13 +76,13 @@
72 76 var memberstate = "";
73 77 var membercountry = "";
74 78 $("#delivery_country").change(function () {
75 79 var country = $("#delivery_country option:selected").val();
76 - uscesForm.changeStates( country, "delivery" );
80 + uscesForm.changeStates( country, "delivery" );
77 81 });';
78 -
79 - }elseif( (true === $usces->is_member_logged_in() && WCUtils::is_blank($usces->page)) || (true === $usces->is_member_logged_in() && 'member' == $usces->page) || 'editmemberform' == $usces->page || 'newmemberform' == $usces->page ){
80 -
82 +
83 + } elseif ( ( true === $usces->is_member_logged_in() && WCUtils::is_blank( $usces->page ) ) || ( true === $usces->is_member_logged_in() && 'member' === $usces->page ) || 'editmemberform' === $usces->page || 'newmemberform' === $usces->page ) {
84 +
81 85 $js .= 'var customerstate = "";
82 86 var customercountry = "";
83 87 var deliverystate = "";
84 88 var deliverycountry = "";
@@ -85,614 +89,754 @@
85 89 var memberstate = $("#member_pref").get(0).selectedIndex;
86 90 var membercountry = $("#member_country").val();
87 91 $("#member_country").change(function () {
88 92 var country = $("#member_country option:selected").val();
89 - uscesForm.changeStates( country, "member" );
93 + uscesForm.changeStates( country, "member" );
90 94 });';
91 95 }
92 96 $js .= '})(jQuery);
93 97 </script>';
94 98 }
95 -
96 - echo apply_filters('usces_filter_states_form_js', $js);
99 +
100 + echo apply_filters( 'usces_filter_states_form_js', $js );
97 101 }
98 102
99 -function usces_get_pointreduction($currency){
103 +/**
104 + * Point reduction control
105 + *
106 + * @param string $currency Currency code.
107 + */
108 +function usces_get_pointreduction( $currency ) {
100 109 global $usces, $usces_settings;
101 110
102 - $form = $usces_settings['currency'][$currency];
103 - if( 2 == $form[1] ){
111 + $form = $usces_settings['currency'][ $currency ];
112 + if ( 2 === (int) $form[1] ) {
104 113 $reduction = 0.01;
105 - }else{
114 + } else {
106 115 $reduction = 1;
107 116 }
108 - $reduction = apply_filters('usces_filter_pointreduction', $reduction);
117 + $reduction = apply_filters( 'usces_filter_pointreduction', $reduction );
109 118 return $reduction;
110 119 }
111 120
112 -function usces_zeus_3dsecure_enrol(){
113 - global $usces;
114 -
115 - $acting_opts = $usces->options['acting_settings']['zeus'];
121 +/**
122 + * Admin Item Page.
123 + * current_screen
124 + */
125 +function admin_prodauct_current_screen() {
126 + global $current_screen, $post, $typenow;
116 127
117 - $member = $usces->get_member();
118 - $pcid = $usces->get_member_meta_value('zeus_pcid', $member['ID']);
128 + $wp_version = get_bloginfo( 'version' );
129 + if ( version_compare( $wp_version, '3.4-beta3', '<' ) ) {
130 + return;
131 + }
119 132
120 - $data = array();
133 + if ( ! ( isset( $_GET['page'] ) && ( ( 'usces_itemedit' === $_GET['page'] && isset( $_GET['action'] ) ) || 'usces_itemnew' === $_GET['page'] ) ) ) {
134 + return;
135 + }
121 136
122 - //if( 2 == $acting_opts['security'] && 'on' == $acting_opts['quickcharge'] && $pcid == '8888888888888888' && $usces->is_member_logged_in() ){
123 - if( 'on' == $acting_opts['quickcharge'] && $pcid == '8888888888888888' && $usces->is_member_logged_in() ){
124 - $data['authentication']['clientip'] = $acting_opts['clientip'];
125 - $data['authentication']['key'] = $acting_opts['authkey'];
126 - $data['card']['history']['key'] = 'sendid';
127 - $data['card']['history']['action'] = 'send_email';
128 - $data['card']['cvv'] = $_POST['securecode'];
129 - $data['payment']['amount'] = $_POST['money'];
130 - if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
131 - $data['payment']['count'] = $_POST['div'];
132 - }else{
133 - $data['payment']['count'] = '01';
137 + $typenow = 'product';
138 +
139 + if ( isset( $_GET['post'] ) ) {
140 + $post_id = $post_ID = (int) $_GET['post'];
141 + } elseif ( isset( $_POST['post_ID'] ) ) {
142 + $post_id = $post_ID = (int) $_POST['post_ID'];
143 + } else {
144 + $post_id = $post_ID = 0;
145 + }
146 + $post_type = 'post';
147 + $post_type_object = get_post_type_object( $post_type );
148 +
149 + if ( $post_id ) {
150 + $product = wel_get_product( $post_id );
151 + $post = $product['_pst'];
152 + } else {
153 + $post = get_default_post_to_edit( $post_type, true );
154 + $post_ID = $post->ID;
155 + }
156 +
157 + require_once USCES_PLUGIN_DIR . '/includes/meta-boxes.php';
158 +
159 + add_meta_box( 'submitdiv', __( 'Publish' ), 'usces_post_submit_meta_box', $post_type, 'side', 'core' );
160 + if ( NEW_PRODUCT_IMAGE_REGISTER::$opts['switch_flag'] ) {
161 + add_meta_box( 'item-main-pict', __( 'Item image', 'usces' ), 'wel_post_item_pict_box_html', $post_type, 'side', 'high' );
162 + } else {
163 + add_meta_box( 'item-main-pict', __( 'Item image', 'usces' ), 'post_item_pict_box', $post_type, 'side', 'high' );
164 + }
165 +
166 + /* all taxonomies */
167 + foreach ( get_object_taxonomies( $post_type ) as $tax_name ) {
168 + $taxonomy = get_taxonomy( $tax_name );
169 + if ( ! $taxonomy->show_ui ) {
170 + continue;
134 171 }
135 - $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
136 - $data['user']['email'] = $_POST['email'];
137 - $data['uniq_key']['sendid'] = $_POST['sendid'];
138 - $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
139 -
140 - }else{
141 - $data['authentication']['clientip'] = $acting_opts['clientip'];
142 - $data['authentication']['key'] = $acting_opts['authkey'];
143 - $data['card']['number'] = $_POST['cardnumber'];
144 - $data['card']['expires']['year'] = (int)$_POST['expyy'];
145 - $data['card']['expires']['month'] = (int)$_POST['expmm'];
146 - if( 1 == $acting_opts['security'] ){
147 - $data['card']['cvv'] = $_POST['securecode'];
172 + $label = $taxonomy->labels->name;
173 +
174 + if ( ! is_taxonomy_hierarchical( $tax_name ) ) {
175 + add_meta_box( 'tagsdiv-' . $tax_name, $label, 'usces_post_tags_meta_box', $post_type, 'side', 'core' );
176 + } else {
177 + add_meta_box( $tax_name . 'div', $label, 'usces_post_categories_meta_box', $post_type, 'side', 'core', array( 'taxonomy' => $tax_name, 'descendants_and_self' => USCES_ITEM_CAT_PARENT_ID ) );
148 178 }
149 - $data['card']['name'] = $_POST['username'];
150 - $data['payment']['amount'] = $_POST['money'];
151 - if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
152 - $data['payment']['count'] = $_POST['div'];
153 - }else{
154 - $data['payment']['count'] = '01';
179 + }
180 +
181 + if ( post_type_supports( $post_type, 'page-attributes' ) ) {
182 + add_meta_box( 'pageparentdiv', 'page' === $post_type ? __( 'Page Attributes' ) : __( 'Attributes' ), 'usces_page_attributes_meta_box', $post_type, 'side', 'core' );
183 + }
184 + if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ) ) {
185 + add_meta_box( 'postimagediv', __( 'Featured image', 'usces' ), 'usces_post_thumbnail_meta_box', $post_type, 'side', 'low' );
186 + }
187 + if ( post_type_supports( $post_type, 'excerpt' ) ) {
188 + add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'usces_post_excerpt_meta_box', $post_type, 'normal', 'core' );
189 + }
190 + if ( post_type_supports( $post_type, 'trackbacks' ) ) {
191 + add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'usces_post_trackback_meta_box', $post_type, 'normal', 'core' );
192 + }
193 + if ( post_type_supports( $post_type, 'custom-fields' ) ) {
194 + add_meta_box( 'postcustom', __( 'Custom Fields' ), 'usces_post_custom_meta_box', $post_type, 'normal', 'core' );
195 + }
196 + if ( post_type_supports( $post_type, 'comments' ) ) {
197 + add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'usces_post_comment_status_meta_box', $post_type, 'normal', 'core' );
198 + }
199 + if ( ( isset( $post->post_status ) && ( 'publish' === $post->post_status || 'private' === $post->post_status ) ) && post_type_supports( $post_type, 'comments' ) ) {
200 + add_meta_box( 'commentsdiv', __( 'Comments' ), 'usces_post_comment_meta_box', $post_type, 'normal', 'core' );
201 + }
202 + if ( ! ( ( isset( $post->post_status ) && 'pending' === $post->post_status ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
203 + add_meta_box( 'slugdiv', __( 'Slug' ), 'usces_post_slug_meta_box', $post_type, 'normal', 'core' );
204 + }
205 + if ( post_type_supports( $post_type, 'author' ) ) {
206 + if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) {
207 + add_meta_box( 'authordiv', __( 'Author' ), 'usces_post_author_meta_box', $post_type, 'normal', 'core' );
155 208 }
156 - $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
157 - $data['user']['email'] = $_POST['email'];
158 - $data['uniq_key']['sendid'] = $_POST['sendid'];
159 - $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
160 209 }
161 -
162 - $EnrolReq = '<?xml version="1.0" encoding="utf-8"?>';
163 - $EnrolReq .= '<request service="secure_link_3d" action="enroll">';
164 - $EnrolReq .= usces_assoc2xml($data);
165 - $EnrolReq .= '</request>';
166 210
211 + if ( post_type_supports( $post_type, 'revisions' ) && 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) {
212 + add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'usces_post_revisions_meta_box', $post_type, 'normal', 'core' );
213 + }
167 214
168 - $xml = usces_get_xml($acting_opts['card_secureurl'], $EnrolReq);
169 - if ( empty($xml) ){
170 - usces_log('zeus : EnrolRes Error', 'acting_transaction.log');
171 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=EnrolReq&code=0');
172 - exit;
215 + $current_screen->base = $post_type;
216 + $current_screen->id = $post_type;
217 + $current_screen->post_type = $post_type;
218 +}
219 +
220 +/**
221 + * Edit Item Page Header.
222 + * admin_head-welcart-shop_page_usces_itemedit
223 + */
224 +function admin_prodauct_header() {
225 +
226 + $wp_version = get_bloginfo( 'version' );
227 + if ( version_compare( $wp_version, '3.4-beta3', '<' ) ) {
228 + return;
173 229 }
230 + if ( isset( $_REQUEST['action'] ) && 'edit' === $_REQUEST['action'] ) {
174 231
175 - $EnrolRes = usces_xml2assoc($xml);
176 - usces_log('EnrolRes : ' . print_r($EnrolRes, true), 'acting_transaction.log');
177 -
178 - if( 'outside' == $EnrolRes['response']['result']['status'] ){
179 -
180 - usces_log('EnrolRes : outside', 'acting_transaction.log');
181 - usces_auth_order_acting_data($_POST['sendpoint']);
182 -
183 - $data = array();
184 - $data['xid'] = $EnrolRes['response']['xid'];//$_REQUEST['MD'];
185 - $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
186 - $PayReq .= '<request service="secure_link_3d" action="payment">';
187 - $PayReq .= usces_assoc2xml($data);
188 - $PayReq .= '</request>';
189 -
190 - //usces_log('zeus : PayReq1'.print_r($PayReq, true), 'acting_transaction.log');
191 - $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
192 - //usces_log('zeus : PayReq2'.print_r($xml, true), 'acting_transaction.log');
193 - if ( empty($xml) ){
194 - usces_log('zeus : PayRes Error', 'acting_transaction.log');
195 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayRes&code=0');
196 - exit;
197 - }
232 + $suport_display = '<p>' . __( 'Product registration documentation', 'usces' ) . '<br /><a href="http://www.welcart.com/documents/manual-2/%E6%96%B0%E8%A6%8F%E5%95%86%E5%93%81%E8%BF%BD%E5%8A%A0" target="_new">' . __( 'Product editing screen', 'usces' ) . '</a></p>';
198 233
234 + get_current_screen()->add_help_tab(
235 + array(
236 + 'id' => 'suport-display',
237 + 'title' => 'Documents',
238 + 'content' => $suport_display,
239 + )
240 + );
241 + }
242 +}
199 243
200 - $PayRes = usces_xml2assoc($xml);
201 - usces_log('usces_zeus_3dsecure_enrol : PayRes '.print_r($PayRes, true), 'acting_transaction.log');
202 -
203 - if( 'success' != $PayRes['response']['result']['status'] ){
204 - usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
205 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
206 - exit;
207 - }else{
208 - //usces_log('zeus : PayRes '.print_r($PayRes, true), 'acting_transaction.log');
209 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=1&zeussuffix=' . $PayRes['response']['card']['number']['suffix'] . '&zeusyear=' . $PayRes['response']['card']['expires']['year'] . '&zeusmonth=' . $PayRes['response']['card']['expires']['month'] . '&zeusordd=' . $PayRes['response']['order_number'] . '&wctid=' . $_POST['sendpoint']);
210 - exit;
211 - }
212 - exit;
213 -
214 - }elseif( 'success' == $EnrolRes['response']['result']['status'] ){
215 -
216 - usces_log('EnrolRes : success', 'acting_transaction.log');
217 - usces_auth_order_acting_data($_POST['sendpoint']);
218 -
219 - ?>
220 - <form name="zeus" action="<?php echo $EnrolRes['response']['redirection']['acs_url']; ?>" method="post">
221 - <input name="MD" type="hidden" value="<?php echo $EnrolRes['response']['xid']; ?>" />
222 - <input name="PaReq" type="hidden" value="<?php echo $EnrolRes['response']['redirection']['PaReq']; ?>" />
223 - <input name="TermUrl" type="hidden" value="<?php echo USCES_CART_URL . $usces->delim . 'purchase=1&PaRes=1&sendpoint=' . $_POST['sendpoint']; ?>" />
224 - </form>
225 - <script type="text/javascript">document.zeus.submit();</script>
226 - <?php
227 -
228 - exit;
229 -
230 - }else{
231 -
232 - usces_log('zeus bad status : status=' . $EnrolRes['response']['result']['status'] . ' code=' . $EnrolRes['response']['result']['code'], 'acting_transaction.log');
233 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $EnrolRes['response']['result']['status'] . '&code=' . $EnrolRes['response']['result']['code']);
234 - exit;
244 +/**
245 + * New Item Page Header.
246 + * admin_head-welcart-shop_page_usces_itemnew
247 + */
248 +function admin_new_prodauct_header() {
249 +
250 + $wp_version = get_bloginfo( 'version' );
251 + if ( version_compare( $wp_version, '3.4-beta3', '<' ) ) {
252 + return;
235 253 }
254 + $customize_display = '<p>' . __( 'The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.' ) . '</p>';
236 255
256 + get_current_screen()->add_help_tab(
257 + array(
258 + 'id' => 'customize-display',
259 + 'title' => __( 'Customizing This Display' ),
260 + 'content' => $customize_display,
261 + )
262 + );
237 263 }
238 264
239 -function usces_zeus_3dsecure_auth(){
240 - global $usces;
241 -
242 - $acting_opts = $usces->options['acting_settings']['zeus'];
265 +/**
266 + * Delete member payment information.
267 + *
268 + * @param string $id Meta key.
269 + */
270 +function usces_clear_quickcharge( $id ) {
271 + global $wpdb;
272 + $table_name = usces_get_tablename( 'usces_member_meta' );
273 + $query = $wpdb->prepare( "DELETE FROM $table_name WHERE meta_key = %s", $id );
274 + $res = $wpdb->query( $query );
243 275
244 - $data = array();
245 - $data['xid'] = $_REQUEST['MD'];
246 - $data['PaRes'] = $_REQUEST['PaRes'];
247 - $AuthReq = '<?xml version="1.0" encoding="utf-8" ?>';
248 - $AuthReq .= '<request service="secure_link_3d" action="authentication">';
249 - $AuthReq .= usces_assoc2xml($data);
250 - $AuthReq .= '</request>';
276 + return $res;
277 +}
251 278
252 - $xml = usces_get_xml($acting_opts['card_secureurl'], $AuthReq);
253 - if ( strpos($xml, 'Invalid') ){
254 - usces_log('zeus : AuthReq Error'.print_r($xml, true), 'acting_transaction.log');
255 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=AuthReq&code=0');
256 - exit;
279 +/**
280 + * Admin notice action.
281 + *
282 + * @param string $status Status.
283 + * @param string $message Message.
284 + */
285 +function usces_admin_action_status( $status = '', $message = '' ) {
286 + global $usces;
287 + if ( empty( $status ) ) {
288 + $status = $usces->action_status;
289 + $usces->action_status = 'none';
257 290 }
258 - //usces_log('xml : '.print_r($xml, true), 'acting_transaction.log');
259 -
260 - $AuthRes = usces_xml2assoc($xml);
261 - usces_log('usces_zeus_3dsecure_auth : AuthRes '.print_r($AuthRes, true), 'acting_transaction.log');
262 -
263 - if( 'success' != $AuthRes['response']['result']['status'] ){
264 - usces_log('zeus bad status : status=' . $AuthRes['response']['result']['status'] . ' code=' . $AuthRes['response']['result']['code'], 'acting_transaction.log');
265 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $AuthRes['response']['result']['status'] . '&code=' . $AuthRes['response']['result']['code']);
266 - exit;
291 + if ( empty( $message ) ) {
292 + $message = $usces->action_message;
293 + $usces->action_message = '';
267 294 }
268 -
269 -
270 - $data = array();
271 - $data['xid'] = $_REQUEST['MD'];
272 - $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
273 - $PayReq .= '<request service="secure_link_3d" action="payment">';
274 - $PayReq .= usces_assoc2xml($data);
275 - $PayReq .= '</request>';
295 + $class = '';
296 + if ( 'success' === $status ) {
297 + $class = 'updated';
298 + } elseif ( 'caution' === $status ) {
299 + $class = 'update-nag';
300 + } elseif ( 'error' === $status ) {
301 + $class = 'error';
302 + }
303 + if ( '' !== $class ) {
304 + ?>
305 +<div id="usces_admin_status">
306 + <div id="usces_action_status" class="<?php echo esc_attr( $class ); ?> notice is-dismissible">
307 + <p><strong><?php echo wp_kses_post( $message ); ?></strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'usces' ); ?></span></button>
308 + </div>
309 +</div>
310 + <?php
311 + } else {
312 + ?>
313 +<div id="usces_admin_status"></div>
314 + <?php
315 + }
316 +}
276 317
277 -//usces_log('zeus : PayReq1'.print_r($PayReq, true), 'acting_transaction.log');
278 - $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
279 -//usces_log('zeus : PayReq2'.print_r($xml, true), 'acting_transaction.log');
280 - if ( empty($xml) ){
281 - usces_log('zeus : PayRes Error', 'acting_transaction.log');
282 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayRes&code=0');
283 - exit;
318 +/**
319 + * Admin notice messages.
320 + */
321 +function usces_get_admin_script_message() {
322 + $mes_str = '';
323 + $message = array();
324 + $message[] = __( 'Please enter the option name.', 'usces' ); /* 0 */
325 + $message[] = __( 'The same option name exists.', 'usces' ); /* 1 */
326 + $message[] = __( 'Please enter the select value.', 'usces' ); /* 2 */
327 + $message[] = __( 'Leave the select value blank for text and textarea.', 'usces' ); /* 3 */
328 + $message[] = __( 'Please enter the SKU code value.', 'usces' ); /* 4 */
329 + $message[] = __( 'Please enter the sale price value.', 'usces' ); /* 5 */
330 + $message[] = __( 'Enter the SKU code in single-byte alphanumeric characters (including-_).', 'usces' ); /* 6 */
331 + $message[] = __( 'Enter the normal price numerically.', 'usces' ); /* 7 */
332 + $message[] = __( 'Enter the sale price numerically.', 'usces' ); /* 8 */
333 + $message[] = __( 'Enter the stock numerically.', 'usces' ); /* 9 */
334 + $message[] = __( 'The same SKU code exists.', 'usces' ); /* 10 */
335 + $message[] = __( 'Please enter the payment method name value.', 'usces' ); /* 11 */
336 + $message[] = __( 'Please select the payment type.', 'usces' ); /* 12 */
337 + $message[] = __( 'Please enter the value for the payment module.', 'usces' ); /* 13 */
338 + $message[] = __( 'The same payment method name exists.', 'usces' ); /* 14 */
339 + $message[] = __( 'Chose the %s', 'usces' ); /* 15 */
340 + $message[] = __( 'Input the %s', 'usces' ); /* 16 */
341 + $message[] = __( 'Please enter a numeric value.', 'usces' ); /* 17 */
342 + $message[] = __( 'Delete', 'usces' ); /* 18 */
343 + $message[] = __( 'Dismiss this notice.', 'usces' ); /* 19 */
344 + $message[] = __( ' - ', 'usces' ); /* 20 */
345 + $message[] = __( 'Enter the field key in single-byte alphanumeric characters (including-_).', 'usces' ); /* 21 */
346 + $message[] = __( 'Please enter the field name.', 'usces' ); /* 22 */
347 + $message[] = __( 'The same value as the field key exists.', 'usces' ); /* 23 */
348 + $message[] = __( 'The same value as the field name exists.', 'usces' ); /* 24 */
349 + $message[] = __( 'Delete SKU (********). Are you sure?', 'usces' ); /* 25 */
350 + $message = apply_filters( 'usces_filter_admin_script_message', $message );
351 + foreach ( (array) $message as $key => $mes ) {
352 + $mes_str .= "'" . $mes . "',";
284 353 }
285 -
286 - $PayRes = usces_xml2assoc($xml);
287 - usces_log('usces_zeus_3dsecure_auth : PayReq '.print_r($PayReq, true), 'acting_transaction.log');
288 -
289 - if( 'success' != $PayRes['response']['result']['status'] ){
290 - usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
291 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
292 - exit;
293 - }else{
294 - //usces_log('zeus : PayRes '.print_r($PayRes, true), 'acting_transaction.log');
295 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=1&zeussuffix=' . $PayRes['response']['card']['number']['suffix'] . '&zeusyear=' . $PayRes['response']['card']['expires']['year'] . '&zeusmonth=' . $PayRes['response']['card']['expires']['month'] . '&zeusordd=' . $PayRes['response']['order_number'] . '&wctid=' . $_REQUEST['sendpoint']);
296 - exit;
354 + $mes_str = rtrim( $mes_str, ',' );
355 + return $mes_str;
356 +}
357 +
358 +/**
359 + * Force the payment ID to be displayed in the order list.
360 + */
361 +function usces_admin_orderlist_show_wc_trans_id() {
362 +
363 + $list_option = get_option( 'usces_orderlist_option', array() );
364 + $wc_trans_id = ( isset( $list_option['view_column']['wc_trans_id'] ) ) ? $list_option['view_column']['wc_trans_id'] : 0;
365 + if ( empty( $wc_trans_id ) ) {
366 + $list_option['view_column']['wc_trans_id'] = 1;
367 + update_option( 'usces_orderlist_option', $list_option );
297 368 }
298 - exit;
299 369 }
300 370
301 -function usces_zeus_secure_payreq(){
371 +/**
372 + * Optional control of mail settings page.
373 + * admin_print_footer_scripts
374 + */
375 +function usces_admin_print_footer_scripts() {
302 376 global $usces;
303 -
304 - $acting_opts = $usces->options['acting_settings']['zeus'];
305 377
306 - $member = $usces->get_member();
307 - $pcid = $usces->get_member_meta_value('zeus_pcid', $member['ID']);
378 + $admin_page = ( isset( $_GET['page'] ) ) ? wp_unslash( $_GET['page'] ) : '';
379 + switch ( $admin_page ) :
380 + case 'usces_mail':
381 + $email_attach_feature = ( isset( $usces->options['email_attach_feature'] ) ) ? $usces->options['email_attach_feature'] : '0';
382 + ?>
383 +<script type="text/javascript">
384 +jQuery( document ).ready( function( $ ) {
385 + var email_attach_feature = "<?php echo esc_js( $email_attach_feature ); ?>";
386 + if ( "1" == email_attach_feature ) {
387 + $( ".email_attach_feature" ).css( "display", "" );
388 + } else {
389 + $( ".email_attach_feature" ).css( "display", "none" );
390 + }
391 + $( document ).on( "change", "input[name='email_attach_feature']", function() {
392 + if ( "1" == $( this ).val() ) {
393 + $( ".email_attach_feature" ).css( "display", "" );
394 + } else {
395 + $( ".email_attach_feature" ).css( "display", "none" );
396 + }
397 + });
398 +});
399 +</script>
400 + <?php
401 + break;
402 + endswitch;
403 +}
308 404
309 - $data = array();
405 +/**
406 + * Mail data.
407 + *
408 + * @return array
409 + */
410 +function usces_mail_data() {
411 + global $usces;
310 412
311 - //if( 2 == $acting_opts['security'] && 'on' == $acting_opts['quickcharge'] && $pcid == '8888888888888888' && $usces->is_member_logged_in() ){
312 - if( 'on' == $acting_opts['quickcharge'] && $pcid == '8888888888888888' && $usces->is_member_logged_in() ){
313 - $data['authentication']['clientip'] = $acting_opts['clientip'];
314 - $data['authentication']['key'] = $acting_opts['authkey'];
315 - $data['card']['history_action_send_email']['key'] = $_POST['sendid'];
316 - $data['payment']['amount'] = $_POST['money'];
317 - if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
318 - $data['payment']['count'] = $_POST['div'];
319 - }else{
320 - $data['payment']['count'] = '01';
413 + $options = get_option( 'usces', array() );
414 + $mail_data_title = $options['mail_data']['title'];
415 + $mail_data_header = $options['mail_data']['header'];
416 + $mail_data_footer = $options['mail_data']['footer'];
417 + foreach ( $mail_data_title as $mail => $value ) {
418 + if ( empty( $value ) && isset( $options['mail_default']['title'][ $mail ] ) ) {
419 + $mail_data_title[ $mail ] = $options['mail_default']['title'][ $mail ];
321 420 }
322 - $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
323 - $data['user']['email'] = $_POST['email'];
324 - $data['uniq_key']['sendid'] = $_POST['sendid'];
325 - $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
326 -
327 - }else{
328 - $data['authentication']['clientip'] = $acting_opts['clientip'];
329 - $data['authentication']['key'] = $acting_opts['authkey'];
330 - $data['card']['number'] = $_POST['cardnumber'];
331 - $data['card']['expires']['year'] = (int)$_POST['expyy'];
332 - $data['card']['expires']['month'] = (int)$_POST['expmm'];
333 - if( 1 == $acting_opts['security'] ){
334 - $data['card']['cvv'] = $_POST['securecode'];
421 + }
422 + foreach ( $mail_data_header as $mail => $value ) {
423 + if ( empty( $value ) && isset( $options['mail_default']['header'][ $mail ] ) ) {
424 + $mail_data_header[ $mail ] = $options['mail_default']['header'][ $mail ];
335 425 }
336 - $data['card']['name'] = $_POST['username'];
337 - $data['payment']['amount'] = $_POST['money'];
338 - if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ){
339 - $data['payment']['count'] = $_POST['div'];
340 - }else{
341 - $data['payment']['count'] = '01';
426 + }
427 + foreach ( $mail_data_footer as $mail => $value ) {
428 + if ( empty( $value ) && isset( $options['mail_default']['footer'][ $mail ] ) ) {
429 + $mail_data_footer[ $mail ] = $options['mail_default']['footer'][ $mail ];
342 430 }
343 - $data['user']['telno'] = str_replace('-', '', $_POST['telno']);
344 - $data['user']['email'] = $_POST['email'];
345 - $data['uniq_key']['sendid'] = $_POST['sendid'];
346 - $data['uniq_key']['sendpoint'] = $_POST['sendpoint'];
347 431 }
432 + $mail_thankyou = get_option( 'usces_mail_thankyou', array( 'title' => $mail_data_title['thankyou'], 'header' => $mail_data_header['thankyou'], 'footer' => $mail_data_footer['thankyou'] ) );
433 + $mail_order = get_option( 'usces_mail_order', array( 'title' => $mail_data_title['order'], 'header' => $mail_data_header['order'], 'footer' => $mail_data_footer['order'] ) );
434 + $mail_inquiry = get_option( 'usces_mail_inquiry', array( 'title' => $mail_data_title['inquiry'], 'header' => $mail_data_header['inquiry'], 'footer' => $mail_data_footer['inquiry'] ) );
435 + $mail_membercomp = get_option( 'usces_mail_membercomp', array( 'title' => $mail_data_title['membercomp'], 'header' => $mail_data_header['membercomp'], 'footer' => $mail_data_footer['membercomp'] ) );
436 + $mail_completionmail = get_option( 'usces_mail_completionmail', array( 'title' => $mail_data_title['completionmail'], 'header' => $mail_data_header['completionmail'], 'footer' => $mail_data_footer['completionmail'] ) );
437 + $mail_ordermail = get_option( 'usces_mail_ordermail', array( 'title' => $mail_data_title['ordermail'], 'header' => $mail_data_header['ordermail'], 'footer' => $mail_data_footer['ordermail'] ) );
438 + $mail_changemail = get_option( 'usces_mail_changemail', array( 'title' => $mail_data_title['changemail'], 'header' => $mail_data_header['changemail'], 'footer' => $mail_data_footer['changemail'] ) );
439 + $mail_receiptmail = get_option( 'usces_mail_receiptmail', array( 'title' => $mail_data_title['receiptmail'], 'header' => $mail_data_header['receiptmail'], 'footer' => $mail_data_footer['receiptmail'] ) );
440 + $mail_mitumorimail = get_option( 'usces_mail_mitumorimail', array( 'title' => $mail_data_title['mitumorimail'], 'header' => $mail_data_header['mitumorimail'], 'footer' => $mail_data_footer['mitumorimail'] ) );
441 + $mail_cancelmail = get_option( 'usces_mail_cancelmail', array( 'title' => $mail_data_title['cancelmail'], 'header' => $mail_data_header['cancelmail'], 'footer' => $mail_data_footer['cancelmail'] ) );
442 + $mail_othermail = get_option( 'usces_mail_othermail', array( 'title' => $mail_data_title['othermail'], 'header' => $mail_data_header['othermail'], 'footer' => $mail_data_footer['othermail'] ) );
348 443
349 - $PayReq = '<?xml version="1.0" encoding="utf-8" ?>';
350 - $PayReq .= '<request service="secure_link" action="payment">';
351 - $PayReq .= usces_assoc2xml($data);
352 - $PayReq .= '</request>';
444 + $mail_data = array();
445 + $mail_data['title'] = array(
446 + 'thankyou' => $mail_thankyou['title'],
447 + 'order' => $mail_order['title'],
448 + 'inquiry' => $mail_inquiry['title'],
449 + 'membercomp' => $mail_membercomp['title'],
450 + 'completionmail' => $mail_completionmail['title'],
451 + 'ordermail' => $mail_ordermail['title'],
452 + 'changemail' => $mail_changemail['title'],
453 + 'receiptmail' => $mail_receiptmail['title'],
454 + 'mitumorimail' => $mail_mitumorimail['title'],
455 + 'cancelmail' => $mail_cancelmail['title'],
456 + 'othermail' => $mail_othermail['title'],
457 + );
458 + $mail_data['header'] = array(
459 + 'thankyou' => $mail_thankyou['header'],
460 + 'order' => $mail_order['header'],
461 + 'inquiry' => $mail_inquiry['header'],
462 + 'membercomp' => $mail_membercomp['header'],
463 + 'completionmail' => $mail_completionmail['header'],
464 + 'ordermail' => $mail_ordermail['header'],
465 + 'changemail' => $mail_changemail['header'],
466 + 'receiptmail' => $mail_receiptmail['header'],
467 + 'mitumorimail' => $mail_mitumorimail['header'],
468 + 'cancelmail' => $mail_cancelmail['header'],
469 + 'othermail' => $mail_othermail['header'],
470 + );
471 + $mail_data['footer'] = array(
472 + 'thankyou' => $mail_thankyou['footer'],
473 + 'order' => $mail_order['footer'],
474 + 'inquiry' => $mail_inquiry['footer'],
475 + 'membercomp' => $mail_membercomp['footer'],
476 + 'completionmail' => $mail_completionmail['footer'],
477 + 'ordermail' => $mail_ordermail['footer'],
478 + 'changemail' => $mail_changemail['footer'],
479 + 'receiptmail' => $mail_receiptmail['footer'],
480 + 'mitumorimail' => $mail_mitumorimail['footer'],
481 + 'cancelmail' => $mail_cancelmail['footer'],
482 + 'othermail' => $mail_othermail['footer'],
483 + );
484 + return apply_filters( 'usces_filter_mail_data', $mail_data, $mail_data_title, $mail_data_header, $mail_data_footer );
485 +}
353 486
354 - $xml = usces_get_xml($acting_opts['card_secureurl'], $PayReq);
355 - if ( empty($xml) ){
356 - usces_log('zeus : PayReq Error', 'acting_transaction.log');
357 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=PayReq&code=0');
358 - exit;
359 - }
487 +/**
488 + * Hide the none item categories in the "Item category" tab of the category post box.
489 + * Implementation of the "admin_print_footer_scripts" action hook.
490 + *
491 + * @return void
492 + */
493 +function usces_hide_none_item_cat() {
494 + global $wp_version;
495 + $current_page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
496 + $is_new_or_edit_item = in_array( $current_page, array( 'usces_itemnew', 'usces_itemedit' ), true );
497 + if ( $is_new_or_edit_item ) :
498 + $item_cats = get_term_children( USCES_ITEM_CAT_PARENT_ID, 'category' );
499 + if ( version_compare( $wp_version, '6.7', '>=' ) ) {
500 + $li_category_id = '[id*="in-category-' . USCES_ITEM_CAT_PARENT_ID . '-"]';
501 + $li_category_prefix = 'in-category-';
502 + } else {
503 + $li_category_id = '#category-' . USCES_ITEM_CAT_PARENT_ID;
504 + $li_category_prefix = 'category-';
505 + }
506 + $item_cat_checkbox_ids = array( $li_category_id );
507 + foreach ( $item_cats as $item_cat_id ) {
508 + if ( version_compare( $wp_version, '6.7', '>=' ) ) {
509 + $li_category_id = '[id*="in-category-' . $item_cat_id . '-"]';
510 + } else {
511 + $li_category_id = '#category-' . $item_cat_id;
512 + }
513 + $item_cat_checkbox_ids[] = $li_category_id;
514 + }
515 + $item_cat_checkbox_ids_str = implode( ',', $item_cat_checkbox_ids );
516 + ?>
517 +<script>
518 + (function($) {
519 + $('#category-all ul#categorychecklist li[id*="<?php echo esc_attr( $li_category_prefix ); ?>"]').not('<?php wel_esc_script_e( $item_cat_checkbox_ids_str ); ?>').hide();
520 + })(jQuery);
521 +</script>
522 + <?php
523 + endif;
524 +}
360 525
361 - usces_auth_order_acting_data($_POST['sendpoint']);
526 +/**
527 + * Whether Welcart was installed for the first time.
528 + *
529 + * @return boolean
530 + */
531 +function wel_is_first_install() {
532 + global $wpdb;
362 533
363 - $PayRes = usces_xml2assoc($xml);
364 - usces_log('usces_zeus_secure_payreq : PayRes'.print_r($PayRes, true), 'acting_transaction.log');
365 -
366 - if( 'success' == $PayRes['response']['result']['status'] ){
367 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=1&zeussuffix=' . $PayRes['response']['card']['number']['suffix'] . '&zeusyear=' . $PayRes['response']['card']['expires']['year'] . '&zeusmonth=' . $PayRes['response']['card']['expires']['month'] . '&zeusordd=' . $PayRes['response']['order_number'] . '&wctid=' . $_POST['sendpoint']);
368 - exit;
369 - }else{
370 - usces_log('zeus bad status : status=' . $PayRes['response']['result']['status'] . ' code=' . $PayRes['response']['result']['code'], 'acting_transaction.log');
371 - header("Location: " . USCES_CART_URL . $usces->delim . 'acting=zeus_card&acting_return=0&status=' . $PayRes['response']['result']['status'] . '&code=' . $PayRes['response']['result']['code']);
372 - exit;
534 + $target = $wpdb->get_col(
535 + $wpdb->prepare(
536 + "SELECT ID FROM $wpdb->posts
537 + WHERE (post_status = %s OR post_status = %s OR post_status = %s OR post_status = %s OR post_status LIKE %s )
538 + AND post_type = %s AND post_mime_type = %s",
539 + 'publish',
540 + 'private',
541 + 'future',
542 + 'pending',
543 + '%draft%',
544 + 'post',
545 + 'item'
546 + )
547 + );
548 +
549 + if ( is_array( $target ) && 0 < count( $target ) ) {
550 + return false;
551 + } else {
552 + return true;
373 553 }
374 554 }
375 555
376 -function usces_xml2assoc($xml) {
377 - $arr = array();
378 - if (!preg_match_all('|\<\s*?(\w+).*?\>(.*)\<\/\s*\\1.*?\>|s', $xml, $m)) return $xml;
379 - if (is_array($m[1]))
380 - for ($i = 0;$i < sizeof($m[1]); $i++) $arr[$m[1][$i]] = usces_xml2assoc($m[2][$i]);
381 - else $arr[$m[1]] = usces_xml2assoc($m[2]);
556 +/**
557 + * Get the circulation amount in the last month.
558 + *
559 + * @return int
560 + */
561 +function wel_get_circulating_amount() {
562 + global $wpdb;
382 563
383 - return $arr;
384 -}
385 -function usces_assoc2xml($prm_array){
386 - $xml = '';
387 - if(is_array($prm_array)){
388 - $i=0;
389 - foreach ($prm_array as $index => $element){
390 - if(is_array($element)){
391 - $acts = explode('_', $index, 3);
392 - if( 2 < count($acts) && 'history' == $acts[0] && 'action' == $acts[1] ){
393 - $xml .= '<history action="' . $acts[2] . '">';
394 - $xml .= usces_assoc2xml($element);
395 - $xml .= '</history>';
396 - }else{
397 - $xml .= '<' . $index . '>';
398 - $xml .= usces_assoc2xml($element);
399 - $xml .= '</' . $index . '>';
400 - }
401 - }else{
402 - $xml .= '<' . $index . '>' . $element . '</' . $index . '>';
403 - }
404 - if($i>500) break;
405 - }
406 - }
407 - return $xml;
408 -}
409 -function usces_get_xml($url, $paras){
410 - $interface = parse_url($url);
411 - $header = "POST " . $interface['path'] . " HTTP/1.1\r\n";
412 - $header .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n";
413 - $header .= "User-Agent: PHP Script\r\n";
414 - $header .= "Content-Type: text/xml\r\n";
415 - $header .= "Content-Length: " . strlen($paras) . "\r\n";
416 - $header .= "Connection: close\r\n\r\n";
417 - $header .= $paras;
418 - $fp = fsockopen('ssl://'.$interface['host'],443,$errno,$errstr,30);
419 - //usces_log('header : '.print_r($header, true), 'acting_transaction.log');
420 -
421 - $xml = '';
422 - if ($fp){
423 - fwrite($fp, $header);
424 - while ( !feof($fp) ) {
425 - $xml .= fgets($fp, 1024);
564 + $current_time = current_time( 'timestamp' );
565 + $last_month_time = strtotime( 'first day of last month 00:00:00', $current_time );
566 + $last_month = wp_date( 'Y-m-d H:i:s', $last_month_time );
567 + $this_month_time = strtotime( 'first day of this month 00:00:00', $current_time );
568 + $this_month = wp_date( 'Y-m-d H:i:s', $this_month_time );
569 + $next_month_time = strtotime( 'last day of this month 23:59:59', $this_month_time );
570 + $next_month = wp_date( 'Y-m-d H:i:s', $next_month_time );
571 +
572 + $table_name = $wpdb->prefix . 'usces_order';
573 + $normal_res = $wpdb->get_row(
574 + $wpdb->prepare(
575 + "SELECT SUM(
576 + order_item_total_price + order_shipping_charge + order_cod_fee + order_tax - order_usedpoint + order_discount
577 + ) AS total_full_price, COUNT(*) AS count
578 + FROM {$table_name}
579 + WHERE order_status NOT LIKE %s
580 + AND order_status NOT LIKE %s
581 + AND order_status NOT LIKE %s
582 + AND order_date >= %s
583 + AND order_date < %s",
584 + '%%mitumori%%',
585 + '%%cancel%%',
586 + '%%pending%%',
587 + $last_month,
588 + $this_month
589 + ),
590 + ARRAY_A
591 + );
592 +
593 + $normal = array(
594 + 'total_full_price' => isset( $normal_res['total_full_price'] ) ? (int) $normal_res['total_full_price'] : 0,
595 + 'count' => isset( $normal_res['count'] ) ? (int) $normal_res['count'] : 0,
596 + );
597 +
598 + $continue = array(
599 + 'total_con_price' => 0,
600 + 'count' => 0,
601 + );
602 + if ( defined( 'WCEX_DLSELLER' ) ) {
603 + $access_table = $wpdb->prefix . 'usces_continuation';
604 + if ( $access_table !== $wpdb->get_var( "SHOW TABLES LIKE '$access_table'" ) ) {
605 + $conres = array(
606 + 'total_con_price' => 0,
607 + 'count' => 0,
608 + );
609 + } else {
610 + $this_month = substr( $this_month, 0, 10 );
611 + $next_month = substr( $next_month, 0, 10 );
612 + $conres = $wpdb->get_row(
613 + $wpdb->prepare(
614 + "SELECT SUM( con_price ) AS total_con_price, COUNT(*) AS count FROM {$access_table}
615 + WHERE con_status = %s
616 + AND con_next_charging >= %s AND con_next_charging <= %s",
617 + 'continuation',
618 + $this_month,
619 + $next_month
620 + ),
621 + ARRAY_A
622 + );
426 623 }
427 - fclose($fp);
624 +
625 + $continue = array(
626 + 'total_con_price' => isset( $conres['total_con_price'] ) ? (int) $conres['total_con_price'] : 0,
627 + 'count' => isset( $conres['count'] ) ? (int) $conres['count'] : 0,
628 + );
428 629 }
429 - //usces_log('get_return : '.print_r($xml, true), 'acting_transaction.log');
430 -
431 - return $xml;
630 + $result = array(
631 + 'amount' => (int) $normal['total_full_price'] + (int) $continue['total_con_price'],
632 + 'count' => (int) $normal['count'] + (int) $continue['count'],
633 + );
634 + return $result;
432 635 }
433 636
434 -//function admin_prodauct_meta_box(){
435 -// $wp_version = get_bloginfo('version');
436 -// if (version_compare($wp_version, '3.4-beta3', '<'))
437 -// return;
438 -//
439 -// if ( 'usces_itemedit' == $_GET['page'] && !isset($_GET['action']))
440 -// return;
441 -//
442 -//
443 -//}
637 +/**
638 + * Get item categories.
639 + *
640 + * @return string
641 + */
642 +function wel_get_categories() {
444 643
445 -function admin_prodauct_current_screen(){
446 - global $current_screen, $post;
644 + $parent_category_slug = 'itemgenre';
645 + $parent_category = get_category_by_slug( $parent_category_slug );
447 646
647 + if ( $parent_category ) {
648 + $categories = get_categories(
649 + array(
650 + 'taxonomy' => 'category',
651 + 'hide_empty' => 0,
652 + 'parent' => $parent_category->term_id,
653 + )
654 + );
655 + }
448 656
449 -
450 - $wp_version = get_bloginfo('version');
451 - if (version_compare($wp_version, '3.4-beta3', '<'))
452 - return;
453 -
454 - if ( !(isset($_GET['page']) && (('usces_itemedit' == $_GET['page'] && isset($_GET['action'])) || 'usces_itemnew' == $_GET['page'])) )
455 - return;
456 -
457 - if ( isset( $_GET['post'] ) )
458 - $post_id = $post_ID = (int) $_GET['post'];
459 - elseif ( isset( $_POST['post_ID'] ) )
460 - $post_id = $post_ID = (int) $_POST['post_ID'];
461 - else
462 - $post_id = $post_ID = 0;
657 + if ( empty( $categories ) ) {
658 + $fallback_category_slug = 'item';
659 + $fallback_category = get_category_by_slug( $fallback_category_slug );
463 660
464 - $post_type = 'post';
465 - $post_type_object = get_post_type_object( $post_type );
661 + if ( $fallback_category ) {
662 + $categories = get_categories(
663 + array(
664 + 'taxonomy' => 'category',
665 + 'hide_empty' => 0,
666 + 'parent' => $fallback_category->term_id,
667 + )
668 + );
669 + }
670 + }
466 671
467 - if ( $post_id ){
468 - $post = get_post( $post_id );
469 - }else{
470 - $post = get_default_post_to_edit( $post_type, true );
471 - $post_ID = $post->ID;
672 + $result = '';
673 + if ( ! empty( $categories ) ) {
674 + foreach ( $categories as $index => $category ) {
675 + if ( 10 > $index ) {
676 + $result .= $category->name . ':';
677 + } else {
678 + break;
679 + }
680 + }
681 + $result = trim( $result, ':' );
472 682 }
473 683
474 - require_once(USCES_PLUGIN_DIR.'/includes/meta-boxes.php');
684 + return $result;
685 +}
475 686
476 - add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core');
687 +/**
688 + * Get total number of item categories.
689 + *
690 + * @return int
691 + */
692 +function wel_get_cat_total_num() {
477 693
478 - // all taxonomies
479 - foreach ( get_object_taxonomies($post_type) as $tax_name ) {
480 - $taxonomy = get_taxonomy($tax_name);
481 - if ( ! $taxonomy->show_ui )
482 - continue;
483 -
484 - $label = $taxonomy->labels->name;
485 -
486 - if ( !is_taxonomy_hierarchical($tax_name) )
487 - add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core');
488 - else
489 - add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', $post_type, 'side', 'core', array( 'taxonomy' => $tax_name, 'descendants_and_self' => USCES_ITEM_CAT_PARENT_ID ));
694 + $item_category = get_category_by_slug( 'item' );
695 + if ( $item_category ) {
696 + $args = array(
697 + 'child_of' => $item_category->term_id,
698 + 'taxonomy' => 'category',
699 + 'hide_empty' => false,
700 + );
701 +
702 + $subcategories = get_categories( $args );
703 + $subcategory_count = count( $subcategories );
704 +
705 + } else {
706 + $subcategory_count = 0;
490 707 }
491 -
492 - if ( post_type_supports($post_type, 'page-attributes') )
493 - add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');
494 -
495 - if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports($post_type, 'thumbnail') )
496 - add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
497 -
498 - if ( post_type_supports($post_type, 'excerpt') )
499 - add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
500 -
501 - if ( post_type_supports($post_type, 'trackbacks') )
502 - add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core');
503 -
504 - if ( post_type_supports($post_type, 'custom-fields') )
505 - add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core');
506 -
507 - //do_action('dbx_post_advanced');
508 - if ( post_type_supports($post_type, 'comments') )
509 - add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core');
510 -
511 - if ( (isset($post->post_status) && ('publish' == $post->post_status || 'private' == $post->post_status) ) && post_type_supports($post_type, 'comments') )
512 - add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');
513 -
514 - if ( !( (isset( $post->post_status ) && 'pending' == $post->post_status) && !current_user_can( $post_type_object->cap->publish_posts ) ) )
515 - add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
516 -
517 - if ( post_type_supports($post_type, 'author') ) {
518 - if ( version_compare($wp_version, '3.1', '>=') ){
519 - if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
520 - add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
521 - }else{
522 - $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
523 - if ( isset($post->post_author) && $post->post_author && !in_array($post->post_author, $authors) )
524 - $authors[] = $post->post_author;
525 - if ( ( $authors && count( $authors ) > 1 ) || is_super_admin() )
526 - add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
527 - }
528 - }
529 -
530 - if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
531 - add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
532 -
533 - //add_screen_option('layout_columns', array('max' => 2, 'default' => 2) );
534 708
709 + return (int) $subcategory_count;
710 +}
535 711
536 - $current_screen->base = $post_type;
537 - $current_screen->id = $post_type;
538 - $current_screen->post_type = $post_type;
539 - //usces_p($current_screen);
712 +/**
713 + * Get total number of SKU.
714 + *
715 + * @return int
716 + */
717 +function wel_get_sku_total_num() {
718 + global $wpdb;
540 719
541 -}
720 + $status = array();
721 + $sku_table = $wpdb->prefix . 'usces_skus';
542 722
543 -function admin_prodauct_header(){
723 + $data = $wpdb->get_var(
724 + $wpdb->prepare(
725 + "SELECT COUNT(*) AS sku_num FROM {$wpdb->posts} LEFT JOIN {$sku_table} ON ID = post_id
726 + WHERE post_mime_type = %s AND post_type = %s AND post_status <> %s",
727 + 'item',
728 + 'post',
729 + 'trash'
730 + )
731 + );
544 732
545 - $wp_version = get_bloginfo('version');
546 - if (version_compare($wp_version, '3.4-beta3', '<'))
547 - return;
548 -
549 - if ( isset($_REQUEST['action'])){
550 -
551 - $suport_display = '<p>'.__('Product registration documentation','usces').'<br /><a href="http://www.welcart.com/documents/manual-2/%E6%96%B0%E8%A6%8F%E5%95%86%E5%93%81%E8%BF%BD%E5%8A%A0" target="_new">'.__('Product editing screen','usces').'</a></p>';
552 -
553 - get_current_screen()->add_help_tab( array(
554 - 'id' => 'suport-display',
555 - 'title' => 'Documents',
556 - 'content' => $suport_display,
557 - ) );
558 -//
559 -// $title_and_editor = '<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>';
560 -// $title_and_editor .= '<p>' . __('<strong>Post editor</strong> - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in HTML mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular post editor.') . '</p>';
561 -//
562 -// get_current_screen()->add_help_tab( array(
563 -// 'id' => 'title-post-editor',
564 -// 'title' => __('Title and Post Editor'),
565 -// 'content' => $title_and_editor,
566 -// ) );
567 -//
568 -// $publish_box = '<p>' . __('<strong>Publish</strong> - You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.') . '</p>';
569 -//
570 -// if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
571 -// $publish_box .= '<p>' . __( '<strong>Post Format</strong> - This designates how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="http://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.' ) . '</p>';
572 -// }
573 -//
574 -// if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
575 -// $publish_box .= '<p>' . __('<strong>Featured Image</strong> - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '</p>';
576 -// }
577 -//
578 -// get_current_screen()->add_help_tab( array(
579 -// 'id' => 'publish-box',
580 -// 'title' => __('Publish Box'),
581 -// 'content' => $publish_box,
582 -// ) );
583 -//
584 -// $discussion_settings = '<p>' . __('<strong>Send Trackbacks</strong> - Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>';
585 -// $discussion_settings .= '<p>' . __('<strong>Discussion</strong> - You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '</p>';
586 -//
587 -// get_current_screen()->add_help_tab( array(
588 -// 'id' => 'discussion-settings',
589 -// 'title' => __('Discussion Settings'),
590 -// 'content' => $discussion_settings,
591 -// ) );
592 -//
593 -// get_current_screen()->set_help_sidebar(
594 -// '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
595 -// '<p><strong>' . __('For more information:') . '</strong></p>' .
596 -// '<p>' . __('<a href="http://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
597 -// '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
598 -// );
599 - }else{
600 -
733 + if ( $data ) {
734 + $res = (int) $data;
735 + } else {
736 + $res = 0;
601 737 }
738 + return $res;
602 739 }
603 740
604 -function admin_new_prodauct_header(){
741 +/**
742 + * Get active theme.
743 + *
744 + * @return string
745 + */
746 +function wel_get_themes() {
747 + $result = '';
605 748
606 - $wp_version = get_bloginfo('version');
607 - if (version_compare($wp_version, '3.4-beta3', '<'))
608 - return;
609 -
610 - $customize_display = '<p>' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '</p>';
749 + $active_theme = wp_get_theme();
750 + $result = $active_theme->get( 'Name' );
611 751
612 - get_current_screen()->add_help_tab( array(
613 - 'id' => 'customize-display',
614 - 'title' => __('Customizing This Display'),
615 - 'content' => $customize_display,
616 - ) );
617 -//
618 -// $title_and_editor = '<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>';
619 -// $title_and_editor .= '<p>' . __('<strong>Post editor</strong> - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in HTML mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular post editor.') . '</p>';
620 -//
621 -// get_current_screen()->add_help_tab( array(
622 -// 'id' => 'title-post-editor',
623 -// 'title' => __('Title and Post Editor'),
624 -// 'content' => $title_and_editor,
625 -// ) );
626 -//
627 -// $publish_box = '<p>' . __('<strong>Publish</strong> - You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.') . '</p>';
628 -//
629 -// if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
630 -// $publish_box .= '<p>' . __( '<strong>Post Format</strong> - This designates how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="http://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.' ) . '</p>';
631 -// }
632 -//
633 -// if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
634 -// $publish_box .= '<p>' . __('<strong>Featured Image</strong> - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '</p>';
635 -// }
636 -//
637 -// get_current_screen()->add_help_tab( array(
638 -// 'id' => 'publish-box',
639 -// 'title' => __('Publish Box'),
640 -// 'content' => $publish_box,
641 -// ) );
642 -//
643 -// $discussion_settings = '<p>' . __('<strong>Send Trackbacks</strong> - Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>';
644 -// $discussion_settings .= '<p>' . __('<strong>Discussion</strong> - You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '</p>';
645 -//
646 -// get_current_screen()->add_help_tab( array(
647 -// 'id' => 'discussion-settings',
648 -// 'title' => __('Discussion Settings'),
649 -// 'content' => $discussion_settings,
650 -// ) );
651 -//
652 -// get_current_screen()->set_help_sidebar(
653 -// '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
654 -// '<p><strong>' . __('For more information:') . '</strong></p>' .
655 -// '<p>' . __('<a href="http://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
656 -// '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
657 -// );
752 + if ( $active_theme->parent() ) {
753 + $parent_theme = $active_theme->parent();
754 + $result .= ' : ' . $parent_theme->get( 'Name' );
755 + }
756 +
757 + return $result;
658 758 }
659 759
660 -function usces_clear_quickcharge( $id ) {
661 - global $wpdb;
662 - $table_name = $wpdb->prefix . 'usces_member_meta';
663 -//$wpdb->show_errors();
664 - $query = $wpdb->prepare( "DELETE FROM $table_name WHERE meta_key = %s", $id );
665 - $res = $wpdb->query( $query );
760 +/**
761 + * Get active plugins.
762 + *
763 + * @return string
764 + */
765 +function wel_get_plugins() {
766 + $result = '';
666 767
667 - return $res;
768 + $all_plugins = get_plugins();
769 + $active_plugins = get_option( 'active_plugins', array() );
770 +
771 + foreach ( $active_plugins as $plugin_path ) {
772 + if ( strpos( $plugin_path, 'wcex' ) === 0 && isset( $all_plugins[ $plugin_path ] ) ) {
773 + $plugin = $all_plugins[ $plugin_path ];
774 + $result .= dirname( $plugin_path ) . '(' . $plugin['Version'] . '):';
775 + }
776 + }
777 + $result = trim( $result, ':' );
778 + return $result;
668 779 }
669 780
670 -function usces_get_order_number( $page ) {
671 - if( empty($page) ) return '';
781 +/**
782 + * Get active payment methods.
783 + *
784 + * @return string
785 + */
786 +function wel_get_activ_pay_methd() {
787 + global $usces;
672 788
673 - $log = explode( "\r\n", $page );
674 - $ordd = '';
675 - foreach( (array)$log as $line ) {
676 - //if( false !== strpos( $line, 'Success_order' ) ) {
677 - if( false !== strpos( $line, 'ordd' ) ) {
678 - //list( $status, $ordd ) = explode( "\n", $line );
679 - list( $status, $ordd ) = explode( "=", $line );
789 + $result = '';
790 + $payment_method = get_option( 'usces_payment_method', array() );
791 +
792 + foreach ( $payment_method as $method ) {
793 + if ( empty( $method['use'] ) || 'activate' !== $method['use'] ) {
794 + continue;
680 795 }
796 + $payname = str_replace( 'acting', '', $method['settlement'] );
797 + $payname = ltrim( $payname, '_' );
798 + if ( empty( $payname ) ) {
799 + $payname = $method['module'];
800 + }
801 + $result .= $payname . ':';
681 802 }
682 - return $ordd;
803 + $result = trim( $result, ':' );
804 + return $result;
683 805 }
684 806
685 -function usces_get_err_code( $page ) {
686 - if( empty($page) ) return '';
687 -
688 - $log = explode( "\r\n", $page );
689 - $err_code = '';
690 - foreach( (array)$log as $line ) {
691 - if( false !== strpos( $line, 'err_code' ) ) {
692 - list( $name, $err_code ) = explode( "=", $line );
807 +/**
808 + * Implementation of hook "init".
809 + * - Activate Paidy payment.
810 + *
811 + * @see includes\default_filters.php
812 + */
813 +function usces_paidyapi() {
814 + $allowed_ip = '52.68.140.181';
815 + $request_ip = isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
816 + $is_allowed_ip = $allowed_ip === $request_ip;
817 + if ( $is_allowed_ip ) {
818 + $method = isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) : 'GET';
819 + $is_post_method = 'POST' === $method;
820 + if ( $is_post_method ) {
821 + $is_paidy_result = filter_input( INPUT_POST, 'paidy_result' );
822 + if ( $is_paidy_result ) {
823 + InstantPaidyDashboard::get_instance()->receive_paidy_result();
824 + }
693 825 }
694 826 }
695 - return $err_code;
696 827 }
697 828
698 -?>
829 +/**
830 + * Prefecture name handler.
831 + *
832 + * This function checks user capability and returns the input as-is.
833 + *
834 + * @param string $pref Input string.
835 + * @return string The original input string (trimmed).
836 + */
837 +function wel_validate_prefecture_name( $pref ) {
838 + if ( ! current_user_can( 'wel_manage_setting' ) ) {
839 + wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
840 + }
841 + return trim( $pref );
842 +}