Dưới đây là function lấy địa chỉ ip, Để đây anh em copy về xài nhé (ghi chú function này chỉ chạy trong môi trường wordpress)
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function get_ip() { 		if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { 			// check ip from share internet. 			$ip = filter_var( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ), FILTER_VALIDATE_IP ); 		} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { 			// to check ip is pass from proxy. 			$ips = explode( ',', wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ); 			if ( is_array( $ips ) ) { 				$ip = filter_var( $ips[0], FILTER_VALIDATE_IP ); 			} else { 				$ip = filter_var( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ), FILTER_VALIDATE_IP ); 			} 		} else { 			$ip = filter_var( wp_unslash( $_SERVER['REMOTE_ADDR'] ), FILTER_VALIDATE_IP ); 		} 		return  $ip ; 	} | 
Mọi sự sao chép xin ghi rõ nguồn là fcwordpress.net
Chuyên trang về wordpress: hướng dẫn thiết kế theme, plugin, thủ thuật wordpress
Chili Comment. Giấy phép không hợp lệ. Kích hoạt tại đây