wordpress-给博客添加复制文本提示!

//添加复制提示框
function copy_tips() {
 echo '<script type="text/javascript">document.body.oncopy=function(){alert("复制成功!若要转载请务必保留原文链接,申明来源,谢谢合作!");}</script> ';
}
add_action( 'wp_footer', 'copy_tips', 100 );
function zm_copyright_tips() {
echo '<link rel="stylesheet" type="text/css" 
href="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.css" target="_blank" rel="external nofollow" >';
echo '<script 
src="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.js"></script>';
echo '<script>document.body.oncopy = function() { swal("复制成功!", "转载请务必保留原文链接,申明来源,谢谢合作!!","success");};</script>';
}
add_action( 'wp_footer', 'zm_copyright_tips', 100 );

转自:npc.ink