Merhaba arkadaşlar, bu yazıda wordpress eklentisi Woocommerce e-ticaret altyapısı ile sitenizdeki ürünlere veya blog yazılarınızda eklenti olmadan sosyal paylaşım butonları nasıl eklenir? Bunu göstereceğim.
Öncelikle bu sosyal paylaşım butonlarını görmek için woocommerce eklentisinin kurulu gerekiyor. Daha sonra WordPress admin panelinde görünüm sekmesinin altında tema düzenleyici tıklıyoruz. Karşımıza bir düzenleme ekranı çıkıyor. Bu düzenleme ekranın sağ tarafında tema işlevleri yani function.php dosyasını açıyoruz ve aşağıdaki kodları sırasıyla yazıyoruz.
insta_link_pasif
adında bir fonksiyon oluşturalım. Bu fonksiyon instagram checkbox tıklandığında altına text alanı açmak için kullanıyoruz.
function insta_link_pasif(){
$social_instagram = get_theme_mod( 'social_instagram_s');
if( empty( $social_instagram['insta_aktif'] ) ) {
return false;
}
return true;
}
Asıl işlemler burada başlıyor WordPress’in özelleştirme sayfasına yeni alan ekliyoruz.
add_action
ile özelleştirme alanında tanımlanacak fonksiyonu burada oluşturacağız.
add_action( 'customize_register', 'customizer_sosyal' );
// customizer_sosyal adlı fonksiyonumuz
function customizer_sosyal ( $wp_customize ) {
//
}
Fonksiyonumuzun içine özel bölme oluşturuyoruz ki bütün sosyal paylaşım checkboxları içinde olsun.
//özel bölme ekliyoruz
$wp_customize->add_section(
'admin_social', // önemli olan nokta burası [section id]
array(
'title' => 'Sosyal Paylaşım',
'description' => 'Sosyal Paylaşım',
'priority' => 0,
)
);
Bölme ekledikten sonra bu bölmelerin içine sosyal medya paylaşım checkbox ekleyeceğiz.
//facebook
$wp_customize->add_setting( 'social_facebook_s',
array(
'default' => false, // varsayılanı ayarlama fal
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'theme_social_facebook_s',
array(
'label' => 'Facebook',
'section' => 'admin_social', //[section id]
'settings' => 'social_facebook_s',
'type' => 'checkbox',
)
);
//Twitter
$wp_customize->add_setting( 'social_twitter_s',
array(
'default' => false,
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'theme_social_twitter_s',
array(
'label' => 'Twitter',
'section' => 'admin_social',
'settings' => 'social_twitter_s',
'type' => 'checkbox',
)
);
//Telegram
$wp_customize->add_setting( 'social_telegram_s',
array(
'default' => false,
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'theme_social_telegram_s',
array(
'label' => 'Telegram',
'section' => 'admin_social',
'settings' => 'social_telegram_s',
'type' => 'checkbox',
)
);
//Tumblr
$wp_customize->add_setting( 'social_tumblr_s',
array(
'default' => false,
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'theme_social_tumblr_s',
array(
'label' => 'Tumblr',
'section' => 'admin_social',
'settings' => 'social_tumblr_s',
'type' => 'checkbox',
)
);
//Pinterest
$wp_customize->add_setting( 'social_pinterest_s',
array(
'default' => false,
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'theme_social_pinterest_s',
array(
'label' => 'Pinterest',
'section' => 'admin_social',
'settings' => 'social_pinterest_s',
'type' => 'checkbox',
)
);
//E-posta
$wp_customize->add_setting( 'social_mail_s',
array(
'default' => false,
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'theme_social_mail_s',
array(
'label' => 'E-posta',
'section' => 'admin_social',
'settings' => 'social_mail_s',
'type' => 'checkbox',
)
);
//Whatsapp
$wp_customize->add_setting( 'social_whatsapp_s',
array(
'default' => false,
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'theme_social_whatsapp_s',
array(
'label' => 'Whatsapp',
'section' => 'admin_social',
'settings' => 'social_whatsapp_s',
'type' => 'checkbox',
)
);
//Linkedin
$wp_customize->add_setting( 'social_linkedin_s',
array(
'default' => false,
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'theme_social_linkedin_s',
array(
'label' => 'Linkedin',
'section' => 'admin_social',
'settings' => 'social_linkedin_s',
'type' => 'checkbox',
)
);
Sosyal paylaşım butonları için checkbox ekledik fakat sadece instagram için eklemedik. Çünkü instgram’ı paylaşım olarak değil de direkt instagram hesabına yönlendirmek için checkbox tıklandığında altına bir text alanı açılacak şekilde yapmak daha doğru olacaktır. Daha doğrusu farklı bir örnek göstermek için bunu kullanacağız.
/instagrma/
$wp_customize->add_setting( 'social_instagram_s[insta_aktif]',
array(
'default' => false,
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'insta_aktif',
array(
'label' => 'İnstagram',
'section' => 'admin_social',
'settings' => 'social_instagram_s[insta_aktif]',
'type' => 'checkbox',
)
);
//instagram checkbox tıklandığında açılacak olan metin kutusu
$wp_customize->add_setting( 'social_instagram_s[insta_link]',
array(
'default' => 'https://instagram.com/',
'capability' => 'edit_theme_options',
)
);
$wp_customize->add_control(
'insta_link',
array(
'label' => 'instagram Linki',
'description' => 'Bu bir paylaşım butonu değildir',
'section' => 'admin_social',
'settings' => 'social_instagram_s[insta_link]',
'type' => 'text',
'active_callback' => 'insta_link_pasif',
)
);
function get_the_post_thumbnail_src($img){
return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : '';
}
Daha Sonra sosyal paylaşım butonlarını ekleyeceğimiz fonksiyonu oluşturyoruz.
function social_share_add() {
$url = urlencode(get_the_permalink());
$title = urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8'));
$media = urlencode(get_the_post_thumbnail_url(get_the_ID(), 'full'));
$facebookcheck = get_theme_mod('social_facebook_s');
$twittercheck = get_theme_mod('social_twitter_s');
$tumblrcheck = get_theme_mod('social_tumblr_s');
$pinterestcheck = get_theme_mod('social_pinterest_s');
$telegramcheck = get_theme_mod('social_telegram_s');
$whatsappcheck = get_theme_mod('social_whatsapp_s');
$mailcheck = get_theme_mod('social_mail_s');
$linkedincheck = get_theme_mod('social_linkedin_s');
$instagramcheck = get_theme_mod('social_instagram_s');
if($facebookcheck == true){
echo '<!-- Sharingbutton Facebook --> <a class="resp-sharing-button__link" href="https://www.facebook.com/sharer/sharer.php?u='.$url.'&t='.$title.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--facebook resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.77 7.46H14.5v-1.9c0-.9.6-1.1 1-1.1h3V.5h-4.33C10.24.5 9.5 3.44 9.5 5.32v2.15h-3v4h3v12h5v-12h3.85l.42-4z"/></svg> </div> </div> </a> ';
}
if($twittercheck == true){
echo '<!-- Sharingbutton Twitter --> <a class="resp-sharing-button__link" href="https://twitter.com/intent/tweet?text='.$title.'&amp;url='.$url.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--twitter resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M23.44 4.83c-.8.37-1.5.38-2.22.02.93-.56.98-.96 1.32-2.02-.88.52-1.86.9-2.9 1.1-.82-.88-2-1.43-3.3-1.43-2.5 0-4.55 2.04-4.55 4.54 0 .36.03.7.1 1.04-3.77-.2-7.12-2-9.36-4.75-.4.67-.6 1.45-.6 2.3 0 1.56.8 2.95 2 3.77-.74-.03-1.44-.23-2.05-.57v.06c0 2.2 1.56 4.03 3.64 4.44-.67.2-1.37.2-2.06.08.58 1.8 2.26 3.12 4.25 3.16C5.78 18.1 3.37 18.74 1 18.46c2 1.3 4.4 2.04 6.97 2.04 8.35 0 12.92-6.92 12.92-12.93 0-.2 0-.4-.02-.6.9-.63 1.96-1.22 2.56-2.14z"/></svg> </div> </div> </a> ';
}
if($tumblrcheck == true){
echo '<!-- Sharingbutton Tumblr --> <a class="resp-sharing-button__link" href="https://www.tumblr.com/widgets/share/tool?posttype=link&amp;title='.$title.'&amp;caption='.$title.'&amp;content='.$url.'&amp;canonicalUrl='.$url.'&amp;shareSource=tumblr_share_button" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--tumblr resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13.5.5v5h5v4h-5V15c0 5 3.5 4.4 6 2.8v4.4c-6.7 3.2-12 0-12-4.2V9.5h-3V6.7c1-.3 2.2-.7 3-1.3.5-.5 1-1.2 1.4-2 .3-.7.6-1.7.7-3h3.8z"/></svg> </div> </div> </a> ';
}
if($pinterestcheck == true){
echo '<!-- Sharingbutton Pinterest --> <a class="resp-sharing-button__link" href="http://pinterest.com/pin/create/button/?url='.$url.'&amp;media='.$media.'&amp;description='.$title.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--pinterest resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12.14.5C5.86.5 2.7 5 2.7 8.75c0 2.27.86 4.3 2.7 5.05.3.12.57 0 .66-.33l.27-1.06c.1-.32.06-.44-.2-.73-.52-.62-.86-1.44-.86-2.6 0-3.33 2.5-6.32 6.5-6.32 3.55 0 5.5 2.17 5.5 5.07 0 3.8-1.7 7.02-4.2 7.02-1.37 0-2.4-1.14-2.07-2.54.4-1.68 1.16-3.48 1.16-4.7 0-1.07-.58-1.98-1.78-1.98-1.4 0-2.55 1.47-2.55 3.42 0 1.25.43 2.1.43 2.1l-1.7 7.2c-.5 2.13-.08 4.75-.04 5 .02.17.22.2.3.1.14-.18 1.82-2.26 2.4-4.33.16-.58.93-3.63.93-3.63.45.88 1.8 1.65 3.22 1.65 4.25 0 7.13-3.87 7.13-9.05C20.5 4.15 17.18.5 12.14.5z"/></svg> </div> </div> </a> ';
}
if($telegramcheck == true){
echo '<!-- Sharingbutton Telegram --> <a class="resp-sharing-button__link" href="https://telegram.me/share/url?text='.$title.'&amp;url='.$url.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--telegram resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M.707 8.475C.275 8.64 0 9.508 0 9.508s.284.867.718 1.03l5.09 1.897 1.986 6.38a1.102 1.102 0 0 0 1.75.527l2.96-2.41a.405.405 0 0 1 .494-.013l5.34 3.87a1.1 1.1 0 0 0 1.046.135 1.1 1.1 0 0 0 .682-.803l3.91-18.795A1.102 1.102 0 0 0 22.5.075L.706 8.475z"/></svg> </div> </div> </a> ';
}
if($whatsappcheck == true){
echo '<!-- Sharingbutton WhatsApp --> <a class="resp-sharing-button__link" href="whatsapp://send?text='.$title.'%20'.$url.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--whatsapp resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.1 3.9C17.9 1.7 15 .5 12 .5 5.8.5.7 5.6.7 11.9c0 2 .5 3.9 1.5 5.6L.6 23.4l6-1.6c1.6.9 3.5 1.3 5.4 1.3 6.3 0 11.4-5.1 11.4-11.4-.1-2.8-1.2-5.7-3.3-7.8zM12 21.4c-1.7 0-3.3-.5-4.8-1.3l-.4-.2-3.5 1 1-3.4L4 17c-1-1.5-1.4-3.2-1.4-5.1 0-5.2 4.2-9.4 9.4-9.4 2.5 0 4.9 1 6.7 2.8 1.8 1.8 2.8 4.2 2.8 6.7-.1 5.2-4.3 9.4-9.5 9.4zm5.1-7.1c-.3-.1-1.7-.9-1.9-1-.3-.1-.5-.1-.7.1-.2.3-.8 1-.9 1.1-.2.2-.3.2-.6.1s-1.2-.5-2.3-1.4c-.9-.8-1.4-1.7-1.6-2-.2-.3 0-.5.1-.6s.3-.3.4-.5c.2-.1.3-.3.4-.5.1-.2 0-.4 0-.5C10 9 9.3 7.6 9 7c-.1-.4-.4-.3-.5-.3h-.6s-.4.1-.7.3c-.3.3-1 1-1 2.4s1 2.8 1.1 3c.1.2 2 3.1 4.9 4.3.7.3 1.2.5 1.6.6.7.2 1.3.2 1.8.1.6-.1 1.7-.7 1.9-1.3.2-.7.2-1.2.2-1.3-.1-.3-.3-.4-.6-.5z"/></svg> </div> </div> </a> ';
}
if($mailcheck == true){
echo '<!-- Sharingbutton E-Mail --> <a class="resp-sharing-button__link" href="mailto:?subject='.$title.'&amp;body='.$url.'" target="_self" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--email resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 4H2C.9 4 0 4.9 0 6v12c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM7.25 14.43l-3.5 2c-.08.05-.17.07-.25.07-.17 0-.34-.1-.43-.25-.14-.24-.06-.55.18-.68l3.5-2c.24-.14.55-.06.68.18.14.24.06.55-.18.68zm4.75.07c-.1 0-.2-.03-.27-.08l-8.5-5.5c-.23-.15-.3-.46-.15-.7.15-.22.46-.3.7-.14L12 13.4l8.23-5.32c.23-.15.54-.08.7.15.14.23.07.54-.16.7l-8.5 5.5c-.08.04-.17.07-.27.07zm8.93 1.75c-.1.16-.26.25-.43.25-.08 0-.17-.02-.25-.07l-3.5-2c-.24-.13-.32-.44-.18-.68s.44-.32.68-.18l3.5 2c.24.13.32.44.18.68z"/></svg> </div> </div> </a> ';
}
if($linkedincheck == true){
echo '<!-- Sharingbutton LinkedIn --> <a class="resp-sharing-button__link" href="https://www.linkedin.com/shareArticle?mini=true&amp;url='.$url.'&amp;'.$title.'=kahve&amp;summary=kahve&amp;source=link" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--linkedin resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.5 21.5h-5v-13h5v13zM4 6.5C2.5 6.5 1.5 5.3 1.5 4s1-2.4 2.5-2.4c1.6 0 2.5 1 2.6 2.5 0 1.4-1 2.5-2.6 2.5zm11.5 6c-1 0-2 1-2 2v7h-5v-13h5V10s1.6-1.5 4-1.5c3 0 5 2.2 5 6.3v6.7h-5v-7c0-1-1-2-2-2z"/></svg> </div> </div> </a> ';
}
if($instagramcheck['insta_aktif'] == true){
$insta_get= get_theme_mod('social_instagram_s');
echo ' <!-- Sharingbutton instagram --> <a class="resp-sharing-button__link" href="'.$insta_get['insta_link'].'" target="_self" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--instagram resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1.1em" height="1.1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 20 20"><path d="M12.7 10c0-1.5-1.2-2.7-2.7-2.7S7.3 8.5 7.3 10s1.2 2.7 2.7 2.7c1.5 0 2.7-1.2 2.7-2.7zm1.4 0c0 2.3-1.8 4.1-4.1 4.1S5.9 12.3 5.9 10S7.7 5.9 10 5.9s4.1 1.8 4.1 4.1zm1.1-4.3c0 .6-.4 1-1 1s-1-.4-1-1s.4-1 1-1s1 .5 1 1zM10 3.4c-1.2 0-3.7-.1-4.7.3c-.7.3-1.3.9-1.5 1.6c-.4 1-.3 3.5-.3 4.7s-.1 3.7.3 4.7c.2.7.8 1.3 1.5 1.5c1 .4 3.6.3 4.7.3s3.7.1 4.7-.3c.7-.3 1.2-.8 1.5-1.5c.4-1.1.3-3.6.3-4.7s.1-3.7-.3-4.7c-.2-.7-.8-1.3-1.5-1.5c-1-.5-3.5-.4-4.7-.4zm8 6.6v3.3c0 1.2-.4 2.4-1.3 3.4c-.9.9-2.1 1.3-3.4 1.3H6.7c-1.2 0-2.4-.4-3.4-1.3c-.8-.9-1.3-2.1-1.3-3.4V10V6.7c0-1.3.5-2.5 1.3-3.4C4.3 2.5 5.5 2 6.7 2h6.6c1.2 0 2.4.4 3.4 1.3c.8.9 1.3 2.1 1.3 3.4V10z" fill="#fff"/></svg> </div> </div> </a> '; } /**/
};
social_share_add
fonksiyonu ekledikten sonra ise add_action();
kodu ile wordpress’te istediğimiz yere ekleyebilirsiniz.
woocommcere ürünlerin altına eklemek için;
add_action( 'woocommerce_single_product_summary', 'social_share_add', 50 );
Yada wordpress postların altına eklemek için ise bütün echo ile yazdırdıklarımızı bir değişkene atıyoruz.
function social_share_post_add() {
$url = urlencode(get_the_permalink());
$title = urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8'));
$media = urlencode(get_the_post_thumbnail_url(get_the_ID(), 'full'));
$facebookcheck = get_theme_mod('social_facebook_s'); $twittercheck = get_theme_mod('social_twitter_s'); $tumblrcheck = get_theme_mod('social_tumblr_s'); $pinterestcheck = get_theme_mod('social_pinterest_s'); $telegramcheck = get_theme_mod('social_telegram_s'); $whatsappcheck = get_theme_mod('social_whatsapp_s'); $mailcheck = get_theme_mod('social_mail_s'); $linkedincheck = get_theme_mod('social_linkedin_s'); $instagramcheck = get_theme_mod('social_instagram_s'); if($facebookcheck == true){ $facebook_sha = ' <!-- Sharingbutton Facebook --> <a class="resp-sharing-button__link" href="https://www.facebook.com/sharer/sharer.php?u='.$url.'&t='.$title.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--facebook resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.77 7.46H14.5v-1.9c0-.9.6-1.1 1-1.1h3V.5h-4.33C10.24.5 9.5 3.44 9.5 5.32v2.15h-3v4h3v12h5v-12h3.85l.42-4z"/></svg> </div> </div> </a> '; } if($twittercheck == true){ $twitter_sha = ' <!-- Sharingbutton Twitter --> <a class="resp-sharing-button__link" href="https://twitter.com/intent/tweet?text='.$title.'&amp;url='.$url.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--twitter resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M23.44 4.83c-.8.37-1.5.38-2.22.02.93-.56.98-.96 1.32-2.02-.88.52-1.86.9-2.9 1.1-.82-.88-2-1.43-3.3-1.43-2.5 0-4.55 2.04-4.55 4.54 0 .36.03.7.1 1.04-3.77-.2-7.12-2-9.36-4.75-.4.67-.6 1.45-.6 2.3 0 1.56.8 2.95 2 3.77-.74-.03-1.44-.23-2.05-.57v.06c0 2.2 1.56 4.03 3.64 4.44-.67.2-1.37.2-2.06.08.58 1.8 2.26 3.12 4.25 3.16C5.78 18.1 3.37 18.74 1 18.46c2 1.3 4.4 2.04 6.97 2.04 8.35 0 12.92-6.92 12.92-12.93 0-.2 0-.4-.02-.6.9-.63 1.96-1.22 2.56-2.14z"/></svg> </div> </div> </a> '; } if($tumblrcheck == true){ $tumblr_sha = ' <!-- Sharingbutton Tumblr --> <a class="resp-sharing-button__link" href="https://www.tumblr.com/widgets/share/tool?posttype=link&amp;title='.$title.'&amp;caption='.$title.'&amp;content='.$url.'&amp;canonicalUrl='.$url.'&amp;shareSource=tumblr_share_button" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--tumblr resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13.5.5v5h5v4h-5V15c0 5 3.5 4.4 6 2.8v4.4c-6.7 3.2-12 0-12-4.2V9.5h-3V6.7c1-.3 2.2-.7 3-1.3.5-.5 1-1.2 1.4-2 .3-.7.6-1.7.7-3h3.8z"/></svg> </div> </div> </a> '; } if($pinterestcheck == true){ $pinterest_sha = ' <!-- Sharingbutton Pinterest --> <a class="resp-sharing-button__link" href="http://pinterest.com/pin/create/button/?url='.$url.'&amp;media='.$media.'&amp;description='.$title.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--pinterest resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12.14.5C5.86.5 2.7 5 2.7 8.75c0 2.27.86 4.3 2.7 5.05.3.12.57 0 .66-.33l.27-1.06c.1-.32.06-.44-.2-.73-.52-.62-.86-1.44-.86-2.6 0-3.33 2.5-6.32 6.5-6.32 3.55 0 5.5 2.17 5.5 5.07 0 3.8-1.7 7.02-4.2 7.02-1.37 0-2.4-1.14-2.07-2.54.4-1.68 1.16-3.48 1.16-4.7 0-1.07-.58-1.98-1.78-1.98-1.4 0-2.55 1.47-2.55 3.42 0 1.25.43 2.1.43 2.1l-1.7 7.2c-.5 2.13-.08 4.75-.04 5 .02.17.22.2.3.1.14-.18 1.82-2.26 2.4-4.33.16-.58.93-3.63.93-3.63.45.88 1.8 1.65 3.22 1.65 4.25 0 7.13-3.87 7.13-9.05C20.5 4.15 17.18.5 12.14.5z"/></svg> </div> </div> </a> '; } if($telegramcheck == true){ $telegram_sha = ' <!-- Sharingbutton Telegram --> <a class="resp-sharing-button__link" href="https://telegram.me/share/url?text='.$title.'&amp;url='.$url.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--telegram resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M.707 8.475C.275 8.64 0 9.508 0 9.508s.284.867.718 1.03l5.09 1.897 1.986 6.38a1.102 1.102 0 0 0 1.75.527l2.96-2.41a.405.405 0 0 1 .494-.013l5.34 3.87a1.1 1.1 0 0 0 1.046.135 1.1 1.1 0 0 0 .682-.803l3.91-18.795A1.102 1.102 0 0 0 22.5.075L.706 8.475z"/></svg> </div> </div> </a> '; } if($whatsappcheck == true){ $whatsapp_sha = ' <!-- Sharingbutton WhatsApp --> <a class="resp-sharing-button__link" href="whatsapp://send?text='.$title.'%20'.$url.'" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--whatsapp resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.1 3.9C17.9 1.7 15 .5 12 .5 5.8.5.7 5.6.7 11.9c0 2 .5 3.9 1.5 5.6L.6 23.4l6-1.6c1.6.9 3.5 1.3 5.4 1.3 6.3 0 11.4-5.1 11.4-11.4-.1-2.8-1.2-5.7-3.3-7.8zM12 21.4c-1.7 0-3.3-.5-4.8-1.3l-.4-.2-3.5 1 1-3.4L4 17c-1-1.5-1.4-3.2-1.4-5.1 0-5.2 4.2-9.4 9.4-9.4 2.5 0 4.9 1 6.7 2.8 1.8 1.8 2.8 4.2 2.8 6.7-.1 5.2-4.3 9.4-9.5 9.4zm5.1-7.1c-.3-.1-1.7-.9-1.9-1-.3-.1-.5-.1-.7.1-.2.3-.8 1-.9 1.1-.2.2-.3.2-.6.1s-1.2-.5-2.3-1.4c-.9-.8-1.4-1.7-1.6-2-.2-.3 0-.5.1-.6s.3-.3.4-.5c.2-.1.3-.3.4-.5.1-.2 0-.4 0-.5C10 9 9.3 7.6 9 7c-.1-.4-.4-.3-.5-.3h-.6s-.4.1-.7.3c-.3.3-1 1-1 2.4s1 2.8 1.1 3c.1.2 2 3.1 4.9 4.3.7.3 1.2.5 1.6.6.7.2 1.3.2 1.8.1.6-.1 1.7-.7 1.9-1.3.2-.7.2-1.2.2-1.3-.1-.3-.3-.4-.6-.5z"/></svg> </div> </div> </a> '; } if($mailcheck == true){ $mail_sha = ' <!-- Sharingbutton E-Mail --> <a class="resp-sharing-button__link" href="mailto:?subject='.$title.'&amp;body='.$url.'" target="_self" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--email resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22 4H2C.9 4 0 4.9 0 6v12c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM7.25 14.43l-3.5 2c-.08.05-.17.07-.25.07-.17 0-.34-.1-.43-.25-.14-.24-.06-.55.18-.68l3.5-2c.24-.14.55-.06.68.18.14.24.06.55-.18.68zm4.75.07c-.1 0-.2-.03-.27-.08l-8.5-5.5c-.23-.15-.3-.46-.15-.7.15-.22.46-.3.7-.14L12 13.4l8.23-5.32c.23-.15.54-.08.7.15.14.23.07.54-.16.7l-8.5 5.5c-.08.04-.17.07-.27.07zm8.93 1.75c-.1.16-.26.25-.43.25-.08 0-.17-.02-.25-.07l-3.5-2c-.24-.13-.32-.44-.18-.68s.44-.32.68-.18l3.5 2c.24.13.32.44.18.68z"/></svg> </div> </div> </a> '; } if($linkedincheck == true){ $linkedin_sha = ' <!-- Sharingbutton LinkedIn --> <a class="resp-sharing-button__link" href="https://www.linkedin.com/shareArticle?mini=true&amp;url='.$url.'&amp;'.$title.'=kahve&amp;summary=kahve&amp;source=link" target="_blank" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--linkedin resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.5 21.5h-5v-13h5v13zM4 6.5C2.5 6.5 1.5 5.3 1.5 4s1-2.4 2.5-2.4c1.6 0 2.5 1 2.6 2.5 0 1.4-1 2.5-2.6 2.5zm11.5 6c-1 0-2 1-2 2v7h-5v-13h5V10s1.6-1.5 4-1.5c3 0 5 2.2 5 6.3v6.7h-5v-7c0-1-1-2-2-2z"/></svg> </div> </div> </a> '; } if($instagramcheck['insta_aktif'] == true){ $insta_get= get_theme_mod('social_instagram_s'); $instagram_sha = ' <!-- Sharingbutton instagram --> <a class="resp-sharing-button__link" href="'.$insta_get['insta_link'].'" target="_self" rel="noopener" aria-label=""> <div class="resp-sharing-button resp-sharing-button--instagram resp-sharing-button--small"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1.1em" height="1.1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 20 20"><path d="M12.7 10c0-1.5-1.2-2.7-2.7-2.7S7.3 8.5 7.3 10s1.2 2.7 2.7 2.7c1.5 0 2.7-1.2 2.7-2.7zm1.4 0c0 2.3-1.8 4.1-4.1 4.1S5.9 12.3 5.9 10S7.7 5.9 10 5.9s4.1 1.8 4.1 4.1zm1.1-4.3c0 .6-.4 1-1 1s-1-.4-1-1s.4-1 1-1s1 .5 1 1zM10 3.4c-1.2 0-3.7-.1-4.7.3c-.7.3-1.3.9-1.5 1.6c-.4 1-.3 3.5-.3 4.7s-.1 3.7.3 4.7c.2.7.8 1.3 1.5 1.5c1 .4 3.6.3 4.7.3s3.7.1 4.7-.3c.7-.3 1.2-.8 1.5-1.5c.4-1.1.3-3.6.3-4.7s.1-3.7-.3-4.7c-.2-.7-.8-1.3-1.5-1.5c-1-.5-3.5-.4-4.7-.4zm8 6.6v3.3c0 1.2-.4 2.4-1.3 3.4c-.9.9-2.1 1.3-3.4 1.3H6.7c-1.2 0-2.4-.4-3.4-1.3c-.8-.9-1.3-2.1-1.3-3.4V10V6.7c0-1.3.5-2.5 1.3-3.4C4.3 2.5 5.5 2 6.7 2h6.6c1.2 0 2.4.4 3.4 1.3c.8.9 1.3 2.1 1.3 3.4V10z" fill="#fff"/></svg> </div> </div> </a> '; } $social_sha = $facebook_sha.$twitter_sha.$tumblr_sha.$pinterest_sha.$telegram_sha.$whatsapp_sha.$mail_sha.$linkedin_sha.$instagram_sha; return $social_sha; /**/
};
Oluşturduğumuz postunun sonuna eklemek istersek $content değişkenimiz ile yukarıdaki fonksiyon
function post_share_add( $content ) {
$after_share = social_share_post_add();
if( is_single() ) {
$content .= $after_share;
}
return $content;
}
add_filter( 'the_content', 'post_share_add' );
Paylaştığınız yazı veya sayfa içerisinde istediğiniz herhangi bir yerde sosyal paylaşım butonlarını görüntülemek için kısa kod oluşturulalım.
add_shortcode('social_place', 'social_share_post_add');
Bütün kodlara ulaşmak için: https://drive.google.com/file/d/1LKEWovFrpNPFuldry_9nqtASRiRJDaRD/view?usp=sharing
Unutmayın! Paylaşmak; kazanmanın en hızlı ve kolay yoludur. Bir sonraki blog’ta görüşmek dileğiyle esen kalın.