Last active
December 20, 2015 14:39
-
-
Save WerdsWords/6148166 to your computer and use it in GitHub Desktop.
#26: heartbeat_nopriv_received
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't the 2 on line 21 be a 3? or remove $screen_id from the passed-in parameters on line 15?