V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  geekzu  ›  全部回复第 42 页 / 共 50 页
回复总数  985
1 ... 34  35  36  37  38  39  40  41  42  43 ... 50  
2015-02-21 19:47:52 +08:00
回复了 ivmm 创建的主题 问与答 Functions.php 的分与享
以上是本人博客的functions.php的一部分,希望能对大家有所帮助
本人博客: http://www.geekzu.cn/
公共加速服务: http://cdn.geekzu.org/
2015-02-21 19:46:05 +08:00
回复了 ivmm 创建的主题 问与答 Functions.php 的分与享
//后台字体切换雅黑
function geekzu_admin_font(){
echo'<style>*{font-family:"Microsoft YaHei";}</style>';
}
add_action('admin_head', 'geekzu_admin_font');

//友情链接
add_filter( 'pre_option_link_manager_enabled', '__return_true' );

//判断当前文章是否被百度收录,若没有被收录则可点击提交至百度,加速收录!(此插件在文章页面仅管理员可见)
function d4v($url){
$url='http://www.baidu.com/s?wd='.$url;
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$rs=curl_exec($curl);
curl_close($curl);
if(!strpos($rs,'没有找到')){
return 1;
}else{
return 0;
}
}
add_filter( 'the_content', 'baidu_submit' );
function baidu_submit( $content ) {
if( is_single() && current_user_can( 'manage_options') )
if(d4v(get_permalink()) == 1)
$content="<p align=right>本文百度已收录!</p>".$content;
else
$content="<p align=right><b><a style=color:red target=_blank href=http://zhanzhang.baidu.com/sitesubmit/index?sitename=".get_permalink().">百度未收录!点击此处提交</a></b>(仅管理员可见)</p>".$content;
return $content;
}

//防采集
$ua = $_SERVER['HTTP_USER_AGENT'];
$now_ua = array('FeedDemon ','ZmEu','Indy Library','oBot','jaunty'); //将恶意USER_AGENT存入数组
if(!$ua) { //禁止空USER_AGENT,dedecms等主流采集程序都是空USER_AGENT,部分sql注入工具也是空USER_AGENT
header("Content-type: text/html; charset=utf-8");
wp_die('请勿采集,因为采集的站长木JJ! www.geekzu.cn');
}else{
foreach($now_ua as $value )
if(eregi($value,$ua)) {
header("Content-type: text/html; charset=utf-8");
wp_die('请勿采集本站,因为采集的站长木JJ!www.geekzu.cn');
}
}

//移除头部多余信息
remove_action('wp_head','wp_generator'); //禁止在head泄露wordpress版本号
remove_action('wp_head','rsd_link'); //移除head中的rel="EditURI"
remove_action('wp_head','wlwmanifest_link'); //移除head中的rel="wlwmanifest"
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 ); //rel=shortlink
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );//rel='prev' rel='next'
remove_action('wp_head', 'rel_canonical' );//rel='canonical'

//移除wp近期评论加载样式
function remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head' , array( $wp_widget_factory -> widgets['WP_Widget_Recent_Comments'] , 'recent_comments_style' ) );
}
add_action( 'widgets_init' , 'remove_recent_comments_style' );

// 开启支持 文章形式
add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

//头像中转极客族公共加速服务 解决被墙问题
function get_ssl_avatar($avatar) {
$avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&amp;.*/','<img class="avatar avatar-$2" src="//sdn.geekzu.org/avatar/$1?s=$2" alt="" width="$2" height="$2" />',$avatar);
return $avatar;
}
add_filter('get_avatar', 'get_ssl_avatar');

//禁用半角符号自动转换为全角
remove_filter('the_content', 'wptexturize');

// 禁止全英文和日文评论
function GeekZu_comment_post( $incoming_comment ) {
$pattern = '/[一-龥]/u';
$jpattern ='/[ぁ-ん]+|[ァ-ヴ]+/u';
if(!preg_match($pattern, $incoming_comment['comment_content'])) {
err( "评论请用天朝语言 Comments must include the Chinese(like“你好”)" );
}
if(preg_match($jpattern, $incoming_comment['comment_content'])){
err( "日本人滚一边玩儿蛋去!Japanese Get out!日本語出て行け!" );
}
return( $incoming_comment );
}
add_filter('preprocess_comment', 'GeekZu_comment_post');

