public function update_mailpoet()
 {
     $result = 0;
     $list = ESSBSocialFollowersCounterHelper::get_option('mailpoet_id');
     if (!empty($list)) {
         if ($list == 'all') {
             $result = ESSBSocialFollowersCounterHelper::mailpoet_total_subscribers();
         } else {
             $result = ESSBSocialFollowersCounterHelper::mailpoet_get_list_users($list);
         }
     }
     return $result;
 }
 /**
  * draw_followers
  *
  * Display instance of generated followers counter
  *
  * @param $options array       	
  * @param $draw_title boolean       	
  * @since 3.4
  */
 public static function draw_followers($options, $draw_title = false)
 {
     $hide_title = isset($options['hide_title']) ? $options['hide_title'] : 0;
     if (intval($hide_title) == 1) {
         $draw_title = false;
     }
     $instance_title = isset($options['title']) ? $options['title'] : '';
     $instance_new_window = isset($options['new_window']) ? $options['new_window'] : 0;
     $instance_nofollow = isset($options['nofollow']) ? $options['nofollow'] : 0;
     $instance_show_total = isset($options['show_total']) ? $options['show_total'] : 0;
     $instance_total_type = isset($options['total_type']) ? $options['total_type'] : 'button_single';
     $instance_columns = isset($options['columns']) ? $options['columns'] : 3;
     $instance_template = isset($options['template']) ? $options['template'] : 'flat';
     $instance_animation = isset($options['animation']) ? $options['animation'] : '';
     $instance_bgcolor = isset($options['bgcolor']) ? $options['bgcolor'] : '';
     $instance_nospace = isset($options['nospace']) ? $options['nospace'] : 0;
     // compatibility with previous template slugs
     if (!empty($instance_template)) {
         if ($instance_template == "lite") {
             $instance_template = "light";
         }
         if ($instance_template == "grey-transparent") {
             $instance_template = "grey";
         }
         if ($instance_template == "color-transparent") {
             $instance_template = "color";
         }
     }
     $class_template = !empty($instance_template) ? " essbfc-template-" . $instance_template : '';
     $class_animation = !empty($instance_animation) ? " essbfc-icon-" . $instance_animation : '';
     $class_columns = !empty($instance_columns) ? " essbfc-col-" . $instance_columns : '';
     $class_nospace = intval($instance_nospace) == 1 ? " essbfc-nospace" : "";
     $style_bgcolor = !empty($instance_bgcolor) ? ' style="background-color:' . $instance_bgcolor . ';"' : '';
     $link_nofollow = intval($instance_nofollow) == 1 ? ' rel="nofollow"' : '';
     $link_newwindow = intval($instance_new_window) == 1 ? ' target="_blank"' : '';
     // loading animations
     if (!empty($class_animation)) {
         essb_resource_builder()->add_static_footer_css(ESSB3_PLUGIN_URL . '/lib/modules/social-followers-counter/assets/css/hover.css', 'essb-social-followers-counter-animations', 'css');
     }
     // followers main element
     printf('<div class="essbfc-container%1$s%2$s%3$s%5$s"%4$s>', '', $class_columns, $class_template, $style_bgcolor, $class_nospace);
     if ($draw_title && !empty($instance_title)) {
         printf('<h3>%1$s</h3>', $instance_title);
     }
     // get current state of followers counter
     $followers_count = essb_followers_counter()->get_followers();
     $display_total = intval($instance_show_total) == 1 ? true : false;
     $total_followers = 0;
     if ($display_total) {
         foreach ($followers_count as $network => $count) {
             if (intval($count) > 0) {
                 $total_followers += intval($count);
             }
         }
     }
     if ($display_total && $instance_total_type == "text_before") {
         printf('<div class="essbfc-totalastext">%1$s %2$s</div>', self::followers_number($total_followers), ESSBSocialFollowersCounterHelper::get_option('total_text'));
     }
     echo '<ul>';
     foreach (essb_followers_counter()->active_social_networks() as $social) {
         $social_followers_text = ESSBSocialFollowersCounterHelper::get_option($social . '_text');
         $social_followers_counter = isset($followers_count[$social]) ? $followers_count[$social] : 0;
         $social_display = $social;
         if ($social_display == "instgram") {
             $social_display = "instagram";
         }
         printf('<li class="essbfc-%1$s">', $social_display);
         $follow_url = essb_followers_counter()->create_follow_address($social);
         if (!empty($follow_url)) {
             printf('<a href="%1$s"%2$s%3$s>', $follow_url, $link_newwindow, $link_nofollow);
         }
         echo '<div class="essbfc-network">';
         printf('<i class="essbfc-icon essbfc-icon-%1$s%2$s"></i>', $social_display, $class_animation);
         printf('<span class="essbfc-followers-count">%1$s</span>', self::followers_number($social_followers_counter));
         printf('<span class="essbfc-followers-text">%1$s</span>', $social_followers_text);
         echo '</div>';
         if (!empty($follow_url)) {
             echo '</a>';
         }
         echo '</li>';
     }
     if ($display_total && $instance_total_type == "button_single") {
         $social = 'total';
         printf('<li class="essbfc-%1$s">', $social);
         echo '<div class="essbfc-network">';
         printf('<i class="essbfc-icon  essbfc-icon-%1$s%2$s"></i>', $social, $class_animation);
         printf('<span class="essbfc-followers-count">%1$s</span>', self::followers_number($total_followers));
         printf('<span class="essbfc-followers-text">%1$s</span>', ESSBSocialFollowersCounterHelper::get_option('total_text'));
         echo '</div>';
         echo '</li>';
     }
     echo '</ul>';
     if ($display_total && $instance_total_type == "text_after") {
         printf('<div class="essbfc-totalastext">%1$s %2$s</div>', self::followers_number($total_followers), ESSBSocialFollowersCounterHelper::get_option('total_text'));
     }
     echo '</div>';
     // followers: end
 }
 /**
  * create_follow_address
  * 
  * Generate social follow address based on user settings
  * 
  * @param string $social
  * @return string
  * @since 3.4
  */
 public static function create_follow_address($social)
 {
     switch ($social) {
         case 'facebook':
             return 'https://www.facebook.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'twitter':
             return 'https://www.twitter.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'google':
             return 'https://plus.google.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'pinterest':
             return 'https://www.pinterest.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'linkedin':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'github':
             return 'http://github.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'vimeo':
             if (ESSBSocialFollowersCounterHelper::get_option($social . '_account_type', 'channel') == 'user') {
                 $vimeo_id = trim(ESSBSocialFollowersCounterHelper::get_option($social . '_id'));
                 if (preg_match('/^[0-9]+$/', $vimeo_id)) {
                     return 'http://vimeo.com/user' . $vimeo_id;
                 } else {
                     return 'http://vimeo.com/' . $vimeo_id;
                 }
             } else {
                 return 'http://vimeo.com/channels/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             }
             break;
         case 'dribbble':
             return 'http://dribbble.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'soundcloud':
             return 'https://soundcloud.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'behance':
             return 'http://www.behance.net/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'foursquare':
             if (intval(ESSBSocialFollowersCounterHelper::get_option($social . '_id')) && intval(ESSBSocialFollowersCounterHelper::get_option($social . '_id')) == ESSBSocialFollowersCounterHelper::get_option($social . '_id')) {
                 return 'https://foursquare.com/user/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             } else {
                 return 'https://foursquare.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             }
             break;
         case 'forrst':
             return 'http://forrst.com/people/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'mailchimp':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_list_url');
             break;
         case 'delicious':
             return 'https://delicious.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'instgram':
         case 'instagram':
             return 'http://instagram.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_username');
             break;
         case 'youtube':
             return 'https://www.youtube.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_account_type') . '/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'envato':
             $ref = '';
             if (ESSBSocialFollowersCounterHelper::get_option($social . '_ref')) {
                 $ref = '?ref=' . ESSBSocialFollowersCounterHelper::get_option($social . '_ref');
             }
             return 'http://www.' . ESSBSocialFollowersCounterHelper::get_option($social . '_site') . '.net/user/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id') . $ref;
             break;
         case 'vk':
             $account_type = ESSBSocialFollowersCounterHelper::get_option($social . '_account_type');
             if ($account_type == "community") {
                 return 'http://www.vk.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             } else {
                 return 'http://www.vk.com/id' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             }
             break;
         case 'rss':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_link');
             break;
         case 'vine':
             return 'https://vine.co/' . ESSBSocialFollowersCounterHelper::get_option($social . '_username');
             break;
         case 'tumblr':
             $basename2arr = explode('.', ESSBSocialFollowersCounterHelper::get_option($social . '_basename'));
             if ($basename2arr == 'www') {
                 return 'http://' . ESSBSocialFollowersCounterHelper::get_option($social . '_basename');
             } else {
                 return 'http://www.tumblr.com/follow/' . @$basename2arr[0];
             }
             break;
         case 'slideshare':
             return 'http://www.slideshare.net/' . ESSBSocialFollowersCounterHelper::get_option($social . '_username');
             break;
         case '500px':
             return 'http://500px.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_username');
             break;
         case 'flickr':
             return 'https://www.flickr.com/photos/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'wp_posts':
         case 'wp_users':
         case 'wp_comments':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_url');
             break;
         case 'audioboo':
             return 'https://audioboo.fm/users/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'steamcommunity':
             return 'http://steamcommunity.com/groups/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'weheartit':
             return 'http://weheartit.com/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
         case 'love':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_url');
             break;
         case 'total':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_url');
             break;
         case 'feedly':
             return 'http://feedly.com/i/subscription/feed' . urlencode('/' . ESSBSocialFollowersCounterHelper::get_option($social . '_url'));
             break;
         case 'mymail':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_url');
             break;
         case 'mailpoet':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_url');
             break;
         case 'twitch':
             return 'http://www.twitch.tv/' . ESSBSocialFollowersCounterHelper::get_option($social . '_id') . '/profile';
             break;
         case 'spotify':
             return ESSBSocialFollowersCounterHelper::get_option($social . '_id');
             break;
     }
 }