/**
  * @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;
 }
예제 #2
0
 /**
  * Build output for the subscriptions column.
  *
  * @see manage_users_custom_column filter trigger
  *
  * @param string $value
  * @param string $column_name
  * @param int $user_id
  * @return string column content
  */
 public static function subscriptions_column($value, $column_name, $user_id)
 {
     if (self::$subscriptions_column_name !== $column_name) {
         return $value;
     }
     $column_content = '';
     $edit_url = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user_id)));
     $signup_lists = Prompt_Subscribing::get_signup_lists();
     foreach ($signup_lists as $signup_list) {
         $column_content .= self::signup_list_column_content($user_id, $signup_list, $edit_url);
     }
     $author_count = count(Prompt_User::subscribed_object_ids($user_id));
     if ($author_count > 0) {
         $column_content .= html('a', array('href' => $edit_url . '#prompt-author-subscriptions'), sprintf(_n('%d Author', '%d authors', $author_count), $author_count), '<br/>');
     }
     $post_count = count(Prompt_Post::subscribed_object_ids($user_id));
     if ($post_count > 0) {
         $column_content .= html('a', array('href' => $edit_url . '#prompt-post-subscriptions'), sprintf(_n('%d Conversations', '%d Conversations', $post_count), $post_count), '<br/>');
     }
     return $column_content;
 }
예제 #3
0
 /**
  * @since 1.0.0
  *
  * @param array $recipients
  * @param string $subject
  * @param string $message
  */
 public function schedule_invites($recipients, $subject, $message)
 {
     $users_data = array();
     $address_index = array();
     $failures = array();
     $lists = Prompt_Subscribing::get_signup_lists();
     $current_user = wp_get_current_user();
     foreach ($recipients as $recipient) {
         $to_address = Prompt_Email_Batch::address($recipient);
         $lower_case_to_address = strtolower($to_address);
         if (isset($address_index[$lower_case_to_address])) {
             $failures[] = __('Duplicate email address', 'Postmatic') . ': ' . $recipient;
             continue;
         }
         if (!is_email($to_address)) {
             $failures[] = __('Invalid email address', 'Postmatic') . ': ' . $recipient;
             continue;
         }
         $user = get_user_by('email', $to_address);
         if ($user and $this->is_subscribed_to_any($user->ID, $lists)) {
             $failures[] = __('Already subscribed', 'Postmatic') . ': ' . $recipient;
             continue;
         }
         $address_index[$lower_case_to_address] = true;
         $to_name = Prompt_Email_Batch::name($recipient);
         $users_data[] = array('user_email' => $to_address, 'display_name' => $to_name);
     }
     if (!empty($users_data)) {
         $message_data = array('subject' => html_entity_decode($subject, ENT_QUOTES), 'invite_introduction' => $message, 'message_type' => Prompt_Enum_Message_Types::INVITATION, 'from_name' => $current_user->display_name . ' - ' . get_option('blogname'));
         Prompt_Subscription_Mailing::schedule_agreements($lists, $users_data, $message_data);
         $confirmation_format = _n('Success. %d invite sent.', 'Success. %d invites sent.', count($users_data), 'Postmatic');
         $this->add_notice(sprintf($confirmation_format, count($users_data)));
     }
     if (!empty($failures)) {
         $failure_notice = __('Something went wrong and these invites were not sent: ', 'Postmatic') . '<br/>' . implode('<br/>', $failures);
         $this->add_notice($failure_notice, 'error');
     }
 }
