Yes. It is possible.
Add a custom link to the href
attribute of the function, maybe with attributes for the url. This parameter plan you Parse, like about the global $_GET
and run your file, script etc. if it the right parameters.
As example, see on the href
-Parameter. I add the follow get-parameters in the href-Attribute.
$scheme = ( is_ssl() ? 'https' : 'http' );
$url = $scheme . '://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
$str = array( '?debug', '&debug', '#debugobjects' );
$url = esc_url( str_replace( $str, '', $url ) );
$get="?";
if ( FALSE !== strpos( $url, '?' ) ) {
$get="&";
}
$href = $url . $get . "debug#debugobjects";
The completly source to add my custom item in the Admin bar. You find all of this code in this repo.
$wp_admin_bar->add_menu(
array(
'parent' => 'network-admin',
'secondary' => FALSE,
'id' => 'network-' . self::get_textdomain(),
'title' => self::get_plugin_data( 'Name' ),
'meta' => array( 'class' => $classes ),
'href' => network_admin_url( 'settings.php?page=" . plugin_basename( __FILE__ ) ),
)
);
$scheme = ( is_ssl() ? "https' : 'http' );
$url = $scheme . '://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
$str = array( '?debug', '&debug', '#debugobjects' );
$url = esc_url( str_replace( $str, '', $url ) );
$get="?";
if ( FALSE !== strpos( $url, '?' ) ) {
$get="&";
}
$href = $url . $get . "debug#debugobjects";
$wp_admin_bar->add_menu(
array(
'id' => 'debug_objects',
'parent' => 'top-secondary',
'title' => '<img style="float:left;height:28px;" src="'
. plugins_url( '/img/bug-32.png', parent::$plugin )
. '" alt="The Bug" />'
. __( ' Objects', self::get_textdomain() ),
'meta' => array( 'class' => $classes ),
'href' => $href
)
);