Changeset 2561870
- Timestamp:
- 07/10/2021 01:05:10 PM (5 years ago)
- Location:
- yektanet-affiliate/trunk
- Files:
-
- 3 edited
-
includes/aw_plugin-database.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
yektanet-affiliate.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
yektanet-affiliate/trunk/includes/aw_plugin-database.php
r2560031 r2561870 24 24 function yektanetaffiliate_create_table () { 25 25 if (get_option('yektanetaffiliate_version') === false) { 26 update_option('yektanetaffiliate_version', '1.0. 6');26 update_option('yektanetaffiliate_version', '1.0.7'); 27 27 } 28 28 if (get_option('yektanetaffiliate_db_version') === false) { -
yektanet-affiliate/trunk/readme.txt
r2560031 r2561870 4 4 Requires at least: 5.4 5 5 Tested up to: 5.7 6 Stable tag: 1.0. 66 Stable tag: 1.0.7 7 7 Requires PHP: 7.0 8 8 License: GPL v2 or later -
yektanet-affiliate/trunk/yektanet-affiliate.php
r2560031 r2561870 6 6 Requires at least: 5.4 7 7 Requires PHP: 7.0 8 Version: 1.0. 68 Version: 1.0.7 9 9 License: GPL v2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 42 42 43 43 if (!defined('YEKTANETAFFILIATE_VERSION')) { 44 define('YEKTANETAFFILIATE_VERSION', '1.0. 6');44 define('YEKTANETAFFILIATE_VERSION', '1.0.7'); 45 45 } 46 46 if (!defined('YEKTANETAFFILIATE_DB_VERSION')) { … … 70 70 71 71 add_action('woocommerce_thankyou', 'yektanetaffiliate_success_page', 10, 1); 72 73 add_action('woocommerce_checkout_order_processed', 'yektanetaffiliate_process', 10, 1); 74 75 add_action('woocommerce_before_cart', 'yektanetaffiliate_cart', 10, 1); 76 77 add_action('woocommerce_review_order_before_payment', 'yektanetaffiliate_checkout', 10, 0); 72 78 73 79 // update check … … 130 136 131 137 function yektanetaffiliate_send_data($order, $partial, $datetime, $type, $status, $new_status) { 132 global $wp;138 global $wp; 133 139 $raw_cookies = (array_reduce( 134 140 explode(';', $_SERVER['HTTP_COOKIE'] ?? ''), … … 207 213 $field['paid_at'] = $datetime->format('Y-m-d\TH:i:sP'); 208 214 } 209 $user_id = wp_get_current_user()->ID; 210 $field['user_id'] = $user_id; 211 $roles = []; 212 foreach (get_user_meta($user_id, 'wp_capabilities', true) as $role => $exist) { 213 if ($exist) { 214 array_push($roles, $role); 215 } 216 } 217 $field['user_roles'] = $roles; 215 global $current_user; 216 $field['user_id'] = wp_get_current_user()->ID; 217 $field['user_roles'] = $current_user->roles; 218 218 $field['items'] = $items_data; 219 219 $fields = array(); … … 247 247 } 248 248 249 function yektanetaffiliate_send_temp_data($status) { 250 global $wp; 251 $raw_cookies = (array_reduce( 252 explode(';', $_SERVER['HTTP_COOKIE'] ?? ''), 253 function($carry, $item) { 254 $pair_arr = explode('=', $item); 255 $carry[ trim($pair_arr[0]) ] = trim($pair_arr[1]); 256 return $carry; 257 }, 258 [] 259 ) ?: []); 260 261 if (!isset($_COOKIE["_yngt"]) || empty($_COOKIE["_yngt"])) { 262 $yngt = ''; 263 } else { 264 $yngt = $raw_cookies["_yngt"]; 265 } 266 if (isset($_COOKIE["analytics_campaign"]) && !empty($_COOKIE["analytics_campaign"])) { 267 $ynsrc = $raw_cookies["analytics_campaign"]; 268 } else if (isset($_COOKIE["_ynsrc"]) && !empty($_COOKIE["_ynsrc"])) { 269 $ynsrc = $raw_cookies["_ynsrc"]; 270 } else { 271 $ynsrc = ''; 272 } 273 $field = [ 274 'ip' => $_SERVER['REMOTE_ADDR'], 275 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 276 'status' => $status, 277 'current_url' => add_query_arg($wp->query_vars, home_url( $wp->request )), 278 'cookies_count' => count($_COOKIE), 279 'yn_ch_test' => $_COOKIE['yn_ch_test'], 280 'ynsrc' => $ynsrc, 281 'yngt' => $yngt, 282 'paid_at' => $_SERVER['REQUEST_TIME'] 283 ]; 284 global $current_user; 285 $field['user_id'] = wp_get_current_user()->ID; 286 $field['user_roles'] = $current_user->roles; 287 $fields = array(); 288 array_push($fields, $field); 289 $token=get_option('yektanetaffiliate_settings')['yektanetaffiliate_token']; 290 $url = 'https://trk.chavosh.org/api/v1/event/'; 291 $header = array(); 292 $header['Content-type'] = 'application/json'; 293 $header['Authorization'] = 'Token ' . $token; 294 $args = array( 295 'body' => json_encode($fields), 296 'headers' => $header, 297 ); 298 $response = wp_remote_post($url ,$args); 299 } 300 301 function yektanetaffiliate_checkout() { 302 yektanetaffiliate_send_temp_data('checkout'); 303 } 304 305 function yektanetaffiliate_cart($temp) { 306 yektanetaffiliate_send_temp_data('cart'); 307 } 308 309 function yektanetaffiliate_process($order_id) { 310 $order = wc_get_order($order_id); 311 $datetime = $order->get_date_paid(); 312 yektanetaffiliate_send_data($order, False, $datetime, 'process', 'pending', 'process'); 313 } 314 249 315 function yektanetaffiliate_success_page($order_id) { 250 316 $order = wc_get_order($order_id);
Note: See TracChangeset
for help on using the changeset viewer.