WordPress站点内容被别人复制是常有的事,你可以给你的WordPress站点添加一个功能:内容被复制后,弹出版权提示,并在粘贴的时候自动在后面添加文章链接。

部署方法
将下面的代码添加到主题的 functions.php
文件中
function add_copyright_text() { ?>
<script type='text/javascript'>
function addLink() {
var body_element = document.getElementsByTagName('body')[0];
var selection;
if(window.getSelection){//DOM,FF,Webkit,Chrome,IE10
selection = window.getSelection();
alert("文字复制成功!原文出自[ vjiujiang.com ] \n转载请注明出处:"+document.location.href);
}else if(document.getSelection){//IE10
selection= document.getSelection();
alert("文字复制成功!原文出自[ vjiujiang.com ] \n转载请注明出处:"+document.location.href);
}else if(document.selection){//IE6+10-
selection= document.selection.createRange().text;
alert("文字复制成功!原文出自[ vjiujiang.com ] \n转载请注明出处:"+document.location.href);
}else{
selection= "";
alert("浏览器兼容问题导致复制失败!");
}
var pagelink = "<br /><br /> 转载请注明来源: <a href='"+document.location.href+"'>"+document.location.href+"</a>";
var copy_text = selection + pagelink;
var new_div = document.createElement('div');
new_div.style.left='-99999px';
new_div.style.position='absolute';
body_element.appendChild(new_div );
new_div.innerHTML = copy_text ;
selection.selectAllChildren(new_div );
window.setTimeout(function() {
body_element.removeChild(new_div );
},0);
}
document.body.oncopy = addLink;
</script>
<?php
}
add_action( 'wp_footer', 'add_copyright_text');