/**
* Listens to requests to check the IMAP inbox.
*
* If a POST request is made to check the IMAP inbox, RBE will actually
* process this request in this function. We also make sure that WP-cron is
* running before pinging the IMAP inbox.
*
* @since 1.0-RC3
*
* @see bp_rbe_spawn_inbox_check()
*/
function bp_rbe_run_inbox_listener()
{
if (empty($_POST['_bp_rbe_check'])) {
return;
}
// make sure WP-cron isn't running
if (defined('DOING_CRON') || isset($_GET['doing_wp_cron'])) {
return;
}
if (bp_rbe_is_connecting(array('clearcache' => true))) {
return;
}
if (bp_rbe_is_connected()) {
return;
}
bp_rbe_add_imap_lock();
// run our inbox check
$imap = BP_Reply_By_Email_IMAP::init();
$imap = $imap->run();
// Do not run the inbox check again on failure.
if (false === $imap) {
remove_action('shutdown', 'bp_rbe_spawn_inbox_check');
}
// kill the rest of this page
die;
}