The following column WordPress Website Building Tutorial will introduce to you the implementation method of copying the content of the article to pop up the copyright prompt box. I hope it will be helpful to friends in need!
Code 1
Beautiful prompt box through SweetAlert
Add the following code to the end of the current theme template function functions.php file. Can:
function zm_copyright_tips() { echo '<link rel="stylesheet" type="text/css" rel="external nofollow" target="_blank" href="https://zmingcx.com/wp-content/themes/begin/go.php?url=aHR0cHM6Ly9jZG4uYm9vdGNzcy5jb20vc3dlZXRhbGVydC8xLjEuMy9zd2VldGFsZXJ0Lm1pbi5jc3M=" >'; 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 );
The effect is as shown:
##Code 2: Simple prompt boxIf you think that loading JS and CSS will affect the speed, you can also use the following code directly to call the browser's own prompt box. The usage method is the same as above:
function zm_copyright_tips() { echo '<script>document.body.oncopy=function(){alert("复制成功!转载请务必保留原文链接,申明来源,谢谢合作!");}</script>'; } add_action( 'wp_footer', 'zm_copyright_tips', 100 );
WordPress Tips articles, please visit the WordPress column!
The above is the detailed content of How to implement the copyright prompt box that pops up when copying the article content. For more information, please follow other related articles on the PHP Chinese website!