Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* WordPress中文版 自动下载安装脚本
* v3.0.1
*
* 作者:沙渺 http://shamiao.com
* 脚本主页:http://shamiao.com/wp-downunzip
**/
define('SCRIPT_VERSION', '3.0.1');
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
<?php
/* wp_title() expand
https://gist.github.com/mcatm/5113723
---------------------------------- */
function wp_title_expand($str = null) {
global $page, $paged;
$str .= (!$str) ? get_bloginfo('name') : ' - '.get_bloginfo('name');
<?php
/* Remove autolinks in comments
http://blog.wpjam.com/m/remove-autolinks-in-comments/
-------------------------------------------------- */
remove_filter('comment_text', 'make_clickable', 9);
?>
<?php
/* Remove the width and height attributes from wp image uploader.
http://blog.wpjam.com/m/how-to-remove-the-width-and-height-attributes-from-wp-image-uploader/
------------------------------------------------------------------------------------------ */
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
<?php
/* Redirect to post if search results only returns one post.
http://blog.wpjam.com/m/redirect-to-post-if-search-results-only-returns-one-post/
------------------------------------------------------------------------------ */
add_action('template_redirect', 'search_redirect_post');
function search_redirect_post() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1) {
<?php
/* Apply Custom CSS to Specific Browsers
http://wpforce.com/custom-css-specific-browsers/
--------------------------------------------- */
add_filter('body_class','browser_body_class');
function browser_body_class($classes) {
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
<?php
/* Change the WordPress Default Permalinks for Pages
http://wpforce.com/change-wordpress-page-permalinks/
------------------------------------------------- */
add_action( 'init', 'custom_page_rules' );
function custom_page_rules() {
global $wp_rewrite;
$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html';
}
<?php
/* Add a default comment icon in Wordpress
------------------------------------ */
function add_default_avatar($avatar_defaults)
{
$icon = get_bloginfo('template_directory') . '/images/default-comment-icon.png';
$avatar_defaults[$icon] = 'Custom Default';
return $avatar_defaults;
}
<?php
/* Add the anchor link button back to the TinyMCE Editor in WordPress
--------------------------------------------------------------- */
function sennza_add_more_buttons( $buttons ) {
$buttons[] = 'anchor';
return $buttons;
}
add_filter( 'mce_buttons', 'sennza_mce_buttons' );
?>