Skip to content

Instantly share code, notes, and snippets.

@vaurdan
Last active August 29, 2015 14:16
Show Gist options
  • Save vaurdan/c0d441e4b514d992c9d5 to your computer and use it in GitHub Desktop.
Save vaurdan/c0d441e4b514d992c9d5 to your computer and use it in GitHub Desktop.
Get the IP address of a given hostname. Use it on a WordPress blog with a easy to use shortcode.
<?php
/*
Plugin Name: Shortcode for IP
Description: Get's an IP from an hostname
Author: Henrique Mouta
Version: 1.0
Author URI: http://henrique.mouta.org/
*/
add_shortcode( 'get_ip', function( $atts ) {
$attributes = shortcode_atts( array(
'host' => 'google.com',
), $atts );
return gethostbyname($attributes['host']);
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment