Last active
July 13, 2017 21:28
-
-
Save dnaber-de/5219882 to your computer and use it in GitHub Desktop.
WordPress Plugin to show the Server Address (IP) in Admin-Bar
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 | |
/** | |
* Plugin Name: dna IP to Admin Bar | |
* Plugin URI: https://gist.github.com/dnaber-de/5219882 | |
* Description: Shows the current Server IP in the Admin Bar. (Requires PHP 5.3) | |
* Author: David Naber | |
* Author URI: http://dnaber.de/ | |
* Version: 2013.03.22 | |
* License: MIT | |
* License URI: http://opensource.org/licenses/mit-license.php | |
*/ | |
namespace dna\ip_to_admin_bar; | |
if ( ! function_exists( 'add_filter' ) ) | |
return; | |
add_action( 'plugins_loaded', array( Plugin::get_instance(), 'init_plugin' ) ); | |
class Plugin { | |
/** | |
* the plugin instance | |
* | |
* @var Plugin | |
*/ | |
private static $instance = NULL; | |
/** | |
* get the plugin instance | |
* | |
* @return Plugin | |
*/ | |
public static function get_instance() { | |
if ( NULL === self::$instance ) | |
self::$instance = new self; | |
return self::$instance; | |
} | |
/** | |
* hook in | |
* | |
* @wp-hook plugins_loaded | |
*/ | |
public function init_plugin() { | |
add_action( 'wp_before_admin_bar_render', array( $this, 'admin_bar' ) ); | |
} | |
/** | |
* add a item to the admin bar | |
* | |
* @wp-hook wp_before_admin_bar_render | |
* @global $wp_admin_bar; | |
* @return | |
*/ | |
public function admin_bar() { | |
$server_addrss = $_SERVER[ 'SERVER_ADDR' ]; | |
$GLOBALS[ 'wp_admin_bar' ]->add_menu( | |
array( | |
'id' => 'dna-ip-addr', | |
'title' => $server_addrss, | |
'href' => '#' | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment