/**
 * Add the "Google Ads Console" item to the WordPress admin bar.
 *
 * @param WP_Admin_Bar $wp_admin_bar A reference to the global $wp_admin_bar object.
 */
function googleadconsole_add_node($wp_admin_bar)
{
    // Don't display this in the admin area
    if (is_admin()) {
        return;
    }
    $url = googleadconsole_toggle_console_url();
    $args = array('id' => 'google-ad-console-toggle', 'title' => esc_html__('Google Ad Console', 'google-ad-console'), 'href' => esc_url($url));
    // Active state for the node
    if (get_query_var('google_force_console', false)) {
        $args['meta'] = array('class' => 'hover');
    }
    /**
     * Filter the arguments used to construct the "Google Ads Console" admin bar node.
     *
     * @param array $args WP admin bar node arguments.
     */
    $args = apply_filters('googleadconsole_before_add_node', $args);
    $wp_admin_bar->add_node($args);
}
 public function test_googleadconsole_toggle_console_url_removes_query_arg()
 {
     M::wpFunction('get_query_var', array('times' => 1, 'args' => array('google_force_console', false), 'return' => true));
     M::wpFunction('add_query_arg', array('times' => 1, 'args' => array('google_force_console', false), 'return' => 'http://example.com'));
     $this->assertEquals('http://example.com', googleadconsole_toggle_console_url());
 }