微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

实施社交分享短代码时出现“意外的令牌 < JSON 中的位置 0”

如何解决实施社交分享短代码时出现“意外的令牌 < JSON 中的位置 0”

我正在尝试通过短代码实现这些共享按钮,但是当我保存帖子时,我的网站现在出现错误“更新失败。意外的令牌

代码是从 Crunchify 上的一些东西修改而来的,然后被制作成一个代码,这样我就可以更容易地在我的主题中实现它。

谁能发现我做错了什么?另外,感谢您成为如此棒的社区:)

/**
* Shortcode function ish
*/
add_shortcode( 'share-social','social_share_plugin_shortcode' );
function social_share_plugin_shortcode( $attr ) {
global $plugin_code;
   // Get current page URL 
$socialURL = urlencode(get_permalink());

// Get current page title
$socialTitle = str_replace( ' ','%20',get_the_title());

// Get Post Thumbnail for Pinterest
$socialThumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),'full' );

// Construct sharing URL
$twitterURL = 'https://twitter.com/intent/tweet?text='.$socialTitle.'&amp;url='.$socialURL.'&amp;via=ObsidianUrbex';
$facebookURL = 'https://www.facebook.com/sharer/sharer.PHP?u='.$socialURL;
$whatsappURL = 'whatsapp://send?text='.$socialTitle . ' ' . $socialURL;
$pinterestURL = 'https://pinterest.com/pin/create/button/?url='.$socialURL.'&amp;media='.$socialThumbnail[0].'&amp;description='.$socialTitle;

echo '<div class="social-social">';

echo '<div class="share-post-social-icons">';

echo '
    <a class="social-link social-facebook" href="'.$facebookURL.'" target="_blank" rel="noopener"><i class="fa fa-facebook"></i> Share</a>

    <a class="social-link social-twitter" href="'. $twitterURL .'" target="_blank" rel="noopener"><i class="fa fa-twitter"></i> Tweet</a>

    <a  class="social-link social-reddit" target="_blank" href="http://reddit.com/submit?url='. get_permalink() .'&amp;title='. the_title('','',FALSE) .'" target="_blank" rel="noopener"><i class="fa fa-reddit"></i>Reddit</a>

    <a class="social-link social-pinterest" href="'.$pinterestURL.'" data-pin-custom="true" target="_blank" rel="noopener"><i class="fa fa-pinterest-p"></i>Pin It</a>
    
    <a class="social-link social-whatsapp" href="'.$whatsappURL.'" target="_blank" rel="noopener"><i class="fa fa-whatsapp"></i>WhatsApp</a>

    ' .
    "
</div>
</div>";
}
/* social  */
@media screen and (min-width: 1024px) {
    .social-whatsapp {
    display: none !important;
    }
}

.social-link {
    padding: 2px 20px;
    color: #000;
    font-size: 14px;
    border-radius: 20px;
    margin-right: 5px;
    cursor: pointer;
    -moz-background-clip: padding;
    -webkit-background-clip: padding-Box;
    Box-shadow: inset 0 -3px 0 rgba(0,.2);
    -moz-Box-shadow: inset 0 -3px 0 rgba(0,.2);
    -webkit-Box-shadow: inset 0 -3px 0 rgba(0,.2);
    margin-top: 4px;
    min-width: 100px;
display: inline-block;
    border: 1px solid grey;

}
 
.social-link:hover,.social-link:active {
    color: white;
}
 
.social-twitter {
    background: #fff;
}
 
.social-twitter:hover,.social-twitter:active {
    background: #00B6F1;
        ;
}
 
.social-facebook {
    background: #fff;
}
 
.social-facebook:hover,.social-facebook:active {
    background: #3B5998;
}

.social-pinterest {
    background: #fff;
}
 
.social-pinterest:hover,.social-pinterest:active {
    background: #CB2027;
}

.social-reddit {
    background: #fff;
}
 
.social-reddit:hover,.social-reddit:active {
    background: #ff4500;
}
 
.social-whatsapp {
    background: #fff;
}
 
.social-whatsapp:hover,.social-whatsapp:active {
    background: #43d854;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。