PluginProbe
QuadMenu – Mega Menu / 3.3.6
QuadMenu – Mega Menu v3.3.6
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / jetpack_vendor / automattic / jetpack-status / src / class-visitor.php

class-visitor.php in QuadMenu – Mega Menu 3.3.6, at jetpack_vendor/automattic/jetpack-status/src/class-visitor.php

57 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Status and information regarding the site visitor.
4 *
5 * @package automattic/jetpack-status
6 */
7
8 namespace Automattic\Jetpack\Status;
9
10 /**
11 * Visitor class.
12 */
13 class Visitor {
14
15 /**
16 * Gets current user IP address.
17 *
18 * @param bool $check_all_headers Check all headers? Default is `false`.
19 *
20 * @return string Current user IP address.
21 */
22 public function get_ip( $check_all_headers = false ) {
23 if ( $check_all_headers ) {
24 foreach ( array(
25 'HTTP_CF_CONNECTING_IP',
26 'HTTP_CLIENT_IP',
27 'HTTP_X_FORWARDED_FOR',
28 'HTTP_X_FORWARDED',
29 'HTTP_X_CLUSTER_CLIENT_IP',
30 'HTTP_FORWARDED_FOR',
31 'HTTP_FORWARDED',
32 'HTTP_VIA',
33 ) as $key ) {
34 if ( ! empty( $_SERVER[ $key ] ) ) {
35 // @todo Some of these might actually be lists of IPs (e.g. HTTP_X_FORWARDED_FOR) or something else entirely (HTTP_VIA).
36 return filter_var( wp_unslash( $_SERVER[ $key ] ) );
37 }
38 }
39 }
40
41 return ! empty( $_SERVER['REMOTE_ADDR'] ) ? filter_var( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
42 }
43
44 /**
45 * Simple gate check for a11n feature testing purposes using AT_PROXIED_REQUEST constant.
46 * IMPORTANT: Only use it for internal feature test purposes, not authorization.
47 *
48 * The goal of this function is to help us gate features by using a similar function name
49 * we find on simple sites: is_automattician().
50 *
51 * @return bool True if the current request is PROXIED, false otherwise.
52 */
53 public function is_automattician_feature_flags_only() {
54 return ( defined( 'AT_PROXIED_REQUEST' ) && AT_PROXIED_REQUEST );
55 }
56 }
57