| 1 |
<?php declare(strict_types=1); |
| 2 |
|
| 3 |
namespace MultiSafepay\WooCommerce\Utils; |
| 4 |
|
| 5 |
/** |
| 6 |
* This class defines methods to handle easily different actions related with the WC_Order object |
| 7 |
*/ |
| 8 |
class QrOrder { |
| 9 |
|
| 10 |
/** |
| 11 |
* Get the customer IP address. |
| 12 |
* |
| 13 |
* @return string |
| 14 |
*/ |
| 15 |
public function get_customer_ip_address(): string { |
| 16 |
$possible_ip_sources = array( |
| 17 |
'HTTP_CLIENT_IP', |
| 18 |
'HTTP_X_FORWARDED_FOR', |
| 19 |
'REMOTE_ADDR', |
| 20 |
); |
| 21 |
|
| 22 |
foreach ( $possible_ip_sources as $source ) { |
| 23 |
if ( ! empty( $_SERVER[ $source ] ) ) { |
| 24 |
return sanitize_text_field( wp_unslash( $_SERVER[ $source ] ) ); |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
return ''; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Get the user agent. |
| 33 |
* |
| 34 |
* @return string |
| 35 |
*/ |
| 36 |
public function get_user_agent(): string { |
| 37 |
return sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ?? '' ) ); |
| 38 |
} |
| 39 |
|
| 40 |
} |
| 41 |
|