Skip to content

Instantly share code, notes, and snippets.

@shrimp2t
Last active January 17, 2025 08:19
Show Gist options
  • Select an option

  • Save shrimp2t/acaf48f39bb0bc5e1b27059b1d5c6e2b to your computer and use it in GitHub Desktop.

Select an option

Save shrimp2t/acaf48f39bb0bc5e1b27059b1d5c6e2b to your computer and use it in GitHub Desktop.
<?hp
$ip_res = wp_remote_get(
'https://api.ipify.org?format=json',
array(
'timeout' => 30,
'sslverify' => false,
)
);
$code = wp_remote_retrieve_response_code( $ip_res );
if ( $code >= 200 && $code < 300 ) {
$ip_data = json_decode( wp_remote_retrieve_body( $ip_res ), true );
?>
<p><?php esc_html_e('Your server IP is:', 'onepres-plus') ?> <strong><?php echo esc_html( $ip_data['ip'] ); ?></strong></p>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment