I started working on a cool new plugin that allows you to post content to multiple WordPress sites. It has a simple and clean interface. The plugin adds a very convenient link to the top WP admin bar. Below is the code I used to create this easy to access menu. Related
- https://codex.wordpress.org/Administration_Menus
- http://www.paulund.co.uk/add-menu-item-to-wordpress-admin
[code]
$orb_just_write_admin_obj = orb_just_write_admin::get_instance();
add_action('wp_before_admin_bar_render', array($orb_just_write_admin_obj, "add2admin_bar") );
/**
* Description of admin
*
* @author User
*/
class orb_just_write_admin {
public function add2admin_bar() {
global $wp_admin_bar;
$icon_url = ORBISIUS_JUST_WRITE_URL . 'modules/images/icon.png';
$wp_admin_bar->add_node(array(
'id' => __CLASS__ . '-toolbar',
'title' => "<img style='vertical-align:middle;' alt='' src='$icon_url' /> " . ORBISIUS_JUST_WRITE_PLUGIN_NAME,
'href' => site_url('/?orbisius_just_write'),
'meta' => array(
"class" => __CLASS__ . '-toolbar',
'target' => '_blank',
),
));
}
/**
* Singleton pattern i.e. we have only one instance of this obj
*
* @staticvar type $instance
* @return \cls
*/
public static function get_instance() {
static $instance = null;
if (is_null($instance)) {
$cls = __CLASS__;
$instance = new $cls();
}
return $instance;
}
[/code]