Written by Anonymous
<?php //SNSページのフォローボタン
/**
* Cocoon WordPress Theme
* @author: yhira
* @link: https://wp-cocoon.com/
* @license: http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
*/
if ( !defined( 'ABSPATH' ) ) exit; ?>
<?php
if ( is_any_sns_follow_buttons_exist() ):
//呼び出し前にユーザーIDが設定されている場合
$user_id = isset($_USER_ID) ? $_USER_ID : get_the_posts_author_id();
?>
<!-- SNSページ -->
<div class="sns-follow<?php echo get_additional_sns_follow_button_classes($option); ?>">
<?php if ( get_sns_follow_message() ): //フォローメッセージがあるか?>
<div class="sns-follow-message"><?php echo get_sns_follow_display_message(); //フォローメッセージの取得?></div>
<?php endif; ?>
<div class="sns-follow-buttons sns-buttons">
<?php
// WordPress標準のウェブサイトURL(独立して直接取得)
$website_url = get_the_author_meta('url', $user_id);
if ( $website_url ): ?>
<a href="<?php echo esc_url($website_url); ?>" class="sns-button follow-button website-button website-follow-button-sq" target="_blank" title="<?php _e( '著者サイト', THEME_NAME ) ?>" rel="nofollow noopener noreferrer" aria-label="<?php _e( '著作サイトをチェック', THEME_NAME ) ?>"><span class="icon-home-logo"></span></a>
<?php endif; ?>
<?php
// 定意した拡張SNSサービス配列をループ(純粋なカスタムSNSのみ)
$sns_services = get_theme_sns_follow_services_extended();
foreach ( $sns_services as $meta_key => $data ):
// 拡張配列からウェブサイト用のデータを取得可能
$url = get_the_author_meta($meta_key, $user_id);
if ( $url ):
$rel_attr = ($meta_key === 'google_plus_url') ? 'nofollow publisher' : 'nofollow noopener noreferrer';
?>
<a href="<?php echo esc_url($url); ?>"
class="sns-button follow-button <?php echo esc_attr($data['class']); ?>"
target="_blank"
title="<?php echo esc_attr($data['label']); ?>"
rel="<?php echo esc_attr($rel_attr); ?>"
aria-label="<?php echo esc_attr($data['aria']); ?>">
<span class="<?php echo esc_attr($data['icon']); ?>"></span>
</a>
<?php
endif;
endforeach;
?>
<?php if ( is_feedly_follow_button_visible() )://feedlyフォローボタンを表示するか ?>
<a href="//feedly.com/i/discover/sources/search/feed/<?php echo urlencode(get_site_url()); ?>" class="sns-button follow-button feedly-button feedly-follow-button-sq" target="_blank" title="<?php _e( 'feedlyで更新情報を購読', THEME_NAME ) ?>" rel="nofollow noopener noreferrer" aria-label="<?php _e( 'feedlyで更新情報を購読', THEME_NAME ) ?>"><span class="icon-feedly-logo"></span><span class="follow-count feedly-follow-count"><?php echo get_feedly_count(); ?></span></a>
<?php endif; ?>
<?php if ( is_rss_follow_button_visible() )://RSSフォローボタンを表示するか ?>
<a href="<?php bloginfo('rss2_url'); ?>" class="sns-button follow-button rss-button rss-follow-button-sq" target="_blank" title="<?php _e( 'RSSで更新情報を購読', THEME_NAME ) ?>" rel="nofollow noopener noreferrer" aria-label="<?php _e( 'RSSで更新情報を購読', THEME_NAME ) ?>"><span class="icon-rss-logo"></span></a>
<?php endif; ?>
</div><!-- /.sns-follow-buttons -->
</div><!-- /.sns-follow -->
<?php endif; ?>