Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share button updates #2285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions assets/js/modules/social.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ nebula.socialSharing = async function(){
});

nebula.createCookie('shareapi', true); //Set a cookie to speed up future page loads by not loading third-party share buttons.
} else {
jQuery('a.shareapi, .shareapi a, a.nebula-share.shareapi, .nebula-share a.shareapi').addClass('hidden');
jQuery('a.shareapi, .shareapi a, a.nebula-share.shareapi, .nebula-share a.shareapi').removeClass('hidden');
}
}
};
17 changes: 5 additions & 12 deletions assets/scss/partials/_helpers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -213,30 +213,23 @@ body.admin-bar {scroll-padding-top: 32px;} //Account for the admin bar height wh
//Nebula social share buttons
a.nebula-share-btn {display: inline-block; padding: 5px 7px; border-radius: 3px; font-size: rem(12px); line-height: 1; color: #fff !important; text-shadow: 1px 1px rgb(0 0 0 / 25%); margin-right: 5px;
&:last-child {margin-right: 0;}
&::before {font-family: "Font Awesome 5 Brands"; margin-right: 4px; text-shadow: none;}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the encoded before content, the icons do not appear for me:
Screen Shot 2024-04-23 at 10 20 20 AM

Compared to when I add them back (by reverting to previous):
Screen Shot 2024-04-23 at 10 21 41 AM


&.facebook {background: brand(facebook);
&::before {content: "\f09a";}
&:hover {background: darken(brand(facebook), 15%);}
}
&.twitter {background: brand(twitter);
&::before {content: "\f099";}
&.twitter {background: brand(twitter);
&:hover {background: darken(brand(twitter), 15%);}
}
&.linkedin {background: brand(linkedin);
&::before {content: "\f0e1";}
&.linkedin {background: brand(linkedin);
&:hover {background: darken(brand(linkedin), 15%);}
}
&.pinterest{background: brand(pinterest);
&::before {content: "\f0d2";}
&.pinterest{background: brand(pinterest);
&:hover {background: darken(brand(pinterest), 15%);}
}
&.email {background: grey;
&::before {content: "\f0e0"; @include font-awesome("solid");}
&.email {background: grey;
&:hover {background: darken(grey, 15%);}
}
&.shareapi {background: orange;
&::before {content: "\f1e0"; @include font-awesome("solid");}
&.shareapi {background: orange;
&:hover {background: darken(orange, 15%);}
}
}
Expand Down
14 changes: 7 additions & 7 deletions libs/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1044,32 +1044,32 @@ public function share($networks=array('shareapi', 'facebook', 'twitter'), $id=fa
foreach ( $networks as $network ){
//Share API
if ( in_array($network, array('shareapi')) ){
echo '<a class="nebula-share-btn nebula-share shareapi" href="#">' . __('Share', 'nebula') . '</a>';
echo '<a class="nebula-share-btn nebula-share shareapi hidden" href="#" title="Share this post"><i class="fa-solid fa-share-nodes me-1"></i>' . __('Share', 'nebula') . '</a>';
}

//Facebook
if ( in_array($network, array('facebook', 'fb')) ){
echo '<a class="nebula-share-btn facebook" href="http://www.facebook.com/sharer.php?u=' . $encoded_url . '&t=' . $encoded_title . '" target="_blank" rel="noopener">' . __('Share', 'nebula') . '</a>';
echo '<a class="nebula-share-btn facebook" href="http://www.facebook.com/sharer.php?u=' . $encoded_url . '&t=' . $encoded_title . '" target="_blank" rel="noopener" title="Share on Facebook"><i class="fa-brands fa-facebook me-1"></i>' . __('Share', 'nebula') . '</a>';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only note here is lets wrap the titles in translation functions so instead of:
title="Share on Facebook"

use:
title="' . __('Share on Facebook', 'nebula') . '"

}

//Twitter
if ( in_array($network, array('twitter')) ){
echo '<a class="nebula-share-btn twitter" href="https://twitter.com/intent/tweet?text=' . $encoded_title . '&url=' . $encoded_url . '" target="_blank" rel="noopener">' . __('Tweet', 'nebula') . '</a>';
if ( in_array($network, array('twitter', 'x')) ){
echo '<a class="nebula-share-btn twitter" href="https://twitter.com/intent/tweet?text=' . $encoded_title . '&url=' . $encoded_url . '" target="_blank" rel="noopener" title="Share on Twitter"><i class="fa-brands fa-x-twitter me-1"></i></i>' . __('Tweet', 'nebula') . '</a>';
}

//LinkedIn
if ( in_array($network, array('linkedin', 'li')) ){
echo '<a class="nebula-share-btn linkedin" href="http://www.linkedin.com/shareArticle?mini=true&url=' . $encoded_url . '&title=' . $encoded_title . '" target="_blank" rel="noopener">' . __('Share', 'nebula') . '</a>';
echo '<a class="nebula-share-btn linkedin" href="http://www.linkedin.com/shareArticle?mini=true&url=' . $encoded_url . '&title=' . $encoded_title . '" target="_blank" rel="noopener" title="Share on Linkedin"><i class="fa-brands fa-linkedin me-1" aria-hidden="true"></i>' . __('Share', 'nebula') . '</a>';
}

//Pinterest
if ( in_array($network, array('pinterest', 'pin')) ){
echo '<a class="nebula-share-btn pinterest" href="http://pinterest.com/pin/create/button/?url=' . $encoded_url . '" target="_blank" rel="noopener">' . __('Share', 'nebula') . '</a>';
echo '<a class="nebula-share-btn pinterest" href="http://pinterest.com/pin/create/button/?url=' . $encoded_url . '" target="_blank" rel="noopener" title="Share on Pinterest"><i class="fa-brands fa-pinterest me-1" aria-hidden="true"></i>' . __('Share', 'nebula') . '</a>';
}

//Email
if ( in_array($network, array('email')) ){
echo '<a class="nebula-share-btn email" href="mailto:?subject=' . $encoded_title . '&body=' . $encoded_url . '" target="_blank" rel="noopener">' . __('Email', 'nebula') . '</a>';
echo '<a class="nebula-share-btn email" href="mailto:?subject=' . $encoded_title . '&body=' . $encoded_url . '" target="_blank" rel="noopener" title="Share by email"><i class="fa-solid fa-envelope me-1" aria-hidden="true"></i>' . __('Email', 'nebula') . '</a>';
}
}

Expand Down
Loading