使用方法:将下面“版权代码”整体添加到你wordpress主题的functions.php中就好了。
// 正文末尾加本文地址
function add_after_post_content($content) {
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$url = "http" . (($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$url_title = get_the_title($ID);
$url = "\r\n" . "本文地址:" . "<a href='$url'>" . "$url" . "</a>" . " $url_title" ;
$content .= $url;
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
主题header.php加入 复制保留版权
<script>
$(function () {
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
if (window.ActiveXObject) {
document.body.oncopy = function () {
event.returnValue = false;
var t = document.selection.createRange().text;
var s = "<br /><br /> 原文出自 [优鱼博客] 转载请保留原文链接: " + location.href;
clipboardData.setData('Text', t + '\r\n' + s)
}
} else {
function addLink() {
var body_element = document.getElementsByTagName('body')[0];
var selection;
selection = window.getSelection();
var pagelink = "<br /><br /> 原文出自 [优鱼博客] 转载请保留原文链接: " + document.location.href;
var copytext = selection + pagelink;
var newdiv = document.createElement('div');
newdiv.style.position = 'absolute';
newdiv.style.left = '-99999px';
body_element.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function () {
body_element.removeChild(newdiv)
}, 0)
}
document.oncopy = addLink
}
});
</script>
本文地址:http://81uyu.com/uyu/1099.html wordpress文章增加版权 - 我的微信
- 这是我的微信扫一扫
- 我的微信公众号
- 我的微信公众号扫一扫