/** * Trigger form submission. * * @since 1.0.0 * @return void */ public function submit() { if (!wpbo_is_provider_ready()) { return; } $data = $this->get_clean_fields(); $result = call_user_func(array(wpbo_get_provider_class(), 'submit'), $data); // Log the conversion $conversion = $this->new_conversion(); $first_name = isset($data['first_name']) ? $data['first_name'] : $data['name']; $last_name = isset($data['last_name']) ? $data['last_name'] : ''; // Dismiss the popup wpbo_dismiss_popup($this->popup_id); // Backup the subscriber in case something went wrong if (true !== $result) { $failsafe = array('conversion_id' => $conversion, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $data['email'], 'status' => 'failed'); wpbo_failsafe_add_subscriber($failsafe); } // Redirect wp_redirect($this->get_return_url()); exit; }
/** * Check if the mailing provider is loaded and ready * * @since 2.0 * @return bool */ function wpbo_is_provider_ready() { $class_name = wpbo_get_provider_class(); if (empty($class_name)) { return false; } if (!class_exists($class_name)) { return false; } if (!method_exists($class_name, 'submit')) { return false; } return true; }