| @@ -59,9 +59,10 @@ | ||
| 59 | 59 | * @param string $http_ip_header HTTP header for identifying client's IP. |
| 60 | 60 | * |
| 61 | 61 | * @since 4.5.1 |
| 62 | 62 | */ |
| 63 | - $http_ip_header = (string) apply_filters( 'wpdef_firewall_ip_detection', $this->http_ip_header ); | |
| 63 | + $http_ip_header = apply_filters( 'wpdef_firewall_ip_detection', $this->http_ip_header ); | |
| 64 | + $http_ip_header = is_string( $http_ip_header ) ? $http_ip_header : (string) $http_ip_header; | |
| 64 | 65 | switch ( $http_ip_header ) { |
| 65 | 66 | case 'HTTP_X_FORWARDED_FOR': |
| 66 | 67 | case 'HTTP_X_REAL_IP': |
| 67 | 68 | case 'HTTP_CF_CONNECTING_IP': |
| @@ -103,15 +104,15 @@ | ||
| 103 | 104 | */ |
| 104 | 105 | public function get_http_ip_header_value( string $http_ip_header_key ): string { |
| 105 | 106 | $ip_array = array(); |
| 106 | 107 | $server = defender_get_data_from_request( null, 's' ); |
| 107 | - if ( empty( $http_ip_header_key ) ) { | |
| 108 | + if ( '' === $http_ip_header_key ) { | |
| 108 | 109 | $ip_array = wd_di()->get( Classic_Remote_Address::class )->get_ip_header(); |
| 109 | 110 | } elseif ( isset( $server[ $http_ip_header_key ] ) ) { |
| 110 | 111 | $ip_array[] = $server[ $http_ip_header_key ]; |
| 111 | 112 | } |
| 112 | 113 | |
| 113 | - return ! empty( $ip_array ) ? | |
| 114 | + return array() !== $ip_array ? | |
| 114 | 115 | implode( ', ', $ip_array ) : |
| 115 | 116 | sprintf( /* translators: %s - HTTP IP header */ |
| 116 | 117 | esc_html__( '%s header missing in $_SERVER global variable.', 'defender-security' ), |
| 117 | 118 | $http_ip_header_key |