Created
April 21, 2020 09:37
-
-
Save paulgoodchild/d33fb15f53d4147229b4eee0ec888bcb to your computer and use it in GitHub Desktop.
Find your outgoing server IP addresses.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add this to your functions.php and then call your site URL with "get_my_server_ip" in your query. | |
* e.g. https://www.example.com/?get_my_server_ip=1 | |
*/ | |
if ( isset( $_GET[ 'get_my_server_ip' ] ) ) { | |
add_action( 'init', function () { | |
echo 'Server IPs:<br/>'.implode( '<br/>', array_unique( [ | |
wp_remote_get( 'https://api.ipify.org' )[ 'body' ], | |
wp_remote_get( 'https://api6.ipify.org' )[ 'body' ], | |
] ) ); | |
die(); | |
} ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment