public static function draw_share_counter_code($position, $counter, $counter_hidden)
 {
     $css_hidden_negative = "";
     if ($counter_hidden != '') {
         if (intval($counter_hidden) > intval($counter)) {
             $css_hidden_negative = ' style="display: none;"';
         }
     }
     $counter_short = "";
     if ($position != "hidden" && $position != "_hidden") {
         $counter_short = ESSBButtonHelper::kilomega($counter);
     }
     return '<span class="essb_counter' . $position . '" cnt="' . $counter . '"' . $css_hidden_negative . '>' . $counter_short . '</span>';
 }
Ejemplo n.º 2
0
 public static function twitter_message_optimization($tweet, $url, $user, $hashtags, $method = '1')
 {
     global $essb_options;
     $max_message_length = 140;
     $twitter_message_optimize_dots = ESSBOptionValuesHelper::options_bool_value($essb_options, 'twitter_message_optimize_dots');
     $current_message_length = ESSBButtonHelper::twitter_message_length($tweet, $url, $user, $hashtags);
     $result = array();
     $result['tweet'] = $tweet;
     $result['hashtags'] = $hashtags;
     $result['user'] = $user;
     if ($current_message_length < $max_message_length) {
         return $result;
     } else {
         switch ($method) {
             case "1":
                 $result['hashtags'] = '';
                 $current_message_length = ESSBButtonHelper::twitter_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                 if ($current_message_length > $max_message_length) {
                     $result['user'] = '';
                     $current_message_length = ESSBButtonHelper::twitter_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                     if ($current_message_length > $max_message_length) {
                         $length = ESSBButtonHelper::twitter_maximum_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                         if ($twitter_message_optimize_dots) {
                             $length -= 3;
                         }
                         $last_space = strrpos(substr($result['tweet'], 0, $length), '+');
                         $trimmed_text = substr($result['tweet'], 0, $last_space);
                         if ($twitter_message_optimize_dots) {
                             $trimmed_text .= '...';
                         }
                         $result['tweet'] = $trimmed_text;
                     }
                 }
                 break;
             case "2":
                 $result['user'] = '';
                 $current_message_length = ESSBButtonHelper::twitter_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                 if ($current_message_length > $max_message_length) {
                     $result['hashtags'] = '';
                     $current_message_length = ESSBButtonHelper::twitter_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                     if ($current_message_length > $max_message_length) {
                         $length = ESSBButtonHelper::twitter_maximum_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                         if ($twitter_message_optimize_dots) {
                             $length -= 3;
                         }
                         $last_space = strrpos(substr($result['tweet'], 0, $length), '+');
                         $trimmed_text = substr($result['tweet'], 0, $last_space);
                         if ($twitter_message_optimize_dots) {
                             $trimmed_text .= '...';
                         }
                         $result['tweet'] = $trimmed_text;
                     }
                 }
                 break;
             case "3":
                 $result['user'] = '';
                 $current_message_length = ESSBButtonHelper::twitter_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                 if ($current_message_length > $max_message_length) {
                     $length = ESSBButtonHelper::twitter_maximum_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                     if ($twitter_message_optimize_dots) {
                         $length -= 3;
                     }
                     $last_space = strrpos(substr($result['tweet'], 0, $length), '+');
                     $trimmed_text = substr($result['tweet'], 0, $last_space);
                     if ($twitter_message_optimize_dots) {
                         $trimmed_text .= '...';
                     }
                     $result['tweet'] = $trimmed_text;
                 }
                 break;
             case "4":
                 $result['hashtags'] = '';
                 $current_message_length = ESSBButtonHelper::twitter_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                 if ($current_message_length > $max_message_length) {
                     $length = ESSBButtonHelper::twitter_maximum_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                     if ($twitter_message_optimize_dots) {
                         $length -= 3;
                     }
                     $last_space = strrpos(substr($result['tweet'], 0, $length), '+');
                     $trimmed_text = substr($result['tweet'], 0, $last_space);
                     if ($twitter_message_optimize_dots) {
                         $trimmed_text .= '...';
                     }
                     $result['tweet'] = $trimmed_text;
                 }
                 break;
             case "5":
                 $length = ESSBButtonHelper::twitter_maximum_message_length($result['tweet'], $url, $result['user'], $result['hashtags']);
                 if ($twitter_message_optimize_dots) {
                     $length -= 3;
                 }
                 $last_space = strrpos(substr($result['tweet'], 0, $length), '+');
                 $trimmed_text = substr($result['tweet'], 0, $last_space);
                 if ($twitter_message_optimize_dots) {
                     $trimmed_text .= '...';
                 }
                 $result['tweet'] = $trimmed_text;
                 break;
         }
         return $result;
     }
 }
