WordPress 链接关系(XFN)中添加 nofollow 选项的方法
分类 网站技术/村民张先生 发布于 2017-08-28 23:25
请将以下内容保存为 Add-nofollow-to-XFN.php 并上传至 wp-content/plugins/ 目录,然后在后台启用该插件即可。您也可以直接下载该插件:Add-nofollow-to-XFN 插件
<?php
/*
Plugin Name: Add-nofollow-to-XFN
Plugin URI: http://www.slyar.com/blog/Add-nofollow-to-XFN
Description: 在后台链接管理的XFN关系中添加一个 nofollow 标签
Author: Slyar
Version: 1.2
Author URI: http://www.slyar.com/
*/
function admin_xfn() {?>
<script type="text/javascript">
<!--
addLoadEvent(addNofollowTag);
function addNofollowTag() {
tables = document.getElementsByTagName('table');
for(i=0;i<tables.length;i++) {
if(tables[i].getAttribute("class") == "links-table") {
tr = tables[i].insertRow(1);
th = document.createElement('th');
th.setAttribute('scope','row');
th.appendChild(document.createTextNode('Follow'));
td = document.createElement('td');
tr.appendChild(th);
label = document.createElement('label');
input = document.createElement('input');
input.setAttribute('type','checkbox');
input.setAttribute('id','nofollow');
input.setAttribute('value','nofollow');
label.appendChild(input);
label.appendChild(document.createTextNode(' nofollow'));
td.appendChild(label);
tr.appendChild(td);
input.name = 'nofollow';
input.className = 'valinp';
if (document.getElementById('link_rel').value.indexOf('nofollow') != -1) {
input.setAttribute('checked','checked');
}
return;
}
}
}
//-->
</script>
<?php
}
add_action('admin_head','admin_xfn');
return;
欢迎谈谈你的看法(无须登录) *正文中请勿包含"http://"否则将被拦截