], $form->settings['replace_interests']); } $log = $this->get_log(); // do stuff on failure if (! is_object($result) || empty($result->id)) { $error_code = $mailchimp->get_error_code(); $error_message = $mailchimp->get_error_message(); if ((int) $mailchimp->get_error_code() === 214) { $form->add_error('already_subscribed'); $form->add_notice($form->messages['already_subscribed'], 'notice'); $log->warning(sprintf('Form %d > %s is already subscribed to the selected list(s)', $form->ID, $data['EMAIL'])); } else { $form->add_error($error_code); $form->add_notice($form->messages['error'], 'error'); $log->error(sprintf('Form %d > Mailchimp API error: %s %s', $form->ID, $error_code, $error_message)); /** * Fire action hook so API errors can be hooked into. * * @param MC4WP_Form $form * @param string $error_message */ do_action('mc4wp_form_api_error', $form, $error_message); } // bail return; } // Success! Did we update or newly subscribe? if ($result->status === 'subscribed' && $result->was_already_on_list) { $form->last_event = 'updated_subscriber'; $form->add_notice($form->messages['updated'], 'success'); $log->info(sprintf('Form %d > Successfully updated %s', $form->ID, $data['EMAIL'])); /** * Fires right after a form was used to update an existing subscriber. * * @since 3.0 * * @param MC4WP_Form $form Instance of the submitted form * @param string $email * @param array $data */ do_action('mc4wp_form_updated_subscriber', $form, $subscriber->email_address, $data); } else { $form->last_event = 'subscribed'; $form->add_notice($form->messages['subscribed'], 'success'); $log->info(sprintf('Form %d > Successfully subscribed %s', $form->ID, $data['EMAIL'])); /** * Fires right after a form was used to add a new subscriber. * * @since 4.8.13 * * @param MC4WP_Form $form Instance of the submitted form * @param string $email * @param array $data */ do_action('mc4wp_form_added_subscriber', $form, $subscriber->email_address, $data); } /** * Fires right after a form was used to add a new subscriber (or update an existing one). * * @since 3.0 * * @param MC4WP_Form $form Instance of the submitted form * @param string $email * @param array $data * @param MC4WP_MailChimp_Subscriber[] $subscriber */ do_action('mc4wp_form_subscribed', $form, $subscriber->email_address, $data, $map); } /** * @param MC4WP_Form $form */ public function process_unsubscribe_form(MC4WP_Form $form) { $mailchimp = new MC4WP_MailChimp(); $log = $this->get_log(); $result = null; $data = $form->get_data(); // unsubscribe from each list foreach ($form->get_lists() as $list_id) { $result = $mailchimp->list_unsubscribe($list_id, $data['EMAIL']); } if (! $result) { $form->add_notice($form->messages['error'], 'error'); $log->error(sprintf('Form %d > Mailchimp API error: %s', $form->ID, $mailchimp->get_error_message())); // bail return; } // Success! Unsubscribed. $form->last_event = 'unsubscribed'; $form->add_notice($form->messages['unsubscribed'], 'notice'); $log->info(sprintf('Form %d > Successfully unsubscribed %s', $form->ID, $data['EMAIL'])); /** * Fires right after a form was used to unsubscribe. * * @since 3.0 * * @param MC4WP_Form $form Instance of the submitted form. * @param string $email */ do_action('mc4wp_form_unsubscribed', $form, $data['EMAIL']); } /** * @param MC4WP_Form $form */ public function respond(MC4WP_Form $form) { $success = ! $form->has_errors(); if ($success) { /** * Fires right after a form is submitted without any errors (success). * * @since 3.0 * * @param MC4WP_Form $form Instance of the submitted form */ do_action('mc4wp_form_success', $form); } else { /** * Fires right after a form is submitted with errors. * * @since 3.0 * * @param MC4WP_Form $form The submitted form instance. */ do_action('mc4wp_form_error', $form); // fire a dedicated event for each error foreach ($form->errors as $error) { /** * Fires right after a form was submitted with errors. * * The dynamic portion of the hook, `$error`, refers to the error that occurred. * * Default errors give us the following possible hooks: * * - mc4wp_form_error_error General errors * - mc4wp_form_error_spam * - mc4wp_form_error_invalid_email Invalid email address * - mc4wp_form_error_already_subscribed Email is already on selected list(s) * - mc4wp_form_error_required_field_missing One or more required fields are missing * - mc4wp_form_error_no_lists_selected No Mailchimp lists were selected * * @since 3.0 * * @param MC4WP_Form $form The form instance of the submitted form. */ do_action('mc4wp_form_error_' . $error, $form); } } /** * Fires right before responding to the form request. * * @since 3.0 * * @param MC4WP_Form $form Instance of the submitted form. */ do_action('mc4wp_form_respond', $form); // do stuff on success (if form was submitted over plain HTTP, not for AJAX or REST requests) if ($success && ! $this->request_wants_json()) { $redirect_url = $form->get_redirect_url(); if (! empty($redirect_url)) { wp_redirect($redirect_url); exit; } } } private function request_wants_json() { if (isset($_SERVER['HTTP_ACCEPT']) && false !== strpos($_SERVER['HTTP_ACCEPT'], 'application/json')) { return true; } return false; } /** * @return MC4WP_API_V3 */ protected function get_api() { return mc4wp('api'); } /** * @return MC4WP_Debug_Log */ protected function get_log() { return mc4wp('log'); } }
Fatal error: Uncaught Error: Class "MC4WP_Form_Listener" not found in /htdocs/wp-content/plugins/mailchimp-for-wp/includes/forms/class-form-manager.php:51 Stack trace: #0 /htdocs/wp-content/plugins/mailchimp-for-wp/mailchimp-for-wp.php(68): MC4WP_Form_Manager->__construct() #1 /htdocs/wp-includes/class-wp-hook.php(324): _mc4wp_load_plugin('') #2 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #3 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #5 /htdocs/wp-config.php(178): require_once('/htdocs/wp-sett...') #6 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #7 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #8 /htdocs/index.php(17): require('/htdocs/wp-blog...') #9 {main} thrown in /htdocs/wp-content/plugins/mailchimp-for-wp/includes/forms/class-form-manager.php on line 51