/** * Cleanup RBE. * * Clears RBE's scheduled hook from WP, as well as any DB entries and * files. * * @since 1.0-RC1 */ function bp_rbe_cleanup() { // remove remnants from any previous failed attempts to stop the inbox bp_rbe_should_stop(); bp_rbe_remove_imap_lock(); bp_rbe_remove_imap_connection_marker(); // we don't use these options anymore bp_delete_option('bp_rbe_is_connected'); bp_delete_option('bp_rbe_spawn_cron'); bp_delete_option('bp_rbe_lock'); delete_site_transient('bp_rbe_is_connected'); delete_site_transient('bp_rbe_lock'); // we don't use WP's cron feature anymore, but we clear RBE's old scheduled // hook just in case wp_clear_scheduled_hook('bp_rbe_schedule'); }
/** * Connects to the IMAP inbox. * * @return bool */ private function connect() { bp_rbe_log('--- Attempting to start new connection... ---'); // if our DB marker says we're already connected, stop now! // this is an extra precaution if (bp_rbe_is_connected()) { bp_rbe_log('--- RBE is already connected! ---'); return false; } // Let's open the IMAP stream! $this->connection = BP_Reply_By_Email_Connect::init(); // couldn't connect :( if ($this->connection === false) { bp_rbe_log('Cannot connect: ' . imap_last_error()); bp_rbe_remove_imap_lock(); bp_rbe_remove_imap_connection_marker(); return false; } // add an entry in the DB to say that we're connected //bp_update_option( 'bp_rbe_is_connected', time() + bp_rbe_get_execution_time() ); bp_rbe_add_imap_connection_marker(); bp_rbe_log('--- Connection successful! ---'); return true; }