Your Entire code is correct and you have no errors in it.
AS for as the WordPress is considered it is case sensitive
and it will through errors pointing out even though if it is case sensitive issues.
Ensure that you use the correct syntax and structures while handling with the Admin Side or as well as in the core file.
WP_Admin_Bar - WP_Admin_Bar is WordPress' class for generating the Toolbar that lines the top of WordPress sites when signed in. This class can be hooked and modified to add or remove options that appear in the admin bar.
Usage: This class is used internally by WordPress to create an object called $wp_admin_bar. Most modifications to WordPress toolbar will generally be done by modifying the $wp_admin_bar object that is passed through the admin_bar_menu hook.
Example:
add_action( 'admin_bar_menu', 'modify_admin_bar' );
function modify_admin_bar( $wp_admin_bar ){
global $wp_admin_bar;
// do something with $wp_admin_bar;
}
Corrections that you have to make:
- Where ever you have used
global $WP_Admin_Bar;
you have to change it to global $wp_admin_bar;
.
Note: Please note that the hooks are available for modifying this class but they have very limited use. In many cases, you will simply want to modify the $wp_admin_bar
object.
And your Entire Code look like.
function wp_add_google_link(){
global $wp_admin_bar;
//var_dump($wp_admin_bar); If you need you remove the slash and check
$wp_admin_bar->add_menu(array(
'id'=>'google_analytics',
'title'=>'GoogleAnalytics',
'href'=>'https://google.com/analytics'
));
}
add_action('admin_bar_menu','wp_add_google_link');
wp_admin_bar
instead$WP_Admin_Bar
see detail here. anyway explain what really want ?