Skip to content

Instantly share code, notes, and snippets.

@paulgoodchild
Created April 21, 2020 09:37
Show Gist options
  • Save paulgoodchild/d33fb15f53d4147229b4eee0ec888bcb to your computer and use it in GitHub Desktop.
Save paulgoodchild/d33fb15f53d4147229b4eee0ec888bcb to your computer and use it in GitHub Desktop.
Find your outgoing server IP addresses.
<?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