//禁用Open Sans
class Disable_Google_Fonts {
public function __construct() {
add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 );
}
public function disable_open_sans( $translations, $text, $context, $domain ) {
if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
}
$disable_google_fonts = new Disable_Google_Fonts;
add_filter('content_save_pre', 'auto_save_image');
function auto_save_image($content) {
$upload_path = '';
$upload_url_path = get_bloginfo('url');
2015-02-21 19:38:45 +08:00
回复了 extreme 创建的主题 问与答 使用 KVM 虚拟化,磁盘用 Virtio,这 INPUT/OUTPUT 性能如何?
@66CCFF 技术帝,认识好久了,蛮靠谱,并不是所有OneMan都不靠谱的哟~
2015-02-19 20:43:20 +08:00
回复了 cokebar 创建的主题 NGINX 从 apache 迁移到 nginx 需要注意些什么?
@phoenixlzx nginx不带
2015-02-19 11:29:22 +08:00
回复了 cokebar 创建的主题 NGINX 从 apache 迁移到 nginx 需要注意些什么?
首先是Rewrite规则
其次,记得编译Nginx的时候就编译进去SSL和SPDY
另外,如果条件允许,建议前端Nginx+后端Apache,WP仍然跑在Apache上
2015-02-18 13:34:28 +08:00
回复了 guolei1998 创建的主题 问与答 初创 APP 部署到哪里好?国内各种云?国外 VPS? IDC?
@imlonghao 醉醉哒,各种问题
2015-02-18 13:14:05 +08:00
回复了 oott123 创建的主题 程序员 SourceForge 把一封通知邮件显式地群发给了 400 多个邮件地址
也是醉了,azure cn之前某某次邮件也是这样
如果是某vps商,或者是某个机房比较慢,那就不能说是电信国际出口问题
看需求,流量特别大的话肯定要加CDN,那时候免费的就别考虑了
你说的那三家,免费版只能糊弄糊弄人
2015-02-16 23:16:58 +08:00
回复了 liuchen9586 创建的主题 服务器 有没有仁兄知道 MicroSoft Azure 香港怎么注册?
我是进来想说8楼的下半句话的
2015-02-16 15:20:13 +08:00
回复了 n37r06u3 创建的主题 问与答 求推荐香港或者 日本的 php 虚拟空间?
@n37r06u3 要是这么说的话,HE.net 技术也很差咯?
2015-02-16 15:19:12 +08:00
回复了 n37r06u3 创建的主题 问与答 求推荐香港或者 日本的 php 虚拟空间?
可以来看看 http://www.geekzu.cn/archives/tnc.html
澳门公司,机器托管在香港,另外有韩国KT主机
价格很公道,客服人好~
2015-02-16 15:08:36 +08:00
回复了 moonkiller 创建的主题 问与答 nexus4 啪唧拍在地上,,,碎了,还有拯救价值吗?
你确定这只是掉到地上了?从楼上掉下来的?
2015-02-14 16:20:56 +08:00
回复了 holinhot 创建的主题 SSL 现在的沃通 ssl 发可怕
他家老早就收购了根,不过兼容性不好,所以去年这样弄了startssl的交叉根增强兼容性,虽然我不太喜欢这家,但请大家别乱说乱黑好不好
2015-02-14 15:45:49 +08:00
回复了 zhangming 创建的主题 SSL 某国内 CA 忽悠又出新花样了:使用国外 CA 违法
@bigboyq
@dndx
Wosign早期收购了USERTrust的根CA,但是兼容性不好,所以用了Startssl的交叉根
2015-02-14 15:42:03 +08:00
回复了 spencerqiu 创建的主题 宽带症候群 17CE 我这边从早上开始一直 500 诶
他们的问题
BGP的话100M肯定贵
单线的话,可以找找一些二三线城市的机房,价格比一线城市便宜很多
@youxiachai 不止双线吧
2015-02-13 15:08:29 +08:00
回复了 GreenJoson 创建的主题 问与答 apache2 开了 phpfcgid,原来 Mysql 就是这样被挤掉的~
1 ... 34  35  36  37  38  39  40  41  42  43 ... 50  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1316 人在线   最高记录 6547   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 54ms · UTC 17:48 · PVG 01:48 · LAX 10:48 · JFK 13:48
Developed with CodeLauncher
♥ Do have faith in what you're doing.