get_lists() public method

The following data sources are tried in the following order. - Transient Cache (5 days) - Remote MailChimp API - Option Cache (forever)
public get_lists ( ) : array
return array
 /**
  * Show the API settings page
  */
 public function show_generals_setting_page()
 {
     $opts = mc4wp_get_options();
     $connected = mc4wp('api')->is_connected();
     $lists = $this->mailchimp->get_lists();
     require MC4WP_PLUGIN_DIR . 'includes/views/general-settings.php';
 }
Exemplo n.º 2
0
 /**
  * Show checkbox settings page
  */
 public function show_checkbox_settings()
 {
     $opts = mc4wp_get_options('checkbox');
     $lists = $this->mailchimp->get_lists();
     $checkbox_plugins = $this->get_checkbox_compatible_plugins();
     $selected_checkbox_hooks = $this->get_selected_checkbox_hooks();
     require MC4WP_PLUGIN_DIR . 'includes/views/pages/admin-checkbox-settings.php';
 }
Exemplo n.º 3
0
 /**
  * @param string $slug
  *
  * @internal
  */
 public function show_integration_settings_page($slug)
 {
     try {
         $integration = $this->integrations->get($slug);
     } catch (Exception $e) {
         echo sprintf('<h3>Integration not found.</h3><p>No integration with slug <strong>%s</strong> was found.</p>', $slug);
         return;
     }
     $opts = $integration->options;
     $lists = $this->mailchimp->get_lists();
     require dirname(__FILE__) . '/views/integration-settings.php';
 }
Exemplo n.º 4
0
 /**
  * Show the forms settings page
  */
 public function show_form_settings()
 {
     $opts = mc4wp_get_options('form');
     $mailchimp = new MC4WP_MailChimp();
     $lists = $mailchimp->get_lists();
     require MC4WP_LITE_PLUGIN_DIR . 'includes/views/form-settings.php';
 }
 /**
  * @return int
  */
 protected function get_mailchimp_lists_count()
 {
     $mailchimp = new MC4WP_MailChimp();
     $lists = $mailchimp->get_lists(false, true);
     return count($lists);
 }
Exemplo n.º 6
0
 /**
  * Shows the "Add Form" page
  *
  * @internal
  */
 public function show_add_page()
 {
     $lists = $this->mailchimp->get_lists();
     $number_of_lists = count($lists);
     require dirname(__FILE__) . '/views/add-form.php';
 }
Exemplo n.º 7
0
 /**
  * Show the forms settings page
  */
 public function show_form_settings()
 {
     $opts = mc4wp_get_options('form');
     $mailchimp = new MC4WP_MailChimp();
     $lists = $mailchimp->get_lists();
     // create array of missing form fields
     $missing_form_fields = array();
     // check if form contains EMAIL field
     $search = preg_match('/<(input|textarea)(?=[^>]*name="EMAIL")[^>]*>/i', $opts['markup']);
     if (!$search) {
         $missing_form_fields[] = sprintf(__('An EMAIL field. Example: <code>%s</code>', 'mailchimp-for-wp'), '&lt;input type="email" name="EMAIL" /&gt;');
     }
     // check if form contains submit button
     $search = preg_match('/<(input|button)(?=[^>]*type="submit")[^>]*>/i', $opts['markup']);
     if (!$search) {
         $missing_form_fields[] = sprintf(__('A submit button. Example: <code>%s</code>', 'mailchimp-for-wp'), '&lt;input type="submit" value="' . __('Sign Up', 'mailchimp-for-wp') . '" /&gt;');
     }
     // loop through selected list ids
     if (isset($opts['lists']) && is_array($opts['lists'])) {
         foreach ($opts['lists'] as $list_id) {
             // get list object
             $list = $mailchimp->get_list($list_id);
             if (!is_object($list)) {
                 continue;
             }
             // loop through merge vars of this list
             foreach ($list->merge_vars as $merge_var) {
                 // if field is required, make sure it's in the form mark-up
                 if (!$merge_var->req || $merge_var->tag === 'EMAIL') {
                     continue;
                 }
                 // search for field tag in form mark-up using 'name="FIELD_NAME' without closing " because of array fields
                 $search = stristr($opts['markup'], 'name="' . $merge_var->tag);
                 if (false === $search) {
                     $missing_form_fields[] = sprintf(__('A \'%s\' field', 'mailchimp-for-wp'), $merge_var->tag);
                 }
             }
         }
     }
     require MC4WP_LITE_PLUGIN_DIR . 'includes/views/form-settings.php';
 }
Exemplo n.º 8
0
 /**
  * Helper function to retrieve MailChimp lists through MailChimp for WordPress
  *
  * Will try v3.0+ first, then fallback to older versions.
  *
  * @return array
  */
 protected function get_mailchimp_lists()
 {
     /**
      * @since 3.0
      */
     if (class_exists('MC4WP_MailChimp_Tools') && method_exists('MC4WP_MailChimp_Tools', 'get_lists')) {
         return MC4WP_MailChimp_Tools::get_lists();
     }
     /** @deprecated MailChimp for WordPress v3.0  */
     if (class_exists('MC4WP_MailChimp')) {
         $mailchimp = new \MC4WP_MailChimp();
         return $mailchimp->get_lists();
     }
     return array();
 }