public static function get_instance() { if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
public static function draw_share_buttons($share = array(), $style = array(), $networks = array(), $networks_order = array(), $network_names = array(), $position = '', $salt = '', $like_or_share = 'share', $native_buttons = '') { global $essb_networks, $essb_options; $content = ""; $leading_width_mode_fullwidth = false; $button_width_full_first = ESSBOptionValuesHelper::options_value($style, 'button_width_full_first'); $button_width_full_second = ESSBOptionValuesHelper::options_value($style, 'button_width_full_second'); if (!empty($button_width_full_first) || !empty($button_width_full_second)) { $leading_width_mode_fullwidth = true; } $sigle_counter_hidden_till = ESSBGlobalSettings::$button_counter_hidden_till; //ESSBOptionValuesHelper::options_value($essb_options, 'button_counter_hidden_till'); $mycred_group = ESSBGlobalSettings::$mycred_group; //ESSBOptionValuesHelper::options_value($essb_options, 'mycred_group', 'mycred_default'); $mycred_points = ESSBGlobalSettings::$mycred_points; //ESSBOptionValuesHelper::options_value($essb_options, 'mycred_points', '1'); $more_button_icon = ESSBGlobalSettings::$more_button_icon; //ESSBOptionValuesHelper::options_value($essb_options, 'more_button_icon'); $comments_address = ESSBGlobalSettings::$comments_address; //ESSBOptionValuesHelper::options_value($essb_options, 'comments_address'); if ($comments_address == '') { $comments_address = '#comments'; } $button_follow_state = "nofollow"; //if (ESSBOptionValuesHelper::options_bool_value($essb_options, 'use_rel_me')) { if (ESSBGlobalSettings::$use_rel_me) { $button_follow_state = "me"; } if (isset($style['more_button_icon'])) { $more_button_icon = $style['more_button_icon']; } // since @3.2.4 // encoding of url parts $share['essb_encode_text'] = ESSBGlobalSettings::$essb_encode_text; //ESSBOptionValuesHelper::options_bool_value($essb_options, 'essb_encode_text'); $share['essb_encode_url'] = ESSBGlobalSettings::$essb_encode_url; //ESSBOptionValuesHelper::options_bool_value($essb_options, 'essb_encode_url'); $share['essb_encode_text_plus'] = ESSBGlobalSettings::$essb_encode_text_plus; //ESSBOptionValuesHelper::options_bool_value($essb_options, 'essb_encode_text_plus'); $cached_counters = array(); $cached_counters_active = false; if (defined('ESSB3_CACHED_COUNTERS') && $style['show_counter']) { $cached_counter_networks = ESSBCachedCounters::prepare_list_of_networks_with_counter($networks_order, $networks); $cached_counters = ESSBCachedCounters::get_counters($share['post_id'], $share, $cached_counter_networks); $cached_counters_active = true; } // beginning of share buttons snippet $content .= ESSBButtonHelper::draw_buttons_start($style, $position, $salt, $like_or_share, $share, $cached_counters); $is_active_more_button = false; $is_active_fullwidth = false; if ($style['button_width'] == 'full') { $is_active_fullwidth = true; } $count_displayed = 0; foreach ($networks_order as $single) { // generate single network button if (in_array($single, $networks)) { if ($single == "no") { continue; } $count_displayed++; $url = ''; $api_command = ''; $link_target = "_blank"; $single_share_address = $single; $icon = $single; $cached_code_left = ""; $cached_code_right = ""; $cached_code_insidebefore = ""; $cached_code_insideafter = ""; $cached_code_before = ""; if ($cached_counters_active) { if (isset($cached_counters[$single])) { $single_counter = isset($cached_counters[$single]) ? $cached_counters[$single] : '0'; if ($style['counter_pos'] == "left" || $style['counter_pos'] == "" || $style['counter_pos'] == "leftm" || $style['counter_pos'] == "topm" || $style['counter_pos'] == "top") { $cached_code_left = ESSBButtonHelper::draw_share_counter_code('', $single_counter, $sigle_counter_hidden_till); } if ($style['counter_pos'] == "right" || $style['counter_pos'] == "rightm") { $cached_code_right = ESSBButtonHelper::draw_share_counter_code('_right', $single_counter, $sigle_counter_hidden_till); } if ($style['counter_pos'] == "insidename" || $style['counter_pos'] == "inside" || $style['counter_pos'] == "bottom") { $cached_code_insideafter = ESSBButtonHelper::draw_share_counter_code('_' . $style['counter_pos'], $single_counter, $sigle_counter_hidden_till); } if ($style['counter_pos'] == "insidebeforename") { $cached_code_insidebefore = ESSBButtonHelper::draw_share_counter_code('_' . $style['counter_pos'], $single_counter, $sigle_counter_hidden_till); } if ($style['counter_pos'] == "hidden") { $cached_code_right = ESSBButtonHelper::draw_share_counter_code('_' . $style['counter_pos'], $single_counter, $sigle_counter_hidden_till); } if ($style['counter_pos'] == "topn") { $cached_code_before = ESSBButtonHelper::draw_share_counter_code('_' . $style['counter_pos'], $single_counter, $sigle_counter_hidden_till); } } } // specail network code //if ($single == "print" && ESSBOptionValuesHelper::options_bool_value($essb_options, 'print_use_printfriendly')) { if ($single == "print" && ESSBGlobalSettings::$print_use_printfriendly) { $single_share_address = "print_friendly"; } if ($single == "mail" && $style['mail_function'] == "form") { $single_share_address = "mail_form"; } //if ($single == "pinterest" && !ESSBOptionValuesHelper::options_bool_value($essb_options, 'pinterest_sniff_disable')) { if ($single == "pinterest" && !ESSBGlobalSettings::$pinterest_sniff_disable) { $single_share_address = "pinterest_picker"; } if (!$style['is_mobile']) { //if ($single == "facebook" && ESSBOptionValuesHelper::options_bool_value($essb_options, 'facebookadvanced')) { if ($single == "facebook" && ESSBGlobalSettings::$facebookadvanced) { $fbappid = ESSBGlobalSettings::$facebookadvancedappid; //ESSBOptionValuesHelper::options_value($essb_options, 'facebookadvancedappid'); if ($fbappid != '') { $single_share_address = "facebook_advanced"; } } } if ($single == "more" && $style['more_button_func'] != "1") { $single_share_address = "more_popup"; } if ($single == "more" && $more_button_icon == "dots") { $icon = "more_dots"; } if ($is_active_fullwidth && $count_displayed == 1 && $leading_width_mode_fullwidth) { $icon .= ' essb_item_fw_first'; } if ($is_active_fullwidth && $count_displayed == 2 && $leading_width_mode_fullwidth) { $icon .= ' essb_item_fw_second'; } // get single social network commands $share_details = ESSBButtonHelper::get_share_address($single_share_address, $share, $salt); $url = $share_details['url']; $api_command = $share_details['api_command']; if ($single == "sidebar-close") { $api_command = ""; } if ($single == "comments") { $api_command = ""; $url = $comments_address; $link_target = "_self"; } if ($single_share_address == "mail" || $single_share_address == "line" || $single_share_address == "whatsapp") { $link_target = "_self"; } $hover_text = ESSBOptionValuesHelper::options_value($essb_options, 'hovertext_' . $single); $name = isset($network_names[$single]) ? $network_names[$single] : ''; $noname_class = ""; if ($style['button_style'] == "icon" || $name == "-" || $single == "more") { $noname_class = " essb_noname"; } if ($style['counter_pos'] == "insidehover" && $style['counters']) { $noname_class .= " essb_hideonhover"; } // clean network names when depends on button style or seleceted network if ($style['button_style'] == "icon" || ($style['counter_pos'] == "inside" || $style['counter_pos'] == "bottom") && $style['show_counter'] || $name == "-" || $single == "more") { $name = ""; } $mycred_token = ""; if (defined('ESSB3_MYCRED_ACTIVE')) { $mycred_token = ESSBMyCredIntegration::generate_mycred_datatoken($mycred_group, $mycred_points); } $more_after_class = $is_active_more_button ? " essb_after_more" : ""; if ($single == "sidebar-close") { $more_after_class = ""; } $content .= sprintf('<li class="essb_item essb_link_%8$s nolightbox%2$s"> %12$s<a href="%3$s" title="%4$s" onclick="%5$s" target="%10$s" rel="%11$s" %7$s>%13$s<span class="essb_icon"></span><span class="essb_network_name%9$s">%14$s%6$s%15$s</span></a>%16$s</li>', $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); // at the end toggle more button state if ($single == "more") { $is_active_more_button = true; } } } // adding less button when + function of more button is active if ($is_active_more_button && $style['more_button_func'] == "1") { $share_details = ESSBButtonHelper::get_share_address("less", $share, $salt); $url = $share_details['url']; $api_command = $share_details['api_command']; $content .= sprintf('<li class="essb_item essb_link_%1$s nolightbox%2$s"> <a href="%3$s" title="%4$s" onclick="%5$s" target="_blank" rel="nofollow"><span class="essb_icon"></span><span class="essb_network_name">%6$s</span></a></li>', "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 .= ESSBButtonHelper::draw_buttons_end($style, $position, $salt, $like_or_share, $native_buttons, $cached_counters, $share); return $content; }
public static function draw_share_buttons($share = array(), $style = array(), $networks = array(), $networks_order = array(), $network_names = array(), $position = '', $salt = '', $like_or_share = 'share', $native_buttons = '') { global $essb_networks, $essb_options; $content = ""; $mycred_group = ESSBOptionValuesHelper::options_value($essb_options, 'mycred_group', 'mycred_default'); $mycred_points = ESSBOptionValuesHelper::options_value($essb_options, 'mycred_points', '1'); $more_button_icon = ESSBOptionValuesHelper::options_value($essb_options, 'more_button_icon'); $comments_address = ESSBOptionValuesHelper::options_value($essb_options, 'comments_address'); if ($comments_address == '') { $comments_address = '#comments'; } $button_follow_state = "nofollow"; if (ESSBOptionValuesHelper::options_bool_value($essb_options, 'use_rel_me')) { $button_follow_state = "me"; } if (isset($style['more_button_icon'])) { $more_button_icon = $style['more_button_icon']; } // since @3.2.4 // encoding of url parts $share['essb_encode_text'] = ESSBOptionValuesHelper::options_bool_value($essb_options, 'essb_encode_text'); $share['essb_encode_url'] = ESSBOptionValuesHelper::options_bool_value($essb_options, 'essb_encode_url'); // beginning of share buttons snippet $content .= ESSBButtonHelper::draw_buttons_start($style, $position, $salt, $like_or_share, $share); $is_active_more_button = false; foreach ($networks_order as $single) { // generate single network button if (in_array($single, $networks)) { if ($single == "no") { continue; } $url = ''; $api_command = ''; $link_target = "_blank"; $single_share_address = $single; $icon = $single; // specail network code if ($single == "print" && ESSBOptionValuesHelper::options_bool_value($essb_options, 'print_use_printfriendly')) { $single_share_address = "print_friendly"; } if ($single == "mail" && $style['mail_function'] == "form") { $single_share_address = "mail_form"; } if ($single == "pinterest" && !ESSBOptionValuesHelper::options_bool_value($essb_options, 'pinterest_sniff_disable')) { $single_share_address = "pinterest_picker"; } if (!$style['is_mobile']) { if ($single == "facebook" && ESSBOptionValuesHelper::options_bool_value($essb_options, 'facebookadvanced')) { $fbappid = ESSBOptionValuesHelper::options_value($essb_options, 'facebookadvancedappid'); if ($fbappid != '') { $single_share_address = "facebook_advanced"; } } } if ($single == "more" && $style['more_button_func'] != "1") { $single_share_address = "more_popup"; } if ($single == "more" && $more_button_icon == "dots") { $icon = "more_dots"; } // get single social network commands $share_details = ESSBButtonHelper::get_share_address($single_share_address, $share, $salt); $url = $share_details['url']; $api_command = $share_details['api_command']; if ($single == "sidebar-close") { $api_command = ""; } if ($single == "comments") { $api_command = ""; $url = $comments_address; $link_target = "_self"; } if ($single_share_address == "mail") { $link_target = "_self"; } $hover_text = ESSBOptionValuesHelper::options_value($essb_options, 'hovertext_' . $single); $name = isset($network_names[$single]) ? $network_names[$single] : ''; $noname_class = ""; if ($style['button_style'] == "icon" || $name == "-" || $single == "more") { $noname_class = " essb_noname"; } if ($style['counter_pos'] == "insidehover" && $style['counters']) { $noname_class .= " essb_hideonhover"; } // clean network names when depends on button style or seleceted network if ($style['button_style'] == "icon" || ($style['counter_pos'] == "inside" || $style['counter_pos'] == "bottom") && $style['show_counter'] || $name == "-" || $single == "more") { $name = ""; } $mycred_token = ""; if (defined('ESSB3_MYCRED_ACTIVE')) { $mycred_token = ESSBMyCredIntegration::generate_mycred_datatoken($mycred_group, $mycred_points); } $more_after_class = $is_active_more_button ? " essb_after_more" : ""; if ($single == "sidebar-close") { $more_after_class = ""; } $content .= sprintf('<li class="essb_item essb_link_%8$s nolightbox%2$s"> <a href="%3$s" title="%4$s" onclick="%5$s" target="%10$s" rel="%11$s" %7$s><span class="essb_icon"></span><span class="essb_network_name%9$s">%6$s</span></a></li>', $single, $more_after_class, $url, $hover_text, $api_command, $name, $mycred_token, $icon, $noname_class, $link_target, $button_follow_state); // at the end toggle more button state if ($single == "more") { $is_active_more_button = true; } } } // adding less button when + function of more button is active if ($is_active_more_button && $style['more_button_func'] == "1") { $share_details = ESSBButtonHelper::get_share_address("less", $share, $salt); $url = $share_details['url']; $api_command = $share_details['api_command']; $content .= sprintf('<li class="essb_item essb_link_%1$s nolightbox%2$s"> <a href="%3$s" title="%4$s" onclick="%5$s" target="_blank" rel="nofollow"><span class="essb_icon"></span><span class="essb_network_name">%6$s</span></a></li>', "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 .= ESSBButtonHelper::draw_buttons_end($style, $position, $salt, $like_or_share, $native_buttons); return $content; }
define('ESSB3_NATIVE_ACTIVE', true); } } // including additional plugin modules if (ESSBOptionValuesHelper::is_active_module('sso')) { include_once ESSB3_PLUGIN_ROOT . 'lib/modules/social-share-optimization/essb-social-share-optimization-frontend.php'; define('ESSB3_SSO_ACTIVE', true); } if (ESSBOptionValuesHelper::is_active_module('ssanalytics')) { include_once ESSB3_PLUGIN_ROOT . 'lib/modules/social-share-analytics/essb-social-share-analytics.php'; define('ESSB3_SSA_ACTIVE', true); } if (ESSBOptionValuesHelper::is_active_module('mycred')) { include_once ESSB3_PLUGIN_ROOT . 'lib/modules/mycred/essb-mycred-integration.php'; define('ESSB3_MYCRED_ACTIVE', true); ESSBMyCredIntegration::get_instance(); } if (ESSBOptionValuesHelper::is_active_module('aftershare')) { include_once ESSB3_PLUGIN_ROOT . 'lib/modules/after-share-close/essb-after-share-close.php'; define('ESSB3_AFTERSHARE_ACTIVE', true); } else { if (ESSB3_DEMO_MODE) { $is_active_option = isset($_REQUEST['aftershare']) ? $_REQUEST['aftershare'] : ''; if ($is_active_option != '') { include_once ESSB3_PLUGIN_ROOT . 'lib/modules/after-share-close/essb-after-share-close.php'; define('ESSB3_AFTERSHARE_ACTIVE', true); } } } if (ESSBOptionValuesHelper::is_active_module('imageshare')) { include_once ESSB3_PLUGIN_ROOT . 'lib/modules/social-image-share/essb-social-image-share.php';