Skip to content

Instantly share code, notes, and snippets.

@bewho
bewho / cache-nav-menu.php
Created December 13, 2017 16:32 — forked from lukecav/cache-nav-menu.php
Cache Nav Menus
<?php
/*
* Plugin Name: Cache Nav Menus
* Description: Allows Core Nav Menus to be cached using WP.com's Advanced Post Cache.
* Author: Automattic
*/
function cache_nav_menu_parse_query( &$query ) {
if ( !isset( $query->query_vars['post_type'] ) || 'nav_menu_item' !== $query->query_vars['post_type'] ) {
@bewho
bewho / functions.php
Created December 13, 2017 16:28 — forked from lukecav/functions.php
Remove footer generated by W3 Total Cache
function remove_footer(){
// Disable W3TC footer comment for everyone but Admins (single site & network mode)
if(!current_user_can('activate_plugins')){
add_filter('w3tc_can_print_comment','__return_false',10,1);
}
// Disable W3TC footer comment for all users
//add_filter('w3tc_can_print_comment','__return_false',10,1);
}
add_action('plugins_loaded','remove_footer');
@bewho
bewho / functions.php
Created December 13, 2017 16:24 — forked from lukecav/functions.php
Disable zoom-on-hover effect on product images in WooCommerce 3.0
add_action( 'wp_enqueue_scripts', 'jk_disable_magnification' );
function jk_disable_magnification() {
wp_dequeue_script( 'zoom' );
}
@bewho
bewho / mime.types
Created December 13, 2017 16:21 — forked from lukecav/mime.types
NGNIX Mime Types
types {
application/atom+xml atom;
application/dart dart;
application/gzip gz;
application/java-archive jar war ear;
application/javascript js jsonp;
application/json json;
application/owl+xml owl owx;
application/pdf pdf;
application/postscript ai eps ps;
@bewho
bewho / wordpress.conf
Created December 13, 2017 16:18 — forked from lukecav/wordpress.conf
NGNIX use state cache itmes while updating in the background
#Use stale cache items while updating in the background
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_cache_lock on;
fastcgi_cache_lock_timeout 5s;
@bewho
bewho / my.cnf
Created December 13, 2017 16:08 — forked from lukecav/my.cnf
MariaDB - Performance changes
optimizer_switch='mrr=on'
optimizer_switch='mrr_sort_keys=on'
optimizer_switch='mrr_cost_based=off'
mrr_buffer_size=32M
optimizer_switch='join_cache_incremental=on'
optimizer_switch='join_cache_hashed=on'
optimizer_switch='join_cache_bka=on'
join_cache_level=4
join_buffer_size=32M
@bewho
bewho / toc.php
Created December 13, 2017 11:47
wordpress Table of Contents
/*-----------------------------------------------------------------------------------*/
/* Table of Contents - Shortcode */
/*-----------------------------------------------------------------------------------*/
if ( ! function_exists( 'woo_shortcode_table_of_contents' ) ) {
function woo_shortcode_table_of_contents ( $atts, $content = null ) {
global $post;
$defaults = array();
$atts = shortcode_atts( $defaults, $atts );
@bewho
bewho / ngnix.config
Created December 8, 2017 07:08 — forked from lukecav/ngnix.config
Gzip enabled in NGNIX
# Enable gzip compression.
# Default: off
gzip on;
# Enable compression both for HTTP/1.0 and HTTP/1.1.
gzip_http_version 1.1;
# Compression level (1-9).
# 5 is a perfect compromise between size and CPU usage, offering about
# 75% reduction for most ASCII files (almost identical to level 9).
@bewho
bewho / functions.php
Created December 8, 2017 03:54 — forked from lukecav/functions.php
Kill Gutenberg in WordPress
function kill_gutenberg_post_type( $is_enabled, $post_type ) {
if ( ‘post’ === $post_type || ‘page’ === $post_type ) {
return false; //==> add_action( ‘admin_print_scripts-edit.php’,…) ==> gutenberg_replace_default_add_new_button is disabled
}
return $is_enabled;
}
add_filter( ‘gutenberg_can_edit_post_type’, ‘kill_gutenberg_post_type’, 10, 2 ); //gutenberg_add_edit_link_for_post_type
function kill_gutenberg_modify_add_new_button_url( $url, $path ) {
@bewho
bewho / functions.php
Created December 8, 2017 03:53 — forked from lukecav/functions.php
Stop WordPress sending anything but essential data during the update check
function wp_update_privacy( $query ) {
unset($query['php']);
unset($query['mysql']);
unset($query['local_package']);
unset($query['blogs']);
unset($query['users']);
unset($query['multisite_enabled']);
unset($query['initial_db_version']);
return $query;
}