Skip to content

Instantly share code, notes, and snippets.

@bewho
bewho / parallelize.php
Created May 5, 2017 07:42 — forked from leowebguy/parallelize.php
Parallelize downloads across hostnames for WordPress. Useful to boost static resources load speed on websites. Recommended by GTmetrix, Pingdom, Google Speed Insights, and others.
<?php
/******
Parallelize downloads across hostnames for WordPress.
Useful to boost static resources load speed on websites.
Recommended by GTmetrix, Pingdom, Google Speed Insights, and others.
See full post > https://medium.com/p/32e9dc2fec0c
In order to work properly, all subdomains/hostnames MUST have the same structure/path. Ex:
http://mydomain.com/wp-content/uploads/2015/11/myimage.jpg
@bewho
bewho / functions.php
Created May 13, 2017 16:11 — forked from DevinWalker/functions.php
WooCommerce force SSL entire shop
<?php
/*
Author: Doug Edgington
Description: modified version of Woocomemrce SSL functionality, forces ssl on Woocommerce pages and two additional custom pages
*/
function dee_ssl_template_redirect() {
if ( ! is_ssl() ) {
if ( is_checkout() || is_account_page() || is_woocommerce() ) {
@bewho
bewho / Index.md
Created May 14, 2017 02:06 — forked from randgroupmrkt/Index.md
Wordpress Performance Tweaks
@bewho
bewho / gist:dbaaa3c08bb016aea1c1f4123e1aa072
Created May 14, 2017 02:19 — forked from tylerdigital/gist:c127ae0c33f456b1f6c6
Fix WordPress Hierarchical Post Performance Issue
add_action( 'pre_get_posts', array( $this, 'fix_hierarchy_performance_issue' ) );
function fix_hierarchy_performance_issue( $query ) {
if ( $query->query['post_type']=='hotspot' && $query->query['orderby']=='menu_order title' ) {
$query->set( 'orderby', 'menu_order title post_name' );
}
}
@bewho
bewho / core_query_bans.php
Created May 14, 2017 02:21 — forked from selul/core_query_bans.php
Block slow performance queries from wordpress core
add_filter( 'query', 'sel_filter_slow_query', 999 );
function sel_filter_slow_query( $query ) {
//set an array of functions which run the slow queries:
$banned_functions = array ( 'count_users','bbp_get_statistics', 'bpbbpst_support_statistics' );
foreach($banned_functions as $banned_function){
if ( in_array( $banned_function , wp_list_pluck( debug_backtrace(), 'function' ) ) ) {
return "SELECT 1 ";
}
}
@bewho
bewho / README.md
Created May 14, 2017 02:46 — forked from nielslange/README.md
WordPress snippets

WordPress snippets

Security snippets

Improve WordPress security (.htaccess)

# Enable .htpasswd authentication
<If "%{HTTP_HOST} != 'dev'">
AuthType Basic
AuthName "Login to dashboard"
@bewho
bewho / .htaccess
Created May 14, 2017 02:47 — forked from GaryJones/.htaccess
.htaccess performance and other improvements
# Increase the memory usage.
# If you get an error after adding this, try 64M or 32M instead.
php_value memory_limit "128M"
# Add syntax highlighting
AddType application/x-httpd-php-source .phps
# JavaScript
# Normalize to standard type (it's sniffed in IE anyways)
# tools.ietf.org/html/rfc4329#section-7.2
@bewho
bewho / wp-config-optimizations
Created May 14, 2017 02:47 — forked from skipshean/wp-config-optimizations
WordPress config optimizations, place in wp-config.php file for optimal performance
// other general wordpress optimizations, place in wp-config.php file before "That's all, stop editing!" line.
define('WP_DEBUG', false);
define('WP_POST_REVISIONS', 5);
define('AUTOSAVE_INTERVAL', 600);
define( 'EMPTY_TRASH_DAYS', 3 );
define('WP_MEMORY_LIMIT','256M');
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
// optional, remove this comment and the // below if you want to limit external requests in admin screens
@bewho
bewho / functions.php
Created May 14, 2017 03:06 — forked from jamesmrobinson/functions.php
WordPress functions.php file with various cleanup, security, performance and helper functions. Obviously requires customisation as per theme needs.
<?php
function im_setup() {
// ++++++++++++++++ REGISTER THEME OBJECTS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// Register and enqueue Javascript
function im_js() {
// Modernizr
@bewho
bewho / wordpress.sql
Created May 14, 2017 10:18 — forked from ansonl/wordpress.sql
sample wordpress sql
-- MySQL dump 10.13 Distrib 5.5.29, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: wordpress
-- ------------------------------------------------------
-- Server version 5.5.29-0ubuntu0.12.04.2
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;