function include_social_image_share() { global $essb_options; if (ESSBCoreHelper::is_plugin_deactivated_on() || ESSBCoreHelper::is_module_deactivate_on('sis')) { return; } $mobile_detect = new ESSB_Mobile_Detect(); if ($mobile_detect->isMobile() && !ESSBOptionValuesHelper::options_bool_value($essb_options, 'sis_on_mobile')) { return false; } $current_post_address = ESSBUrlHelper::get_current_page_url(); $current_post_address = ESSBUrlHelper::attach_tracking_code($current_post_address, 'essb-image-share=yes'); $calling = 'jQuery(document).ready(function(){jQuery("' . $this->get_settings('sis_selector', 'img') . '").essbis({selector:"' . $this->get_settings('sis_selector', 'img') . '",dontshow:"' . $this->get_settings('sis_dontshow') . '",minWidth:' . $this->get_settings('sis_minWidth', '100') . ',minHeight:' . $this->get_settings('sis_minHeight', '100') . ',align:{x:"' . $this->get_settings('sis_align_x', 'left') . '",y:"' . $this->get_settings('sis_align_y', 'top') . '"},offset:{x:' . $this->get_settings('sis_offset_x', '0') . ',y:' . $this->get_settings('sis_offset_y', '0') . '},orientation:"' . $this->get_settings('sis_orientation') . '",style:"' . $this->get_settings('sis_style') . '",sharer:"' . ($this->get_settings('sis_sharer') == 'true' ? $current_post_address : '') . '",is_mobile:' . ($mobile_detect->isMobile() ? 'true' : 'false') . ',always_show:' . $this->get_settings('sis_always_show', 'false') . ',pinterest_alt:' . $this->get_settings('sis_pinterest_alt', 'false') . ',primary_menu: [ ' . $this->get_primary_menu() . '],avoid_class: "' . $this->get_settings('sis_dontaddclass') . '"});});'; essb_resource_builder()->add_js($calling, true, 'essb-onmedia-code'); }
function essb_ctt_shortcode($atts) { global $essb_options; extract(shortcode_atts(array('tweet' => '', 'via' => 'yes', 'url' => 'yes', 'nofollow' => 'no', 'user' => '', 'hashtags' => '', 'usehashtags' => 'yes'), $atts)); $handle = $user; if (function_exists('mb_internal_encoding')) { $handle_length = 6 + mb_strlen($handle); } else { $handle_length = 6 + strlen($handle); } if (!empty($handle) && $via != 'no') { $handle_code = "&via=" . $handle . "&related=" . $handle; } else { $handle_code = ''; } if ($via != 'yes') { $handle = ''; $handle_code = ''; $handle_length = 0; } if ($usehashtags != 'no' && $hashtags != '') { $handle_code .= "&hashtags=" . $hashtags; if (function_exists('mb_internal_encoding')) { $handle_length = 6 + mb_strlen($hashtags); } else { $handle_length = 6 + strlen($hashtags); } } $text = $tweet; $post_url = get_permalink(); $short_url = ""; $twitter_shareshort = ESSBOptionValuesHelper::options_bool_value($essb_options, 'twitter_shareshort'); if ($twitter_shareshort) { $provider = ESSBOptionValuesHelper::options_value($essb_options, 'twitter_shareshort_service'); $shorturl_bitlyuser = ESSBOptionValuesHelper::options_value($essb_options, 'shorturl_bitlyuser'); $shorturl_bitlyapi = ESSBOptionValuesHelper::options_value($essb_options, 'shorturl_bitlyapi'); $short_url = ESSBUrlHelper::short_url($post_url, $provider, get_the_ID(), $shorturl_bitlyuser, $shorturl_bitlyapi); } if (filter_var($url, FILTER_VALIDATE_URL)) { $bcttURL = '&url=' . $url; } elseif ($url != 'no') { if ($short_url != '') { $bcttURL = '&url=' . $short_url . '&counturl=' . $post_url; } else { $bcttURL = '&url=' . $post_url; } } else { $bcttURL = ''; } $bcttBttn = __('Click to Tweet', ESSB3_TEXT_DOMAIN); $user_text = ESSBOptionValuesHelper::options_value($essb_options, 'translate_clicktotweet'); if ($user_text != '') { $bcttBttn = $user_text; } if ($url != 'no') { $short = essb_ctt_shorten($text, 117 - $handle_length); } else { $short = essb_ctt_shorten($text, 140 - $handle_length); } $link_short = $short; //$link_short = str_replace('#', '%23', $link_short); if ($nofollow != 'no') { $rel = "rel='nofollow'"; } else { $rel = ''; } if (!is_feed()) { return "<div class='essb-click-to-tweet' onclick=\"window.open('https://twitter.com/intent/tweet?text=" . urlencode($link_short) . $handle_code . $bcttURL . "', 'essb_share_window', 'height=300,width=500,resizable=1,scrollbars=yes');\">\n\t\t\t<span class='essb-click-to-tweet-quote'>\n\t\t\t" . $short . "\n\t\t\t</span>\n\t\t\t<span class='essb-click-to-tweet-button'>" . $bcttBttn . "<span class='essb-click-to-tweet-button-icon'></span>\n\t\t</div>"; } //else { // return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . urlencode ( $short ) . $handle_code . $bcttURL . "' target='_blank' class='essb-ctt-ctt-btn'" . $rel . ">" . $bcttBttn . "</a><br /><hr />"; //} }
public static function get_share_address($network, $share = array(), $salt = '') { global $essb_networks, $essb_options; // TODO: add handle of user_image_url if (ESSBOptionValuesHelper::options_bool_value($essb_options, 'advanced_custom_share')) { $as_url = ESSBOptionValuesHelper::options_value($essb_options, 'as_' . $network . '_url'); $as_text = ESSBOptionValuesHelper::options_value($essb_options, 'as_' . $network . '_text'); $as_image = ESSBOptionValuesHelper::options_value($essb_options, 'as_' . $network . '_image'); $as_desc = ESSBOptionValuesHelper::options_value($essb_options, 'as_' . $network . '_desc'); if (!empty($as_url)) { $share['url'] = $as_url; } if (!empty($as_text)) { $as_text = preg_replace(array('#%title%#', '#%siteurl%#', '#%permalink%#', '#%image%#', '#%shorturl%#'), array($share['title'], get_site_url(), $share['url'], $share['image'], $share['short_url']), $as_text); $share['title'] = $as_text; } if (!empty($as_image)) { $share['image'] = $as_image; } if (!empty($as_desc)) { $as_desc = preg_replace(array('#%title%#', '#%siteurl%#', '#%permalink%#', '#%image%#', '#%shorturl%#'), array($share['title'], get_site_url(), $share['url'], $share['image'], $share['short_url']), $as_desc); $share['description'] = $as_desc; } } // @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 != '') { $share['url'] = str_replace('{network}', $network, $share['url']); $share['full_url'] = str_replace('{network}', $network, $share['full_url']); $share['url'] = str_replace('{title}', $share['title'], $share['url']); $share['full_url'] = str_replace('{title}', $share['title'], $share['full_url']); // rebuild shorturls if GA tracking is active // code refactor @since 3.4.2 if (ESSBOptionValuesHelper::options_bool_value($essb_options, 'shorturl_activate')) { $global_provider = ESSBOptionValuesHelper::options_value($essb_options, 'shorturl_type'); if (ESSBOptionValuesHelper::options_bool_value($essb_options, 'twitter_shareshort')) { $global_shorturl = ESSBUrlHelper::short_url($share['full_url'], $global_provider, get_the_ID(), ESSBOptionValuesHelper::options_value($essb_options, 'shorturl_bitlyuser'), ESSBOptionValuesHelper::options_value($essb_options, 'shorturl_bitlyapi')); $share['short_url_twitter'] = $global_shorturl; $share['short_url_whatsapp'] = $global_shorturl; } else { $share['short_url'] = ESSBUrlHelper::short_url($share['full_url'], $global_provider, get_the_ID(), ESSBOptionValuesHelper::options_value($essb_options, 'shorturl_bitlyuser'), ESSBOptionValuesHelper::options_value($essb_options, 'shorturl_bitlyapi')); $share['short_url_twitter'] = $share['short_url']; $share['short_url_whatsapp'] = $share['short_url']; } if ($share['short_url_twitter'] == '') { $share['short_url_twitter'] = $share['url']; } if ($share['short_url_whatsapp'] == '') { $share['short_url_whatsapp'] = $share['url']; } if ($share['short_url'] == '') { $share['short_url'] = $share['url']; } } else { $share['twitter_tweet'] .= '%20' . $share['url']; $share['short_url_twitter'] = esc_attr($share['url']); $share['short_url_whatsapp'] = esc_attr($share['url']); } /*if (ESSBOptionValuesHelper::options_bool_value ( $essb_options, 'twitter_shareshort' ) || ESSBOptionValuesHelper::options_bool_value ( $essb_options, 'shorturl_activate' ) || ESSBOptionValuesHelper::options_bool_value ( $essb_options, 'whatsapp_shareshort' )) { $global_provider = ESSBOptionValuesHelper::options_value ( $essb_options, 'shorturl_type' ); if (ESSBOptionValuesHelper::options_bool_value ( $essb_options, 'shorturl_activate' )) { $share ['short_url'] = ESSBUrlHelper::short_url ( $share ['full_url'], $global_provider, get_the_ID (), ESSBOptionValuesHelper::options_value ( $essb_options, 'shorturl_bitlyuser' ), ESSBOptionValuesHelper::options_value ( $essb_options, 'shorturl_bitlyapi' ) ); $share ['short_url_twitter'] = $share ['short_url']; $share ['short_url_whatsapp'] = $share ['short_url']; } else { if (ESSBOptionValuesHelper::options_bool_value ( $essb_options, 'twitter_shareshort' )) { $provider = ESSBOptionValuesHelper::options_value ( $essb_options, 'twitter_shareshort_service' ); $share ['short_url_twitter'] = ESSBUrlHelper::short_url ( $share ['full_url'], $global_provider, get_the_ID (), ESSBOptionValuesHelper::options_value ( $essb_options, 'shorturl_bitlyuser' ), ESSBOptionValuesHelper::options_value ( $essb_options, 'shorturl_bitlyapi' ) ); } if (ESSBOptionValuesHelper::options_bool_value ( $essb_options, 'whatsapp_shareshort' )) { $provider = ESSBOptionValuesHelper::options_value ( $essb_options, 'whatsapp_shareshort_service' ); if ($provider == ESSBOptionValuesHelper::options_value ( $essb_options, 'twitter_shareshort_service' ) && ESSBOptionValuesHelper::options_bool_value ( $essb_options, 'twitter_shareshort' )) { $share ['short_url_whatsapp'] = $share ['short_url_twitter']; } else { $share ['short_url_whatsapp'] = ESSBUrlHelper::short_url ( $share ['full_url'], $global_provider, get_the_ID (), ESSBOptionValuesHelper::options_value ( $essb_options, 'shorturl_bitlyuser' ), ESSBOptionValuesHelper::options_value ( $essb_options, 'shorturl_bitlyapi' ) ); } } if ($share ['short_url_twitter'] == '') { $share ['short_url_twitter'] = $share ['url']; } if ($share ['short_url_whatsapp'] == '') { $share ['short_url_whatsapp'] = $share ['url']; } } } else { $share ['twitter_tweet'] .= '%20' . $share ['url']; $share ['short_url_twitter'] = esc_attr ( $share ['url'] ); $share ['short_url_whatsapp'] = esc_attr ( $share ['url'] ); }*/ } if (!isset($share['query'])) { if (isset($share['essb_encode_url'])) { if ($share['essb_encode_url']) { $share['short_url_twitter'] = urlencode($share['short_url_twitter']); $share['full_url'] = urlencode($share['full_url']); $share['url'] = urlencode($share['url']); $share['full_url'] = str_replace('&', '&', $share['full_url']); $share['url'] = str_replace('&', '&', $share['url']); } } if (isset($share['essb_encode_text'])) { if ($share['essb_encode_text']) { $share['twitter_tweet'] = str_replace("+", " ", $share['twitter_tweet']); $share['title'] = urlencode($share['title']); $share['twitter_tweet'] = urlencode($share['twitter_tweet']); $share['description'] = urlencode($share['description']); $share['twitter_tweet'] = str_replace(" ", "%20", $share['twitter_tweet']); $share['twitter_tweet'] = str_replace("+", "%20", $share['twitter_tweet']); $share['twitter_tweet'] = str_replace('&', '&', $share['twitter_tweet']); $share['title'] = str_replace('&', '&', $share['title']); $share['description'] = str_replace('&', '&', $share['description']); } } 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']); 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['description']; if (empty($pinterest_description)) { $pinterest_description = $share['title']; } // @since version 3.0.4 - fix for shorturl $shorturl_activate = ESSBOptionValuesHelper::options_bool_value($essb_options, '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": $url = sprintf('http://www.facebook.com/sharer/sharer.php?u=%1$s&t=%2$s', $share['url'], $share['title']); break; case "facebook_advanced": $fbappid = ESSBOptionValuesHelper::options_value($essb_options, 'facebookadvancedappid'); $url = 'https://www.facebook.com/dialog/feed?app_id=' . $fbappid . '&display=popup&name=' . $share['title'] . '&link=' . $share['url'] . '&redirect_uri=https://www.facebook.com'; 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']; } $use_tweet = $share['twitter_tweet']; $use_tweet = str_replace('#', '%23', $use_tweet); $use_tweet = str_replace('|', '%7C', $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 = ESSBOptionValuesHelper::options_value($essb_options, 'twitter_message_optimize_method'); $optmized_tweet = ESSBButtonHelper::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": $url = sprintf('http://www.linkedin.com/shareArticle?mini=true&ro=true&trk=EasySocialShareButtons&title=%1$s&url=%2$s', $share['title'], $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']); 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": $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', ESSBCoreHelper::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 (!$share['mail_subject']) { $share['mail_subject'] = ''; } if (!$share['mail_body']) { $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_mailform_" . $salt . "('" . $salt . "'); return false;"; break; 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 // @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', ESSBCoreHelper::urlencode ( $share ['title'] ), rawurlencode ( $share ['short_url_whatsapp'] )); $url = sprintf('line://msg/text/%1$s%3$s%2$s', ESSBCoreHelper::urlencode($share['title_plain']), rawurlencode($share['short_url_whatsapp']), '%20'); $api_command = "essb_tracking_only('', 'line', '" . $salt . "', true);"; break; case "embedly": $url = ""; $api_command = "embedly.modal();"; 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']; } $url = sprintf('sms:&body=%1$s%3$s%2$s', ESSBCoreHelper::urlencode($share['title_plain']), rawurlencode($share['short_url_whatsapp']), '%20'); 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', ESSBCoreHelper::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', ESSBCoreHelper::urlencode($share['title_plain']), rawurlencode($share['short_url_whatsapp'])); } else { $url = sprintf('tg://msg?text=%1$s%3$s%2$s', ESSBCoreHelper::urlencode($share['title_plain']), rawurlencode($share['short_url_whatsapp']), '%20'); } $api_command = "essb_tracking_only('', 'telegram', '" . $salt . "', true);"; break; default: // @since 3.0 - module parsing social buttons or custom social buttons if ($network_type != 'buildin') { /*$url = ''; $api_command = ''; $button_object_name = "ESSBNetwork_".$network; if (method_exists($button_object_name, 'get_share_address')) { $url = $button_object_name::get_share_address($share); } if (method_exists($button_object_name, 'get_api_command')) { $api_command = $button_object_name::get_api_command($share); }*/ } break; } if ($api_command == '') { $api_command = sprintf('essb_window('%1$s','%2$s','%3$s'); return false;', $url, $network, $salt); if ($network == "twitter") { $url = "#"; } } if ($share['essb_encode_url']) { $url = str_replace('&', '&', $url); //print $url; } return array("url" => $url, 'api_command' => $api_command); }
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; }
function include_social_image_share() { global $essb_options; if (ESSBCoreHelper::is_plugin_deactivated_on() || ESSBCoreHelper::is_module_deactivate_on('sis')) { return; } $mobile_detect = new ESSB_Mobile_Detect(); if ($mobile_detect->isMobile() && !ESSBOptionValuesHelper::options_bool_value($essb_options, 'sis_on_mobile')) { return false; } $current_post_address = ESSBUrlHelper::get_current_page_url(); $current_post_address = ESSBUrlHelper::attach_tracking_code($current_post_address, 'essb-image-share=yes'); ?> <script> <?php echo $calling = $this->get_settings('sis_always_show') === 'true' ? 'jQuery(window).load(function(){' : 'jQuery(document).ready(function(){'; ?> jQuery('<?php echo $this->get_settings('sis_selector', 'img'); ?> ').socialImageShare({ selector: "<?php echo $this->get_settings('sis_selector', 'img'); ?> ", dontshow: "<?php echo $this->get_settings('sis_dontshow'); ?> ", title: "<?php echo $this->get_settings('sis_title'); ?> ", summary: "<?php echo $this->get_settings('sis_summary'); ?> ", minWidth: <?php echo $this->get_settings('sis_minWidth', '100'); ?> , minHeight: <?php echo $this->get_settings('sis_minHeight', '100'); ?> , fb_app: "<?php echo $this->get_settings('sis_fb_app'); ?> ", scroll: <?php echo $this->get_settings('sis_scroll', 'false', true); ?> , align: { x: "<?php echo $this->get_settings('sis_align_x', 'left'); ?> ", y: "<?php echo $this->get_settings('sis_align_y', 'top'); ?> " }, offset: { x: <?php echo $this->get_settings('sis_offset_x', '0'); ?> , y: <?php echo $this->get_settings('sis_offset_y', '0'); ?> }, orientation: "<?php echo $this->get_settings('sis_orientation'); ?> ", style: '<?php echo $this->get_settings('sis_style'); ?> ', sharer: "<?php echo $sharer = $this->get_settings('sis_sharer') == 'true' ? $current_post_address : ''; ?> ", is_mobile: <?php echo $is_mobile = $mobile_detect->isMobile() ? 'true' : 'false'; ?> , always_show: <?php echo $this->get_settings('sis_always_show', 'false'); ?> , pinterest_alt: <?php echo $this->get_settings('sis_pinterest_alt', 'false'); ?> , primary_menu: [ <?php echo $this->get_primary_menu(); ?> ], }); }); </script> <?php }
function essb_shortcode_total_shares($atts) { global $post; $atts = shortcode_atts(array('message' => '', 'align' => '', 'url' => '', 'share_text' => '', 'fullnumber' => 'no', 'networks' => ''), $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'; $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']; $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'; $this->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 . '"'; } $output = ""; $output .= '<div 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 .= '<div class="essb-message essb-block">' . $message . '</div>'; } $output .= '<div class="essb-total-value essb-block">0</div>'; if ($share_text != '') { $output .= '<div class="essb-total-text essb-block">' . $share_text . '</div>'; } $output .= '</div>'; return $output; }
public static function short_url($url, $provider, $post_id = '', $bitly_user = '', $bitly_api = '') { global $essb_options; $deactivate_cache = ESSBOptionValuesHelper::options_bool_value($essb_options, 'deactivate_shorturl_cache'); $shorturl_googlapi = ESSBOptionValuesHelper::options_value($essb_options, 'shorturl_googlapi'); $short_url = ""; if ($provider == "ssu") { if (!defined('ESSB3_SSU_VERSION')) { $provider = "wp"; } } switch ($provider) { case "wp": $short_url = wp_get_shortlink(); break; case "goo.gl": $short_url = self::short_googl($url, $post_id, $deactivate_cache, $shorturl_googlapi); break; case "bit.ly": $short_url = self::short_bitly($url, $bitly_user, $bitly_api, $post_id, $deactivate_cache); break; case "ssu": $short_url = self::short_ssu($url, $post_id, $deactivate_cache); break; } // @since 3.4 affiliate intergration with wp shorturl $affwp_active = ESSBOptionValuesHelper::options_bool_value($essb_options, 'affwp_active'); if ($affwp_active) { $short_url = ESSBUrlHelper::generate_affiliatewp_referral_link($short_url); } $affs_active = ESSBOptionValuesHelper::options_bool_value($essb_options, 'affs_active'); if ($affs_active) { $short_url = do_shortcode('[affiliates_url]' . $short_url . '[/affiliates_url]'); } return $short_url; }