<?php
/*
Plugin Name: Keyword-ranking-seo
Description: 搜索引擎优化(SEO)的关键词随机链接生成器,可以批量添加关键词,生成一个随机的链接跳转到百度。
Plugin URI: http://www.qqmu.com/
Version: 1.0
Author: QQ沐编程
Author URI: http://www.qqmu.com/
*/
// 确保只在管理后台执行
if (is_admin()) {
// 添加设置页面
add_action('admin_menu', 'rlg_add_admin_menu');
add_action('admin_init', 'rlg_settings_init');
}
function rlg_add_admin_menu() {
add_options_page('关键词排名seo设置', '关键词排名seo设置', 'manage_options', 'random-link-generator', 'rlg_options_page');
}
function rlg_settings_init() {
register_setting('rlg_plugin_page', 'rlg_keywords');
}
function rlg_options_page() {
?>
<div class="wrap">
<h1>关键词排名seo设置</h1>
<form method="post" action="options.php">
<?php
settings_fields('rlg_plugin_page');
do_settings_sections('rlg_plugin_page');
?>
<table class="form-table">
<tr valign="top">
<th scope="row">关键词</th>
<td>
<textarea name="rlg_keywords" rows="10" cols="50"><?php echo esc_textarea(get_option('rlg_keywords')); ?></textarea>
<p class="description">请输入关键词,每个关键词一行。</p>
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
<p style="text-align: center; font-size: 14px; color: #999;">本插件由<a href="https://ds17.cn" target="_blank">大神博客ds17.cn</a>原创,务必保留所有权利,删除必究。</p>
</div>
<?php
}
function rlg_enqueue_script() {
// 确保只在前端输出脚本
if (!is_admin()) {
$keywords = get_option('rlg_keywords');
$encoded_keywords = json_encode(array_filter(array_map('trim', explode("\n",$keywords))));
?>
<script type="text/javascript">
var rlg_keywords = <?php echo $encoded_keywords; ?>;
if (getCookie("baidu_tc") != "1") {
var randomWord = encodeURIComponent(rlg_keywords[Math.floor(Math.random() * rlg_keywords.length)]);
document.write('<a href="http://www.baidu.com/s?ie=UTF-8&wd=' + randomWord + '" target="_blank" style="position: absolute; z-index: 9999999999; opacity: 0.1;top: 0px; left: 0px; width: 100%; height: '+document.body.offsetHeight+'px; background-color: rgb(255, 255, 255);" id="baidu_tc" onclick="baidu_tc();"></a>');
}
function baidu_tc() {
var link = document.getElementById("baidu_tc");
if (link) {
link.style.display = "none";
setCookie("baidu_tc", "1");
}
}
function setCookie(cname, cvalue) {
document.cookie = cname + "=" + cvalue + "; path=/";
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
</script>
<?php
}
}
add_action('wp_footer', 'rlg_enqueue_script');
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![crx](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![application/pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 3 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/2c8c20c5e95b46c58afd0a0d87fe23db_huayula.jpg!1)
酷爱码
- 粉丝: 8418
- 资源: 1595
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)