本文整理汇总了PHP中swp_kilomega函数的典型用法代码示例。如果您正苦于以下问题:PHP swp_kilomega函数的具体用法?PHP swp_kilomega怎么用?PHP swp_kilomega使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了swp_kilomega函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: swp_linkedIn_button_html
function swp_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 (isset($array['options']['newOrderOfIcons']['linkedIn']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['linkedIn'])) {
$array['totes'] += $array['shares']['linkedIn'];
++$array['count'];
$array['resource']['linkedIn'] = '<div class="nc_tweetContainer linkedIn" data-id="' . $array['count'] . '" data-network="linked_in">';
$link = urlencode(urldecode(swp_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="swp_share"> ' . __('Share', 'social-warfare') . '</span>';
$array['resource']['linkedIn'] .= '</span></span>';
$array['resource']['linkedIn'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['linkedIn']) . '</span>';
} else {
$array['resource']['linkedIn'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-linkedin"></i><span class="swp_share"> ' . __('Share', 'social-warfare') . '</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;
}
示例2: swp_buffer_button_html
function swp_buffer_button_html($array)
{
// If we've already generated this button, just use our existing html
if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['buffer'])) {
$array['resource']['buffer'] = $_GLOBALS['sw']['buttons'][$array['postID']]['buffer'];
// If not, let's check if Buffer is activated and create the button HTML
} elseif (isset($array['options']['newOrderOfIcons']['buffer']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['buffer'])) {
// Collect the Title
$title = get_post_meta($array['postID'], 'nc_ogTitle', true);
if (!$title) {
$title = get_the_title();
}
$array['totes'] += $array['shares']['buffer'];
++$array['count'];
$array['resource']['buffer'] = '<div class="nc_tweetContainer swp_buffer" data-id="' . $array['count'] . '" data-network="buffer">';
$link = urlencode(urldecode(swp_process_url($array['url'], 'buffer', $array['postID'])));
$array['resource']['buffer'] .= '<a target="_blank" href="http://bufferapp.com/add?url=' . $link . '&text=' . urlencode(html_entity_decode($title, ENT_COMPAT, 'UTF-8')) . '" data-link="http://bufferapp.com/add?url=' . $link . '&text=' . urlencode(html_entity_decode($title, ENT_COMPAT, 'UTF-8')) . '" class="nc_tweet buffer_link">';
if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['buffer'] > 0) {
$array['resource']['buffer'] .= '<span class="iconFiller">';
$array['resource']['buffer'] .= '<span class="spaceManWilly">';
$array['resource']['buffer'] .= '<i class="sw sw-buffer"></i>';
$array['resource']['buffer'] .= '<span class="swp_share"> ' . __('Buffer', 'social-warfare') . '</span>';
$array['resource']['buffer'] .= '</span></span>';
$array['resource']['buffer'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['buffer']) . '</span>';
} else {
$array['resource']['buffer'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-buffer"></i><span class="swp_share"> ' . __('Buffer', 'social-warfare') . '</span></span></span></span>';
}
$array['resource']['buffer'] .= '</a>';
$array['resource']['buffer'] .= '</div>';
// Store these buttons so that we don't have to generate them for each set
$_GLOBALS['sw']['buttons'][$array['postID']]['buffer'] = $array['resource']['buffer'];
}
return $array;
}
示例3: swp_hacker_news_button_html
function swp_hacker_news_button_html($array)
{
if (isset($array['options']['newOrderOfIcons']['hacker_news']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['hacker_news'])) {
// Collect the Title
$title = get_post_meta($array['postID'], 'nc_ogTitle', true);
if (!$title) {
$title = get_the_title();
}
++$array['count'];
$array['resource']['hacker_news'] = '<div class="nc_tweetContainer swp_hacker_news" data-id="' . $array['count'] . '" data-network="hacker_news">';
$link = urlencode(urldecode(swp_process_url($array['url'], 'email', $array['postID'])));
$array['resource']['hacker_news'] .= '<a rel="nofollow" target="_blank" href="http://news.ycombinator.com/submitlink?u=' . $link . '&t=' . urlencode($title) . '" data-link="http://news.ycombinator.com/submitlink?u=' . $link . '&t=' . urlencode($title) . '" class="nc_tweet">';
if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['hacker_news'] > 0) {
$array['resource']['hacker_news'] .= '<span class="iconFiller">';
$array['resource']['hacker_news'] .= '<span class="spaceManWilly">';
$array['resource']['hacker_news'] .= '<i class="sw sw-hacker_news"></i>';
$array['resource']['hacker_news'] .= '<span class="swp_share"> ' . __('Vote', 'social-warfare') . '</span>';
$array['resource']['hacker_news'] .= '</span></span>';
$array['resource']['hacker_news'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['hacker_news']) . '</span>';
} else {
$array['resource']['hacker_news'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-hacker_news"></i><span class="swp_share"> ' . __('Vote', 'social-warfare') . '</span></span></span></span>';
}
$array['resource']['hacker_news'] .= '</a>';
$array['resource']['hacker_news'] .= '</div>';
}
return $array;
}
示例4: swp_stumbleupon_button_html
function swp_stumbleupon_button_html($array)
{
// If we've already generated this button, just use our existing html
if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['stumbleupon'])) {
$array['resource']['stumbleupon'] = $_GLOBALS['sw']['buttons'][$array['postID']]['stumbleupon'];
// If not, let's check if Facebook is activated and create the button HTML
} elseif (isset($array['options']['newOrderOfIcons']['stumbleupon']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['stumbleupon'])) {
if (isset($array['shares']['stumbleupon'])) {
$array['totes'] += $array['shares']['stumbleupon'];
}
++$array['count'];
// Collect the Title
$title = get_post_meta($array['postID'], 'nc_ogTitle', true);
if (!$title) {
$title = get_the_title();
}
$array['resource']['stumbleupon'] = '<div class="nc_tweetContainer swp_stumbleupon" data-id="' . $array['count'] . '" data-network="stumble_upon">';
$link = $array['url'];
$array['resource']['stumbleupon'] .= '<a target="_blank" href="http://www.stumbleupon.com/submit?url=' . $link . '&title=' . urlencode($title) . '" data-link="http://www.stumbleupon.com/submit?url=' . $link . '&title=' . urlencode($title) . '" class="nc_tweet">';
if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && isset($array['shares']['stumbleupon']) && $array['shares']['stumbleupon'] > 0) {
$array['resource']['stumbleupon'] .= '<span class="iconFiller">';
$array['resource']['stumbleupon'] .= '<span class="spaceManWilly">';
$array['resource']['stumbleupon'] .= '<i class="sw sw-stumbleupon"></i>';
$array['resource']['stumbleupon'] .= '<span class="swp_share"> ' . __('Stumble', 'social-warfare') . '</span>';
$array['resource']['stumbleupon'] .= '</span></span>';
$array['resource']['stumbleupon'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['stumbleupon']) . '</span>';
} else {
$array['resource']['stumbleupon'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-stumbleupon"></i><span class="swp_share"> ' . __('Stumble', 'social-warfare') . '</span></span></span></span>';
}
$array['resource']['stumbleupon'] .= '</a>';
$array['resource']['stumbleupon'] .= '</div>';
// Store these buttons so that we don't have to generate them for each set
$_GLOBALS['sw']['buttons'][$array['postID']]['stumbleupon'] = $array['resource']['stumbleupon'];
}
return $array;
}
示例5: swp_twitter_button_html
function swp_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']['newOrderOfIcons']['twitter']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['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 = swp_process_url($array['url'], 'twitter', $array['postID']);
if (strpos($ct, 'http') !== false) {
$urlParam = '&url=/';
} else {
$urlParam = '&url=' . $twitterLink;
}
if (swp_is_cache_fresh($array['postID']) == false) {
$user_twitter_handle = get_the_author_meta('swp_twitter', swp_get_author($array['postID']));
if ($user_twitter_handle) {
delete_post_meta($array['postID'], 'swp_twitter_username');
update_post_meta($array['postID'], 'swp_twitter_username', $user_twitter_handle);
} else {
delete_post_meta($array['postID'], 'swp_twitter_username');
}
} else {
$user_twitter_handle = get_post_meta($array['postID'], 'swp_twitter_username', true);
}
if ($user_twitter_handle) {
$viaText = '&via=' . str_replace('@', '', $user_twitter_handle);
} elseif ($array['options']['twitterID']) {
$viaText = '&via=' . str_replace('@', '', $array['options']['twitterID']);
} else {
$viaText = '';
}
$array['resource']['twitter'] = '<div class="nc_tweetContainer twitter" data-id="' . $array['count'] . '" data-network="twitter">';
$array['resource']['twitter'] .= '<a rel="nofollow" target="_blank" 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['shares']['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="swp_share"> ' . __('Tweet', 'social-warfare') . '</span>';
$array['resource']['twitter'] .= '</span></span>';
$array['resource']['twitter'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['twitter']) . '</span>';
} else {
$array['resource']['twitter'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-twitter"></i><span class="swp_share"> ' . __('Tweet', 'social-warfare') . '</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;
}
示例6: socialWarfareSideFloat
function socialWarfareSideFloat()
{
// Get the options...or create them if they don't exist
wp_reset_query();
$postID = get_the_ID();
$options = swp_get_user_options();
$postType = get_post_type($postID);
if (is_singular()) {
$postType = get_post_type($postID);
if (isset($options['float_location_' . $postType])) {
$visibility = $options['float_location_' . $postType];
} else {
$visibility = 'on';
}
} else {
$visibility = 'on';
}
if (is_singular() && get_post_status($postID) == 'publish' && get_post_meta($postID, 'nc_floatLocation', true) != 'off' && $visibility == 'on' && !is_home()) {
// Acquire the social stats from the networks
// Acquire the social stats from the networks
if (isset($array['url'])) {
$buttonsArray['url'] = $array['url'];
} else {
$buttonsArray['url'] = get_permalink($postID);
}
if ($options['float'] && is_singular()) {
$floatOption = 'float' . ucfirst($options['floatOption']);
} else {
$floatOption = 'floatNone';
}
if ($options['floatStyleSource'] == true) {
$options['sideDColorSet'] = $options['dColorSet'];
$options['sideIColorSet'] = $options['iColorSet'];
$options['sideOColorSet'] = $options['oColorSet'];
}
// Setup the buttons array to pass into the 'swp_network_buttons' hook
$buttonsArray['shares'] = get_social_warfare_shares($postID);
$buttonsArray['count'] = 0;
$buttonsArray['totes'] = 0;
$buttonsArray['options'] = $options;
if ($buttonsArray['options']['totes'] && $buttonsArray['shares']['totes'] >= $buttonsArray['options']['minTotes']) {
++$buttonsArray['count'];
}
$buttonsArray['resource'] = array();
$buttonsArray['postID'] = $postID;
$buttonsArray = apply_filters('swp_network_buttons', $buttonsArray);
// Create the social panel
$assets = '<div class="nc_socialPanelSide nc_socialPanel swp_' . $options['floatStyle'] . ' swp_d_' . $options['sideDColorSet'] . ' swp_i_' . $options['sideIColorSet'] . ' swp_o_' . $options['sideOColorSet'] . ' ' . $options['sideReveal'] . '" data-position="' . $options['location_post'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-screen-width="' . $options['swp_float_scr_sz'] . '" data-transition="' . $options['sideReveal'] . '">';
// Display Total Shares if the Threshold has been met
if ($options['totes'] && $buttonsArray['totes'] >= $options['minTotes']) {
$assets .= '<div class="nc_tweetContainer totes totesalt" data-id="6" >';
$assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . '</span><span class="swp_label"> ' . __('Shares', 'social-warfare') . '</span>';
$assets .= '</div>';
}
$i = 0;
// Sort the buttons according to the user's preferences
if (isset($buttonsArray) && isset($buttonsArray['buttons'])) {
foreach ($buttonsArray['buttons'] as $key => $value) {
if (isset($buttonsArray['resource'][$key]) && $i < 5) {
$assets .= $buttonsArray['resource'][$key];
}
++$i;
}
} elseif ($options['orderOfIconsSelect'] == 'manual') {
foreach ($options['newOrderOfIcons'] as $key => $value) {
if (isset($buttonsArray['resource'][$key]) && $i < 5) {
$assets .= $buttonsArray['resource'][$key];
}
++$i;
}
} elseif ($options['orderOfIconsSelect'] == 'dynamic') {
arsort($buttonsArray['shares']);
foreach ($buttonsArray['shares'] as $thisIcon => $status) {
if (isset($buttonsArray['resource'][$thisIcon]) && $i < 5) {
$assets .= $buttonsArray['resource'][$thisIcon];
}
++$i;
}
}
// Close the Social Panel
$assets .= '</div>';
echo $assets;
}
}
示例7: social_warfare_buttons
//.........这里部分代码省略.........
// Store the result in the array that gets passed to the HTML generator
$buttonsArray['buttons'][$key] = $button;
// Declare a default share count of zero. This will be overriden later
if (!isset($buttonsArray['shares'][$key])) {
$buttonsArray['shares'][$key] = 0;
}
}
}
// Manually turn the total shares on or off
if (array_search('Total', $button_set_array)) {
$buttonsArray['buttons']['totes'] = 'Total';
}
}
// Setup the buttons array to pass into the 'swp_network_buttons' hook
$buttonsArray['count'] = 0;
$buttonsArray['totes'] = 0;
if ($buttonsArray['options']['totes'] && $buttonsArray['shares']['totes'] >= $buttonsArray['options']['minTotes'] && !isset($array['buttons']) || isset($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
++$buttonsArray['count'];
}
$buttonsArray['resource'] = array();
$buttonsArray['postID'] = $postID;
// Disable the subtitles plugin to avoid letting them inject their subtitle into our share titles
if (is_plugin_active('subtitles/subtitles.php') && class_exists('Subtitles')) {
remove_filter('the_title', array(Subtitles::getinstance(), 'the_subtitle'), 10, 2);
}
// This array will contain the HTML for all of the individual buttons
$buttonsArray = apply_filters('swp_network_buttons', $buttonsArray);
// Create the social panel
$assets = '<div class="nc_socialPanel swp_' . $options['visualTheme'] . ' swp_d_' . $options['dColorSet'] . ' swp_i_' . $options['iColorSet'] . ' swp_o_' . $options['oColorSet'] . '" data-position="' . $options['location_post'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-scale="' . $options['buttonSize'] . '" data-align="' . $options['buttonFloat'] . '">';
// Setup the total shares count if it's on the left
if ($options['totes'] && $options['swTotesFormat'] == 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes'] && !isset($array['buttons']) || $options['swTotesFormat'] == 'totesAltLeft' && isset($array['buttons']) && isset($array['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
++$buttonsArray['count'];
$assets .= '<div class="nc_tweetContainer totes totesalt" data-id="' . $buttonsArray['count'] . '" >';
$assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . ' <span class="swp_label">' . __('Shares', 'social-warfare') . '</span></span>';
$assets .= '</div>';
}
// Sort the buttons according to the user's preferences
if (isset($buttonsArray) && isset($buttonsArray['buttons'])) {
foreach ($buttonsArray['buttons'] as $key => $value) {
if (isset($buttonsArray['resource'][$key])) {
$assets .= $buttonsArray['resource'][$key];
}
}
} elseif ($options['orderOfIconsSelect'] == 'manual') {
foreach ($options['newOrderOfIcons'] as $key => $value) {
if (isset($buttonsArray['resource'][$key])) {
$assets .= $buttonsArray['resource'][$key];
}
}
} elseif ($options['orderOfIconsSelect'] == 'dynamic') {
arsort($buttonsArray['shares']);
foreach ($buttonsArray['shares'] as $thisIcon => $status) {
if (isset($buttonsArray['resource'][$thisIcon])) {
$assets .= $buttonsArray['resource'][$thisIcon];
}
}
}
// Create the Total Shares Box if it's on the right
if ($options['totes'] && $options['swTotesFormat'] != 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes'] && !isset($buttonsArray['buttons']) || $options['swTotesFormat'] != 'totesAltLeft' && isset($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
++$buttonsArray['count'];
if ($options['swTotesFormat'] == 'totes') {
$assets .= '<div class="nc_tweetContainer totes" data-id="' . $buttonsArray['count'] . '" >';
$assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . ' <span class="swp_label">' . __('Shares', 'social-warfare') . '</span></span>';
$assets .= '</div>';
} else {
$assets .= '<div class="nc_tweetContainer totes totesalt" data-id="' . $buttonsArray['count'] . '" >';
示例8: swp_yummly_button_html
function swp_yummly_button_html($array)
{
// If we've already generated this button, just use our existing html
if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['yummly'])) {
$array['resource']['yummly'] = $_GLOBALS['sw']['buttons'][$array['postID']]['yummly'];
// If not, let's check if Yummly is activated and create the button HTML
} elseif (isset($array['options']['newOrderOfIcons']['yummly']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['yummly'])) {
if (isset($array['options']['yummly_categories']) && $array['options']['yummly_categories'] != '' && in_category($array['options']['yummly_categories'], $array['postID']) || isset($array['options']['yummly_tags']) && $array['options']['yummly_tags'] != '' && has_tag($array['options']['yummly_tags'], $array['postID']) || (!isset($array['options']['yummly_tags']) && !isset($array['options']['yummly_categories']) || $array['options']['yummly_categories'] == '' && $array['options']['yummly_tags'] == '')) {
$array['totes'] += $array['shares']['yummly'];
++$array['count'];
// Let's create a title
if (get_post_meta($array['postID'], 'nc_ogTitle', true)) {
// If the user defined an social media title, let's use it.
$title = urlencode(urldecode(get_post_meta($array['postID'], 'nc_ogTitle', true)));
} else {
// Otherwise we'll use the default post title
$title = urlencode(urldecode(get_the_title()));
}
if (get_post_meta($array['postID'], 'swp_open_graph_image_url')) {
$image = urlencode(urldecode(get_post_meta($array['postID'], 'swp_open_graph_image_url', true)));
} else {
$image = urlencode(urldecode(get_post_meta($array['postID'], 'swp_open_thumbnail_url', true)));
}
$array['resource']['yummly'] = '<div class="nc_tweetContainer swp_yummly" data-id="' . $array['count'] . '" data-network="yummly">';
// $link = urlencode(urldecode(swp_process_url( $array['url'] , 'yummly' , $array['postID'] )));
$link = $array['url'];
$array['resource']['yummly'] .= '<a target="_blank" href="http://www.yummly.com/urb/verify?url=' . $link . '&title=' . $title . '&image=' . $image . '&yumtype=button" data-link="http://www.yummly.com/urb/verify?url=' . $link . '&title=' . $title . '&image=' . $image . '&yumtype=button" class="nc_tweet">';
if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['yummly'] > 0) {
$array['resource']['yummly'] .= '<span class="iconFiller">';
$array['resource']['yummly'] .= '<span class="spaceManWilly">';
$array['resource']['yummly'] .= '<i class="sw sw-yummly"></i>';
$array['resource']['yummly'] .= '<span class="swp_share"> ' . __('Yum', 'social-warfare') . '</span>';
$array['resource']['yummly'] .= '</span></span>';
$array['resource']['yummly'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['yummly']) . '</span>';
} else {
$array['resource']['yummly'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-yummly"></i><span class="swp_share"> ' . __('Yum', 'social-warfare') . '</span></span></span></span>';
}
$array['resource']['yummly'] .= '</a>';
$array['resource']['yummly'] .= '</div>';
// Store these buttons so that we don't have to generate them for each set
$_GLOBALS['sw']['buttons'][$array['postID']]['yummly'] = $array['resource']['yummly'];
}
}
return $array;
}
示例9: swp_pinterest_button_html
function swp_pinterest_button_html($array)
{
// If we've already generated this button, just use our existing html
if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['pinterest'])) {
$array['resource']['pinterest'] = $_GLOBALS['sw']['buttons'][$array['postID']]['pinterest'];
// If not, let's check if Facebook is activated and create the button HTML
} elseif ($array['options']['newOrderOfIcons']['pinterest'] && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['pinterest'])) {
$array['totes'] += $array['shares']['pinterest'];
++$array['count'];
$pi = get_post_meta($array['postID'], 'nc_pinterestImage', true);
// Pinterest Username
$pinterest_username = $array['options']['pinterestID'];
if (isset($pinterest_username) && $pinterest_username != '') {
$pu = ' via @' . str_replace('@', '', $pinterest_username);
} else {
$pu = '';
}
if (swp_is_cache_fresh($array['postID']) == false) {
// Check if an image ID has been provided
$array['imageID'] = get_post_meta($array['postID'], 'nc_pinterestImage', true);
if ($array['imageID']) {
$array['imageURL'] = wp_get_attachment_url($array['imageID']);
delete_post_meta($array['postID'], 'swp_pinterest_image_url');
update_post_meta($array['postID'], 'swp_pinterest_image_url', $array['imageURL']);
// else:
// $array['imageURL'] = wp_get_attachment_url( get_post_thumbnail_id( $array['postID'] ) );
// delete_post_meta($array['postID'],'swp_pinterest_image_url');
}
} else {
// Check if we have a cached Open Graph Image URL
$array['imageURL'] = get_post_meta($array['postID'], 'swp_pinterest_image_url', true);
// If not, let's check to see if we have an ID to generate one
if (!$array['imageURL']) {
// Check for an Open Graph Image ID
$array['imageID'] = get_post_meta($array['postID'], 'nc_pinterestImage', true);
if ($array['imageID']) {
// If we find one, let's convert it to a link and cache it for next time
$array['imageURL'] = wp_get_attachment_url($array['imageID']);
delete_post_meta($array['postID'], 'swp_pinterest_image_url');
update_post_meta($array['postID'], 'swp_pinterest_image_url', $array['imageURL']);
} else {
// If we don't find one, let's see if we can use a post thumbnail
$array['imageURL'] = wp_get_attachment_url(get_post_thumbnail_id($array['postID']));
}
}
}
$pd = get_post_meta($array['postID'], 'nc_pinterestDescription', true);
if ($array['imageURL']) {
$pi = '&media=' . urlencode(html_entity_decode($array['imageURL'], ENT_COMPAT, 'UTF-8'));
} else {
$pi = '';
}
$pinterestLink = $array['url'];
$title = strip_tags(get_the_title($array['postID']));
$title = str_replace('|', '', $title);
if ($pi != '' && is_swp_registered()) {
$a = '<a data-link="https://pinterest.com/pin/create/button/?url=' . $pinterestLink . '' . $pi . '&description=' . ($pd != '' ? urlencode(html_entity_decode($pd . $pu, ENT_COMPAT, 'UTF-8')) : urlencode(html_entity_decode($title . $pu, ENT_COMPAT, 'UTF-8'))) . '" class="nc_tweet" data-count="0">';
} else {
$a = '<a onClick="var e=document.createElement(\'script\');e.setAttribute(\'type\',\'text/javascript\');e.setAttribute(\'charset\',\'UTF-8\');e.setAttribute(\'src\',\'//assets.pinterest.com/js/pinmarklet.js?r=\'+Math.random()*99999999);document.body.appendChild(e);" class="nc_tweet noPop">';
}
$array['resource']['pinterest'] = '<div class="nc_tweetContainer nc_pinterest" data-id="' . $array['count'] . '" data-network="pinterest">';
$array['resource']['pinterest'] .= $a;
if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['pinterest'] > 0) {
$array['resource']['pinterest'] .= '<span class="iconFiller">';
$array['resource']['pinterest'] .= '<span class="spaceManWilly" style="width:55px;">';
$array['resource']['pinterest'] .= '<i class="sw sw-pinterest"></i>';
$array['resource']['pinterest'] .= '<span class="swp_share"> ' . __('Pin', 'social-warfare') . '</span>';
$array['resource']['pinterest'] .= '</span></span>';
$array['resource']['pinterest'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['pinterest']) . '</span>';
} else {
$array['resource']['pinterest'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly" style="width:55px;"><i class="sw sw-pinterest"></i><span class="swp_share"> ' . __('Pin', 'social-warfare') . '</span></span></span></span>';
}
$array['resource']['pinterest'] .= '</a>';
$array['resource']['pinterest'] .= '</div>';
// Store these buttons so that we don't have to generate them for each set
$_GLOBALS['sw']['buttons'][$array['postID']]['pinterest'] = $array['resource']['pinterest'];
}
return $array;
}
示例10: widget
/**
* FUNCTION - OUTPUT THE WIDGET TO THE SITE
*/
function widget($args, $instance)
{
extract($args);
isset($instance['title']) ? $title = $instance['title'] : ($title = 'Popular Posts');
isset($instance['count']) ? $count = $instance['count'] : ($count = '10');
isset($instance['timeframe']) ? $timeframe = $instance['timeframe'] : ($timeframe = '0');
isset($instance['network']) ? $network = $instance['network'] : ($network = 'totes');
isset($instance['showCount']) ? $showCount = $instance['showCount'] : ($showCount = 'true');
isset($instance['countLabel']) ? $countLabel = $instance['countLabel'] : ($countLabel = 'Total Shares');
isset($instance['style']) ? $style = $instance['style'] : ($style = 'style_01');
isset($instance['thumbnails']) ? $thumbnails = $instance['thumbnails'] : ($thumbnails = 'true');
isset($instance['thumb_size']) ? $thumb_size = $instance['thumb_size'] : ($thumb_size = '100');
isset($instance['font_size']) ? $font_size = $instance['font_size'] : ($font_size = '100');
isset($instance['custom_bg']) ? $custom_bg = $instance['custom_bg'] : ($custom_bg = '#ffffff');
isset($instance['custom_link']) ? $custom_link = $instance['custom_link'] : ($custom_link = '#000000');
// Correct the previous style with the new version if it is present on the site
if ($style == 'first_style' || $style == 'second_style') {
$style = 'style_01';
}
/**
* STYLES - CREATE AN ARRAY OF BACKGROUNDS AND LINK COLORS
*/
// Vanilla (No Styling)
$styles['style_01']['wrapper'] = 'background:transparent;';
$styles['style_01']['links'] = '';
// Inspired by Twitter
$styles['style_02']['wrapper'] = 'padding:15px;background:#429cd6;';
$styles['style_02']['links'] = 'color:#ffffff;';
// Inspired by Facebook
$styles['style_03']['wrapper'] = 'padding:15px;background:#3a589e;';
$styles['style_03']['links'] = 'color:#ffffff;';
// Inspired by Google Plus
$styles['style_04']['wrapper'] = 'padding:15px;background:#df4b37;';
$styles['style_04']['links'] = 'color:#ffffff;';
// Inspired by LinkedIn
$styles['style_05']['wrapper'] = 'padding:15px;background:#0d77b7;';
$styles['style_05']['links'] = 'color:#ffffff;';
// Inspired by Pinterest
$styles['style_06']['wrapper'] = 'padding:15px;background:#cd2029;';
$styles['style_06']['links'] = 'color:#ffffff;';
// Don't Stop Believin'
$styles['style_07']['wrapper'] = 'padding:15px;background:#333333;';
$styles['style_07']['links'] = 'color:#ffffff;';
// Thunderstruck
$styles['style_08']['wrapper'] = 'padding:15px;background:#30394F;';
$styles['style_08']['links'] = 'color:#ffffff;';
// Livin' On A Prayer
$styles['style_09']['wrapper'] = 'padding:15px;background:#EEEEEE;';
$styles['style_09']['links'] = 'color:#30394F;';
// Custom
$styles['custom']['wrapper'] = 'padding:15px;background:' . $custom_bg . ';';
$styles['custom']['links'] = 'color:' . $custom_link . ';';
/**
* BUILD OUT THE WIDGET
*/
// Begin output of the widget html
echo $before_widget;
echo '<div class="widget-text swp_widget_box" style="' . $styles[$style]['wrapper'] . '">';
// Check if title is set
if ($title) {
echo '<h3 class="widgettitle widget-title" style="' . $styles[$style]['links'] . '">' . $title . '</h3>';
}
// If a custom timeframe is not being used....
if ($timeframe == 0) {
// Create the arguments for a query without a timeframe
$swp_args = array('posts_per_page' => $count, 'post_type' => 'post', 'meta_key' => '_' . $network, 'orderby' => 'meta_value_num', 'order' => 'DESC');
// If a custom timeframe is being used....
} else {
// Create the arguments for a query with a timeframe
$swp_args = array('posts_per_page' => $count, 'post_type' => 'post', 'meta_key' => '_' . $network, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'date_query' => array('column' => 'post_date', 'after' => '- ' . $timeframe . ' days'));
}
// Reset the main query
wp_reset_postdata();
// Query and fetch the posts
$swq = new WP_Query($swp_args);
// Begin the loop
if ($swq->have_posts()) {
$i = 1;
while ($swq->have_posts()) {
if ($i <= $count) {
$swq->the_post();
// If we are supposed to show count numbers....
if ($showCount == 'true') {
$postID = get_the_ID();
$shares = get_post_meta($postID, '_' . $network, true);
$share_html = '<span class="swp_pop_count">' . swp_kilomega($shares) . ' ' . $countLabel . '</span>';
// If we are not supposed to show count numbers
} else {
$share_html = '';
}
// If we are supposed to show thumbnails
if ($thumbnails == 'true' && has_post_thumbnail()) {
$thumbnail_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');
$thumbnail_html = '';
$thumbnail_html .= '<a href="' . get_the_permalink() . '">';
$thumbnail_html .= '<img style="width:' . $thumb_size . 'px;height:' . $thumb_size . 'px;" class="swp_pop_thumb" src="' . $thumbnail_url[0] . '" title="' . str_replace('"', '\'', get_the_title()) . '" alt="' . str_replace('"', '\'', get_the_title()) . '">';
$thumbnail_html .= '</a>';
//.........这里部分代码省略.........
示例11: swp_sitewide_shares_function
function swp_sitewide_shares_function($atts)
{
global $wpdb;
$sum = $wpdb->get_results("SELECT SUM(meta_value) AS total FROM {$wpdb->postmeta} WHERE meta_key = '_totes'");
return swp_kilomega($sum[0]->total);
}
示例12: swp_whatsapp_button_html
function swp_whatsapp_button_html($array)
{
// If we've already generated this button, just use our existing html
if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['whatsapp'])) {
$array['resource']['whatsapp'] = $_GLOBALS['sw']['buttons'][$array['postID']]['whatsapp'];
// If not, let's check if WhatsApp is activated and create the button HTML
} elseif (isset($array['options']['newOrderOfIcons']['whatsapp']) && swp_mobile_detection() && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['whatsapp'])) {
$array['totes'] += $array['shares']['whatsapp'];
++$array['count'];
$array['resource']['whatsapp'] = '<div class="nc_tweetContainer swp_whatsapp" data-id="' . $array['count'] . '" data-network="whatsapp">';
$link = urlencode(urldecode(swp_process_url($array['url'], 'whatsapp', $array['postID'])));
$array['resource']['whatsapp'] .= '<a target="_blank" href="whatsapp://send?text=' . $link . '" class="nc_tweet" data-action="share/whatsapp/share">';
if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['whatsapp'] > 0) {
$array['resource']['whatsapp'] .= '<span class="iconFiller">';
$array['resource']['whatsapp'] .= '<span class="spaceManWilly">';
$array['resource']['whatsapp'] .= '<i class="sw sw-whatsapp"></i>';
$array['resource']['whatsapp'] .= '<span class="swp_share"> ' . __('WhatsApp', 'social-warfare') . '</span>';
$array['resource']['whatsapp'] .= '</span></span>';
$array['resource']['whatsapp'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['whatsapp']) . '</span>';
} else {
$array['resource']['whatsapp'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-whatsapp"></i><span class="swp_share"> ' . __('WhatsApp', 'social-warfare') . '</span></span></span></span>';
}
$array['resource']['whatsapp'] .= '</a>';
$array['resource']['whatsapp'] .= '</div>';
// Store these buttons so that we don't have to generate them for each set
$_GLOBALS['sw']['buttons'][$array['postID']]['whatsapp'] = $array['resource']['whatsapp'];
}
return $array;
}