php 共享按钮没有插件或javascript - 分享
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 共享按钮没有插件或javascript - 分享相关的知识,希望对你有一定的参考价值。
function crunchify_social_sharing_buttons($content) {
global $post;
if( is_single() ){
// Get current page URL
$crunchifyURL = urlencode(get_permalink());
// Get current page title
$crunchifyTitle = htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8');
// $crunchifyTitle = str_replace( ' ', '%20', get_the_title());
// Get Post Thumbnail for pinterest
$crunchifyThumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
// Construct sharing URL without using any script
$twitterURL = 'https://twitter.com/intent/tweet?text='.$crunchifyTitle.'&url='.$crunchifyURL;
$facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$crunchifyURL;
$googleURL = 'https://plus.google.com/share?url='.$crunchifyURL;
//$bufferURL = 'https://bufferapp.com/add?url='.$crunchifyURL.'&text='.$crunchifyTitle;
//$linkedInURL = 'https://www.linkedin.com/shareArticle?mini=true&url='.$crunchifyURL.'&title='.$crunchifyTitle;
$whatsappURL = 'https:wa.me/?text='.$crunchifyTitle . ' ' . $crunchifyURL;
// Based on popular demand added Pinterest too
//$pinterestURL = 'https://pinterest.com/pin/create/button/?url='.$crunchifyURL.'&media='.$crunchifyThumbnail[0].'&description='.$crunchifyTitle;
// Add sharing button at the end of page/page content
//$variable .= '<!-- Implement your own social sharing buttons without any JavaScript loading. No plugin required. Detailed steps here: http://crunchify.me/1VIxAsz -->';
$variable .= '<div class="crunchify-social">';
$variable .= '<h5>Compartilhar</h5><a class="crunchify-link crunchify-twitter" href="'. $twitterURL .'" target="_blank">Twitter</a>';
$variable .= '<a class="crunchify-link crunchify-facebook" href="'.$facebookURL.'" target="_blank">Facebook</a>';
$variable .= '<a class="crunchify-link crunchify-whatsapp" href="'.$whatsappURL.'" target="_blank">WhatsApp</a>';
$variable .= '<a class="crunchify-link crunchify-googleplus" href="'.$googleURL.'" target="_blank">Google+</a>';
//$variable .= '<a class="crunchify-link crunchify-buffer" href="'.$bufferURL.'" target="_blank">Buffer</a>';
//$variable .= '<a class="crunchify-link crunchify-linkedin" href="'.$linkedInURL.'" target="_blank">LinkedIn</a>';
//$variable .= '<a class="crunchify-link crunchify-pinterest" href="'.$pinterestURL.'" data-pin-custom="true" target="_blank">Pin It</a>';
$variable .= '</div>';
return $variable.$content.$variable;
}else{
// if not a post/page then don't include sharing button
return $variable.$content.$variable;
}
};
add_filter( 'the_content', 'crunchify_social_sharing_buttons');
以上是关于php 共享按钮没有插件或javascript - 分享的主要内容,如果未能解决你的问题,请参考以下文章
php 或 javascript 抓取按钮上的下一个数组
原生应用程序中的 HTML5 / JS 社交共享插件或示例?
PHP 自动缩小。有没有?
如何使 PHP 或 JavaScript 生成 HTML 表单
php [将产品与社交共享插件集成]将社交共享插件与WooCommerce集成 - Sharedaddy
php [将产品与社交共享插件集成]将社交共享插件与WooCommerce集成 - Sharedaddy