예제 #4
0
 /**
  * @since 1.0.0
  * @return string
  */
 protected function profile_site_subscriptions()
 {
     $signup_lists = Prompt_Subscribing::get_signup_lists();
     $checkboxes = array_map(array($this, 'profile_subscription_checkbox'), $signup_lists);
     if ($this->get_wp_user()->has_cap('manage_options')) {
         $site_comments = new Prompt_Site_Comments();
         $checkboxes[] = $this->profile_subscription_checkbox($site_comments);
     }
     return html('div id="prompt-site-subscription"', html('h4', __('Site Subscriptions:', 'Postmatic')), implode('<br/>', $checkboxes));
 }
 /**
  * The HTML for the UI to start the import.
  *
  * @since 1.0.0
  * @return string
  */
 protected function ready_content()
 {
     $mailpoet_lists = $this->get_mailpoet_lists();
     if (count($mailpoet_lists) === 0) {
         return html('div id="mailpoet-no-subscribers', __('There are no lists available from MailPoet. Are you sure it is activated?', 'Postmatic'));
     }
     $active_subscriber_text = __('Mailpoet is detected. We are ready to import active subscribers from Mailpoet.', 'Postmatic');
     $list_options = array();
     foreach ($mailpoet_lists as $list) {
         $list_options[] = html('option', array('value' => $list['list_id']), $list['name'], ' (', $list['subscribers'], ')');
     }
     $local_list_options = array();
     foreach (Prompt_Subscribing::get_signup_lists() as $index => $list) {
         $local_list_options[] = html('option', array('value' => $index), $list->subscription_object_label());
     }
     $html_parts = array();
     $html_parts[] = html('div id="mailpoet-import-intro"', html('div', html('h3', __('Mailpoet Import FAQ', 'Postmatic')), html('h4', __('Will my subscribers be sent a notification?', 'Postmatic')), html('p', __('No. The import process is invisible to subscribers.', 'Postmatic')), html('h4', __('Which of my subscribers will be 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', __('Can I import multiple lists?', 'Postmatic')), html('p', __('Yes. Re-run this importer with as many lists as you like. Postmatic will not create duplicate subscribers.', 'Postmatic')), html('h4', __('Does Postmatic have lists like Mailpoet does? Is there any way to organize subscribers?', 'Postmatic')), html('p', __('No, we do not have a concept of multiple lists. All users are the same in Postmatic. If list segmentation is important to you please let us know by visiting our support site. You\'ll find the link to the right.', 'Postmatic')), html('h4', __('What will happen to my Mailpoet subscribers?', 'Postmatic')), html('p', __('Mailpoet and Postmatic store subscribers in different places within your WordPress database. Your Mailpoet subscribers will always be available to you provided you have Mailpoet activated.', 'Postmatic'))), $active_subscriber_text);
     $html_parts[] = $this->send_login_warning_content();
     $html_parts[] = html('label for="import_list"', __('Choose a Mailpoet list to import from: ', 'Postmatic'), html('select', array('name' => 'import_list', 'type' => 'select'), implode('', $list_options)));
     $html_parts[] = '<br/>';
     if (count($local_list_options) > 1) {
         $html_parts[] = html('label id="mailpoet_signup_list_index_label" for="signup_list_index"', __('Choose a Postmatic list to import to:', 'Postmatic'), ' ', html('select', array('name' => 'signup_list_index', 'type' => 'select'), implode('', $local_list_options)));
     } else {
         $html_parts[] = html('input', array('type' => 'hidden', 'name' => 'signup_list_index', 'value' => 0));
     }
     $html_parts[] = html('input', array('name' => $this->import_type_name, 'type' => 'hidden', 'value' => $this->import_type));
     return $this->form_wrap(implode('', $html_parts), array('value' => __('Import from Mailpoet', 'Postmatic')));
 }
예제 #6
0
 /**
  *
  * @since 2.0.0
  *
  * @param WP_User $subscriber
  * @return Prompt_Interface_Subscribable[]
  */
 protected static function default_lists_for($subscriber)
 {
     $lists = Prompt_Subscribing::get_signup_lists();
     if (count($lists) == 1) {
         return $lists;
     }
     $not_subscribed_lists = array();
     foreach ($lists as $list) {
         if (!$list->is_subscribed($subscriber->ID)) {
             $not_subscribed_lists[] = $list;
         }
     }
     return apply_filters('prompt/ajax_handling/default_lists_for', $not_subscribed_lists, $subscriber);
 }