Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

WordPress 3.5 Compatible Heartbeat API Usage

View enqueue-heartbeat.php
1 2 3 4 5
<?php
// enqueue the script,
// this fails gracefully if no 'heartbeat' script is registered
wp_enqueue_script('heartbeat');
View enqueue-heartbeat.php
1 2 3 4 5 6 7 8 9 10 11 12 13
(function($) {
// watch for heartbeat event,
// no event will happen if the script isn't included
 
$(document).on('heartbeat-connection-lost', function() {
// do what you need to do here
$('body').addClass('connection-lost')
}).on('heartbeat-connection-restored', function() {
// do what you need to do here
$('body').removeClass('connection-lost')
});
 
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.