Skip to content

Instantly share code, notes, and snippets.

@WerdsWords
Last active December 20, 2015 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WerdsWords/6148166 to your computer and use it in GitHub Desktop.
Save WerdsWords/6148166 to your computer and use it in GitHub Desktop.
#26: heartbeat_nopriv_received
<?php
/**
* Example 'Marco, Polo' Heartbeat nopriv data received filter.
*
* Based on an original Gist by Jason Coleman (https://gist.github.com/strangerstudios/5888123)
*
* @see wp_ajax_nopriv_heartbeat()
*
* @param array|object $response The response object.
* @param array $data An array of $_POST data.
* @param string $screen_id The screen id.
*
* @return mixed The filtered response.
*/
function wpdocs_heartbeat_received( $response, $data, $screen_id ) {
if ( $data['client'] == 'marco' )
$response['server'] = 'polo';
return $response;
}
add_filter( 'heartbeat_nopriv_received', 'wpdocs_heartbeat_received', 10, 3 );
@jtsternberg
Copy link

Shouldn't the 2 on line 21 be a 3? or remove $screen_id from the passed-in parameters on line 15?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment