This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. 检查你的服务器版本是否支持inotify机制,如果输出 CONFIG_INOTIFY_USER=y 则表示支持 | |
$ grep INOTIFY_USER /boot/config-$(uname -r) | |
2. 编译安装inofity-tools工具包 | |
$ wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz | |
$ tar -zxvf inotify-tools-3.14.tar.gz | |
$ ./configure --prefix=/usr --libdir=/lib64 && make && make install | |
3. 脚本 | |
#!/bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$zip = new \ZipArchive(); | |
if ( $zip->open( $zip_name, \ZipArchive::CREATE ) !== true ) { | |
wp_die( 'Can not open file, or file creation failed' ); | |
} | |
foreach ( $files_path as $path ) { | |
if ( file_exists( $path ) ) { | |
$zip->addFile( $path, basename( $path ) ); | |
} | |
} | |
$zip->close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################ | |
## 安装Nginx | |
############################ | |
首先安装必要的库(nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库)。选定/usr/local为安装目录,以下具体版本号根据实际改变。 | |
1.安装PCRE库 | |
$ cd /usr/local/ | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz | |
$ tar -zxvf pcre-8.38.tar.gz | |
$ cd pcre-8.38 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_cache_path /var/nginx/cache/aws/trueniu levels=2:2:2 use_temp_path=off keys_zone=aws_3:500m inactive=30d max_size=10g; | |
server { | |
listen 80; | |
server_name trueniu.com www.trueniu.com; | |
if ( $scheme = http ) { | |
return 301 https://www.trueniu.com$request_uri; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The pagenation | |
* @info 每页显示数量设置:设置->阅读->博客页面至多显示 | |
*/ | |
the_posts_pagination( array( | |
'prev_text' => '«', | |
'next_text' => '»', | |
) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The posts | |
*/ | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
$post_news = new WP_Query(array( | |
'post_type' => 'post', | |
'category_name' => 'news', | |
'posts_per_page' => 1, | |
'post_status' => 'publish', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Delete System Jquery | |
function delete_jquery() { | |
if ( is_admin() ) return; | |
wp_deregister_script('jquery'); | |
} | |
add_action('wp_enqueue_scripts', 'delete_jquery'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Making jQuery Google API | |
function modify_jquery() { | |
if (!is_admin()) { | |
// comment out the next two lines to load the local copy of jQuery | |
wp_deregister_script('jquery'); | |
} | |
} | |
add_action('init', 'modify_jquery'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
官方文档:https://developers.google.com/maps/documentation/javascript/interaction?hl=zh-cn | |
<script> | |
/** | |
* Google Map | |
*/ | |
function initMap() { | |
var uluru = {lat: 34.318877, lng: 108.948488}; | |
var map = new google.maps.Map(document.getElementById('c_map'), { | |
center: uluru, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* robots.txt | |
* | |
* @param string $output The output of the robots.txt file | |
* @return string $public If the site is public facing | |
*/ | |
function robots_mod( $output, $public ) { | |
$output .= "Disallow: /wp-includes/\n"; | |
$output .= "Disallow: /wp-content/plugins/\n"; | |
$output .= "Allow: /\n"; |