function sw_linkedIn_button_html($array) { // If we've already generated this button, just use our existing html if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['linkedIn'])) { $array['resource']['linkedIn'] = $_GLOBALS['sw']['buttons'][$array['postID']]['linkedIn']; // If not, let's check if Facebook is activated and create the button HTML } elseif ($array['options']['linkedIn']) { $array['totes'] += $array['shares']['linkedIn']; ++$array['count']; $array['resource']['linkedIn'] = '<div class="nc_tweetContainer linkedIn" data-id="' . $array['count'] . '">'; $link = urlencode(urldecode(sw_process_url($array['url'], 'linkedIn', $array['postID']))); $array['resource']['linkedIn'] .= '<a target="_blank" href="https://www.linkedin.com/cws/share?url=' . $link . '" data-link="https://www.linkedin.com/cws/share?url=' . $link . '" class="nc_tweet">'; if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['linkedIn'] > 0) { $array['resource']['linkedIn'] .= '<span class="iconFiller">'; $array['resource']['linkedIn'] .= '<span class="spaceManWilly">'; $array['resource']['linkedIn'] .= '<i class="sw sw-linkedin"></i>'; $array['resource']['linkedIn'] .= '<span class="sw_share"> ' . $array['language']['linkedIn'] . '</span>'; $array['resource']['linkedIn'] .= '</span></span>'; $array['resource']['linkedIn'] .= '<span class="sw_count">' . kilomega($array['shares']['linkedIn']) . '</span>'; } else { $array['resource']['linkedIn'] .= '<span class="sw_count sw_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-linkedin"></i><span class="sw_share"> ' . $array['language']['linkedIn'] . '</span></span></span></span>'; } $array['resource']['linkedIn'] .= '</a>'; $array['resource']['linkedIn'] .= '</div>'; // Store these buttons so that we don't have to generate them for each set $_GLOBALS['sw']['buttons'][$array['postID']]['linkedIn'] = $array['resource']['linkedIn']; } return $array; }
function sw_twitter_button_html($array) { // If we've already generated this button, just use our existing html if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['twitter'])) { $array['resource']['twitter'] = $_GLOBALS['sw']['buttons'][$array['postID']]['twitter']; // If not, let's check if Facebook is activated and create the button HTML } elseif (isset($array['options']['twitter']) && $array['options']['twitter']) { $array['totes'] += $array['shares']['twitter']; ++$array['count']; $title = strip_tags(get_the_title($array['postID'])); $title = str_replace('|', '', $title); $ct = get_post_meta($array['postID'], 'nc_customTweet', true); $ct = $ct != '' ? urlencode(html_entity_decode($ct, ENT_COMPAT, 'UTF-8')) : urlencode(html_entity_decode($title, ENT_COMPAT, 'UTF-8')); $twitterLink = sw_process_url($array['url'], 'twitter', $array['postID']); if (strpos($ct, 'http') !== false) { $urlParam = '&url=/'; } else { $urlParam = '&url=' . $twitterLink; } if (sw_is_cache_fresh($array['postID']) == false) { $user_twitter_handle = get_the_author_meta('sw_twitter', sw_get_author($array['postID'])); if ($user_twitter_handle) { delete_post_meta($array['postID'], 'sw_twitter_username'); update_post_meta($array['postID'], 'sw_twitter_username', $user_twitter_handle); } else { delete_post_meta($array['postID'], 'sw_twitter_username'); } } else { $user_twitter_handle = get_post_meta($array['postID'], 'sw_twitter_username', true); } if ($user_twitter_handle) { $viaText = '&via=' . $user_twitter_handle; } elseif ($array['options']['twitterID']) { $viaText = '&via=' . $array['options']['twitterID']; } else { $viaText = ''; } $array['resource']['twitter'] = '<div class="nc_tweetContainer twitter" data-id="' . $array['count'] . '">'; $array['resource']['twitter'] .= '<a href="https://twitter.com/share?original_referer=/&text=' . $ct . '' . $urlParam . '' . $viaText . '" data-link="https://twitter.com/share?original_referer=/&text=' . $ct . '' . $urlParam . '' . $viaText . '" class="nc_tweet">'; if ($array['options']['totesEach'] && $array['totes'] >= $array['options']['minTotes'] && $array['shares']['twitter'] > 0) { $array['resource']['twitter'] .= '<span class="iconFiller">'; $array['resource']['twitter'] .= '<span class="spaceManWilly">'; $array['resource']['twitter'] .= '<i class="sw sw-twitter"></i>'; $array['resource']['twitter'] .= '<span class="sw_share"> ' . $array['language']['twitter'] . '</span>'; $array['resource']['twitter'] .= '</span></span>'; $array['resource']['twitter'] .= '<span class="sw_count">' . kilomega($array['shares']['twitter']) . '</span>'; } else { $array['resource']['twitter'] .= '<span class="sw_count sw_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-twitter"></i><span class="sw_share"> ' . $array['language']['twitter'] . '</span></span></span></span>'; } $array['resource']['twitter'] .= '</a>'; $array['resource']['twitter'] .= '</div>'; // Store these buttons so that we don't have to generate them for each set $_GLOBALS['sw']['buttons'][$array['postID']]['twitter'] = $array['resource']['twitter']; } return $array; }
function sw_email_button_html($array) { if ($array['options']['email']) { // Collect the Title $title = SW_META_meta('nc_ogTitle'); if (!$title) { $title = get_the_title(); } // Collect the Description $description = SW_META_meta('nc_ogDescription'); if (!$description) { $description = sw_get_excerpt_by_id($array['postID']); } $array['resource']['email'] = '<div class="nc_tweetContainer sw_email">'; $link = urlencode(urldecode(sw_process_url($array['url'], 'email', $array['postID']))); $array['resource']['email'] .= '<a href="mailto:?subject=' . urlencode($title) . '&body=' . urlencode($description) . ' Read here: ' . $link . '" class="nc_tweet">'; $array['resource']['email'] .= '<span class="sw_count sw_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-email"></i><span class="sw_share"> ' . $array['language']['email'] . '</span></span></span></span>'; $array['resource']['email'] .= '</a>'; $array['resource']['email'] .= '</div>'; ++$array['count']; } return $array; }
function sw_tumblr_button_html($array) { // If we've already generated this button, just use our existing html if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['tumblr'])) { $array['resource']['tumblr'] = $_GLOBALS['sw']['buttons'][$array['postID']]['tumblr']; // If not, let's check if Facebook is activated and create the button HTML } elseif (isset($array['options']['tumblr']) && $array['options']['tumblr']) { $array['totes'] += $array['shares']['tumblr']; ++$array['count']; // Collect the Title $title = SW_META_meta('nc_ogTitle'); if (!$title) { $title = get_the_title(); } // Collect the Description $description = SW_META_meta('nc_ogDescription'); $array['resource']['tumblr'] = '<div class="nc_tweetContainer sw_tumblr" data-id="' . $array['count'] . '">'; $link = urlencode(urldecode(sw_process_url($array['url'], 'tumblr', $array['postID']))); $array['resource']['tumblr'] .= '<a target="_blank" href="http://www.tumblr.com/share/link?url=' . $link . '&name=' . urlencode($title) . ($description ? '&description=' : '') . urlencode($description) . '" data-link="http://www.tumblr.com/share/link?url=' . $link . '&name=' . urlencode($title) . ($description ? '&description=' : '') . urlencode($description) . '" class="nc_tweet">'; if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['tumblr'] > 0) { $array['resource']['tumblr'] .= '<span class="iconFiller">'; $array['resource']['tumblr'] .= '<span class="spaceManWilly">'; $array['resource']['tumblr'] .= '<i class="sw sw-tumblr"></i>'; $array['resource']['tumblr'] .= '<span class="sw_share"> ' . $array['language']['tumblr'] . '</span>'; $array['resource']['tumblr'] .= '</span></span>'; $array['resource']['tumblr'] .= '<span class="sw_count">' . kilomega($array['shares']['tumblr']) . '</span>'; } else { $array['resource']['tumblr'] .= '<span class="sw_count sw_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-tumblr"></i><span class="sw_share"> ' . $array['language']['tumblr'] . '</span></span></span></span>'; } $array['resource']['tumblr'] .= '</a>'; $array['resource']['tumblr'] .= '</div>'; // Store these buttons so that we don't have to generate them for each set $_GLOBALS['sw']['buttons'][$array['postID']]['tumblr'] = $array['resource']['tumblr']; } return $array; }