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() ):
$user_id = isset($_USER_ID) ? $_USER_ID : get_the_posts_author_id();
// 各SNSのデータを定義(URL生成ロジックもここで完結)
$follow_networks = [
'website' => [ 'visible' => !!get_the_author_website_url($user_id), 'url' => get_the_author_website_url($user_id), 'class' => 'website-button website-follow-button-sq', 'icon' => 'icon-home-logo', 'title' => __( '著者サイト', THEME_NAME ), 'aria' => __( '著作サイトをチェック', THEME_NAME ) ],
'twitter' => [ 'visible' => !!get_the_author_twitter_url($user_id), 'url' => get_the_author_twitter_url($user_id), 'class' => 'twitter-button twitter-follow-button-sq x-corp-button x-corp-follow-button-sq', 'icon' => 'icon-x-corp-logo', 'title' => __( 'Xをフォロー', THEME_NAME ), 'aria' => __( 'Xをフォロー', THEME_NAME ) ],
'mastodon' => [ 'visible' => !!get_the_author_mastodon_url($user_id), 'url' => get_the_author_mastodon_url($user_id), 'class' => 'mastodon-button mastodon-follow-button-sq', 'icon' => 'icon-mastodon-logo', 'title' => __( 'Mastodonをフォロー', THEME_NAME ), 'aria' => __( 'Mastodonをフォロー', THEME_NAME ) ],
'bluesky' => [ 'visible' => !!get_the_author_bluesky_url($user_id), 'url' => get_the_author_bluesky_url($user_id), 'class' => 'bluesky-button bluesky-follow-button-sq', 'icon' => 'icon-bluesky-logo', 'title' => __( 'Blueskyをフォロー', THEME_NAME ), 'aria' => __( 'Blueskyをフォロー', THEME_NAME ) ],
'misskey' => [ 'visible' => !!get_the_author_misskey_url($user_id), 'url' => get_the_author_misskey_url($user_id), 'class' => 'misskey-button misskey-follow-button-sq', 'icon' => 'icon-misskey-logo', 'title' => __( 'Misskeyをフォロー', THEME_NAME ), 'aria' => __( 'Misskeyをフォロー', THEME_NAME ) ],
'facebook' => [ 'visible' => !!get_the_author_facebook_url($user_id), 'url' => get_the_author_facebook_url($user_id), 'class' => 'facebook-button facebook-follow-button-sq', 'icon' => 'icon-facebook-logo', 'title' => __( 'Facebookをフォロー', THEME_NAME ), 'aria' => __( 'Facebookをフォロー', THEME_NAME ) ],
'threads' => [ 'visible' => !!get_the_author_threads_url($user_id), 'url' => get_the_author_threads_url($user_id), 'class' => 'threads-button threads-follow-button-sq', 'icon' => 'icon-threads-logo', 'title' => __( 'Threadsをフォロー', THEME_NAME ), 'aria' => __( 'Threadsをフォロー', THEME_NAME ) ],
'hatebu' => [ 'visible' => !!get_the_author_hatebu_url($user_id), 'url' => get_the_author_hatebu_url($user_id), 'class' => 'hatebu-button hatebu-follow-button-sq', 'icon' => 'icon-hatebu-logo', 'title' => __( 'はてブをフォロー', THEME_NAME ), 'aria' => __( 'はてブをフォロー', THEME_NAME ) ],
'instagram' => [ 'visible' => !!get_the_author_instagram_url($user_id), 'url' => get_the_author_instagram_url($user_id), 'class' => 'instagram-button instagram-follow-button-sq', 'icon' => 'icon-instagram-logo', 'title' => __( 'Instagramをフォロー', THEME_NAME ), 'aria' => __( 'Instagramをフォロー', THEME_NAME ) ],
'youtube' => [ 'visible' => !!get_the_author_youtube_url($user_id), 'url' => get_the_author_youtube_url($user_id), 'class' => 'youtube-button youtube-follow-button-sq', 'icon' => 'icon-youtube-logo', 'title' => __( 'YouTubeをフォロー', THEME_NAME ), 'aria' => __( 'YouTubeをフォロー', THEME_NAME ) ],
'tiktok' => [ 'visible' => !!get_the_author_tiktok_url($user_id), 'url' => get_the_author_tiktok_url($user_id), 'class' => 'tiktok-button tiktok-follow-button-sq', 'icon' => 'icon-tiktok-logo', 'title' => __( 'TikTokをフォロー', THEME_NAME ), 'aria' => __( 'TikTokをフォロー', THEME_NAME ) ],
'linkedin' => [ 'visible' => !!get_the_author_linkedin_url($user_id), 'url' => get_the_author_linkedin_url($user_id), 'class' => 'linkedin-button linkedin-follow-button-sq', 'icon' => 'icon-linkedin-logo', 'title' => __( 'LinkedInをフォロー', THEME_NAME ), 'aria' => __( 'LinkedInをフォロー', THEME_NAME ) ],
'note' => [ 'visible' => !!get_the_author_note_url($user_id), 'url' => get_the_author_note_url($user_id), 'class' => 'note-button note-follow-button-sq', 'icon' => 'icon-note-logo', 'title' => __( 'noteをフォロー', THEME_NAME ), 'aria' => __( 'noteをフォロー', THEME_NAME ) ],
'pinterest' => [ 'visible' => !!get_the_author_pinterest_url($user_id), 'url' => get_the_author_pinterest_url($user_id), 'class' => 'pinterest-button pinterest-follow-button-sq', 'icon' => 'icon-pinterest-logo', 'title' => __( 'Pinterestをフォロー', THEME_NAME ), 'aria' => __( 'Pinterestをフォロー', THEME_NAME ) ],
'line' => [ 'visible' => !!get_the_author_line_at_url($user_id), 'url' => get_the_author_line_at_url($user_id), 'class' => 'line-button line-follow-button-sq', 'icon' => 'icon-line-logo', 'title' => __( 'LINE@をフォロー', THEME_NAME ), 'aria' => __( 'LINE@をフォロー', THEME_NAME ) ],
'amazon' => [ 'visible' => !!get_the_author_amazon_url($user_id), 'url' => get_the_author_amazon_url($user_id), 'class' => 'amazon-button amazon-follow-button-sq', 'icon' => 'icon-amazon-logo', 'title' => __( 'Amazon欲しい物リスト', THEME_NAME ), 'aria' => __( 'Amazonほしい物リストをチェック', THEME_NAME ) ],
'github' => [ 'visible' => !!get_the_author_github_url($user_id), 'url' => get_the_author_github_url($user_id), 'class' => 'github-button github-follow-button-sq', 'icon' => 'icon-github-logo', 'title' => __( 'GitHubをフォロー', THEME_NAME ), 'aria' => __( 'GitHubをフォロー', THEME_NAME ) ],
'feedly' => [ 'visible' => is_feedly_follow_button_visible(), 'url' => '//feedly.com/i/discover/sources/search/feed/'.urlencode(get_site_url()), 'class' => 'feedly-button feedly-follow-button-sq', 'icon' => 'icon-feedly-logo', 'title' => __( 'feedlyで更新情報を購読', THEME_NAME ), 'aria' => __( 'feedlyで更新情報を購読', THEME_NAME ), 'count' => get_feedly_count() ],
'rss' => [ 'visible' => is_rss_follow_button_visible(), 'url' => get_bloginfo('rss2_url'), 'class' => 'rss-button rss-follow-button-sq', 'icon' => 'icon-rss-logo', 'title' => __( 'RSSで更新情報を購読', THEME_NAME ), 'aria' => __( 'RSSで更新情報を購読', THEME_NAME ) ],
];
?>
<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 foreach ( $follow_networks as $key => $sns ): ?>
<?php if ( $sns['visible'] ): ?>
<a href="<?php echo esc_url($sns['url']); ?>"
class="sns-button follow-button <?php echo esc_attr($sns['class']); ?>"
target="_blank"
title="<?php echo esc_attr($sns['title']); ?>"
rel="nofollow noopener noreferrer"
aria-label="<?php echo esc_attr($sns['aria']); ?>">
<span class="<?php echo esc_attr($sns['icon']); ?>"></span>
<?php if ( isset($sns['count']) ): // feedlyなどのカウント表示用 ?>
<span class="follow-count <?php echo $key; ?>-follow-count"><?php echo $sns['count']; ?></span>
<?php endif; ?>
</a>
<?php endif; ?>
<?php endforeach; ?>
</div><!-- /.sns-follow-buttons -->
</div><!-- /.sns-follow -->
<?php endif; ?>