'; $content .= sprintf('', $single, $more_after_class, $url, $hover_text, $api_command, $name, $mycred_token, $icon, $noname_class, $link_target, $button_follow_state, $cached_code_left, $cached_code_before, $cached_code_insidebefore, $cached_code_insideafter, $cached_code_right, $additional_icon, $cached_code_after); // at the end toggle more button state if ($single == 'more') { $is_active_more_button = true; } if ($single == 'share') { $is_active_share_button = true; } } } // adding less button when + function of more button is active //if (($is_active_more_button && $style['more_button_func'] == "1") || ($is_active_share_button && $style['share_button_func'] == '1')) { if (($is_active_more_button && $style['more_button_func'] == '1')) { $share_details = essb_get_share_address('less', $share, $salt); $url = $share_details['url']; $api_command = $share_details['api_command']; $content .= sprintf('', "less", $more_after_class, $url, "", $api_command, ""); } if (is_array($native_buttons)) { if ($native_buttons['active']) { if ($native_buttons['sameline']) { $content .= ESSBNativeButtonsHelper::draw_native_buttons($native_buttons, $native_buttons['order'], $native_buttons['counters'], $native_buttons['sameline'], $native_buttons['skinned']); } } } // end of share buttons snippet $content .= essb_draw_buttons_end ( $style, $position, $salt, $like_or_share, $native_buttons, $cached_counters, $share ); return $content; } function essb_get_share_address($network, $share = array(), $salt = '', $amp_endpoint = false, $is_mobile = false) { // TODO: add handle of user_image_url if (essb_options_bool_value( 'advanced_custom_share')) { essb_depend_load_function('essb_apply_advanced_custom_share', 'lib/core/extenders/essb-buttonhelper-extender-advancedshare.php'); $share = essb_apply_advanced_custom_share($share, $network); } // @since version 3.0.3 - fixes the GA Campaign tracking fields $ga_tracking_code = ESSBGlobalSettings::$activate_ga_campaign_tracking;//ESSBOptionValuesHelper::options_value($essb_options, 'activate_ga_campaign_tracking'); if ($ga_tracking_code != '' || isset($share['ga_mode'])) { essb_depend_load_function('essb_correct_url_on_tracking_code', 'lib/core/extenders/essb-buttonhelper-extender-encode.php'); $share = essb_correct_url_on_tracking_code($share, $network); } if (!isset($share['query'])) { if (isset($share['essb_encode_url'])) { if ($share['essb_encode_url']) { essb_depend_load_function('essb_buttonhelper_encode_url_sharing', 'lib/core/extenders/essb-buttonhelper-extender-encode.php'); $share = essb_buttonhelper_encode_url_sharing($share); } } if (isset($share['essb_encode_text'])) { if ($share['essb_encode_text']) { essb_depend_load_function('essb_buttonhelper_encode_text', 'lib/core/extenders/essb-buttonhelper-extender-encode.php'); $share = essb_buttonhelper_encode_text($share); } } if (isset($share['essb_encode_text_plus'])) { if ($share['essb_encode_text_plus']) { $share['twitter_tweet'] = str_replace(' ', '%20', $share['twitter_tweet']); $share['twitter_tweet'] = str_replace('+', '%20', $share['twitter_tweet']); } } } $share['url'] = esc_attr($share['url']); $share['short_url'] = esc_attr($share['short_url']); $share['full_url'] = esc_attr($share['full_url']); $share['title'] = esc_attr($share['title']); $share['image'] = esc_attr($share['image']); $share['description'] = esc_attr($share['description']); // adding additional support for hashtags everywhere $share['title'] = str_replace('#', '%23', $share['title']); $share['description'] = str_replace('#', '%23', $share['description']); if (isset($share['mail_subject'])) { $share['mail_subject'] = esc_attr(stripslashes($share['mail_subject'])); } if (isset($share['mail_body'])) { $share['mail_body'] = esc_attr(stripslashes($share['mail_body'])); } $pinterest_description = $share['title']; $custom_pinterest_desc = isset($share['pinterest_desc']) ? $share['pinterest_desc'] : ''; if (!empty($custom_pinterest_desc)) { $pinterest_description = $custom_pinterest_desc; } //if (empty($pinterest_description)) { // $pinterest_description = $share['title']; //} // @since version 3.0.4 - fix for shorturl $shorturl_activate = essb_options_bool_value( 'shorturl_activate'); if ($shorturl_activate && !empty($share['short_url'])) { $share['url'] = $share['short_url']; } $url = ''; $api_command = ''; $network_type = 'buildin'; //if (isset($essb_networks[$network])) { // $network_type = isset($essb_networks[$network]['type']) ? $essb_networks[$network]['type'] : "buildin"; //} if (isset($share['query'])) { if ($share['query']) { $share['short_url_twitter'] = urlencode($share['short_url_twitter']); $share['full_url'] = urlencode($share['full_url']); $share ['url'] = urlencode($share['url']); } } switch ($network) { case 'facebook': $close_callback = get_bloginfo('url') . '?sharing-thankyou=yes'; $url = sprintf ( 'https://www.facebook.com/sharer/sharer.php?u=%1$s&t=%2$s', $share ['url'], $share ['title'], $close_callback ); break; case 'facebook_advanced': $fbappid = essb_options_value( 'facebookadvancedappid'); $url = 'https://www.facebook.com/dialog/feed?app_id='.$fbappid.'&display=popup&name='.$share['title'].'&link='.$share['url'].''; if ($share['image'] != '') { $url .= '&picture='.$share['image']; } if ($share['description'] != '') { $url .= '&description='.$share['description']; } break; case 'twitter' : if ($share['short_url_twitter'] == '') { $share['short_url_twitter'] = $share['url']; } if (isset($share['clear_twitter_url'])) { if ($share['clear_twitter_url']) { $share['short_url_twitter'] = ''; } } $use_tweet = $share ['twitter_tweet']; $use_tweet = str_replace('#', '%23', $use_tweet); $use_tweet = str_replace('|', '%7C', $use_tweet); $use_tweet = str_replace('&', '%26', $use_tweet); // @since 3.1 Twitter message optimization $twitter_message_optimize = ESSBGlobalSettings::$twitter_message_optimize;//ESSBOptionValuesHelper::options_bool_value($essb_options, 'twitter_message_optimize'); if ($twitter_message_optimize) { $twitter_message_optimize_method = essb_options_value('twitter_message_optimize_method'); if (!class_exists('ESSBCoreExtenderTweetOptimization')) { include_once (ESSB3_PLUGIN_ROOT . 'lib/core/extenders/essb-core-extender-tweet-optimization.php'); } $optmized_tweet = ESSBCoreExtenderTweetOptimization::twitter_message_optimization($use_tweet, $share['short_url_twitter'], $share['twitter_user'], $share ['twitter_hashtags'], $twitter_message_optimize_method); $use_tweet = $optmized_tweet['tweet']; $share['twitter_user'] = $optmized_tweet['user']; $share['twitter_hashtags'] = $optmized_tweet['hashtags']; } $twitter_pass_user = ($share['twitter_user'] != '') ? sprintf('&related=%1$s&via=%1$s', $share['twitter_user']) : ''; $twitter_pass_hastags = ($share ['twitter_hashtags'] != '') ? sprintf('&hashtags=%1$s', $share ['twitter_hashtags']) : ''; $url = sprintf ( 'https://twitter.com/intent/tweet?text=%1$s&url=%2$s&counturl=%3$s%4$s%5$s', $use_tweet, $share ['short_url_twitter'], $share ['full_url'], $twitter_pass_user, $twitter_pass_hastags ); break; case 'google' : $url = sprintf ( 'https://plus.google.com/share?url=%1$s', $share ['url'] ); break; case 'pinterest' : $pin_image = $share['image']; $custom_pin_image = isset($share['pinterest_image']) ? $share['pinterest_image'] : ''; if (!empty($custom_pin_image)) { $pin_image = $custom_pin_image; } $url = sprintf ( 'http://pinterest.com/pin/create/bookmarklet/?media=%1$s&url=%2$s&title=%3$s&description=%4$s', $pin_image, $share ['url'], $share ['title'], $pinterest_description ); break; case 'pinterest_picker' : $url = '#'; $api_command = "essb.pinterest_picker('" . $salt . "'); return false;"; break; case 'linkedin' : $use_message = $share ['title']; $use_message = str_replace('|', '%7C', $use_message); $url = sprintf ( 'https://www.linkedin.com/shareArticle?mini=true&ro=true&trk=EasySocialShareButtons&title=%1$s&url=%2$s', $use_message, $share ['url'] ); break; case 'digg' : $url = sprintf ( 'http://digg.com/submit?phase=2%20&url=%1$s&title=%2$s', $share ['url'], $share ['title'] ); break; case 'reddit' : $url = sprintf ( 'http://reddit.com/submit?url=%1$s&title=%2$s', $share ['url'], $share ['title'] ); break; case 'del' : //$url = sprintf ( 'https://delicious.com/save?v=5&noui&jump=close&url=%1$s&title=%2$s', $share ['url'], $share ['title'] ); $url = sprintf ( 'https://del.icio.us/login?log=out&provider=essb&title=%2$s&url=%1$s&v=5', $share ['url'], $share ['title'] ); break; case 'buffer' : $url = sprintf ( 'https://bufferapp.com/add?url=%1$s&text=%2$s&via=%3$s&picture=&count=horizontal&source=button', $share ['url'], $share ['title'], $share ['twitter_user'] ); break; case 'love' : $url = '#'; $api_command = "essb.loveThis('" . $salt . "'); return false;"; break; case 'stumbleupon' : $url = sprintf ( 'http://www.stumbleupon.com/badge/?url=%1$s', $share ['full_url'] ); break; case 'tumblr' : $url = sprintf ( 'http://tumblr.com/share?s=&v=3&t=%1$s&u=%2$s', $share ['title'], urlencode ( $share ['url'] ) ); break; case 'vk' : if (ESSBGlobalSettings::$vkontakte_fullshare) { $url = sprintf ( 'http://vk.com/share.php?url=%1$s&image=%2$s&description=%3$s&title=%4$s', $share ['url'], $share['image'], $share['description'], $share['title'] ); } else { $url = sprintf ( 'http://vkontakte.ru/share.php?url=%1$s', $share ['url'] ); } break; case 'ok' : $url = sprintf ( 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1&st._surl=%1$s', $share ['url'] ); break; case 'weibo' : $url = sprintf ( 'http://service.weibo.com/share/share.php?url=%1$s&title=%2$s&pic=%3$s', $share ['url'], $share['title'], $share['image'] ); break; case 'xing' : $url = sprintf ( 'https://www.xing.com/social_plugins/share?h=1;url=%1$s', $share ['url'] ); break; case 'pocket' : $url = sprintf ( 'https://getpocket.com/save?title=%1$s&url=%2$s', $share ['title'], urlencode ( $share ['url'] ) ); break; case 'mwp' : $url = sprintf ( 'http://managewp.org/share/form?url=%1$s', urlencode ( $share ['url'] ) ); break; case 'whatsapp' : if ($share['short_url_whatsapp'] == '') { $share['short_url_whatsapp'] = $share['url']; } $url = sprintf ( 'whatsapp://send?text=%1$s%3$s%2$s', essb_core_helper_urlencode ( $share ['title_plain'] ), rawurlencode ( $share ['short_url_whatsapp'] ), '%20' ); $api_command = "essb.tracking_only('', 'whatsapp', '".$salt."', true);"; if (essb_option_bool_value('whatsapp_api')) { $url = sprintf ( 'https://api.whatsapp.com/send?text=%1$s%3$s%2$s', essb_core_helper_urlencode ( $share ['title_plain'] ), rawurlencode ( $share ['short_url_whatsapp'] ), '%20' ); $api_command = "essb.tracking_only('', 'whatsapp', '".$salt."', true);"; } break; case 'meneame' : $url = sprintf ( 'http://www.meneame.net/submit.php?url=%1$s', $share ['url'] ); break; case 'print_friendly' : $url = sprintf ( 'http://www.printfriendly.com/print/?url=%1$s', $share ['url'] ); break; case 'print' : $url = "#"; $api_command = "essb.print('" . $salt . "'); return false;"; break; case 'mail' : if (!isset($share['mail_subject'])) { $share['mail_subject'] = ''; } if (!isset($share['mail_body'])) { $share['mail_body'] = ''; } $share['mail_body'] = str_replace('"', '%22', $share['mail_body']); $share['mail_body'] = str_replace("'", '%27', $share['mail_body']); $share['mail_body'] = str_replace('&', '%26', $share['mail_body']); $share['mail_body'] = str_replace('&', '%26', $share['mail_body']); $share['mail_body'] = str_replace('"', '%22', $share['mail_body']); $share['mail_body'] = str_replace('%26quot;', '%22', $share['mail_body']); $share['mail_body'] = str_replace('%26#039;', '%27', $share['mail_body']); $url = sprintf('mailto:?subject=%1$s&body=%2$s', $share['mail_subject'], $share['mail_body']); $api_command = "essb.tracking_only('', 'mail', '".$salt."', true);"; break; case 'mail_form' : $url = "#"; $api_command = "essb_open_mailform('" . $salt . "'); return false;"; break; case 'share': case 'more' : $url = "#"; $api_command = "essb.toggle_more('" . $salt . "'); return false;"; break; case 'less' : $url = "#"; $api_command = "essb.toggle_less('" . $salt . "'); return false;"; break; case 'more_popup' : $url = "#"; $api_command = "essb.toggle_more_popup('" . $salt . "'); return false;"; break; case 'flattr' : if (!class_exists('ESSBNetworks_Flattr')) { include_once (ESSB3_PLUGIN_ROOT . 'lib/networks/essb-flattr.php'); } $url = ESSBNetworks_Flattr::getStaticFlattrUrl ($share); break; // @since 3.0 case 'blogger' : $url = sprintf ( 'https://www.blogger.com/blog_this.pyra?t&u=%1$s&n=%2$s', $share ['url'], $share ['title'] ); break; case 'amazon' : $url = sprintf ( 'http://www.amazon.com/gp/wishlist/static-add?u=%1$s&t=%2$s', $share ['url'], $share ['title'] ); break; case 'yahoomail' : $url = sprintf ( 'http://compose.mail.yahoo.com/?body=%1$s', $share ['url'] ); break; case 'gmail' : $url = sprintf ( 'https://mail.google.com/mail/u/0/?view=cm&fs=1&su=%2$s&body=%1$s&ui=2&tf=1', $share ['url'], $share ['title'] ); break; case 'aol' : $url = sprintf ( 'http://webmail.aol.com/Mail/ComposeMessage.aspx?subject=%2$s&body=%1$s', $share ['url'], $share ['title'] ); break; case 'newsvine' : $url = sprintf ( 'http://www.newsvine.com/_tools/seed&save?u=%1$s&h=%2$s', $share ['url'], $share ['title'] ); break; case 'hackernews' : $url = sprintf ( 'https://news.ycombinator.com/submitlink?u=%1$s&t=%2$s', $share ['url'], $share ['title'] ); break; case 'evernote' : $url = sprintf ( 'http://www.evernote.com/clip.action?url=%1$s&title=%2$s', $share ['url'], $share ['title'] ); break; case 'myspace': $url = sprintf( 'https://myspace.com/post?u=%1$s', esc_attr( $share ['url'] ) ); break; case 'mailru': $url = sprintf('http://connect.mail.ru/share?url=%1$s&title=%2$s&description=%3$s', $share['url'], $share['title'], $share['description']); break; case 'viadeo': $url = sprintf('https://www.viadeo.com/?url=%1$s&title=%2$s', $share['url'], $share['title']); break; case 'line': //$url = sprintf('http://line.me/R/msg/text/%1$s%20%2$s', essb_core_helper_urlencode ( $share ['title'] ), rawurlencode ( $share ['short_url_whatsapp'] )); //$url = sprintf('line://msg/text/%1$s%3$s%2$s', essb_core_helper_urlencode ( $share ['title_plain'] ), rawurlencode ( $share ['short_url_whatsapp'] ), '%20'); $url = 'https://social-plugins.line.me/lineit/share?url='.rawurlencode($share['url']); $api_command = "essb.tracking_only('', 'line', '".$salt."', true);"; break; case 'flipboard': $url = sprintf('https://share.flipboard.com/bookmarklet/popout?url=%1$s&title=%2$s', $share['url'], $share['title']); break; case 'yummly' : $url = sprintf ( 'http://www.yummly.com/urb/verify?url=%2$s&title=%3$s&image=%1$s&yumtype=button', $share ['image'], $share ['url'], $share ['title'], $share ['description'] ); break; case 'sms' : if ($share ['short_url_whatsapp'] == '') { $share ['short_url_whatsapp'] = $share ['url']; } $ua = strtolower($_SERVER['HTTP_USER_AGENT']); $joiner = (stripos($ua,'android') !== false) ? '?' : '&'; $url = sprintf ( 'sms:%4$sbody=%1$s%3$s%2$s', essb_core_helper_urlencode ( $share ['title_plain'] ), rawurlencode ( $share ['short_url_whatsapp'] ), '%20', $joiner ); break; case 'viber' : if ($share ['short_url_whatsapp'] == '') { $share ['short_url_whatsapp'] = $share ['url']; } $url = sprintf ( 'viber://forward?text=%1$s%3$s%2$s', essb_core_helper_urlencode ( $share ['title_plain'] ), rawurlencode ( $share ['short_url_whatsapp'] ), '%20' ); $api_command = "essb.tracking_only('', 'viber', '".$salt."', true);"; break; case 'telegram' : if ($share ['short_url_whatsapp'] == '') { $share ['short_url_whatsapp'] = $share ['url']; } // @since 3.4.2 - we include telegram alternative share method if (ESSBGlobalSettings::$telegram_alternative) { $url = sprintf ( 'https://telegram.me/share/url?url=%2$s&text=%1$s', essb_core_helper_urlencode ( $share ['title_plain'] ), rawurlencode ( $share ['short_url_whatsapp'] ) ); } else { $url = sprintf ( 'tg://msg?text=%1$s%3$s%2$s', essb_core_helper_urlencode ( $share ['title_plain'] ), rawurlencode ( $share ['short_url_whatsapp'] ), '%20' ); } $api_command = "essb.tracking_only('', 'telegram', '".$salt."', true);"; break; case 'subscribe': if (ESSBGlobalSettings::$subscribe_function == 'link') { $url = ESSBGlobalSettings::$subscribe_link; $api_command = "essb.tracking_only('', 'subscribe', '".$salt."', true);"; } else { $url = "#"; $api_command = "essb.toggle_subscribe('".$salt."'); return false;"; } break; case 'kakaotalk': $url = sprintf ( 'https://story.kakao.com/share?url=%1$s', $share ['url']); break; case 'skype': $url = sprintf ( 'https://web.skype.com/share?url=%1$s', $share ['url']); break; case 'messenger': if (essb_is_mobile()) { $url = sprintf('fb-messenger://share/?link=%1$s', $share ['url']); } else { $url = sprintf ( 'https://www.facebook.com/dialog/send?app_id=%1$s&link=%2$s&redirect_uri=https://facebook.com', ESSBGlobalSettings::$fbmessengerapp, $share ['url']); } break; case 'livejournal': $url = sprintf('http://www.livejournal.com/update.bml?subject=%1$s&event=%2$s', $share['title_plain'], urlencode(''.$share['title_plain'].'')); break; case 'yammer': $url = sprintf('https://www.yammer.com/messages/new?login=true&trk_event=yammer_share&status=%1$s %2$s', essb_core_helper_urlencode ( $share ['title_plain'] ), urlencode( $share['url'])); break; case 'meetedgar': $url = htmlentities('javascript:(function()%7B!function()%7Bvar e%3Ddocument.getElementsByTagName("head")%5B0%5D,t%3Ddocument.createElement("script")%3Bt.type%3D"text/javascript",t.src%3D"//app.meetedgar.com/share.js%3F"%2BMath.floor(99999*Math.random()),e.appendChild(t)%7D()%7D)()%3B'); $api_command = "essb.tracking_only('', 'meetedgar', '".$salt."', true);"; break; case 'fintel': $url = sprintf('https://fintel.io/submit?url=%1$s', $share ['url']); break; case 'instapaper': $url = sprintf('https://www.instapaper.com/hello2?url=%1$s&title=%2$s&description=%3$s', $share ['url'], $share['title'], $share['description']); break; case 'mix': $url = sprintf('https://mix.com/extension/add?source=%1$s', $share ['url']); break; default: // @since 3.0 - module parsing social buttons or custom social buttons if (has_filter("essb4_shareapi_api_command_{$network}")) { $api_command = apply_filters("essb4_shareapi_api_command_{$network}", $share); } if (has_filter("essb4_shareapi_url_{$network}")) { $url = apply_filters("essb4_shareapi_url_{$network}", $share); } break; } if (has_filter("essb_shareapi_command_{$network}")) { $api_command = apply_filters("essb_shareapi_command_{$network}", $share); } if (has_filter("essb_shareapi_url_{$network}")) { $url = apply_filters("essb_shareapi_url_{$network}", $share); } if ($api_command == '') { $api_command = sprintf('essb.window('%1$s','%2$s','%3$s'); return false;', $url, $network, $salt); // @since 3.6 - commented to allow AMP work if ($network == 'twitter' && !$amp_endpoint && !$is_mobile) { $url = '#'; } } if ($share['essb_encode_url']) { $url = str_replace ('&', '&', $url); //print $url; } $share_command = array('url' => $url, 'api_command' => $api_command); // @since 5.5 - adding a global share generation filter that will make possible to change the execution // of all build in social networks and modify the custom generated share URL if (has_filter("essb_share_command_{$network}")) { $share_command = apply_filters("essb_share_command_{$network}", $share_command); } return $share_command; } function essb_draw_buttons_start($style = array(), $position = '', $salt = '', $like_or_share = 'share', $share = array(), $cached_counters = array(), $networks = array()) { $network_hidden_name_class = ''; if ($style ['button_style'] == 'icon_hover') { $network_hidden_name_class = ' essb_hide_name'; } if ($style ['button_style'] == 'icon') { $network_hidden_name_class = ' essb_force_hide_name essb_force_hide'; } if ($style ['button_style'] == 'button_name') { $network_hidden_name_class = ' essb_hide_icon'; } if ($style ['button_style'] == 'vertical') { $network_hidden_name_class = ' essb_vertical_name'; } $template = essb_template_folder( $style ['template'] ); $instance_template = $template; if ($template != '') { $template = ' essb_template_' . $template; } // TODO: implement all other width styles $css_class_width = ''; if ($style['button_width'] == 'fixed') { $fixedwidth_key = $style['button_width_fixed_value'] . '_' . $style['button_width_fixed_align']; $css_class_width = ' essb_fixedwidth_'.$fixedwidth_key; if ($style['button_width_fixed_align'] == 'center') { $css_class_width .= ' essb_network_align_center'; } if ($style['button_width_fixed_align'] == 'right') { $css_class_width .= ' essb_network_align_right'; $style['button_align'] = 'left'; } if ($style['button_width_fixed_align'] == 'left') { $style['button_align'] = 'left'; } } if ($style['button_width'] == 'full') { $container_width = $style['button_width_full_container']; $single_button_width = intval($container_width) / intval($style['included_button_count']); $single_button_width = floor($single_button_width); //print_r($style); $css_class_width = ' essb_fullwidth_'.$single_button_width.'_'.$style['button_width_full_button'].'_'.$style['button_width_full_container']; if ($style['fullwidth_align'] == 'center') { $css_class_width .= ' essb_network_align_center'; } if ($style['fullwidth_align'] == 'right') { $css_class_width .= ' essb_network_align_right'; $style['button_align'] = 'left'; } if ($style['fullwidth_align'] == 'left') { $style['button_align'] = 'left'; } } if ($style['button_width'] == 'column') { $css_class_width = ' essb_width_columns_'.$style['button_width_columns']; if ($style['fullwidth_share_buttons_columns_align'] == 'center') { $css_class_width .= ' essb_network_align_center'; } if ($style['fullwidth_share_buttons_columns_align'] == 'right') { $css_class_width .= ' essb_network_align_right'; } } if ($style['button_width'] == 'flex') { $css_class_width .= ' essb_width_flex'; } if (isset($style['button_size'])) { if ($style['button_size'] != '') { $css_class_width .= ' essb_size_'.$style['button_size']; } } $css_class_align = ''; if ($style['button_align'] == 'right') { $css_class_align = ' essb_links_right'; } if ($style['button_align'] == 'center') { $css_class_align = ' essb_links_center'; } // modern counter style $essb_css_modern_counter_class = ''; if ($style ['counter_pos'] == 'leftm') { $style ['counter_pos'] = 'left'; $essb_css_modern_counter_class = ' essb_counter_modern_left'; } if ($style ['counter_pos'] == 'rightm') { $style ['counter_pos'] = 'right'; $essb_css_modern_counter_class = ' essb_counter_modern_right'; } if ($style ['counter_pos'] == 'top') { $style ['counter_pos'] = 'left'; $essb_css_modern_counter_class = ' essb_counter_modern_top'; } if ($style ['counter_pos'] == 'topm') { $style ['counter_pos'] = 'left'; $essb_css_modern_counter_class = ' essb_counter_modern_top_mini'; } if ($style ['counter_pos'] == 'bottom') { $essb_css_modern_counter_class = ' essb_counter_modern_bottom'; } if ($style ['counter_pos'] == 'topn') { $essb_css_modern_counter_class = ' essb_counter_modern_topn'; } if (isset($style['button_animation'])) { if ($style['button_animation'] != '' && $style['button_animation'] != 'no') { $css_class_align .= ' '.$style['button_animation']; } } // share button class patch if (in_array('share', $networks)) { if (isset($style['share_button_style'])) { if ($style['share_button_style'] != '') { $css_class_align .= ' essb_sharebtn_'.$style['share_button_style']; } $share_counter_pos = isset($style['share_button_counter']) ? $style['share_button_counter'] : ''; if ($share_counter_pos == '') { $share_counter_pos = essb_option_value('share_button_counter'); } if ($share_counter_pos != '') { $css_class_align .= ' essb_sharebtn_counter_'.$share_counter_pos; } } } $counter_class = ($style ['show_counter']) ? ' essb_counters' : ''; $total_text = ESSBGlobalSettings::$counter_total_text; if (empty($total_text)) { $total_text = __('Total: ', 'essb'); } $activate_total_counter_text = essb_option_value('activate_total_counter_text'); if (empty($activate_total_counter_text)) { $activate_total_counter_text = __('shares', 'essb'); } $activate_total_counter_icon = essb_option_value('activate_total_counter_icon'); if (empty($activate_total_counter_icon)) { $activate_total_counter_icon = 'share-tiny'; } $css_hide_total_counter = ''; if ($style ['total_counter_hidden_till'] != '') { if ($style ['total_counter_pos'] == 'hidden') { $css_hide_total_counter = ' style="display: none !important;"'; } else { $css_hide_total_counter = ' style="display: none !important;" data-essb-hide-till="' . $style ['total_counter_hidden_till'] . '"'; } } $cached_total_counter = ''; $original_cached_total_counter = ''; $cached_counters_active = false; if (defined('ESSB3_CACHED_COUNTERS')) { $cached_total_counter = isset($cached_counters['total']) ? $cached_counters['total'] : '0'; $original_cached_total_counter = $cached_total_counter; if ($style ['total_counter_hidden_till'] != '') { if (intval($cached_total_counter) > intval($style ['total_counter_hidden_till'])) { $css_hide_total_counter = ''; } } $cached_total_counter = essb_kilomega_format($cached_total_counter, 'total'); $cached_counters_active = true; // display veiws instead of shares - @since 5.0 if ($position == 'sharebottom' && essb_option_value('mobile_sharebuttonsbar_total_source') == 'views') { $cached_total_counter = essb_bridge_get_views($share['post_id']); $activate_total_counter_text = essb_bridge_get_views_text(); } } else { // display veiws instead of shares - @since 5.0 if ($position == 'sharebottom' && essb_option_value('mobile_sharebuttonsbar_total_source') == 'views') { $cached_total_counter = essb_bridge_get_views($share['post_id']); $activate_total_counter_text = essb_bridge_get_views_text(); } } $css_class_nospace = ($style['nospace']) ? ' essb_nospace' : ''; $css_class_nostats = ''; if (isset($style['nostats'])) { $css_class_nostats = ($style['nostats']) ? ' essb_nostats' : ''; } $like_share_position = ($like_or_share == 'share') ? ' essb_share' : ' essb_native'; $links_start = ''; $key_position = $position; if ($position == 'sidebar') { $current_sidebar_pos = essb_options_value('sidebar_pos'); if (!empty($style['sidebar_pos'])) { $current_sidebar_pos = $style['sidebar_pos']; } if ($current_sidebar_pos != '' && $current_sidebar_pos != 'left') { $key_position .= '_'.$current_sidebar_pos; } $sidebar_entry_ani = essb_option_value('sidebar_entry_ani'); if ($sidebar_entry_ani != '') { //$key_position .= ' essb_sidebar_transition essb_sidebar_transition_'.$sidebar_entry_ani; // change in 4.2 to assing at $like_share_position $like_share_position .= ' essb_sidebar_transition essb_sidebar_transition_'.$sidebar_entry_ani; } } $counter_url = $share['url']; $counter_full_url = $share['full_url']; if (!defined('ESSB3_LIGHTMODE')) { $ga_tracking_code = ESSBGlobalSettings::$activate_ga_campaign_tracking;//ESSBOptionValuesHelper::options_value($essb_options, 'activate_ga_campaign_tracking'); if ($ga_tracking_code != '' || strpos($counter_url, '{network}') !== false) { $post_ga_campaign_tracking = get_post_meta(get_the_ID(), 'essb_activate_ga_campaign_tracking', true); if ($post_ga_campaign_tracking != '') { $ga_tracking_code = $post_ga_campaign_tracking; } $ga_tracking_code = str_replace('&', '%26', $ga_tracking_code); $counter_url = str_replace($ga_tracking_code, '', $counter_url); $counter_full_url = str_replace('{network}', 'twitter', $counter_full_url); $counter_full_url = str_replace('{title}', '', $counter_full_url); } } $extra_start_options = ''; $buttons_id = 'essb_displayed_'.$position.'_'.$salt; if (has_filter('essb_sharebuttons_draw_id')) { $buttons_id = apply_filters('essb_sharebuttons_draw_id', $buttons_id, $style); } $links_start = sprintf ( ''; return $links_start; } function essb_kilomega_format ( $val, $type) { $value_format_type = ($type == 'total') ? essb_option_value('total_counter_format') : essb_option_value('counter_format'); if ($value_format_type == 'full' || $value_format_type == 'fulldot' || $value_format_type == 'fullcomma' || $value_format_type == 'fullspace') { if ($val) { if ($value_format_type == 'full') { return number_format(intval($val)); } else if ($value_format_type == 'fulldot') { return number_format(intval($val), 0, '', '.'); } else if ($value_format_type == 'fullcomma') { return number_format(intval($val), 0, '', ','); } else if ($value_format_type == 'fullspace') { return number_format(intval($val), 0, '', ' '); } else { return number_format(intval($val)); } } else { return 0; } } else { return essb_kilomega($val); } } function essb_kilomega( $val ) { if ($val) { $val = intval($val); if ($val < 1000) { return number_format ( $val ); } else { if ($val < 1200) { $val = intval ( $val ) / 1000; return number_format ( $val, 1 ) .'K'; } else { if ($val < 1000000) { $val = intval ( $val ) / 1000; return number_format ( $val, 1 ).'K'; } else { $val = intval ( $val ) / 1000000; return number_format ( $val, 1 ).'M'; } } } } else { return 0; } } function essb_prepare_networks_order_by_shares($share_array = array()) { arsort($share_array); $ordered = array(); foreach ($share_array as $key => $shares) { $ordered[] = $key; } return $ordered; } function essb_bridge_get_views($post_id) { $post_views = intval ( get_post_meta ( $post_id, 'essb_views', true ) ); return essb_kilomega($post_views); } function essb_bridge_get_views_text() { global $essb3pv_options; if (!isset($essb3pv_options)) { $essb3pv_options = get_option('essb3-pv'); } return isset($essb3pv_options['postviews_text']) ? $essb3pv_options['postviews_text'] : 'views'; } ?>