[wp-trac] [WordPress Trac] #45962: Is LocalHost Check?

WordPress Trac noreply at wordpress.org
Sat Jan 12 21:08:04 UTC 2019


#45962: Is LocalHost Check?
-------------------------+-----------------------------
 Reporter:  bhubbard     |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 It would be useful if WordPress had its own function to check for
 localhost.

 {{{#!php
 <?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 );
                 }

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45962>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list