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

13108-Preview-for-the-social-sharing-buttons #661

Open
wants to merge 1 commit into
base: master
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
6 changes: 3 additions & 3 deletions view/frontend/templates/addthis-js.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
?>
<?php
/**
* @var $block \Magefan\Blog\Block\Social\AddThi
* @var $block \Magefan\Blog\Block\Social\AddThis
* @var $mfSecureRenderer \Magefan\Community\Api\SecureHtmlRendererInterface
*/
?>
<?php $script = "
function mfShareWindowOpen(url, type) {
function mfShareWindowOpen(url, type, image) {
function reverse(s){
return s.split('').reverse().join('');
}
Expand All @@ -24,7 +24,7 @@
u = reverse('" . strrev('https://www.facebook.com/sharer/sharer.php?u=') . "') + url;
break;
case 'pinterest':
u = reverse('" . strrev('https://pinterest.com/pin/create/button/?url=') . "') + url;
u = reverse('" . strrev('https://pinterest.com/pin/create/button/?url=') . "') + url + '&media='+ image;
break;
case 'twitter':
u =reverse('" . strrev('http://twitter.com/share?url=') . "') + url;
Expand Down
3 changes: 2 additions & 1 deletion view/frontend/templates/post/list/item.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<?php
$_post = $block->getPost();
$_postUrl = $block->escapeUrl($_post->getPostUrl());
$_postImage = $_post->getOgImage()? $_post->getOgImage() : $_post->getFeaturedImage();
$_postName = $block->escapeHtml($_post->getTitle());
?>
<li class="post-holder post-holder-<?= (int)$_post->getId() ?>">
Expand All @@ -34,7 +35,7 @@ $_postName = $block->escapeHtml($_post->getTitle());
<div class="post-sharing post-sharing-top old-post-list-item">
<div class="share-elements">
<?php foreach ($block->getAllowedSocialNetworks() as $network) { ?>
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>')">
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>', '<?= $_postImage ?>')">
<div class="icon" title="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<img src="<?= $this->getViewFileUrl('Magefan_Blog::images/social/' . strtolower($network) . '.svg') ?>" alt="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
</div>
Expand Down
57 changes: 29 additions & 28 deletions view/frontend/templates/post/view-modern.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
*/
?>
<?php
$_post = $block->getPost();
$_postUrl = $_post->getPostUrl();
$_postName = $block->escapeHtml($_post->getTitle(), null);
$_post = $block->getPost();
$_postUrl = $_post->getPostUrl();
$_postImage = $_post->getOgImage()? $_post->getOgImage() : $_post->getFeaturedImage();
$_postName = $block->escapeHtml($_post->getTitle(), null);
?>
<?= $block->getStyleViewModel()->getStyle('Magefan_Blog::css/bootstrap-4.4.1-custom-min.css') ?>
<div class="_post-view post-view-modern">
Expand All @@ -27,13 +28,13 @@
<!-- post category-->
<?php if ($_categoriesCount = $_post->getCategoriesCount()) { ?>
<div class="post-category mb-4">
<?php foreach ($_post->getParentCategories() as $ct) { ?>
<a class="category-name" href="<?= $block->escapeUrl($ct->getCategoryUrl()) ?>"
title="<?= $block->escapeHtml($ct->getTitle()) ?>">
<?= $block->escapeHtml($ct->getTitle()) ?>
</a>
<?php } ?>
</div>
<?php foreach ($_post->getParentCategories() as $ct) { ?>
<a class="category-name" href="<?= $block->escapeUrl($ct->getCategoryUrl()) ?>"
title="<?= $block->escapeHtml($ct->getTitle()) ?>">
<?= $block->escapeHtml($ct->getTitle()) ?>
</a>
<?php } ?>
</div>
<?php } ?>

<!-- block data -->
Expand All @@ -51,8 +52,8 @@
<?php } ?>

<?php
$coAuthors = $_post->getRelatedCoauthors();
$coAuthorsCount = count($coAuthors);
$coAuthors = $_post->getRelatedCoauthors();
$coAuthorsCount = count($coAuthors);
?>
<?php if ($coAuthorsCount) { ?>
<?= $block->escapeHtml(__('and')) ?>
Expand Down Expand Up @@ -108,10 +109,10 @@
<!-- Post Image -->
<?php if ($featuredImage = $_post->getFeaturedImage()) { ?>
<?php
$featuredImgAlt = $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
}
$featuredImgAlt = $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
}
?>
<div class="post-featured-image">
<img src="<?= $block->escapeUrl($featuredImage) ?>"
Expand Down Expand Up @@ -146,20 +147,20 @@
<div class="post-bottom">

<?php if ($block->displayAddThisToolbox()) : ?>
<!-- Post Sharing -->
<div class="post-sharing post-sharing-bottom">
<div class="share-elements">
<?php foreach ($block->getAllowedSocialNetworks() as $network) { ?>
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>')">
<div class="icon" title="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<img src="<?= $this->getViewFileUrl('Magefan_Blog::images/social/' . strtolower($network) . '.svg') ?>" alt="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<!-- Post Sharing -->
<div class="post-sharing post-sharing-bottom">
<div class="share-elements">
<?php foreach ($block->getAllowedSocialNetworks() as $network) { ?>
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>', '<?= $_postImage ?>')">
<div class="icon" title="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<img src="<?= $this->getViewFileUrl('Magefan_Blog::images/social/' . strtolower($network) . '.svg') ?>" alt="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
</div>
<div class="label"><?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?></div>
</div>
<div class="label"><?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?></div>
</div>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
<!-- END Post Sharing -->
<!-- END Post Sharing -->
<?php endif; ?>

<?= $block->getChildHtml('blog.post.bottom') ?>
Expand Down
3 changes: 2 additions & 1 deletion view/frontend/templates/post/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<?php
$_post = $block->getPost();
$_postUrl = $_post->getPostUrl();
$_postImage = $_post->getOgImage()? $_post->getOgImage() : $_post->getFeaturedImage();
$_postName = $block->escapeHtml($_post->getTitle(), null);
?>
<div class="post-view">
Expand All @@ -28,7 +29,7 @@ $_postName = $block->escapeHtml($_post->getTitle(), null);
<div class="post-sharing post-sharing-top old-post-view">
<div class="share-elements">
<?php foreach ($block->getAllowedSocialNetworks() as $network) { ?>
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>')">
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>', '<?= $_postImage ?>')">
<div class="icon" title="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<img src="<?= $this->getViewFileUrl('Magefan_Blog::images/social/' . strtolower($network) . '.svg') ?>" alt="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
</div>
Expand Down