Last Updated: February 25, 2016
·
954
· etienne_tremel

Real-time collaboration using TowTruck

TwoTruck is a new service developped by Mozilla which allow you to collaborate in real-time.

For details about how it works, check this page: https://towtruck.mozillalabs.com/

It can be useful if you have to deal remotely with customers.
The following code add a button to the Top Admin Bar and launch the script.

To make it works, add this snippet to your functions.php:

/**
 * ADD TOWTRUCK TO THE TOP ADMIN BAR
 */

//Add button in admin top bar:
function add_tow_truck( $admin_bar ) {
    $admin_bar->add_menu( array(
        'id'    => __( 'tow-truck' ),
        'title' => 'Get Help',
        'href'  => '#',
        'meta'  => array(
            'onclick'   => 'TowTruck(this); return false;'
        )
    ) );
}
add_action( 'admin_bar_menu', 'add_tow_truck' );

//Load script when admin bar is showing:
function load_tow_truck_script() {
    if ( is_admin_bar_showing() )
        wp_enqueue_script( 'TowTruck', 'https://towtruck.mozillalabs.com/towtruck.js' );
}
add_action( 'wp_enqueue_scripts', 'load_tow_truck_script' );
add_action( 'admin_enqueue_scripts', 'load_tow_truck_script' );

1 Response
Add your response

Thanks for sharing this.

It was super easy to implement and works quite well.

over 1 year ago ·