Skip to content

Instantly share code, notes, and snippets.

@bewho
bewho / index-with-redis.php
Created September 6, 2017 07:32 — forked from JimWestergren/index-with-redis.php
Redis as a Frontend Cache for WordPress
<?php
/*
Author: Jim Westergren & Jeedo Aquino
File: index-with-redis.php
Updated: 2012-10-25
This is a redis caching system for wordpress.
see more here: www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/
@bewho
bewho / functions.php
Created September 7, 2017 09:35
dequeue/deregister JS and CSS on NO Checkout pages
//* Enqueue scripts and styles
//* https://wordpress.org/support/topic/how-to-dequeuederegister-js-and-css-on-no-checkout-pages/
add_action( 'wp_enqueue_scripts', 'dots_disable_woocommerce_loading_css_js' );
function dots_disable_woocommerce_loading_css_js() {
// Check if WooCommerce plugin is active
if( function_exists( 'is_woocommerce' ) ){
// Check if it’s any of WooCommerce page
@bewho
bewho / functions.php
Created September 7, 2017 09:36
Stop Loading WooCommerce .js (javascript) and .css files on all WordPress Posts/Pages
//* http://crunchify.com/how-to-stop-loading-woocommerce-js-javascript-and-css-files-on-all-wordpress-postspages/
//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'crunchify_disable_woocommerce_loading_css_js' );
function crunchify_disable_woocommerce_loading_css_js() {
// Check if WooCommerce plugin is active
if( function_exists( 'is_woocommerce' ) ){
@bewho
bewho / functions.php
Created September 12, 2017 10:04
Add nofollow attribute to category specific links
//Adding this snippet to the functions.php of your wordpress theme will add the nofollow attribute to category specific links within the_content.
function nofollow_cat_posts($text) {
global $post;
if( in_category(1) ) { // SET CATEGORY ID HERE
$text = stripslashes(wp_rel_nofollow($text));
}
return $text;
}
add_filter('the_content', 'nofollow_cat_posts');
@bewho
bewho / gist:c66d2724f0cba8c141bf7fdc90369ff1
Created October 11, 2017 08:06 — forked from designbuildtest/gist:584efcc0405c5ef4d37a
Disable Google Open Sans font in the Admin area
/**
* Disable Google Open Sans font in the Admin area . Implementation idea from ... https://wordpress.org/plugins/disable-google-fonts/
*/
function myplugin_admin_area_minus_open_sans_style() {
// Remove Open Sans. Doesn't work :-(
// See 'Disable_Google_Fonts' class below as an alternative.
wp_dequeue_style('open-sans-css');
// Add custom style definitions to compensate for the removal of Open Sans
wp_enqueue_style('myplugin-admin-minus-open-sans', plugins_url( 'css/admin-minus-open-sans.css', __FILE__ ), false, '1.0.0', 'all');
@bewho
bewho / functions.php
Created November 13, 2017 13:43
html压缩
/*-----------------------------------------------------------------------------------*/
/* html minify snippet class for wordpress (important!)
/*-----------------------------------------------------------------------------------*/
class WP_HTML_Compression {
protected $compress_css = true;
protected $compress_js = true;
protected $info_comment = true;
protected $remove_comments = true;
@bewho
bewho / functions.php
Last active November 13, 2017 14:21
后台增加允许复制文章和页面的选项
/*-----------------------------------------------------------------------------------*/
/* 后台增加允许复制文章和页面的选项 Duplicate Posts and Pages
/*-----------------------------------------------------------------------------------*/
/*
* Function creates post duplicate as a draft and redirects then to the edit post screen
*/
function rd_duplicate_post_as_draft(){
global $wpdb;
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
@bewho
bewho / markdown.css
Created November 29, 2017 02:33 — forked from imjasonh/markdown.css
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@bewho
bewho / nginx.conf
Created December 2, 2017 14:17 — forked from MaherSaif/nginx.conf
### Nginx main config: Tweaks & SSL settings (without the FastCGI-cache config parts)
### Nginx main config: Tweaks & SSL settings (without the FastCGI-cache config parts)
## http {} block:
http {
# [...]
server_tokens off;
reset_timedout_connection on;
@bewho
bewho / wp-fix-enqueued-script-style-https.php
Created December 8, 2017 03:03 — forked from bueltge/wp-fix-enqueued-script-style-https.php
Fix some badly enqueued scripts with no sense of HTTPS for the back end only.
<?php
/**
* Plugin Name: https Fix for enqueue scripts/styles
*/
// Fix some badly enqueued scripts with no sense of HTTPS for the back end only.
// Kudos to http://snippets.webaware.com.au/snippets/cleaning-up-wordpress-plugin-script-and-stylesheet-loads-over-ssl/
add_action( 'wp_print_scripts', 'fb_enqueueScriptsFix', 100 );
add_action( 'wp_print_styles', 'fb_enqueueStylesFix', 100 );