Opened 6 years ago
Closed 10 months ago
#45962 closed enhancement (wontfix)
Is LocalHost Check?
Reported by: | bhubbard | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
It would be useful if WordPress had its own function to check for localhost.
<?php function wp_is_localhost() { // Get remote IP. $remote_ip = filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP ); $local_ips = array( '127.0.0.1', // IPv4. '::1', // IPv6. ); $local_ips = apply_filters( 'wp_localhost_ips', $local_ips ); return in_array( $remote_ip, $local_ips, true ); }
Change History (6)
#4
@
6 years ago
I think having this would be useful to be part of the Health Check & Troubleshooting Plugin that is working its way into core. Many developers put checks in their plugins & themes to check when they are working locally, and display extra info or turn on debug mode for example. Devs & Hosting providers could also use it potentially to check for different setups when copying an install from one environment to another.
Note: See
TracTickets for help on using
tickets.
Where in WordPress core itself could such a function be used? I don't see an immediate benefit here.