mirror of
https://github.com/yunluo/gdk.git
synced 2024-05-23 16:42:19 +02:00
增加一些文件
This commit is contained in:
parent
c3f8d5e822
commit
13501ddc44
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
desktop.ini
|
||||||
|
.ecloud/*
|
||||||
|
.git/
|
|
@ -2,21 +2,22 @@
|
||||||
|
|
||||||
function nc_optimizeup_enqueue_script() {
|
function nc_optimizeup_enqueue_script() {
|
||||||
wp_register_script('nicetheme-optimizeup', plugin_dir_url( __FILE__ ) . 'assets/main.js', array( 'jquery' ));
|
wp_register_script('nicetheme-optimizeup', plugin_dir_url( __FILE__ ) . 'assets/main.js', array( 'jquery' ));
|
||||||
wp_enqueue_script('nicetheme-optimizeup');
|
//wp_enqueue_script('nicetheme-optimizeup');
|
||||||
wp_localize_script( 'nicetheme-optimizeup', 'nicetheme',
|
|
||||||
array(
|
|
||||||
"ajax_url" => admin_url("admin-ajax.php"),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
add_action('admin_enqueue_scripts', 'nc_optimizeup_enqueue_script');
|
add_action('admin_enqueue_scripts', 'nc_optimizeup_enqueue_script');
|
||||||
|
|
||||||
function nc_optimizeup_enqueue_script_frontend() {
|
function nc_optimizeup_enqueue_script_frontend() {
|
||||||
if (!is_admin()) {
|
if (!is_admin()) {
|
||||||
wp_register_style( 'code_prettify_css', NC_BASE_URL.'assets/css/gdk.css', array(), NC_STORE_VER, 'all' );
|
wp_register_style( 'gdk_css', NC_BASE_URL.'assets/css/gdk.css', array(), NC_STORE_VER, 'all' );
|
||||||
wp_register_script('code_prettify_js', NC_BASE_URL.'assets/js/prettify.min.js', array('jquery'), NC_STORE_VER, true);
|
wp_register_script('code_prettify_js', NC_BASE_URL.'assets/js/prettify.min.js', array('jquery'), NC_STORE_VER, true);
|
||||||
|
wp_register_script('fancybox_js', NC_BASE_URL.'assets/js/fancybox.min.js', array('jquery'), NC_STORE_VER, true);
|
||||||
|
wp_register_script('lazyload_js', NC_BASE_URL.'assets/js/lazyload.min.js', array('jquery'), NC_STORE_VER, true);
|
||||||
|
wp_enqueue_style( 'gdk_css' );
|
||||||
wp_enqueue_script('code_prettify_js');
|
wp_enqueue_script('code_prettify_js');
|
||||||
wp_enqueue_style( 'code_prettify_css' );
|
wp_enqueue_script('lazyload_js');
|
||||||
|
wp_enqueue_script('fancybox_js');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('wp_enqueue_scripts', 'nc_optimizeup_enqueue_script_frontend');
|
add_action('wp_enqueue_scripts', 'nc_optimizeup_enqueue_script_frontend');
|
File diff suppressed because one or more lines are too long
16
assets/js/fancybox.min.js
vendored
Normal file
16
assets/js/fancybox.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
assets/js/lazyload.min.js
vendored
Normal file
5
assets/js/lazyload.min.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/*! Lazy Load 1.9.7 - MIT license - Copyright 2010-2015 Mika Tuupola */
|
||||||
|
!function(a,b,c,d){var e=a(b);a.fn.lazyload=function(f){function g(){var b=0;i.each(function(){var c=a(this);if(!j.skip_invisible||c.is(":visible"))if(a.abovethetop(this,j)||a.leftofbegin(this,j));else if(a.belowthefold(this,j)||a.rightoffold(this,j)){if(++b>j.failure_limit)return!1}else c.trigger("appear"),b=0})}var h,i=this,j={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!1,appear:null,load:null,placeholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"};return f&&(d!==f.failurelimit&&(f.failure_limit=f.failurelimit,delete f.failurelimit),d!==f.effectspeed&&(f.effect_speed=f.effectspeed,delete f.effectspeed),a.extend(j,f)),h=j.container===d||j.container===b?e:a(j.container),0===j.event.indexOf("scroll")&&h.bind(j.event,function(){return g()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,(c.attr("src")===d||c.attr("src")===!1)&&c.is("img")&&c.attr("src",j.placeholder),c.one("appear",function(){if(!this.loaded){if(j.appear){var d=i.length;j.appear.call(b,d,j)}a("<img />").bind("load",function(){var d=c.attr("data-"+j.data_attribute);c.hide(),c.is("img")?c.attr("src",d):c.css("background-image","url('"+d+"')"),c[j.effect](j.effect_speed),b.loaded=!0;var e=a.grep(i,function(a){return!a.loaded});if(i=a(e),j.load){var f=i.length;j.load.call(b,f,j)}}).attr("src",c.attr("data-"+j.data_attribute))}}),0!==j.event.indexOf("scroll")&&c.bind(j.event,function(){b.loaded||c.trigger("appear")})}),e.bind("resize",function(){g()}),/(?:iphone|ipod|ipad).*os 5/gi.test(navigator.appVersion)&&e.bind("pageshow",function(b){b.originalEvent&&b.originalEvent.persisted&&i.each(function(){a(this).trigger("appear")})}),a(c).ready(function(){g()}),this},a.belowthefold=function(c,f){var g;return g=f.container===d||f.container===b?(b.innerHeight?b.innerHeight:e.height())+e.scrollTop():a(f.container).offset().top+a(f.container).height(),g<=a(c).offset().top-f.threshold},a.rightoffold=function(c,f){var g;return g=f.container===d||f.container===b?e.width()+e.scrollLeft():a(f.container).offset().left+a(f.container).width(),g<=a(c).offset().left-f.threshold},a.abovethetop=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollTop():a(f.container).offset().top,g>=a(c).offset().top+f.threshold+a(c).height()},a.leftofbegin=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollLeft():a(f.container).offset().left,g>=a(c).offset().left+f.threshold+a(c).width()},a.inviewport=function(b,c){return!(a.rightoffold(b,c)||a.leftofbegin(b,c)||a.belowthefold(b,c)||a.abovethetop(b,c))},a.extend(a.expr[":"],{"below-the-fold":function(b){return a.belowthefold(b,{threshold:0})},"above-the-top":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-screen":function(b){return a.rightoffold(b,{threshold:0})},"left-of-screen":function(b){return!a.rightoffold(b,{threshold:0})},"in-viewport":function(b){return a.inviewport(b,{threshold:0})},"above-the-fold":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-fold":function(b){return a.rightoffold(b,{threshold:0})},"left-of-fold":function(b){return!a.rightoffold(b,{threshold:0})}})}(jQuery,window,document);
|
||||||
|
jQuery(function ($) {
|
||||||
|
$("img").lazyload({effect:"fadeIn",threshold:180});
|
||||||
|
});
|
1
assets/js/prettify.min.js
vendored
1
assets/js/prettify.min.js
vendored
File diff suppressed because one or more lines are too long
94
class/go.php
Normal file
94
class/go.php
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
$t_url = preg_replace('/^url=(.*)$/i','$1',$_SERVER["QUERY_STRING"]);
|
||||||
|
if(!empty($t_url)) {
|
||||||
|
preg_match('/(http|https):\/\//',$t_url,$matches);
|
||||||
|
if($matches){
|
||||||
|
$url=$t_url;
|
||||||
|
$title='页面加载中,请稍候...';
|
||||||
|
} else {
|
||||||
|
$title='加载中...';
|
||||||
|
echo "<script>setTimeout(function(){window.opener=null;window.close();}, 3000);</script>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta http-equiv="refresh" content="1;url='<?php echo $url;?>';">
|
||||||
|
<title><?php echo $title;?></title>
|
||||||
|
<style type="text/css">
|
||||||
|
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
font-size: 100%;
|
||||||
|
font: inherit;
|
||||||
|
vertical-align: baseline
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: #3498db;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loader-container {
|
||||||
|
width: 188px;
|
||||||
|
height: 188px;
|
||||||
|
color: white;
|
||||||
|
margin: 0 auto;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
margin-right: -50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
border: 5px solid #3498db;
|
||||||
|
border-radius: 50%;
|
||||||
|
-webkit-animation: borderScale 1s infinite ease-in-out;
|
||||||
|
animation: borderScale 1s infinite ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loadingText {
|
||||||
|
font-family: 'Raleway', sans-serif;
|
||||||
|
font-size: 1.4em;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
margin-right: -50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes borderScale {
|
||||||
|
0% {
|
||||||
|
border: 5px solid white;
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
border: 25px solid #3498db;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
border: 5px solid white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes borderScale {
|
||||||
|
0% {
|
||||||
|
border: 5px solid white;
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
border: 25px solid #3498db;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
border: 5px solid white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="loader-container"><p id="loadingText">页面加载中...</p></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -218,9 +218,9 @@ $gdk_options = [
|
||||||
'std' => '1'
|
'std' => '1'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => '外链自动GO跳转',
|
'name' => '外链GO跳转',
|
||||||
'desc' => '启用 【启用之后需要新建页面,模板选择Go跳转页面,别名为go】',
|
'desc' => '启用',
|
||||||
'id' => 'git_go',
|
'id' => 'gdk_link_go',
|
||||||
'type' => 'checkbox'
|
'type' => 'checkbox'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*Ajax操作
|
*Ajax操作文件
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function gdk_test_email() {
|
function gdk_test_email() {
|
||||||
$is_error = !wp_mail('donotreply@mywpku.com', '测试发信', 'WP 积木测试发信');
|
$is_error = !wp_mail('donotreply@mywpku.com', '测试发信', 'WP 积木测试发信');
|
||||||
if ($is_error) {
|
if ($is_error) {
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if (gdk_option('gdk_cdn')) add_action('wp_loaded', 'gdk_cdn_start');//七牛CDN
|
||||||
|
|
||||||
|
if (gdk_option('gdk_link_go')) add_filter('the_content','gdk_link_go',999);// 外链GO跳转
|
||||||
|
if (gdk_option('gdk_smtp')) add_action('phpmailer_init', 'gdk_smtp');//SMTP
|
||||||
|
if (gdk_option('git_cdn_water')) add_filter('the_content', 'cdn_water');//CDN水印
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//头像解决方案
|
//头像解决方案
|
||||||
function gdk_switch_get_avatar( $avatar ) {
|
function gdk_switch_get_avatar( $avatar ) {
|
||||||
switch (gdk_option('gdk_switch_get_avatar')) {
|
switch (gdk_option('gdk_switch_get_avatar')) {
|
||||||
|
@ -17,17 +26,44 @@ function gdk_switch_get_avatar( $avatar ) {
|
||||||
}
|
}
|
||||||
add_filter('get_avatar', 'gdk_switch_get_avatar');
|
add_filter('get_avatar', 'gdk_switch_get_avatar');
|
||||||
|
|
||||||
|
//懒加载
|
||||||
|
function lazyload($content){
|
||||||
|
if (!is_feed() || !is_robots()) {
|
||||||
|
$content = preg_replace('/<img(.+)src=[\'"]([^\'"]+)[\'"](.*)>/i', "<img\$1data-original=\"\$2\" \$3>\n<noscript>\$0</noscript>", $content);
|
||||||
|
}
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
add_filter('the_content', 'lazyload');
|
||||||
|
|
||||||
|
|
||||||
//fancybox图片灯箱效果
|
//fancybox图片灯箱效果
|
||||||
function fancybox($content) {
|
function fancybox($content) {
|
||||||
$pattern = "/<a(.*?)href=('|\")([^>]*).(bmp|gif|jpeg|jpg|png|swf)('|\")(.*?)>(.*?)<\\/a>/i";
|
$pattern = "/<a(.*?)href=('|\")([^>]*).(bmp|gif|jpeg|jpg|png|swf)('|\")(.*?)>(.*?)<\\/a>/i";
|
||||||
$replacement = '<a$1href=$2$3.$4$5 rel="box" class="fancybox"$6>$7</a>';
|
$replacement = '<a$1href=$2$3.$4$5 data-fancybox="gallery" rel="box" class="fancybox"$6>$7</a>';
|
||||||
$content = preg_replace($pattern, $replacement, $content);
|
$content = preg_replace($pattern, $replacement, $content);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
add_filter('the_content', 'fancybox');
|
add_filter('the_content', 'fancybox');
|
||||||
|
|
||||||
|
|
||||||
|
function gdk_link_go($content) {
|
||||||
|
if(file_exists(ABSPATH.'go.php')) {
|
||||||
|
$gourl = home_url().'/go.php';
|
||||||
|
} else {
|
||||||
|
$gourl = NC_BASE_URL.'class/go.php';
|
||||||
|
}
|
||||||
|
preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/',$content,$matches);
|
||||||
|
if($matches) {
|
||||||
|
foreach($matches[2] as $val) {
|
||||||
|
if(in_string($val,'://') && !in_string($val,home_url()) && !preg_match('/\.(jpg|jepg|png|ico|bmp|gif|tiff)/i',$val) && !preg_match('/(ed2k|thunder|Flashget|flashget|qqdl):\/\//i',$val)) {
|
||||||
|
$content=str_replace("href=\"$val\"", "href=\"".$gourl."?url=$val\" ",$content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
//邮箱SMTP设置
|
//邮箱SMTP设置
|
||||||
if (gdk_option('gdk_smtp')) {
|
|
||||||
function gdk_smtp( $phpmailer ) {
|
function gdk_smtp( $phpmailer ) {
|
||||||
$phpmailer->FromName = gdk_option('gdk_smtp_mail'); //邮箱地址
|
$phpmailer->FromName = gdk_option('gdk_smtp_mail'); //邮箱地址
|
||||||
$phpmailer->Host = gdk_option('gdk_smtp_host');//服务器地址
|
$phpmailer->Host = gdk_option('gdk_smtp_host');//服务器地址
|
||||||
|
@ -39,23 +75,20 @@ function gdk_smtp( $phpmailer ) {
|
||||||
$phpmailer->SMTPSecure = 'ssl';
|
$phpmailer->SMTPSecure = 'ssl';
|
||||||
$phpmailer->IsSMTP();
|
$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() {
|
||||||
function gdk_cdn_start() {
|
ob_start('gdk_cdn_replace');
|
||||||
ob_start('gdk_cdn_replace');
|
}
|
||||||
}
|
function gdk_cdn_replace($html) {
|
||||||
function gdk_cdn_replace($html) {
|
$local_host = home_url();//博客域名
|
||||||
$local_host = home_url(); //博客域名
|
$cdn_host = gdk_option('gdk_cdn_host');//cdn域名
|
||||||
$cdn_host = gdk_option('gdk_cdn_host'); //cdn域名
|
$cdn_exts = gdk_option('gdk_cdn_ext');//扩展名(使用|分隔)
|
||||||
$cdn_exts = gdk_option('gdk_cdn_ext'); //扩展名(使用|分隔)
|
$cdn_dirs = gdk_option('gdk_cdn_dir');//目录(使用|分隔)
|
||||||
$cdn_dirs = gdk_option('gdk_cdn_dir'); //目录(使用|分隔)
|
$cdn_dirs = str_replace('-', '\-', $cdn_dirs);
|
||||||
$cdn_dirs = str_replace('-', '\-', $cdn_dirs);
|
if ($cdn_dirs) {
|
||||||
if ($cdn_dirs) {
|
$regex = '/' . str_replace('/', '\/', $local_host) . '\/((' . $cdn_dirs . ')\/[^\s\?\\\'\"\;\>\<]{1,}.(' . $cdn_exts . '))([\"\\\'\s\?]{1})/';
|
||||||
$regex = '/' . str_replace('/', '\/', $local_host) . '\/((' . $cdn_dirs . ')\/[^\s\?\\\'\"\;\>\<]{1,}.(' . $cdn_exts . '))([\"\\\'\s\?]{1})/';
|
|
||||||
$html = preg_replace($regex, $cdn_host . '/$1$4', $html);
|
$html = preg_replace($regex, $cdn_host . '/$1$4', $html);
|
||||||
} else {
|
} else {
|
||||||
$regex = '/' . str_replace('/', '\/', $local_host) . '\/([^\s\?\\\'\"\;\>\<]{1,}.(' . $cdn_exts . '))([\"\\\'\s\?]{1})/';
|
$regex = '/' . str_replace('/', '\/', $local_host) . '\/([^\s\?\\\'\"\;\>\<]{1,}.(' . $cdn_exts . '))([\"\\\'\s\?]{1})/';
|
||||||
|
@ -63,21 +96,20 @@ if (gdk_option('gdk_cdn')) {
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//CDN水印
|
//CDN水印
|
||||||
if (gdk_option('git_cdn_water')) {
|
function cdn_water($content) {
|
||||||
function cdn_water($content){
|
if (get_post_type() == 'post') {
|
||||||
if (get_post_type() == 'post') {
|
$pattern = "/<img(.*?)src=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
|
||||||
$pattern = "/<img(.*?)src=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
|
$replacement = '<img$1src=$2$3.$4!water.jpg$5$6>';
|
||||||
$replacement = '<img$1src=$2$3.$4!water.jpg$5$6>';
|
$content = preg_replace($pattern, $replacement, $content);
|
||||||
$content = preg_replace($pattern, $replacement, $content);
|
}
|
||||||
}
|
return $content;
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter('the_content', 'cdn_water');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//自动替换媒体库图片的域名
|
//自动替换媒体库图片的域名
|
||||||
if (is_admin() && gdk_option('gdk_cdn')) {
|
if (is_admin() && gdk_option('gdk_cdn')) {
|
||||||
function attachment_replace($text) {
|
function attachment_replace($text) {
|
||||||
|
|
|
@ -17,6 +17,29 @@ add_filter('use_block_editor_for_post', '__return_false');
|
||||||
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
|
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_filter('user_can_richedit','__return_false');
|
||||||
|
|
||||||
|
//禁用响应式图片
|
||||||
|
function msiw(){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
add_filter('max_srcset_image_width', 'msiw');
|
||||||
|
|
||||||
|
//移除默认的图片宽度以及高度
|
||||||
|
function remove_wps_width($html) {
|
||||||
|
$html = preg_replace('/(width|height)=\"\d*\"\s/', "", $html);
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
add_filter('post_thumbnail_html', 'remove_wps_width', 10);
|
||||||
|
add_filter('image_send_to_editor', 'remove_wps_width', 10);
|
||||||
|
|
||||||
|
//取消后台登陆错误的抖动提示
|
||||||
|
function git_wps_login_error() {
|
||||||
|
remove_action('login_head', 'wp_shake_js', 12);
|
||||||
|
}
|
||||||
|
add_action('login_head', 'git_wps_login_error');
|
||||||
|
|
||||||
|
|
||||||
// 友情链接扩展
|
// 友情链接扩展
|
||||||
add_filter('pre_option_link_manager_enabled', '__return_true');
|
add_filter('pre_option_link_manager_enabled', '__return_true');
|
||||||
|
|
||||||
|
@ -72,6 +95,22 @@ if (gdk_option('gdk_diasble_wp_update')) {
|
||||||
remove_filter( 'the_content', 'wpautop' );
|
remove_filter( 'the_content', 'wpautop' );
|
||||||
add_filter( 'the_content', 'wpautop' , 12);
|
add_filter( 'the_content', 'wpautop' , 12);
|
||||||
|
|
||||||
|
// 禁止后台加载谷歌字体
|
||||||
|
function gdk_remove_open_sans_from_wp_core() {
|
||||||
|
wp_deregister_style( 'open-sans' );
|
||||||
|
wp_register_style( 'open-sans', false );
|
||||||
|
wp_enqueue_style('open-sans','');
|
||||||
|
}
|
||||||
|
add_action( 'init', 'gdk_remove_open_sans_from_wp_core' );
|
||||||
|
|
||||||
|
// 禁止dns-prefetch
|
||||||
|
function remove_dns_prefetch( $hints, $relation_type ) {
|
||||||
|
if ( 'dns-prefetch' === $relation_type ) {
|
||||||
|
return array_diff( wp_dependencies_unique_hosts(), $hints );
|
||||||
|
}
|
||||||
|
return $hints;
|
||||||
|
}
|
||||||
|
add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
|
||||||
|
|
||||||
//强制阻止WordPress代码转义
|
//强制阻止WordPress代码转义
|
||||||
function git_esc_html($content) {
|
function git_esc_html($content) {
|
||||||
|
@ -176,45 +215,39 @@ function gdk_page_permalink() {
|
||||||
add_action('init', 'gdk_page_permalink', -1);
|
add_action('init', 'gdk_page_permalink', -1);
|
||||||
|
|
||||||
|
|
||||||
//中文文件重命名
|
//文件自动重命名
|
||||||
if(gdk_option('gdk_upload_rename')){
|
if(gdk_option('gdk_upload_rename')) {
|
||||||
add_filter('wp_handle_upload_prefilter', 'gdk_upload_rename' );
|
function gdk_upload_rename( $file ) {
|
||||||
function gdk_upload_rename( $file ){
|
$info = pathinfo($file['name']);
|
||||||
$info = pathinfo($file['name']);
|
$ext = $info['extension'];
|
||||||
$ext = $info['extension'];
|
$ignore_exts = ['zip', 'rar', '7z'];
|
||||||
$ignore_exts = ['zip', 'rar', '7z'];//被忽略的文件格式
|
//被忽略的文件格式
|
||||||
|
if (!in_array($ext, $ignore_exts)) {
|
||||||
if (!in_array($ext, $ignore_exts)) {
|
$filedate = date('YmdHis').mt_rand(100, 999);
|
||||||
$filedate = date('YmdHis').mt_rand(100, 999);
|
$file['name'] = $filedate.'.'.$ext;
|
||||||
$file['name'] = $filedate.'.'.$ext;
|
}
|
||||||
}
|
return $file;
|
||||||
return $file;
|
}
|
||||||
}
|
add_filter('wp_handle_upload_prefilter', 'gdk_upload_rename' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 搜索结果为1时候自动跳转到对应页面
|
// 搜索结果为1时候自动跳转到对应页面
|
||||||
if ( ! function_exists( 'gdk_redirect_single_search_result' ) ) {
|
|
||||||
function gdk_redirect_single_search_result() {
|
function gdk_redirect_single_search_result() {
|
||||||
if ( is_search() ) {
|
if ( is_search() ) {
|
||||||
global $wp_query;
|
global $wp_query;
|
||||||
if ($wp_query->post_count == 1) {
|
if ($wp_query->post_count == 1) {
|
||||||
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
|
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
|
||||||
exit();
|
exit();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('template_redirect', 'gdk_redirect_single_search_result');
|
add_action('template_redirect', 'gdk_redirect_single_search_result');
|
||||||
|
|
||||||
|
|
||||||
//搜索链接伪静态
|
//搜索链接伪静态
|
||||||
if ( ! function_exists( 'gdk_redirect_search' ) ) {
|
function gdk_redirect_search() {
|
||||||
function gdk_redirect_search() {
|
if ( is_search() && ! empty( $_GET['s'] ) ) {
|
||||||
if ( is_search() && ! empty( $_GET['s'] ) ) {
|
wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
|
||||||
wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
|
exit();
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('template_redirect', 'gdk_redirect_search' );
|
add_action('template_redirect', 'gdk_redirect_search' );
|
||||||
|
@ -225,9 +258,6 @@ add_filter( 'widget_text', 'shortcode_unautop' );
|
||||||
add_filter( 'widget_text', 'do_shortcode' );
|
add_filter( 'widget_text', 'do_shortcode' );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//替换后台默认的底部文字内容
|
//替换后台默认的底部文字内容
|
||||||
function gdk_replace_footer_admin() {
|
function gdk_replace_footer_admin() {
|
||||||
$result = apply_filters('gdk_filter_admin_footer_text', '由GDK插件提供底层支持');
|
$result = apply_filters('gdk_filter_admin_footer_text', '由GDK插件提供底层支持');
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
define('DISALLOW_FILE_MODS',true);
|
define('DISALLOW_FILE_MODS',true);
|
||||||
|
|
||||||
//阻止乱七八糟的请求
|
//阻止乱七八糟的请求
|
||||||
if(gdk_option('gdk_block_requst')){
|
if(gdk_option('gdk_block_requst')) add_action( 'wp', 'gdk_prevent_script_injection' );
|
||||||
|
|
||||||
|
|
||||||
function gdk_prevent_script_injection() {
|
function gdk_prevent_script_injection() {
|
||||||
global $user_ID;
|
global $user_ID;
|
||||||
if( ! current_user_can( 'level_10' )) {
|
if( ! current_user_can( 'level_10' )) {
|
||||||
|
@ -27,10 +29,10 @@ if(gdk_option('gdk_block_requst')){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action( 'wp', 'gdk_prevent_script_injection' );
|
|
||||||
}
|
|
||||||
|
|
||||||
if(gdk_option('gdk_lock_login')){
|
|
||||||
|
|
||||||
|
|
||||||
if ( ! class_exists( 'GDK_Limit_Login_Attempts' ) ) {
|
if ( ! class_exists( 'GDK_Limit_Login_Attempts' ) ) {
|
||||||
class GDK_Limit_Login_Attempts {
|
class GDK_Limit_Login_Attempts {
|
||||||
private $failed_login_limit;
|
private $failed_login_limit;
|
||||||
|
@ -104,7 +106,9 @@ if(gdk_option('gdk_lock_login')){
|
||||||
$config = [
|
$config = [
|
||||||
'failed_login_limit' => gdk_option('gdk_failed_login_limit'), // 登录失败的次数限制
|
'failed_login_limit' => gdk_option('gdk_failed_login_limit'), // 登录失败的次数限制
|
||||||
'lockout_duration' => gdk_option('gdk_lockout_duration'), // 暂停登陆时间
|
'lockout_duration' => gdk_option('gdk_lockout_duration'), // 暂停登陆时间
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if(gdk_option('gdk_lock_login')){
|
||||||
new GDK_Limit_Login_Attempts($config);
|
new GDK_Limit_Login_Attempts($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ if(gdk_option('gdk_nofollow')){
|
||||||
{
|
{
|
||||||
global $post;
|
global $post;
|
||||||
$bd_submit_site = get_bloginfo('url');
|
$bd_submit_site = get_bloginfo('url');
|
||||||
$bd_submit_token = $others_seo['baidu_submit_key'];
|
$bd_submit_token = gdk_option('gdk_baidu_api');
|
||||||
if (empty($post_ID) || empty($bd_submit_site) || empty($bd_submit_token)) {
|
if (empty($post_ID) || empty($bd_submit_site) || empty($bd_submit_token)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -307,22 +307,6 @@ if(gdk_option('gdk_seo_img')) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//给外部链接加上跳转
|
|
||||||
|
|
||||||
function git_go_url($content){
|
|
||||||
preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/', $content, $matches);
|
|
||||||
if ($matches && !is_page('about')) {
|
|
||||||
foreach ($matches[2] as $val) {
|
|
||||||
if (strpos($val, '://') !== false && strpos($val, home_url()) === false && !preg_match('/\\.(jpg|jpeg|png|ico|bmp|gif|tiff)/i', $val)) {
|
|
||||||
$content = str_replace("href=\"{$val}\"", "href=\"" . get_permalink(git_page_id('go')) . "?url={$val}\" ", $content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
add_filter('the_content', 'git_go_url', 999);
|
|
||||||
|
|
||||||
|
|
||||||
//关键字
|
//关键字
|
||||||
function deel_keywords() {
|
function deel_keywords() {
|
||||||
global $s, $post;
|
global $s, $post;
|
||||||
|
|
Loading…
Reference in a new issue