本文教大家在WordPress主题中,加入复制文章内容时弹出版权提示,提醒转载注明文章出处的小功能。

  • 通过SweetAlert美化的提示框
  • 
    function zm_copyright_tips() {
    echo '<link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.css" >';
    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 );
    

     

  • 将下面代码添加到当前主题模板函数functions.php文件最后即可:
    https://snxa.com/wp-content/uploads/2022/01/1641536375-74bf772045cd39c.png

    效果如图:

 

文章来源  知更鸟  https://zmingcx.com/



微信扫描下方的二维码阅读更多精彩内容

https://snxa.com/wp-content/plugins/rest-api-to-wechat/images/qrcode/qrcode-3231.png