From eb4c64564b951a8d4ca6edc3a01707c45d323008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E8=90=BD?= Date: Mon, 27 Jan 2020 22:28:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=BD=E5=A4=9A=E4=BF=AE=E6=94=B9=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/clean-up.php | 1 + framework/options-config.php | 350 +++++++++------------------ framework/plugin-options.php | 28 ++- functions/Ajax.php | 18 ++ functions/advanced.php | 79 +++++- functions/avatar.php | 8 - functions/optimization.php | 46 +++- functions/security.php | 37 ++- functions/seo.php | 168 ++++++++----- functions/server.php | 45 ---- functions/sitemap-xml.php | 20 +- functions/utils.php | 258 ++++++++++++++++++++ modules/base/functions/anti-spam.php | 2 - modules/base/functions/seo-extra.php | 93 ------- modules/base/functions/smtp.php | 40 --- modules/base/functions/usability.php | 121 +-------- 16 files changed, 682 insertions(+), 632 deletions(-) create mode 100644 functions/Ajax.php delete mode 100644 functions/avatar.php delete mode 100644 modules/base/functions/anti-spam.php delete mode 100644 modules/base/functions/seo-extra.php delete mode 100644 modules/base/functions/smtp.php diff --git a/class/clean-up.php b/class/clean-up.php index ad535e0..15eaa0b 100644 --- a/class/clean-up.php +++ b/class/clean-up.php @@ -191,6 +191,7 @@ function wp_clean_up_optimize(){ } ?> +

