/** * @since 1.0.0 * @return string */ protected function import_content() { $api_key = sanitize_text_field($_POST['mailchimp_api_key']); $list_id = sanitize_text_field($_POST[$this->import_list_name]); $signup_list_index = absint($_POST['signup_list_index']); $signup_lists = Prompt_Subscribing::get_signup_lists(); $import = new Prompt_Admin_MailChimp_Import($api_key, $list_id, $signup_lists[$signup_list_index]); $import->execute(); $content = html('h3', __('Here\'s how it went', 'Postmatic')); $content .= $import->get_error() ? $import->get_error()->get_error_message() : ''; $results_format = _n('Imported one subscriber.', 'Imported %1$s subscribers.', $import->get_imported_count(), 'Postmatic'); if ($import->get_already_subscribed_count() > 0) { $results_format .= ' ' . _n('The one valid user we found was already subscribed.', 'The %2$s valid users we found were already subscribed.', $import->get_already_subscribed_count(), 'Postmatic'); } $rejects = $import->get_rejected_subscribers(); $reject_content = ''; $reject_button = ''; if ($rejects) { $results_format .= '<br />' . _n('One user didn\'t qualify for importing.', 'There were %3$s users which didn\'t qualify for importing.', count($rejects)); $reject_content = html('div id="mailpoet-import-intro"', html('div', html('h4', __('Why weren\'t more of my users imported?', 'Postmatic')), html('p', __('We have a very strict policy regarding user imports: <em>we will never allow anyone to be subscribed to a blog running Postmatic without them having opted in</em> (such as subscriber lists bought and imported in bulk for spamming). Because of this we will not import any MailChimp subscribers unless the following two conditions are true:', 'Postmatic')), html('ol', html('li', __('The user has double opted-in to your MailChimp list', 'Postmatic')), html('li', __('The user exists on a list which is at least 14 days old', 'Postmatic'))), html('h5', __('Why so strict?', 'Postmatic')), html('p', __('Bulk importing unwilling users is easy in MailChimp. If we did not hold our import to a higher standard those unwilling users could be imported into Postmatic. And then they would spam your users. MailChimp is a one-way street. Postmatic is a conversation. That\'s a very important difference.', 'Postmatic')), html('h4', __('But we do have good news', 'Postmatic')), html('p', __('You can send an email to your remaining users. They will be invited to join your site by simply replying.', 'Postmatic')))); $rejected_addresses = array(); foreach ($rejects as $reject) { $name = trim($reject['email']); //$name = trim( $reject['firstname'] . ' ' . $reject['lastname'] ); $rejected_addresses[] = Prompt_Email_Batch::name_address($reject['email'], $name); } $reject_button = html('input', array('name' => $this->rejected_addresses_name, 'class' => 'button', 'data-addresses' => implode(",", $rejected_addresses), 'type' => 'submit', 'value' => __('Preview and send the invitations', 'Postmatic'))); } $content = html('p', $content, sprintf($results_format, $import->get_imported_count(), $import->get_already_subscribed_count(), count($rejects)), $reject_content, $reject_button); return $content; }
/** * Get import results in HTML. * * @since 1.0.0 * @return string */ protected function import_content() { $list_id = intval($_POST[$this->import_list_name]); $signup_list_index = intval($_POST['signup_list_index']); $signup_lists = Prompt_Subscribing::get_signup_lists(); $signup_list = $signup_lists[$signup_list_index]; $import = Prompt_Admin_Mailpoet_Import::make($list_id, $signup_list); $import->execute(); $content = html('h3', __('Here\'s how it went:', 'Postmatic')); $content .= $import->get_error() ? $import->get_error()->get_error_message() : ''; $results_format = _n('Imported one subscriber.', 'Imported %1$s subscribers.', $import->get_imported_count(), 'Postmatic'); if ($import->get_already_subscribed_count() > 0) { $results_format .= ' ' . _n('The one valid user we found was already subscribed.', 'The %2$s valid users we found were already subscribed.', $import->get_already_subscribed_count(), 'Postmatic'); } $rejects = $import->get_rejected_subscribers(); $reject_content = ''; $reject_button = ''; if ($rejects) { $results_format .= '<br />' . _n('One user didn\'t qualify for importing.', 'There were %3$s users which didn\'t qualify for importing.', count($rejects)); $reject_content = html('div id="mailpoet-import-intro"', html('div', html('h4', __('Why weren\'t more of my users imported?', 'Postmatic')), html('p', __('We have a very strict policy regarding user imports: <em>we will never allow anyone to be subscribed to a blog running Postmatic without them having opted in</em> (such as subscriber lists bought and imported in bulk for spamming). Because of this we will not import any Mailpoet subscribers unless the following two conditions are true:', 'Postmatic')), html('ol', html('li', __('The user has opened an email you sent through Mailpoet', 'Postmatic')), html('li', __('The user has clicked a link within an email you sent through Mailpoet', 'Postmatic'))), html('h5', __('Why so strict?', 'Postmatic')), html('p', __('Bulk importing unwilling users and marking them as opted-in is easy in Mailpoet. If we did not hold our import to a higher standard the magic button below would allow those unwilling users to be imported into Postmatic. And then they would spam your grandmother. Nobody wants that. Plus, if a subscriber does not open or interact with your emails maybe they aren\'t all that good of a match anyway, right? Think of it as spring cleaning.', 'Postmatic')), html('h4', __('But we do have good news', 'Postmatic')), html('p', __('You can send an email to your remaining users. They will be invited to join your site by simply replying.', 'Postmatic')))); $rejected_addresses = array(); foreach ($rejects as $reject) { $name = trim($reject['firstname'] . ' ' . $reject['lastname']); $rejected_addresses[] = Prompt_Email_Batch::name_address($reject['email'], $name); } $reject_button = html('input', array('name' => $this->rejected_addresses_name, 'class' => 'button', 'data-addresses' => implode(",", $rejected_addresses), 'type' => 'submit', 'value' => __('Preview and send the invitations', 'Postmatic'))); } $content = html('p', $content, sprintf($results_format, $import->get_imported_count(), $import->get_already_subscribed_count(), count($rejects)), $reject_content, $reject_button); return $content; }