Preventing Copyright Infringement: How to Pop Up a Copyright Prompt Box When Copying WordPress Website Articles

As a webmaster who has wandered on the Internet for many years, he has also published a lot of online articles on his WordPress website, and now self-media is everywhere, and sometimes some articles he writes may be copied casually. Although the Internet is driven by openness, sharing, and freedom, some people can use the following methods to tell users to keep the original information when reposting articles. The following methods have passed the test and can be used with confidence.

The first:

The following methods are available for testing in WordPress, and other PHP-based methods can be tested and used by yourself. You can add the following code directly to your current functions.php file.

 
 

1
2
3
4
5
6
7

// Tips for copying articles
function wz_copyright_tips() { echo '<link rel="stylesheet" type="text/css" rel="external nofollow" target="_blank" href="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.css" >'; echo '<script src="https://cdn.bo otcss.com/sweetalert/1.1.3/sweetalert.min.js"></script>'; echo '<script>document.body.oncopy = function() { swal("Copy successful!", "Please keep the original article link for reprinting, thank you for your cooperation!","success");};</script>'; } add_action( 'wp_footer', 'wz_copyright_ tips' , 100 ) ;




The JS and CSS invoked above are public resources. If you feel that the loading is slow or affects the speed of the website, you can download the file to the local server separately, specify the path and modify the corresponding source code.

The second type:

The second type has no beautification, no CSS style, and can be used directly.

 
 

1
2
3
4
5

// Tips for copying articles
function wz_copyright_tips() { echo '<script>document.body.οncοpy=function(){alert("Copy successfully! Reprint please keep the original article link, thank you for your cooperation!");}</script>'; } add_action ('wp_footer', 'wz_copyright_tips', 100 );


You can also beautify and adjust the style of the prompt box according to your own needs, so no further description will be made here.

After the copyright content copy prompt code is changed, in order to see the effect immediately, it is recommended that you open an incognito window in the browser or press F5 to check the effect.

Guess you like

Origin blog.csdn.net/winkexin/article/details/131801584