diff --git a/framework/options-config.php b/framework/options-config.php index 2770dc9..7fc9df7 100644 --- a/framework/options-config.php +++ b/framework/options-config.php @@ -6,79 +6,90 @@ $gdk_options = [ '优化选项' => [ [ - 'name' => '新版编辑器开关', - 'desc' => '新版编辑器尚不成熟,很多主题不兼容,建议禁用', + 'name' => '禁用新版编辑器', + 'desc' => '新版编辑器尚不成熟,很多主题不兼容,建议开启', 'id' => 'gdk_diasble_gutenberg', 'type' => 'radio', 'options' => [ - '1' => '禁用', - '0' => '开启' + '0' => '禁用', + '1' => '开启' ], 'std' => '1' ], [ 'name' => '禁用头部冗余代码', - 'desc' => 'WordPress头部自带很多无用代码,不安全且浪费,建议禁用', + 'desc' => 'WordPress头部自带很多无用代码,不安全且浪费,建议开启', 'id' => 'gdk_diasble_head_useless', 'type' => 'radio', 'options' => [ - '1' => '禁用', - '0' => '开启' + '0' => '禁用', + '1' => '开启' ], 'std' => '1' ], [ 'name' => '禁用WordPress更新', - 'desc' => 'WordPress更新会不时发送请求数据,所以可以关闭WordPress更新,包括主题,插件和内核更新', + 'desc' => 'WordPress更新会不时发送请求数据,所以可以关闭WordPress更新,包括主题,插件和内核更新,默认禁用', 'id' => 'gdk_diasble_wp_update', 'type' => 'radio', 'options' => [ - '1' => '禁用', - '0' => '开启' + '0' => '禁用', + '1' => '开启' ], - 'std' => '1' + 'std' => '0' ], [ 'name' => '禁用Emojis功能', - 'desc' => 'WordPress的Emojis功能会加载国外资源,那是网站速度,所以建议禁用', + 'desc' => 'WordPress的Emojis功能会加载国外资源,那是网站速度,所以建议开启', 'id' => 'gdk_disable_emojis', 'type' => 'radio', 'options' => [ - '1' => '禁用', - '0' => '开启' + '0' => '禁用', + '1' => '开启' ], 'std' => '1' ], [ 'name' => '禁用XML-RPC功能', - 'desc' => '该功能有安全风险,如果不使用WordPress的手机客户端或者第三方编辑器软件,那么建议禁用', + 'desc' => '该功能有安全风险,如果不使用WordPress的手机客户端或者第三方编辑器软件,那么建议开启', 'id' => 'gdk_disable_xmlrpc', 'type' => 'radio', 'options' => [ - '1' => '禁用', - '0' => '开启' + '0' => '禁用', + '1' => '开启' ], 'std' => '1' ], [ 'name' => '禁用文章版本功能', - 'desc' => '该功能有会造成数据库体量暴增为了你的数据库考虑,建议禁用', + 'desc' => '该功能有会造成数据库体量暴增为了你的数据库考虑,建议开启', 'id' => 'gdk_disable_revision', 'type' => 'radio', 'options' => [ - '1' => '禁用', - '0' => '开启' + '0' => '禁用', + '1' => '开启' ], 'std' => '1' ], [ 'name' => '禁用pingback功能', - 'desc' => '该功能会增加垃圾评论的几率,建议禁用', + 'desc' => '该功能会增加垃圾评论的几率,建议开启', 'id' => 'gdk_disable_trackbacks', 'type' => 'radio', 'options' => [ - '1' => '禁用', - '0' => '开启' + '0' => '禁用', + '1' => '开启' + ], + 'std' => '1' + ], + [ + 'name' => '文件上传重命名', + 'desc' => '该功能会将zip,rar,7z格式以外的所有全部数字重命名,服务器文件不建议使用中文,默认开启', + 'id' => 'gdk_upload_rename', + 'type' => 'radio', + 'options' => [ + '0' => '禁用', + '1' => '开启' ], 'std' => '1' ], @@ -103,7 +114,7 @@ $gdk_options = [ '2' => 'V2EX头像镜像', '3' => '七牛头像镜像', ], - 'std' => '1' + 'std' => '3' ] ], 'SEO设置' => [ @@ -127,6 +138,17 @@ $gdk_options = [ 'type' => 'text', 'std' => '|' ], + [ + 'name' => '自动添加nofollow', + 'desc' => '该功能会给外链自动添加nofollow,默认开启', + 'id' => 'gdk_nofollow', + 'type' => 'radio', + 'options' => [ + '0' => '禁用', + '1' => '开启' + ], + 'std' => '1' + ], [ 'name' => '文章自动内链', 'desc' => '该功能会将文章中与标签匹配的文字自动添加标签链接,如果是纯文字的内容建议打开,默认禁用', @@ -156,6 +178,17 @@ $gdk_options = [ ], 'std' => '1' ], + [ + 'name' => '禁止蜘蛛爬取作者页面', + 'desc' => '该功能会屏蔽蜘蛛访问作者页面,如果是单作者网站没必要展示作者页,根据自己网站实际情况选择是否开启,默认禁用', + 'id' => 'gdk_no_author_page', + 'type' => 'radio', + 'options' => [ + '0' => '禁用', + '1' => '开启' + ], + 'std' => '0' + ], [ 'name' => '网站地图 sitemap_xml', 'desc' => '该功能会自动生成网站地图链接:域名/sitemap_xml,开启后建议更新固定链接一次,默认开启', @@ -168,10 +201,15 @@ $gdk_options = [ 'std' => '1' ], [ - 'name' => '图片自动添加alt以及title', - 'desc' => '启用', - 'id' => 'git_imgalt_b', - 'type' => 'checkbox' + 'name' => '文章图片自动添加alt以及title', + 'desc' => '该功能会自动给文章中图片添加alt和title,并且是按照文章标题进行命名,默认开启', + 'id' => 'gdk_seo_img', + 'type' => 'radio', + 'options' => [ + '0' => '禁用', + '1' => '开启' + ], + 'std' => '1' ], [ 'name' => '外链自动GO跳转', @@ -180,29 +218,35 @@ $gdk_options = [ 'type' => 'checkbox' ], [ - 'name' => '外链自动添加nofollow', - 'desc' => '启用', - 'id' => 'git_nofollow', - 'type' => 'checkbox' - ], - [ - 'name' => 'Robot.txt优化', - 'desc' => '启用 【开启本项之后,将只对搜索引擎开放首页,页面,文章页,其他一律屏蔽】', - 'id' => 'git_robot_b', - 'type' => 'checkbox' - ], - [ - 'title' => '百度主动推送 查看主动推送效果',//标题文字 - 'type' => 'title'//title 是标签下的标题 + 'name' => '百度自动&主动推送', + 'desc' => '该功能会自动给文章中图片添加alt和title,并且是按照文章标题进行命名,默认开启', + 'id' => 'gdk_baidu_push', + 'type' => 'radio', + 'options' => [ + '0' => '禁用', + '1' => '开启' + ], + 'std' => '1' ], [ 'name' => '主动推送接口地址,填写本项即开启推送', - 'desc' => '在百度站长平台获取主动推送接口地址,比如:http://data.zz.baidu.com/urls?site=域名&token=一组字符, 主动推送接口地址', - 'id' => 'git_sitemap_api', + 'desc' => '在百度站长平台获取主动推送接口地址,比如:http://data.zz.baidu.com/urls?site=域名&token=一组字符, 主动推送接口地址', + 'id' => 'gdk_baidu_api', 'type' => 'text' ] ], '安全设置' => [ + [ + 'name' => '屏蔽各种不正常的请求', + 'desc' => '该功能会将各种不正常的请求比如破解,注入类的屏蔽掉,默认开启', + 'id' => 'gdk_block_requst', + 'type' => 'radio', + 'options' => [ + '1' => '开启', + '0' => '禁用' + ], + 'std' => '1' + ], [ 'title' => '登陆安全防御', 'type' => 'title' @@ -244,7 +288,7 @@ $gdk_options = [ ], [ 'name' => '关键词,IP,邮箱屏蔽', - 'desc' => '开启 【启用后,在WordPress-设置-讨论-黑名单中添加想要屏蔽的关键词,邮箱,网址,IP地址,每行一个】如图设置', + 'desc' => '开启 【启用后,在WordPress-设置-讨论-黑名单中添加想要屏蔽的关键词,邮箱,网址,IP地址,每行一个】如图设置', 'id' => 'git_spam_keywords', 'type' => 'checkbox' ], @@ -260,142 +304,6 @@ $gdk_options = [ 'id' => 'git_spam_long', 'type' => 'checkbox' ], - [ - 'title' => '评论设置属性', - 'type' => 'title' - ], - [ - 'name' => '贴图', - 'desc' => '不显示', - 'id' => 'git_tietu', - 'type' => 'checkbox' - ], - [ - 'name' => '加粗', - 'desc' => '不显示', - 'id' => 'git_jiacu', - 'type' => 'checkbox' - ], - [ - 'name' => '删除线', - 'desc' => '不显示', - 'id' => 'git_shanchu', - 'type' => 'checkbox' - ], - [ - 'name' => '居中', - 'desc' => '不显示', - 'id' => 'git_juzhong', - 'type' => 'checkbox' - ], - [ - 'name' => '斜体', - 'desc' => '不显示', - 'id' => 'git_xieti', - 'type' => 'checkbox' - ], - [ - 'name' => '签到', - 'desc' => '不显示', - 'id' => 'git_qiandao', - 'type' => 'checkbox' - ], - [ - 'title' => '评论VIP设置', - 'type' => 'title' - ], - [ - 'name' => '启用', - 'desc' => ' 【启用之后,您需要在下面设置用户的评论数字区间】', - 'id' => 'git_vip', - 'type' => 'checkbox' - ], - [ - 'name' => 'VIP 1', - 'desc' => '输入的数字减一就是VIP 1的所要求的评论数字区间,默认是5', - 'id' => 'git_vip1', - 'type' => 'number', - 'std' => 5 - ], - [ - 'name' => 'VIP 2', - 'desc' => '输入的数字减去上面的数字就是VIP 2的所要求的评论数字区间,默认是10', - 'id' => 'git_vip2', - 'type' => 'number', - 'std' => 10 - ], - [ - 'name' => 'VIP 3', - 'desc' => '输入的数字减去上面的数字就是VIP 3的所要求的评论数字区间,默认是20', - 'id' => 'git_vip3', - 'type' => 'number', - 'std' => 20 - ], - [ - 'name' => 'VIP 4', - 'desc' => '输入的数字减去上面的数字就是VIP 4的所要求的评论数字区间,默认是40', - 'id' => 'git_vip4', - 'type' => 'number', - 'std' => 30 - ], - [ - 'name' => 'VIP 5', - 'desc' => '输入的数字减去上面的数字就是VIP 5的所要求的评论数字区间,默认是70', - 'id' => 'git_vip5', - 'type' => 'number', - 'std' => 40 - ], - [ - 'name' => 'VIP 6', - 'desc' => '输入的数字减去上面的数字就是VIP 6的所要求的评论数字区间,默认是110', - 'id' => 'git_vip6', - 'type' => 'number', - 'std' => 50 - ], - [ - 'name' => '文章摘要', - 'desc' => '个字', - 'id' => 'git_excerpt_length', - 'type' => 'number', - 'std' => 180 - ], - [ - 'name' => '文章二维码', - 'desc' => '启用', - 'id' => 'git_qr_b', - 'type' => 'checkbox' - ], - [ - 'name' => '作者模块', - 'desc' => '启用', - 'id' => 'git_auther_b', - 'type' => 'checkbox' - ], - [ - 'name' => '文章目录索引', - 'desc' => '启用 【开启之后,默认索引文章H2标题】', - 'id' => 'git_article_list', - 'type' => 'checkbox' - ], - [ - 'name' => '相关文章显示条数', - 'desc' => '条       这是是显示文章下面的相关文章数目的', - 'id' => 'git_related_count', - 'type' => 'number', - 'std' => 8 - ], - [ - 'name' => '禁止站内文章Pingback', - 'desc' => '开启       开启后,不会发送站内Pingback,建议开启', - 'id' => 'git_pingback_b', - 'type' => 'checkbox' - ], - [ - 'name' => '禁止后台编辑时自动保存', - 'desc' => '开启       开启后,后台编辑文章时候不会定时保存,有效缩减数据库存储量;但是,一般不建议开启,除非你的数据库容量很小', - 'id' => 'git_autosave_b', - 'type' => 'checkbox' - ], [ 'name' => '文章版权声明', 'desc' => '此处输入的文字将出现在每篇文章最底部,你可以使用:{{title}}表示文章标题,{{link}}表示文章链接', @@ -412,20 +320,20 @@ $gdk_options = [ [ 'name' => '金币和RMB兑换关系', 'desc' => '请输入兑换关系,比如1RMB=10金币,请慎重选择,一旦设置好后面不能修改的', - 'id' => 'git_chongzhi_dh', + 'id' => 'git_payjs_rate', 'type' => 'number', 'std' => 10 ], [ 'name' => '选择一个支付方式', 'desc' => '两种方案选择其中一种,必须选择一个哦', - 'id' => 'git_pay_way', + 'id' => 'git_payjs', 'type' => 'radio', 'options' => [ - 'git_payjs_ok' => '调用Payjs支付', - 'git_eapay_ok' => '调用简付支付' + '0' => '禁用', + '1' => '开启' ], - 'std' => 'git_payjs_ok' + 'std' => '1' ], [ 'title' => 'PayJs支付设置   注册PayJs   【微信官方,微信正规渠道,强烈推荐】', @@ -444,37 +352,19 @@ $gdk_options = [ 'id' => 'git_payjs_secret', 'type' => 'text', 'std' => 444444444 - ], - [ - 'title' => '简付支付设置   注册简付', - 'type' => 'title' - ], - [ - 'name' => '简付App ID', - 'desc' => '', - 'id' => 'git_eapay_id', - 'type' => 'text', - 'std' => 2333333333 - ], - [ - 'name' => '简付App Key', - 'desc' => '', - 'id' => 'git_eapay_secret', - 'type' => 'text', - 'std' => 444444444 ] ], '高级设置' => [ [ 'name' => 'jQuery来源设置', 'desc' => '选择一个适合自己的jQuery公共库来源', - 'id' => 'git_jqcdn', + 'id' => 'git_jq', 'type' => 'radio', 'options' => [ - 'git_jqcdn_upai' => '远程jQuery库【底部加载,速度快,兼容差】', - 'git_jqcdn_bendi' => '本地jQuery库【头部加载,速度慢,兼容好】' + '1' => '远程jQuery库【底部加载,速度快,兼容差】', + '0' => '本地jQuery库【头部加载,速度慢,兼容好】' ], - 'std' => 'git_jqcdn_upai' + 'std' => '1' ], [ 'name' => 'HTML代码压缩', @@ -517,7 +407,7 @@ $gdk_options = [ ], [ 'name' => 'CDN域名', - 'desc' => '输入您的CDN域名,一般需要到cdn后台获取,必须带 http(s):// ,且结尾不能带/ ', + 'desc' => '输入您的CDN域名,一般需要到cdn后台获取,必须带 http(s):// ,且结尾不能带/ ', 'id' => 'gdk_cdn_host', 'type' => 'text', 'std' => '' @@ -549,7 +439,7 @@ $gdk_options = [ ], [ 'name' => 'CDN水印', - 'desc' => '启用【如果启用,请在七牛,又拍,OSS等CDN中设置自定义样式,名字为:water.jpg,分隔符为 ! 】', + 'desc' => '启用【如果启用,请在七牛,又拍,OSS等CDN中设置自定义样式,名字为:water.jpg,分隔符为! 】', 'id' => 'git_cdn_water', 'type' => 'checkbox' ], @@ -611,7 +501,7 @@ $gdk_options = [ 'desc' => '在本输入框内输入您的微信公众号描述信息,支持html代码,字数合适就行,不能太多', 'id' => 'git_mp_tips', 'type' => 'textarea', - 'std' => '请关注极客公园官方微信公众号,关注并订阅云落极客公园获取验证码。在微信里搜索云落极客公园或者微信扫描二维码都可以关注极客公园官方微信公众号。' + 'std' => '请关注极客公园官方微信公众号,关注并订阅云落极客公园获取验证码。在微信里搜索云落极客公园或者微信扫描二维码都可以关注极客公园官方微信公众号。' ], [ 'title' => 'HTML5 桌面推送', @@ -664,50 +554,48 @@ $gdk_options = [ 'type' => 'title' ], [ - 'name' => '发件人地址', - 'desc' => '请输入您的邮箱地址', - 'id' => 'git_maildizhi_b', - 'type' => 'text', - 'std' => '' + 'name' => 'SMTP邮箱发送', + 'desc' => '该功能利用第三方SMTP邮箱服务发送邮件,比如评论邮件,需要配置好再开启', + 'id' => 'gdk_smtp', + 'type' => 'radio', + 'options' => [ + '0' => '禁用', + '1' => '开启' + ], + 'std' => '0' ], [ 'name' => '发件人昵称', - 'desc' => '请输入您的网站名称', - 'id' => 'git_mailnichen_b', + 'desc' => '请输入您的网站名称,比如:云落', + 'id' => 'gdk_smtp_username', 'type' => 'text', 'std' => '' ], [ 'name' => 'SMTP服务器地址', - 'desc' => '请输入您的邮箱的SMTP服务器,查看查看常用SMTP地址', - 'id' => 'git_mailsmtp_b', + 'desc' => '请输入您的邮箱的SMTP服务器,点击查看常用SMTP地址', + 'id' => 'gdk_smtp_host', 'type' => 'text', 'std' => 'smtp.qq.com' ], - [ - 'name' => 'SSL安全连接', - 'desc' => '启用【如果你布吉岛这个是什么东东,那么请不要启用】', - 'id' => 'git_smtpssl_b', - 'type' => 'checkbox' - ], [ 'name' => 'SMTP服务器端口', - 'desc' => '请输入您的smtp端口,一般QQ邮箱25就可以了,如果选择了上面的SSL,推荐使用465端口', - 'id' => 'git_mailport_b', + 'desc' => '请输入您的smtp端口,一般QQ邮箱推荐使用465端口', + 'id' => 'gdk_smtp_port', 'type' => 'number', 'std' => 465 ], [ 'name' => '邮箱账号', 'desc' => '请输入您的邮箱地址,比如云落的sp91@qq.com', - 'id' => 'git_mailuser_b', + 'id' => 'gdk_smtp_mail', 'type' => 'text', 'std' => '' ], [ 'name' => '邮箱密码', - 'desc' => '请输入您的邮箱授权码', - 'id' => 'git_mailpass_b', + 'desc' => '请输入您的邮箱授权码,注意不同邮箱服务器的密码不一样,有的是密码,有的比如QQ邮箱就是授权码', + 'id' => 'gdk_smtp_password', 'type' => 'password', 'std' => '' ], diff --git a/framework/plugin-options.php b/framework/plugin-options.php index 2bb1e2c..67378fb 100644 --- a/framework/plugin-options.php +++ b/framework/plugin-options.php @@ -1,6 +1,6 @@ $name ) { } ?>
  • 数据清理
  • -
  • 关于主题
  • +
  • 关于插件
  • -
    +
    @@ -241,6 +241,12 @@ switch ( $type ) { border-bottom: 1px solid #d2d3e0; padding-bottom: 5px; } +.key_word{ + color:#f70044; + font-weight:bold; + text-decoration:none; + margin: 10px; +} .panel th { font-weight: normal; } @@ -328,6 +334,22 @@ jQuery(function ($) { $(".submit .button").prop("disabled", true); $(this).find(".submit .button").val("正在提交…"); }); +/* 配置文本框以隐藏显示功能*/ +function depend(n, e, i, c, t, u) { + $("input[name=" + n + "]:checked").val(function() { + "0" == this.value && $(e, i, c, t, u).hide(); + }), $("input[name=" + n + "]").click(function() { + $(e, i, c, t, u).toggle(); + }); +} +//依赖关系,第一个是需要点击的name值,后面是需要伸缩的ID值,参照下面写 +depend('gdk_lock_login','#row-gdk_failed_login_limit,#row-gdk_lockout_duration'); +depend('gdk_smtp','#row-gdk_smtp_username,#row-gdk_smtp_host,#row-gdk_smtp_port,#row-gdk_smtp_mail,#row-gdk_smtp_password'); +depend('gdk_baidu_push','#row-gdk_baidu_api'); + + + + }); "; + $avatar = ""; break; case 2: $avatar = preg_replace("/http[s]{0,1}:\/\/(secure|www|\d).gravatar.com\/avatar\//","//cdn.v2ex.com/gravatar/",$avatar); @@ -26,4 +26,81 @@ function fancybox($content) { } add_filter('the_content', 'fancybox'); +//邮箱SMTP设置 +if (gdk_option('gdk_smtp')) { +function gdk_smtp( $phpmailer ) { + $phpmailer->FromName = gdk_option('gdk_smtp_mail'); //邮箱地址 + $phpmailer->Host = gdk_option('gdk_smtp_host');//服务器地址 + $phpmailer->Port = gdk_option('gdk_smtp_port'); //端口 + $phpmailer->Username = gdk_option('gdk_smtp_username'); //昵称 + $phpmailer->Password = gdk_option('gdk_smtp_password'); //密码 + $phpmailer->From = gdk_option('gdk_smtp_mail'); //邮箱地址 + $phpmailer->SMTPAuth = true; + $phpmailer->SMTPSecure = 'ssl'; + $phpmailer->IsSMTP(); +} +add_action('phpmailer_init', 'gdk_smtp'); +} +//七牛CDN +if (gdk_option('gdk_cdn')) { + add_action('wp_loaded', 'gdk_cdn_start'); + function gdk_cdn_start() { + ob_start('gdk_cdn_replace'); + } + function gdk_cdn_replace($html) { + $local_host = home_url(); //博客域名 + $qiniu_host = gdk_option('git_cdnurl_b'); //七牛域名 + $cdn_exts = gdk_option('git_cdnurl_format'); //扩展名(使用|分隔) + $cdn_dirs = gdk_option('git_cdnurl_dir'); //目录(使用|分隔) + $cdn_dirs = str_replace('-', '\-', $cdn_dirs); + if ($cdn_dirs) { + $regex = '/' . str_replace('/', '\/', $local_host) . '\/((' . $cdn_dirs . ')\/[^\s\?\\\'\"\;\>\<]{1,}.(' . $cdn_exts . '))([\"\\\'\s\?]{1})/'; + $html = preg_replace($regex, $qiniu_host . '/$1$4', $html); + } else { + $regex = '/' . str_replace('/', '\/', $local_host) . '\/([^\s\?\\\'\"\;\>\<]{1,}.(' . $cdn_exts . '))([\"\\\'\s\?]{1})/'; + $html = preg_replace($regex, $qiniu_host . '/$1$3', $html); + } + return $html; + } +} + +//CDN水印 +if (gdk_option('git_cdn_water')) { + function cdn_water($content){ + if (get_post_type() == 'post') { + $pattern = "//i"; + $replacement = ''; + $content = preg_replace($pattern, $replacement, $content); + } + return $content; + } + add_filter('the_content', 'cdn_water'); +} + +//自动替换媒体库图片的域名 +if (is_admin() && gdk_option('git_cdnurl_b') && gdk_option('git_adminqn_b')) { + function attachment_replace($text) { + $replace = array( + home_url() => gdk_option('git_cdnurl_b') + ); + $text = str_replace(array_keys($replace) , $replace, $text); + return $text; + } + add_filter('wp_get_attachment_url', 'attachment_replace'); +} + +//一个简单可重复使用的邮件模板 +function mail_temp($mail_title,$mail_cotent,$link,$link_title){ + ?> +
    +
    +
    + +

    +
    本邮件为系统自动发送,请勿回复。
    + 如果不想被此类邮件打扰,请前往 留言说明,由我们来操作处理。 +
    +
    + 首页!'); +} + +add_action('do_feed', 'wpjam_feed_disabled', 1); +add_action('do_feed_rdf', 'wpjam_feed_disabled', 1); +add_action('do_feed_rss', 'wpjam_feed_disabled', 1); +add_action('do_feed_rss2', 'wpjam_feed_disabled', 1); +add_action('do_feed_atom', 'wpjam_feed_disabled', 1); //禁用新版编辑器 if(gdk_option('gdk_diasble_gutenberg')){ @@ -139,12 +148,20 @@ add_action('init', 'gdk_page_permalink', -1); //中文文件重命名 -function gdk_upload_rename($file) { - $time = date("YmdHis"); - $file['name'] = $time . "" . mt_rand(1, 100) . "." . pathinfo($file['name'], PATHINFO_EXTENSION); - return $file; +if(gdk_option('gdk_upload_rename')){ + add_filter('wp_handle_upload_prefilter', 'gdk_upload_rename' ); + function gdk_upload_rename( $file ){ + $info = pathinfo($file['name']); + $ext = $info['extension']; + $ignore_exts = ['zip', 'rar', '7z'];//被忽略的文件格式 + + if (!in_array($ext, $ignore_exts)) { + $filedate = date('YmdHis').mt_rand(100, 999); + $file['name'] = $filedate.'.'.$ext; + } + return $file; + } } -add_filter('wp_handle_upload_prefilter', 'gdk_upload_rename'); // 搜索结果为1时候自动跳转到对应页面 @@ -277,4 +294,21 @@ function log_login( $username, $password ) { } } -} \ No newline at end of file +} + +//前台禁止加载语言包 +add_filter('locale', function($locale) { + $locale = ( is_admin() ) ? $locale : 'en_US'; + return $locale; +}); + +// 定制登录页面链接的连接 +add_filter('login_headerurl', function (){ + return home_url(); +}); + + +// 定制登录页面链接的标题 +add_filter('login_headertext', function (){ + return get_bloginfo('name'); +}); \ No newline at end of file diff --git a/functions/security.php b/functions/security.php index ec35e2a..bc04799 100644 --- a/functions/security.php +++ b/functions/security.php @@ -3,7 +3,7 @@ define('DISALLOW_FILE_MODS',true); //阻止乱七八糟的请求 -add_action( 'wp', 'gdk_prevent_script_injection' ); +if(gdk_option('gdk_block_requst')){ function gdk_prevent_script_injection() { global $user_ID; if( ! current_user_can( 'level_10' )) { @@ -27,19 +27,21 @@ add_action( 'wp', 'gdk_prevent_script_injection' ); } } } + add_action( 'wp', 'gdk_prevent_script_injection' ); +} if(gdk_option('gdk_lock_login')){ if ( ! class_exists( 'GDK_Limit_Login_Attempts' ) ) { class GDK_Limit_Login_Attempts { - var $failed_login_limit = 3; + private $failed_login_limit; //登录失败的次数限制 - var $lockout_duration = 60; + private $lockout_duration; //暂停登陆时间 var $transient_name = 'attempted_login'; //Transient used - public function __construct() { - $failed_login_limit = gdk_option('gdk_failed_login_limit'); - $lockout_duration = gdk_option('gdk_lockout_duration'); + public function __construct($config = null) { + $this->failed_login_limit = $config['failed_login_limit']; + $this->lockout_duration = $config['lockout_duration']; add_filter( 'authenticate', array( $this, 'check_attempted_login' ), 30, 3 ); add_action( 'wp_login_failed', array( $this, 'login_failed' ), 10, 1 ); } @@ -91,7 +93,7 @@ if(gdk_option('gdk_lock_login')){ if ( $diff < $minute * 2 ) return esc_attr( 'about 1 minute ago' ); if ( $diff < $hour ) - return floor( $diff / $minute ) . ' ' . esc_attr( '分' ); + return floor( $diff / $minute ) . ' ' . esc_attr( '分钟' ); if ( $diff < $hour * 2 ) return esc_attr( 'about 1 hour'); return floor( $diff / $hour ) . ' ' . esc_attr( '小时' ); @@ -99,7 +101,11 @@ if(gdk_option('gdk_lock_login')){ } } //Enable it: - new GDK_Limit_Login_Attempts(); + $config = [ + 'failed_login_limit' => gdk_option('gdk_failed_login_limit'), // 登录失败的次数限制 + 'lockout_duration' => gdk_option('gdk_lockout_duration'), // 暂停登陆时间 + ]; + new GDK_Limit_Login_Attempts($config); } @@ -109,7 +115,7 @@ function gdk_disable_login_errors( $error ) { $err_codes = $errors->get_error_codes(); if ( ! in_array( 'too_many_tried', $err_codes ) ) { // For security reason - return esc_attr('Access denied!'); + return esc_attr('Access Denied!'); } return $error; } @@ -147,4 +153,15 @@ function gdk_comment_lang($incoming_comment) { } return($incoming_comment); } -add_filter('preprocess_comment', 'gdk_comment_lang'); \ No newline at end of file +add_filter('preprocess_comment', 'gdk_comment_lang'); + +//禁止使用admin登录 +add_filter( 'wp_authenticate', function ($user){ + if($user == 'admin') exit; +}); +add_filter('sanitize_user', function ($username, $raw_username, $strict){ + if($raw_username == 'admin' || $username == 'admin'){ + exit; + } + return $username; +}, 10, 3); diff --git a/functions/seo.php b/functions/seo.php index 5cde1fc..8b2d985 100644 --- a/functions/seo.php +++ b/functions/seo.php @@ -5,6 +5,18 @@ if(gdk_option('gdk_sitemap_xml')){ include('sitemap-xml.php'); } +// 屏蔽蜘蛛爬取作者页面 +if(gdk_option('gdk_no_author_page')){ + function gdk_no_author_page() + { + if (is_author()) { + wp_no_robots(); + } + } + add_action('wp_head', 'gdk_no_author_page'); +} + + //robots.txt优化功能 if(gdk_option('gdk_robots')){ add_filter('robots_txt', 'gdk_robots_txt', 10, 2); @@ -50,6 +62,97 @@ if(gdk_option('gdk_tag_link')){ add_filter('the_content', 'gdk_tag_link', 1); } +// 自动添加nofloow +if(gdk_option('gdk_nofollow')){ + add_filter('the_content', 'gdk_nofollow'); + add_filter('the_excerpt', 'gdk_nofollow'); + + function gdk_nofollow($content) + { + return preg_replace_callback('/]+/', 'gdk_nofollow_callback', $content); + } + + function gdk_nofollow_callback($matches) + { + $link = $matches[0]; + $site_link = get_bloginfo('url'); + + if (strpos($link, 'rel') === false) { + $link = preg_replace("%(href=\S(?!$site_link))%i", 'rel="nofollow" $1', $link); + } elseif (preg_match("%href=\S(?!$site_link)%i", $link)) { + $link = preg_replace('/rel=\S(?!nofollow)\S*/i', 'rel="nofollow"', $link); + } + return $link; + } +} + + + +if (isset($others_seo['baidu_submit']) && $others_seo['baidu_submit']) { + add_action('post_updated', 'nc_baidu_submit'); + function nc_baidu_submit($post_ID) + { + global $post; + $bd_submit_site = get_bloginfo('url'); + $bd_submit_token = $others_seo['baidu_submit_key']; + if (empty($post_ID) || empty($bd_submit_site) || empty($bd_submit_token)) { + return; + } + $api = 'http://data.zz.baidu.com/urls?site='.$bd_submit_site.'&token='.$bd_submit_token; + $status = $post->post_status; + if ($status != '' && $status != 'publish') { + $url = get_permalink($post_ID); + $ch = curl_init(); + $options = array( + CURLOPT_URL => $api, + CURLOPT_POST => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POSTFIELDS => $url, + CURLOPT_HTTPHEADER => array('Content-Type: text/plain') + ); + curl_setopt_array($ch, $options); + } + } + + function nc_baidu_auto_code(){ + echo ''; + } +} +add_action('wp_footer', 'nc_baidu_auto_code', 500); + + +if(gdk_option('gdk_seo_img')) { + //给文章图片自动添加alt和title信息 + function nc_imagesalt($content) { + global $post; + $pattern ="//i"; + $replacement = ''; + $content = preg_replace($pattern, $replacement, $content); + return $content; + } + add_filter('the_content', 'nc_imagesalt'); + function nc_image_alt_tag($content) { + global $post; + preg_match_all('//', $content, $images); + if(!is_null($images)) { + foreach($images[1] as $index => $value) { + $new_img = str_replace('name == $b->name) return 0; - return (strlen($a->name) > strlen($b->name)) ? -1 : 1; -} -function tag_link($content) { - global $match_num_min, $match_num_max; - $posttags = get_the_tags(); - if ($posttags) { - usort($posttags, "tag_sort"); - foreach ($posttags as $tag) { - $link = get_tag_link($tag->term_id); - $keyword = $tag->name; - $cleankeyword = stripslashes($keyword); - $url = ""; - $limit = $match_num_max; - $content = preg_replace('|(]+>)(.*)(' . $keyword . ')(.*)(]*>)|U' . $case, '$1$2%&&&&&%$4$5', $content); - $content = preg_replace('|()|U' . $case, '$1$2%&&&&&%$4$5', $content); - $content = preg_replace('|(]+>)(.*)(' . $keyword . ')(.*)(]*>)|U' . $case, '$1$2%&&&&&%$4$5', $content); - $cleankeyword = preg_quote($cleankeyword, '\''); - $regEx = '\'(?!((<.*?)|(]*?)>)|([^>]*?))\'s' . $case; - $content = preg_replace($regEx, $url, $content, $limit); - $content = str_replace('%&&&&&%', stripslashes($keyword) , $content); - } - } - return $content; -} - add_filter('the_content', 'tag_link', 1); - -*/ //图片img标签添加alt,title属性 function imagesalt($content){ @@ -192,37 +260,7 @@ function tag_link($content) { } add_filter('the_content', 'aimagesalt'); -//自动给文章以及评论添加nofollow属性 - function git_auto_nofollow($content) - { - $regexp = "]*href=(\"??)([^\" >]*?)\\1[^>]*>"; - if (preg_match_all("/{$regexp}/siU", $content, $matches, PREG_SET_ORDER)) { - if (!empty($matches)) { - $srcUrl = get_option('siteurl'); - for ($i = 0; $i < count($matches); $i++) { - $tag = $matches[$i][0]; - $tag2 = $matches[$i][0]; - $url = $matches[$i][0]; - $noFollow = ''; - $pattern = '/rel\\s*=\\s*"\\s*[n|d]ofollow\\s*"/'; - preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE); - if (count($match) < 1) { - $noFollow .= ' rel="nofollow" '; - } - $pos = strpos($url, $srcUrl); - if ($pos === false) { - $tag = rtrim($tag, '>'); - $tag .= $noFollow . '>'; - $content = str_replace($tag2, $tag, $content); - } - } - } - } - $content = str_replace(']]>', ']]>', $content); - return $content; - } - add_filter('the_content', 'git_auto_nofollow'); //评论分页的seo处理 diff --git a/functions/server.php b/functions/server.php index e66c051..af70d1e 100644 --- a/functions/server.php +++ b/functions/server.php @@ -2,53 +2,8 @@ -//七牛CDN -if (!is_admin() && git_get_option('git_qncdn_b')) { - add_action('wp_loaded', 'gdk_cdn_start'); - function gdk_cdn_start() { - ob_start('gdk_cdn_replace'); - } - function gdk_cdn_replace($html) { - $local_host = home_url(); //博客域名 - $qiniu_host = git_get_option('git_cdnurl_b'); //七牛域名 - $cdn_exts = git_get_option('git_cdnurl_format'); //扩展名(使用|分隔) - $cdn_dirs = git_get_option('git_cdnurl_dir'); //目录(使用|分隔) - $cdn_dirs = str_replace('-', '\-', $cdn_dirs); - if ($cdn_dirs) { - $regex = '/' . str_replace('/', '\/', $local_host) . '\/((' . $cdn_dirs . ')\/[^\s\?\\\'\"\;\>\<]{1,}.(' . $cdn_exts . '))([\"\\\'\s\?]{1})/'; - $html = preg_replace($regex, $qiniu_host . '/$1$4', $html); - } else { - $regex = '/' . str_replace('/', '\/', $local_host) . '\/([^\s\?\\\'\"\;\>\<]{1,}.(' . $cdn_exts . '))([\"\\\'\s\?]{1})/'; - $html = preg_replace($regex, $qiniu_host . '/$1$3', $html); - } - return $html; - } -} -//CDN水印 -if (git_get_option('git_cdn_water')) { - function cdn_water($content){ - if (get_post_type() == 'post') { - $pattern = "//i"; - $replacement = ''; - $content = preg_replace($pattern, $replacement, $content); - } - return $content; - } - add_filter('the_content', 'cdn_water'); -} -//自动替换媒体库图片的域名 -if (is_admin() && git_get_option('git_cdnurl_b') && git_get_option('git_adminqn_b')) { - function attachment_replace($text) { - $replace = array( - home_url() => git_get_option('git_cdnurl_b') - ); - $text = str_replace(array_keys($replace) , $replace, $text); - return $text; - } - add_filter('wp_get_attachment_url', 'attachment_replace'); -} diff --git a/functions/sitemap-xml.php b/functions/sitemap-xml.php index 626556a..2fb95ec 100644 --- a/functions/sitemap-xml.php +++ b/functions/sitemap-xml.php @@ -1,7 +1,7 @@ 5, + 'method' => '', + 'body' => array(), + 'sslverify' => false, + 'blocking' => true, // 如果不需要立刻知道结果,可以设置为 false + 'stream' => false, // 如果是保存远程的文件,这里需要设置为 true + 'filename' => null, // 设置保存下来文件的路径和名字 + 'need_json_decode' => true, + 'need_json_encode' => false, + // 'headers' => array('Accept-Encoding'=>'gzip;'), //使用压缩传输数据 + // 'headers' => array('Accept-Encoding'=>''), + // 'compress' => false, + 'decompress' => true, + )); + + if(isset($_GET['debug'])){ + print_r($args); + } + + $need_json_decode = $args['need_json_decode']; + $need_json_encode = $args['need_json_encode']; + + $method = ($args['method'])?strtoupper($args['method']):($args['body']?'POST':'GET'); + + unset($args['need_json_decode']); + unset($args['need_json_encode']); + unset($args['method']); + + if($method == 'GET'){ + $response = wp_remote_get($url, $args); + }elseif($method == 'POST'){ + if($need_json_encode && is_array($args['body'])){ + $args['body'] = json_encode($args['body']); + } + $response = wp_remote_post($url, $args); + }elseif($method == 'FILE'){ // 上传文件 + $args['method'] = ($args['body'])?'POST':'GET'; + $args['sslcertificates'] = isset($args['sslcertificates'])?$args['sslcertificates']: ABSPATH.WPINC.'/certificates/ca-bundle.crt'; + $args['user-agent'] = isset($args['user-agent'])?$args['user-agent']:'WordPress'; + $wp_http_curl = new WP_Http_Curl(); + $response = $wp_http_curl->request($url, $args); + }elseif($method == 'HEAD'){ + if($need_json_encode && is_array($args['body'])){ + $args['body'] = json_encode($args['body']); + } + + $response = wp_remote_head($url, $args); + }else{ + if($need_json_encode && is_array($args['body'])){ + $args['body'] = json_encode($args['body']); + } + + $response = wp_remote_request($url, $args); + } + + if(is_wp_error($response)){ + trigger_error($url."\n".$response->get_error_code().' : '.$response->get_error_message()."\n".var_export($args['body'],true)); + return $response; + } + + $headers = $response['headers']; + $response = $response['body']; + + if($need_json_decode || isset($headers['content-type']) && strpos($headers['content-type'], '/json')){ + if($args['stream']){ + $response = file_get_contents($args['filename']); + } + + $response = json_decode($response); + + if(get_current_blog_id() == 339){ + // print_r($response); + } + + if(is_wp_error($response)){ + return $response; + } + } + + extract(wp_parse_args($err_args, array( + 'errcode' =>'errcode', + 'errmsg' =>'errmsg', + 'detail' =>'detail', + 'success' =>0, + ))); + + if(isset($response[$errcode]) && $response[$errcode] != $success){ + $errcode = $response[$errcode]; + $errmsg = isset($response[$errmsg])?$response[$errmsg]:''; + + if(isset($response[$detail])){ + $detail = $response[$detail]; + + trigger_error($url."\n".$errcode.' : '.$errmsg."\n".var_export($detail,true)."\n".var_export($args['body'],true)); + return new WP_Error($errcode, $errmsg, $detail); + }else{ + + trigger_error($url."\n".$errcode.' : '.$errmsg."\n".var_export($args['body'],true)); + return new WP_Error($errcode, $errmsg); + } + } + + if(isset($_GET['debug'])){ + echo $url; + print_r($response); + } + + return $response; +} + +// +function gdk_get_qq_vid($id_or_url){ + if(filter_var($id_or_url, FILTER_VALIDATE_URL)){ + if(preg_match('#https://v.qq.com/x/page/(.*?).html#i',$id_or_url, $matches)){ + return $matches[1]; + }elseif(preg_match('#https://v.qq.com/x/cover/.*/(.*?).html#i',$id_or_url, $matches)){ + return $matches[1]; + }else{ + return ''; + } + }else{ + return $id_or_url; + } +} + +function get_video_mp4($id_or_url){ + if(filter_var($id_or_url, FILTER_VALIDATE_URL)){ + if(preg_match('#http://www.miaopai.com/show/(.*?).htm#i',$id_or_url, $matches)){ + return 'http://gslb.miaopai.com/stream/'.esc_attr($matches[1]).'.mp4'; + }elseif(preg_match('#https://v.qq.com/x/page/(.*?).html#i',$id_or_url, $matches)){ + return get_qqv_mp4($matches[1]); + }elseif(preg_match('#https://v.qq.com/x/cover/.*/(.*?).html#i',$id_or_url, $matches)){ + return get_qqv_mp4($matches[1]); + }else{ + return str_replace(['%3A','%2F'], [':','/'], urlencode($id_or_url)); + } + }else{ + return get_qqv_mp4($id_or_url); + } +} + + +function get_qqv_mp4($vid){ + if(strlen($vid) > 20){ + return new WP_Error('invalid_qqv_vid', '非法的腾讯视频 ID'); + } + + $mp4 = wp_cache_get($vid, 'qqv_mp4'); + if($mp4 === false){ + $response = gdk_http_request('http://vv.video.qq.com/getinfo?otype=json&platform=11001&vid='.$vid, array( + 'timeout' =>4, + 'need_json_decode' =>false + )); + + if(is_wp_error($response)){ + return $response; + } + + $response = trim(substr($response, strpos($response, '{')),';'); + $response = json_decode($response); + + if(is_wp_error($response)){ + return $response; + } + + if(empty($response['vl'])){ + return new WP_Error('illegal_qqv', '该腾讯视频不存在或者为收费视频!'); + } + + $u = $response['vl']['vi'][0]; + $p0 = $u['ul']['ui'][0]['url']; + $p1 = $u['fn']; + $p2 = $u['fvkey']; + + $mp4 = $p0.$p1.'?vkey='.$p2; + + wp_cache_set($vid, $mp4, 'qqv_mp4', HOUR_IN_SECONDS*6); + } + + return $mp4; } \ No newline at end of file diff --git a/modules/base/functions/anti-spam.php b/modules/base/functions/anti-spam.php deleted file mode 100644 index a4abe2d..0000000 --- a/modules/base/functions/anti-spam.php +++ /dev/null @@ -1,2 +0,0 @@ -]+/', 'nc_nofollow_callback', $content); - } - - function nc_nofollow_callback($matches) - { - $link = $matches[0]; - $site_link = get_bloginfo('url'); - - if (strpos($link, 'rel') === false) { - $link = preg_replace("%(href=\S(?!$site_link))%i", 'rel="nofollow" $1', $link); - } elseif (preg_match("%href=\S(?!$site_link)%i", $link)) { - $link = preg_replace('/rel=\S(?!nofollow)\S*/i', 'rel="nofollow"', $link); - } - return $link; - } - endif; -} - - - - -if (isset($others_seo['baidu_submit']) && $others_seo['baidu_submit']) { - add_action('post_updated', 'nc_baidu_submit'); - function nc_baidu_submit($post_ID) - { - global $post; - $bd_submit_site = get_bloginfo('url'); - $bd_submit_token = $others_seo['baidu_submit_key']; - if (empty($post_ID) || empty($bd_submit_site) || empty($bd_submit_token)) { - return; - } - $api = 'http://data.zz.baidu.com/urls?site='.$bd_submit_site.'&token='.$bd_submit_token; - $status = $post->post_status; - if ($status != '' && $status != 'publish') { - $url = get_permalink($post_ID); - $ch = curl_init(); - $options = array( - CURLOPT_URL => $api, - CURLOPT_POST => true, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => $url, - CURLOPT_HTTPHEADER => array('Content-Type: text/plain') - ); - curl_setopt_array($ch, $options); - } - } - add_action('wp_footer', 'nc_baidu_auto_code', 500); - function nc_baidu_auto_code() - { - echo ''; - } -} diff --git a/modules/base/functions/smtp.php b/modules/base/functions/smtp.php deleted file mode 100644 index 0300537..0000000 --- a/modules/base/functions/smtp.php +++ /dev/null @@ -1,40 +0,0 @@ -FromName = $smtp['smtp_fromname']; - $phpmailer->Host = $smtp['smtp_host']; - $phpmailer->Port = $smtp['smtp_port']; - $phpmailer->Username = $smtp['smtp_username']; - $phpmailer->Password = $smtp['smtp_password']; - $phpmailer->From = $smtp['smtp_display_mail']; - $phpmailer->SMTPAuth = true; - $phpmailer->SMTPSecure = $smtp['smtp_secure'] == 'none' ? '' : $smtp['smtp_secure']; - $phpmailer->IsSMTP(); - } -endif; - -if (!function_exists('nc_test_email')): - add_action('wp_ajax_nopriv_nc_test_email', 'nc_test_email'); - add_action('wp_ajax_nc_test_email', 'nc_test_email'); - function nc_test_email() { - $is_error = !wp_mail('donotreply@mywpku.com', '测试发信', 'WP 积木测试发信'); - - if ($is_error) { - echo json_encode(array( - 's' => 400, - 'm' => '发信失败,请检查配置是否正确' - )); - die(); - } - echo json_encode(array( - 's' => 200, - 'm' => '测试成功' - )); - die(); - } -endif; \ No newline at end of file diff --git a/modules/base/functions/usability.php b/modules/base/functions/usability.php index 897e394..09794e6 100644 --- a/modules/base/functions/usability.php +++ b/modules/base/functions/usability.php @@ -2,33 +2,7 @@ $nc_option = get_option('nc_option'); $usability = $nc_option['usability']; -if ($usability['friendly_images']) { - //给文章图片自动添加alt和title信息 - if (!function_exists('nc_imagesalt')): - function nc_imagesalt($content) { - global $post; - $pattern ="//i"; - $replacement = ''; - $content = preg_replace($pattern, $replacement, $content); - return $content; - } - add_filter('the_content', 'nc_imagesalt'); - endif; - if (!function_exists('nc_image_alt_tag')): - function nc_image_alt_tag($content) { - global $post; - preg_match_all('//', $content, $images); - if(!is_null($images)) { - foreach($images[1] as $index => $value){ - $new_img = str_replace('addClass('nc-no-lazy'); - $images = pq('body img:not(.nc-no-lazy, .post_cover_image, .loading)'); - $other = pq('body *[style]:not(.nc-no-lazy, .post_cover_image, .loading)'); - pq('body pre *,body code *')->removeClass('nc-no-lazy'); - - foreach ($images as $key => $image) { - - $src = pq( $image )->attr( 'src' ); - - if( $src ){ - pq( $image ) - ->attr( 'src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' ) - ->attr( 'data-src', $src ) - ->attr( 'data-nclazyload', 'true'); - } - - $srcset = pq( $image )->attr( 'srcset' ); - if( $srcset ){ - pq( $image )->attr('data-srcset', $srcset )->removeAttr('srcset'); - } - - $sizes = pq( $image )->attr( 'sizes' ); - if( $sizes ){ - pq( $image )->attr('data-sizes', $sizes )->removeAttr('sizes'); - } - - } - - foreach ($other as $key => $item) { - - $style = pq($item)->attr('style'); - - preg_match('/(.*?)background(-image)?:(\s?url\(.*?\))(.*?)/im', $style, $matches ); - - if( isset( $matches[3] ) ){ - pq($item)->attr('style', $matches[1] . 'background' . $matches[2] . ':url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")' . $matches[4] ); - pq($item)->attr('data-bg', $matches[3])->attr( 'data-nclazyload', 'true'); - } - - - } - - return $html->htmlOuter(); - -} if( $usability['nc_lightgallery'] == 1 && !is_admin() ){ @@ -264,9 +151,7 @@ if( $usability['nc_lightgallery'] == 1 && !is_admin() ){ } -if ($nc_option['wechat_qq_share_custom']) { - include( NC_STORE_ROOT_PATH . 'modules/pluggable/custom_share.php' ); -} + if( isset( $usability['hide_author_url_user_name'] ) && $usability['hide_author_url_user_name'] == 1 ){