Skip to content

Instantly share code, notes, and snippets.

@TanvirAmi
Created November 25, 2022 12:09
Show Gist options
  • Save TanvirAmi/61a4fc1d634ff756819af917c4be9927 to your computer and use it in GitHub Desktop.
Save TanvirAmi/61a4fc1d634ff756819af917c4be9927 to your computer and use it in GitHub Desktop.
<?php
/**
* Partial template for social share buttons on single page.
*
* See: inc/social-share.php for filters and caller.
*/
$props = array_replace([
'active' => [
'facebook', 'twitter', 'pinterest', 'linkedin', 'tumblr', 'email'
],
'style' => '',
], $props);
$services = Bunyad::get('smartmag_social')->share_services();
if (!$props['active']) {
return;
}
$classes = [
'post-share post-share-b',
'spc-social-colors',
(Bunyad::amp() && Bunyad::amp()->active() ? ' all' : ''),
];
// Add BG colors.
if ($props['style'] !== 'b3') {
$social_class = 'spc-social-bg';
}
if ($props['style']) {
$classes[] = 'post-share-' . $props['style'];
}
$large_buttons = Bunyad::options()->single_share_top_large ?: 3;
?>
<div class="<?php echo esc_attr(join(' ', $classes)); ?>">
<?php
$i = 0;
foreach ($props['active'] as $key):
$i++;
$service = $services[$key];
$is_large =
$classes = [
'cf service s-' . $key,
$i <= $large_buttons ? 'service-lg' : 'service-sm'
];
?>
<a href="<?php echo esc_url($service['url']); ?>" class="<?php echo esc_attr(join(' ', $classes)); ?>"
title="<?php echo esc_attr($service['label_full']); ?>" target="_blank" rel="nofollow noopener">
<i class="tsi tsi-<?php echo esc_attr($service['icon']); ?>"></i>
<span class="label"><?php echo esc_html($service['label']); ?></span>
</a>
<?php endforeach; ?>
<a href="javascript:window.print()" title="Print this page" rel="nofollow noopener" class="cf service service-lg">
<span class="label">Print This</span>
</a>
<?php if (count($props['active']) > $large_buttons): ?>
<a href="#" class="show-more" title="<?php esc_attr_e('Show More Social Sharing', 'bunyad'); ?>"><i class="tsi tsi-share"></i></a>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment