问题描述
我正在尝试通过短代码实现这些共享按钮,但是当我保存帖子时,我的网站现在出现错误“更新失败。意外的令牌
代码是从 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.'&url='.$socialURL.'&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.'&media='.$socialThumbnail[0].'&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() .'&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 (将#修改为@)