Ejemplo n.º 3
0
 function essb_shortcode_total_shares($atts)
 {
     global $post;
     $atts = shortcode_atts(array('message' => '', 'align' => '', 'url' => '', 'share_text' => '', 'fullnumber' => 'no', 'networks' => '', 'inline' => 'no'), $atts);
     $align = isset($atts['align']) ? $atts['align'] : '';
     $message = isset($atts['message']) ? $atts['message'] : '';
     $url = isset($atts['url']) ? $atts['url'] : '';
     $share_text = isset($atts['share_text']) ? $atts['share_text'] : '';
     $fullnumber = isset($atts['fullnumber']) ? $atts['fullnumber'] : 'no';
     $networks = isset($atts['networks']) ? $atts['networks'] : 'no';
     $inline = isset($atts['inline']) ? $atts['inline'] : 'no';
     $data_full_number = "false";
     if ($fullnumber == 'yes') {
         $data_full_number = "true";
     }
     // init global options
     $options = $this->options;
     if ($networks != '') {
         $buttons = $networks;
     } else {
         $buttons = implode(',', $this->network_options['networks']);
     }
     $css_class_align = "";
     $data_url = $post ? get_permalink() : ESSBUrlHelper::get_current_url('raw');
     if (ESSBOptionValuesHelper::options_bool_value($this->options, 'avoid_nextpage')) {
         $data_url = $post ? get_permalink(get_the_ID()) : ESSBUrlHelper::get_current_url('raw');
     }
     if (ESSBOptionValuesHelper::options_bool_value($this->options, 'force_wp_fullurl')) {
         $data_url = ESSBUrlHelper::get_current_page_url();
     }
     if (ESSBOptionValuesHelper::options_bool_value($this->options, 'always_use_http')) {
         $data_url = str_replace("https://", "http://", $data_url);
     }
     if ($url != '') {
         $data_url = $url;
     }
     $data_post_id = "";
     if (isset($post)) {
         $data_post_id = $post->ID;
     }
     if ($align == "right" || $align == "center") {
         $css_class_align = $align;
     }
     $total_counter_hidden = $this->general_options['total_counter_hidden_till'];
     // @since 3.3 support for cached counters
     $cached_counters = array();
     $cached_counters_active = false;
     $cached_total_counter = '';
     if (defined('ESSB3_CACHED_COUNTERS')) {
         $share_options = array('url' => $data_url, 'full_url' => $data_url);
         $cached_counter_networks = ESSBCachedCounters::prepare_list_of_networks_with_counter(explode(',', $buttons), explode(',', $buttons));
         $cached_counters = ESSBCachedCounters::get_counters($data_post_id, $share_options, $cached_counter_networks);
         $cached_counters_active = true;
     } else {
         $use_minifed_js = $this->general_options['use_minified_js'] ? ".min" : "";
         $script_url = ESSB3_PLUGIN_URL . '/assets/js/easy-social-share-buttons-total' . $use_minifed_js . '.js';
         essb_resource_builder()->add_static_resource_footer($script_url, 'easy-social-share-buttons-total', 'js');
     }
     $css_hide_total_counter = "";
     if ($total_counter_hidden != '') {
         $css_hide_total_counter = ' style="display: none !important;" data-essb-hide-till="' . $total_counter_hidden . '"';
     }
     if ($cached_counters_active) {
         $cached_total_counter = isset($cached_counters['total']) ? $cached_counters['total'] : '0';
         if ($total_counter_hidden != '') {
             if (intval($cached_total_counter) > intval($total_counter_hidden)) {
                 $css_hide_total_counter = "";
             }
         }
         $cached_total_counter = ESSBButtonHelper::kilomega($cached_total_counter);
     }
     $output = "";
     $tag = $inline == 'yes' ? 'span' : 'div';
     $output .= '<' . $tag . ' class="essb-total ' . $css_class_align . '" data-network-list="' . $buttons . '" data-url="' . $data_url . '" data-full-number="' . $data_full_number . '" data-post="' . $data_post_id . '" ' . $css_hide_total_counter . '>';
     if ($message != '') {
         $output .= '<' . $tag . ' class="essb-message essb-block">' . $message . '</' . $tag . '>';
     }
     $output .= '<' . $tag . ' class="essb-total-value essb-block">' . $cached_total_counter . '</' . $tag . '>';
     if ($share_text != '') {
         $output .= '<' . $tag . ' class="essb-total-text essb-block">' . $share_text . '</' . $tag . '>';
     }
     $output .= '</' . $tag . '>';
     return $output;
 }
Ejemplo n.º 4
0
    function generate_share_buttons($position, $likeshare = 'share', $share_options = array(), $is_shortcode = false, $shortcode_options = array(), $media_url = '')
    {
        global $post;
        $only_share = ESSBOptionValuesHelper::options_bool_value($share_options, 'only_share');
        $post_type = ESSBOptionValuesHelper::options_value($share_options, 'post_type');
        if ($this->general_options['reset_postdata']) {
            wp_reset_postdata();
        }
        $cache_key = "";
        if (isset($post) && defined('ESSB3_CACHE_ACTIVE') && !$is_shortcode) {
            $cache_key = sprintf('essb_cache_share_%1$s_%2$s', $post->ID, $position);
            $cached_data = ESSBDynamicCache::get($cache_key);
            if (!empty($cached_data)) {
                return $cached_data;
            }
        }
        if (empty($post_type) && isset($post)) {
            $post_type = $post->post_type;
        }
        // -- getting main share details based on current post
        $post_share_details = $this->get_post_share_details();
        // generate native button main settings
        $post_native_details = $this->get_native_button_settings($position, $only_share);
        $post_native_details['order'] = $post_native_details['active'] ? ESSBNativeButtonsHelper::active_native_buttons() : array();
        // apply shortcode options
        if ($is_shortcode) {
            if ($shortcode_options['forceurl']) {
                $post_share_details['url'] = ESSBUrlHelper::get_current_page_url();
            }
            if ($shortcode_options['url'] != '') {
                $post_share_details['url'] = $shortcode_options['url'];
            }
            if ($shortcode_options['title'] != '') {
                $post_share_details['title'] = $shortcode_options['title'];
                $post_share_details['title_plain'] = $shortcode_options['title'];
            }
            if ($shortcode_options['image'] != '') {
                $post_share_details['image'] = $shortcode_options['image'];
            }
            if ($shortcode_options['description'] != '') {
                $post_share_details['description'] = $shortcode_options['description'];
            }
            // customize tweet message
            if ($shortcode_options['twitter_user'] != '') {
                $post_share_details['twitter_user'] = $shortcode_options['twitter_user'];
            }
            if ($shortcode_options['twitter_hashtags'] != '') {
                $post_share_details['twitter_hashtags'] = $shortcode_options['twitter_hashtags'];
            }
            if ($shortcode_options['twitter_tweet'] != '') {
                $post_share_details['twitter_tweet'] = $shortcode_options['twitter_tweet'];
            } else {
                if ($shortcode_options['title'] != '') {
                    $post_share_details['twitter_tweet'] = $shortcode_options['title'];
                }
            }
            $affwp_active_shortcode = ESSBOptionValuesHelper::options_bool_value($this->options, 'affwp_active_shortcode');
            if ($affwp_active_shortcode) {
                $post_share_details['url'] = ESSBUrlHelper::generate_affiliatewp_referral_link($post_share_details['url']);
            }
            if (isset($shortcode_options['query'])) {
                $post_share_details['query'] = $shortcode_options['query'];
            }
        } else {
            // activate short url and custom campaign tracking codes
            // apply custom share options
            if (!empty($share_options['url'])) {
                $post_share_details['url'] = $share_options['url'];
            }
            if (!empty($share_options['title'])) {
                $post_share_details['title'] = $share_options['title'];
                $post_share_details['title_plain'] = $share_options['title_plain'];
            }
            if (!empty($share_options['image'])) {
                $post_share_details['image'] = $share_options['image'];
            }
            if (!empty($share_options['description'])) {
                $post_share_details['description'] = $share_options['description'];
            }
            // customize tweet message
            if (!empty($share_options['twitter_user'])) {
                $post_share_details['twitter_user'] = $share_options['twitter_user'];
            }
            if (!empty($share_options['twitter_hashtags'])) {
                $post_share_details['twitter_hashtags'] = $share_options['twitter_hashtags'];
            }
            if (!empty($share_options['twitter_tweet'])) {
                $post_share_details['twitter_tweet'] = $share_options['twitter_tweet'];
            }
            if ($media_url != '') {
                $post_share_details['image'] = $media_url;
                $post_share_details['user_image_url'] = $media_url;
            }
            // Google Campaign Tracking code
            $ga_campaign_tracking = $this->general_options['activate_ga_campaign_tracking'];
            $post_ga_campaign_tracking = get_post_meta(get_the_ID(), 'essb_activate_ga_campaign_tracking', true);
            if ($post_ga_campaign_tracking != '') {
                $ga_campaign_tracking = $post_ga_campaign_tracking;
            }
            if ($ga_campaign_tracking != '') {
                $post_share_details['url'] = ESSBUrlHelper::attach_tracking_code($post_share_details['url'], $ga_campaign_tracking);
            }
        }
        // @since 3.1.2 exist filter to control the share address
        if (has_filter('essb3_share_url')) {
            $post_share_details['url'] = apply_filters('essb3_share_url', $post_share_details['url']);
        }
        // -- short url code block
        $post_share_details['full_url'] = $post_share_details['url'];
        if ($this->network_options['twitter_shareshort'] || $this->general_options['shorturl_activate'] || $this->network_options['whatsapp_shareshort']) {
            $global_provider = $this->general_options['shorturl_type'];
            if ($this->general_options['shorturl_activate']) {
                $post_share_details['short_url'] = ESSBUrlHelper::short_url($post_share_details['url'], $global_provider, get_the_ID(), $this->general_options['shorturl_bitlyuser'], $this->general_options['shorturl_bitlyapi']);
                $post_share_details['short_url_twitter'] = $post_share_details['short_url'];
                $post_share_details['short_url_whatsapp'] = $post_share_details['short_url'];
            } else {
                if ($this->network_options['twitter_shareshort']) {
                    $provider = $this->network_options['twitter_shareshort_service'];
                    $post_share_details['short_url_twitter'] = ESSBUrlHelper::short_url($post_share_details['url'], $provider, get_the_ID(), $this->general_options['shorturl_bitlyuser'], $this->general_options['shorturl_bitlyapi']);
                }
                if ($this->network_options['whatsapp_shareshort']) {
                    $provider = $this->network_options['whatsapp_shareshort_service'];
                    if ($provider == $this->network_options['twitter_shareshort_service'] && $this->network_options['twitter_shareshort']) {
                        $post_share_details['short_url_whatsapp'] = $post_share_details['short_url_twitter'];
                    } else {
                        $post_share_details['short_url_whatsapp'] = ESSBUrlHelper::short_url($post_share_details['url'], $provider, get_the_ID(), $this->general_options['shorturl_bitlyuser'], $this->general_options['shorturl_bitlyapi']);
                    }
                }
                if ($post_share_details['short_url_twitter'] == '') {
                    $post_share_details['short_url_twitter'] = $post_share_details['url'];
                }
                if ($post_share_details['short_url_whatsapp'] == '') {
                    $post_share_details['short_url_whatsapp'] = $post_share_details['url'];
                }
            }
        } else {
            $post_share_details['short_url'] = $post_share_details['url'];
            $post_share_details['short_url_twitter'] = $post_share_details['url'];
            $post_share_details['short_url_whatsapp'] = $post_share_details['url'];
        }
        //-- end: short url code block
        // -- main button design
        $button_style = $this->get_buttons_visual_options($position);
        $social_networks = $this->network_options['networks'];
        $social_networks_order = $this->network_options['networks_order'];
        $social_networks_names = $this->network_options['default_names'];
        // apply settings based on position when active
        $check_position_settings_key = $position;
        if ($this->is_mobile() && ESSBOptionValuesHelper::is_active_position_settings('mobile')) {
            $check_position_settings_key = 'mobile';
        }
        // double check to avoid missconfiguration based on mobile specific settings
        if ($check_position_settings_key != 'sharebar' && $check_position_settings_key != 'sharepoint' && $check_position_settings_key != 'sharebottom') {
            // first check for post type settins - if there are such that will be the settings key. If nothing is active switch to button position
            // settings
            if (!empty($post_type)) {
                if (ESSBOptionValuesHelper::is_active_position_settings(sprintf('post-type-%1$s', $post_type))) {
                    $check_position_settings_key = sprintf('post-type-%1$s', $post_type);
                }
            }
            if (ESSBOptionValuesHelper::is_active_position_settings($check_position_settings_key)) {
                $button_style = ESSBOptionValuesHelper::apply_position_style_settings($check_position_settings_key, $button_style);
                $instance_template = $button_style['template'];
                $instance_template_slug = ESSBCoreHelper::template_folder($instance_template);
                if ($instance_template_slug != $this->design_options['template_slug']) {
                    $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : "";
                    $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $instance_template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css';
                    $this->resource_builder->add_static_footer_css($template_url, 'easy-social-share-buttons-' . $instance_template_slug);
                }
                $personalized_networks = ESSBOptionValuesHelper::get_active_social_networks_by_position($check_position_settings_key);
                $personalized_network_order = ESSBOptionValuesHelper::get_order_of_social_networks_by_position($check_position_settings_key);
                if (is_array($personalized_networks) && count($personalized_networks) > 0) {
                    $social_networks = $personalized_networks;
                }
                if (is_array($personalized_network_order) && count($personalized_network_order) > 0) {
                    $social_networks_order = $personalized_network_order;
                }
                $social_networks_names = ESSBOptionValuesHelper::apply_position_network_names($position, $social_networks_names);
            }
        }
        // apply safe default of mobile styles to avoid miss configured display
        $share_bottom_networks = array();
        if ($position == 'sharebar' || $position == 'sharepoint' || $position == 'sharebottom') {
            // apply mobile personalizations by display methods
            if (ESSBOptionValuesHelper::is_active_position_settings($position)) {
                $button_style = ESSBOptionValuesHelper::apply_mobile_position_style_settings($position, $button_style);
                $instance_template = $button_style['template'];
                $instance_template_slug = ESSBCoreHelper::template_folder($instance_template);
                if ($instance_template_slug != $this->design_options['template_slug']) {
                    $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : "";
                    $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $instance_template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css';
                    $this->resource_builder->add_static_footer_css($template_url, 'easy-social-share-buttons-' . $instance_template_slug);
                }
                $personalized_networks = ESSBOptionValuesHelper::get_active_social_networks_by_position($position);
                $personalized_network_order = ESSBOptionValuesHelper::get_order_of_social_networks_by_position($position);
                if (is_array($personalized_networks) && count($personalized_networks) > 0) {
                    $social_networks = $personalized_networks;
                }
                if (is_array($personalized_network_order) && count($personalized_network_order) > 0) {
                    $social_networks_order = $personalized_network_order;
                }
                $social_networks_names = ESSBOptionValuesHelper::apply_position_network_names($position, $social_networks_names);
            }
            // apply sharebar and sharepoint default styles
            if ($position == 'sharebar' || $position == 'sharepoint') {
                // for those display methods the more buttons is not needed
                if (in_array('more', $social_networks)) {
                    if (($key = array_search('more', $social_networks)) !== false) {
                        unset($social_networks[$key]);
                    }
                }
                $button_style['button_style'] = "button";
                if ($button_style['show_counter']) {
                    if (strpos($button_style['counter_pos'], 'inside') === false && strpos($button_style['counter_pos'], 'hidden') === false) {
                        $button_style['counter_pos'] = "insidename";
                    }
                    if ($button_style['total_counter_pos'] != 'hidden' && $button_style['total_counter_pos'] != 'after') {
                        $button_style['total_counter_pos'] = "before";
                    }
                }
                $button_style['button_width'] = "column";
                $button_style['button_width_columns'] = "1";
            }
            if ($position == 'sharebottom') {
                if (in_array('more', $social_networks)) {
                    if (($key = array_search('more', $social_networks)) !== false) {
                        unset($social_networks[$key]);
                    }
                }
                $button_style['button_style'] = "icon";
                $button_style['show_counter'] = false;
                $button_style['nospace'] = true;
                $button_style['button_width'] = "column";
                $available_networks_count = ESSBOptionValuesHelper::options_value($this->options, 'mobile_sharebuttonsbar_count');
                $mobile_sharebuttonsbar_names = ESSBOptionValuesHelper::options_bool_value($this->options, 'mobile_sharebuttonsbar_names');
                if ($mobile_sharebuttonsbar_names) {
                    $button_style['button_style'] = 'button';
                }
                if (intval($available_networks_count) == 0) {
                    $available_networks_count = 4;
                }
                if (count($social_networks) > intval($available_networks_count)) {
                    $share_bottom_networks = $social_networks;
                    array_splice($social_networks, intval($available_networks_count) - 1);
                    $social_networks[] = "more";
                    //$button_style['more_button_icon'] = "dots";
                }
                $button_style['button_width_columns'] = intval($available_networks_count);
            }
        }
        if (!is_array($social_networks)) {
            $social_networks = array();
        }
        if (!is_array($social_networks_order) || count($social_networks_order) == 0) {
            $social_networks_order = ESSBCoreHelper::generate_network_list();
        }
        // apply shortcode customizations
        if ($is_shortcode) {
            // apply personalization of social networks if set from shortcode
            if (count($shortcode_options['networks']) > 0) {
                $social_networks = $shortcode_options['networks'];
                $social_networks_order = $shortcode_options['networks'];
            }
            if ($shortcode_options['customize_texts']) {
                $social_networks_names = $shortcode_options['network_texts'];
            }
            // apply shortcode counter options
            if ($shortcode_options['counters'] == 1) {
                $button_style['show_counter'] = true;
            } else {
                $button_style['show_counter'] = false;
            }
            if (!empty($shortcode_options['style'])) {
                $button_style['button_style'] = $shortcode_options['style'];
            }
            if (!empty($shortcode_options['counters_pos'])) {
                $button_style['counter_pos'] = $shortcode_options['counters_pos'];
            }
            if (!empty($shortcode_options['total_counter_pos'])) {
                $button_style['total_counter_pos'] = $shortcode_options['total_counter_pos'];
            }
            if ($shortcode_options['hide_total']) {
                $button_style['total_counter_pos'] = "hidden";
            }
            if ($shortcode_options['fullwidth']) {
                $button_style['button_width'] = "full";
                if (!empty($shortcode_options['fullwidth_fix'])) {
                    $button_style['button_width_full_button'] = $shortcode_options['fullwidth_fix'];
                }
                if (!empty($shortcode_options['fullwidth_align'])) {
                    $button_style['fullwidth_align'] = $shortcode_options['fullwidth_align'];
                }
            }
            if ($shortcode_options['fixedwidth']) {
                $button_style['button_width'] = "fixed";
                if (!empty($shortcode_options['fixedwidth_px'])) {
                    $button_style['button_width_fixed_value'] = $shortcode_options['fixedwidth_px'];
                }
                if (!empty($shortcode_options['fixedwidth_align'])) {
                    $button_style['button_width_fixed_align'] = $shortcode_options['fixedwidth_align'];
                }
            }
            if (!empty($shortcode_options['morebutton'])) {
                $button_style['more_button_func'] = $shortcode_options['morebutton'];
            }
            if (!empty($shortcode_options['morebutton_icon'])) {
                $button_style['more_button_icon'] = $shortcode_options['morebutton_icon'];
            }
            if ($shortcode_options['column']) {
                $button_style['button_width'] = "column";
                if (!empty($shortcode_options['columns'])) {
                    $button_style['button_width_columns'] = $shortcode_options['columns'];
                }
            }
            if (!empty($shortcode_options['template'])) {
                $instance_template_slug = $shortcode_options['template'];
                if ($instance_template_slug != $this->design_options['template_slug']) {
                    $use_minifed_css = $this->general_options['use_minified_css'] ? ".min" : "";
                    $template_url = ESSB3_PLUGIN_URL . '/assets/css/' . $instance_template_slug . '/easy-social-share-buttons' . $use_minifed_css . '.css';
                    $this->resource_builder->add_static_footer_css($template_url, 'easy-social-share-buttons-' . $instance_template_slug);
                }
                $button_style['template'] = $shortcode_options['template'];
            }
            if (!empty($shortcode_options['sidebar_pos'])) {
                $button_style['sidebar_pos'] = $shortcode_options['sidebar_pos'];
            }
            $button_style['nospace'] = $shortcode_options['nospace'];
            $button_style['nostats'] = $shortcode_options['nostats'];
            if (!empty($shortcode_options['fblike'])) {
                $post_native_details['facebook_url'] = $shortcode_options['fblike'];
            }
            if (!empty($shortcode_options['plusone'])) {
                $post_native_details['google_url'] = $shortcode_options['plusone'];
            }
            if (!$shortcode_options['message']) {
                $button_style['message_share_buttons'] = "";
                $button_style['message_before_share_buttons'] = "";
            }
            //apply again mobile settings for the mobile buttons bar
            if ($position == 'sharebottom') {
                if (in_array('more', $social_networks)) {
                    if (($key = array_search('more', $social_networks)) !== false) {
                        unset($social_networks[$key]);
                    }
                }
                $button_style['button_style'] = "icon";
                $button_style['show_counter'] = false;
                $button_style['nospace'] = true;
                $button_style['button_width'] = "column";
                $available_networks_count = ESSBOptionValuesHelper::options_value($this->options, 'mobile_sharebuttonsbar_count');
                $mobile_sharebuttonsbar_names = ESSBOptionValuesHelper::options_bool_value($this->options, 'mobile_sharebuttonsbar_names');
                if ($mobile_sharebuttonsbar_names) {
                    $button_style['button_style'] = 'button';
                }
                if (intval($available_networks_count) == 0) {
                    $available_networks_count = 4;
                }
                if (count($social_networks) > intval($available_networks_count)) {
                    $share_bottom_networks = $social_networks;
                    array_splice($social_networks, intval($available_networks_count) - 1);
                    $social_networks[] = "more";
                    $social_networks_order[] = "more";
                    //$button_style['more_button_icon'] = "dots";
                }
                $button_style['button_width_columns'] = intval($available_networks_count);
            }
        }
        // generate unique instance key
        $salt = mt_rand();
        // attache compliled mail message data
        if (in_array("mail", $social_networks)) {
            //if ($this->network_options['mail_function'] == "form") {
            $base_subject = $this->network_options['mail_subject'];
            $base_body = $this->network_options['mail_body'];
            $base_subject = preg_replace(array('#%%title%%#', '#%%siteurl%%#', '#%%permalink%%#', '#%%image%%#', '#%%shorturl%%#'), array($post_share_details['title_plain'], get_site_url(), $post_share_details['url'], $post_share_details['image'], $post_share_details['short_url']), $base_subject);
            $base_body = preg_replace(array('#%%title%%#', '#%%siteurl%%#', '#%%permalink%%#', '#%%image%%#', '#%%shorturl%%#'), array($post_share_details['title_plain'], get_site_url(), $post_share_details['url'], $post_share_details['image'], $post_share_details['short_url']), $base_body);
            $post_share_details['mail_subject'] = $base_subject;
            $post_share_details['mail_body'] = $base_body;
            $ga_tracking = ESSBOptionValuesHelper::options_value($this->options, 'activate_ga_campaign_tracking');
            if ($ga_tracking != '') {
                $post_share_details['mail_subject'] = str_replace('{network}', 'mail', $post_share_details['mail_subject']);
                $post_share_details['mail_body'] = str_replace('{title}', $post_share_details['title_plain'], $post_share_details['mail_body']);
            }
            //}
            //else {
            //	$post_share_details['mail_subject'] = '';
            //	$post_share_details['mail_body'] = '';
            //}
            $this->resource_builder->add_js(ESSBResourceBuilderSnippets::js_build_generate_popup_mailform(), true, 'essb-mailform');
            $this->resource_builder->add_js(ESSBButtonHelper::print_mailer_code($post_share_details['mail_subject'], $post_share_details['mail_body'], $salt, $post_share_details["post_id"], $position), true, 'essb-mailform-' . $salt);
        }
        $button_style['included_button_count'] = count($social_networks);
        if (isset($button_style['total_counter_pos'])) {
            if ($button_style['total_counter_pos'] != 'hidden') {
                $button_style['included_button_count']++;
            }
        }
        $intance_morebutton_func = $this->network_options['more_button_func'];
        if ($position == "sidebar" || $position == "postfloat") {
            //$intance_morebutton_func = "2";
            if ($button_style['more_button_func'] == '1') {
                $button_style['more_button_func'] = "2";
            }
        }
        if ($position == "sharebottom") {
            //$intance_morebutton_func = "3";
            $button_style['more_button_func'] = "3";
        }
        //$button_style['more_button_func'] = $intance_morebutton_func;
        // sidebar close button option if activated into settings
        if ($this->design_options['sidebar_leftright_close'] && $position == "sidebar") {
            $social_networks[] = "sidebar-close";
            $social_networks_order[] = "sidebar-close";
        }
        // apply additional native button options
        if ($post_native_details['active']) {
            $post_native_details['url'] = $post_share_details['url'];
            $post_native_details['text'] = $post_share_details['title'];
        }
        // @since 3.0 beta 4 - check if on post settings we have set counters that are not active generally
        if ($button_style['show_counter']) {
            if (!isset($this->activated_resources['counters'])) {
                if (!defined('ESSB3_COUNTER_LOADED')) {
                    $script_url = ESSB3_PLUGIN_URL . '/assets/js/easy-social-share-buttons' . $this->use_minified_js . '.js';
                    $this->resource_builder->add_static_resource_footer($script_url, 'easy-social-share-buttons', 'js');
                    $this->activated_resources['counters'] = true;
                    define('ESSB3_COUNTER_LOADED', true);
                }
            }
        }
        // @since 3.0.3 fix for the mail function
        $button_style['mail_function'] = $this->network_options['mail_function'];
        // @since 3.2 - passing mobile state to button style to allow deactivate advaned share on mobile (does not work);
        $button_style['is_mobile'] = $this->is_mobile();
        $ssbuttons = ESSBButtonHelper::draw_share_buttons($post_share_details, $button_style, $social_networks, $social_networks_order, $social_networks_names, $position, $salt, $likeshare, $post_native_details);
        //print_r($post_native_details);
        if ($post_native_details['active']) {
            if (!$post_native_details['sameline']) {
                $post_native_details['withshare'] = true;
                //@fixed display of native for float in 3.0beta5
                $native_buttons_code = ESSBNativeButtonsHelper::draw_native_buttons($post_native_details, $post_native_details['order'], $post_native_details['counters'], $post_native_details['sameline'], $post_native_details['skinned']);
                $ssbuttons = str_replace('<!--native--></div>', $native_buttons_code . '</div>', $ssbuttons);
            }
        }
        if ($button_style['button_width'] == "fixed") {
            //print "fixed button code adding";
            $fixedwidth_key = $button_style['button_width_fixed_value'] . "-" . $button_style['button_width_fixed_align'];
            $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_fixedwidth_button($salt, $button_style['button_width_fixed_value'], $button_style['button_width_fixed_align']), 'essb-fixed-width-' . $fixedwidth_key, 'footer');
        }
        if ($button_style['button_width'] == "full") {
            //print_r($button_style);
            //print "fixed button code adding";
            $count_of_social_networks = count($social_networks);
            if (isset($button_style['total_counter_pos'])) {
                if ($button_style['total_counter_pos'] != 'hidden') {
                    $count_of_social_networks++;
                }
            }
            $container_width = $button_style['button_width_full_container'];
            $single_button_width = intval($container_width) / $count_of_social_networks;
            $single_button_width = floor($single_button_width);
            $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_fullwidth_button($single_button_width, $button_style['button_width_full_button'], $button_style['button_width_full_container']), 'essb-full-width-' . $single_button_width . '-' . $button_style['button_width_full_button'] . '-' . $button_style['button_width_full_container'], 'footer');
        }
        // more buttons code append
        if (in_array("more", $social_networks)) {
            //print "position = ".$position. ", more button = ".$intance_morebutton_func;
            $user_set_morebutton_func = $button_style['more_button_func'];
            if ($user_set_morebutton_func == '1') {
                $this->resource_builder->add_js(ESSBResourceBuilderSnippets::js_build_generate_more_button_inline(), true, 'essb-inlinemore-code');
            }
            if ($user_set_morebutton_func == '2' || $user_set_morebutton_func == '3') {
                $this->resource_builder->add_js(ESSBResourceBuilderSnippets::js_build_generate_more_button_popup(), true, 'essb-popupmore-code');
                $listAllNetworks = $user_set_morebutton_func == '2' ? true : false;
                $more_social_networks = ESSBCoreHelper::generate_list_networks($listAllNetworks);
                $more_social_networks_order = ESSBCoreHelper::generate_network_list();
                if ($position == "sharebottom") {
                    $more_social_networks = $share_bottom_networks;
                    $more_social_networks_order = $social_networks_order;
                    //$button_style['more_button_icon'] = "dots";
                }
                $button_style['button_style'] = "button";
                $button_style['show_counter'] = false;
                $button_style['button_width'] = "column";
                $button_style['button_width_columns'] = $this->is_mobile() ? "1" : "3";
                $button_style['counter_pos'] = "left";
                if ($position == "sharebottom") {
                    $button_style['button_width_columns'] = "1";
                }
                $more_salt = mt_rand();
                $ssbuttons .= sprintf('<div class="essb_morepopup essb_morepopup_%1$s" style="display:none;">
						<a href="#" class="essb_morepopup_close" onclick="essb_toggle_less_popup(\'%1$s\'); return false;"></a>
						<div class="essb_morepopup_content essb_morepopup_content_%1$s">%2$s</div></div>
						<div class="essb_morepopup_shadow essb_morepopup_shadow_%1$s" onclick="essb_toggle_less_popup(\'%1$s\'); return false;"></div>', $salt, ESSBButtonHelper::draw_share_buttons($post_share_details, $button_style, $more_social_networks, $more_social_networks_order, $social_networks_names, "more_popup", $more_salt, 'share'));
                $this->resource_builder->add_css(ESSBResourceBuilderSnippets::css_build_morepopup_css(), 'essb-morepopup-css', 'footer');
            }
        }
        // apply clean of new lines
        if (!empty($ssbuttons)) {
            $ssbuttons = trim(preg_replace('/\\s+/', ' ', $ssbuttons));
        }
        if (!empty($cache_key)) {
            ESSBDynamicCache::put($cache_key, $ssbuttons);
        }
        return $ssbuttons;
    }