Skip to content

Instantly share code, notes, and snippets.

@alexdunae
alexdunae / smushit.sh
Created October 15, 2009 16:45
Image optimization with a home-rolled Smush.it
#!/bin/bash
#
# Home-rolled Smush.it, by Alex Dunae (http://dialect.ca).
#
# N.B. This script works for me; it may not work for you.
# Since it overwrites your images with the optimized version, you should
# backup your files before running this script and do a trial run before
# getting too excited. This is your disclaimer.
#
# Uses jpegtran (http://jpegclub.org/jpegtran/), part of libjpeg,
@evansolomon
evansolomon / optimizely.php
Created October 10, 2011 17:37
WordPress.com plugin for running Optimizely experiments
<?php
/*
Plugin Name: Optimizely
Description: Runs Optimizely experiments.
Author: koop, evansolomon
Version: 0.2
*/
class WPCOM_Optimizely {
public $version;
@mikejolley
mikejolley / gist:1597957
Created January 12, 2012 01:40
WooCommerce - Replace '' with 'Call for price' when price is left blank
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_empty_price_html', 'custom_call_for_price');
function custom_call_for_price() {
return 'Call for price';
}
@kloon
kloon / gist:4037251
Created November 8, 2012 06:38
WooCommerce Currency Converter in non widget area
//Display currency converter widget in non widget area
function custom_ccw_display_meta_end() {
$instance = array();
$instance['title'] = 'Currency Converter';
$instance['show_reset'] = 'yes'; // leave empty to disable
$instance['message'] = 'See the prices in your currency';
$instance['currency_codes'] = "USD"."\n"."ZAR"."\n"."EUR"; // Must use \n between currencies and between ""
$args = array();
the_widget( 'WooCommerce_Widget_Currency_Converter', $instance, $args);
}
@AliMD
AliMD / Useful Htaccess Tricks and Tips.md
Last active March 31, 2021 19:28
Useful Htaccess Tricks and Tips for your websites (better performance, speed up, stability and more) Optimized for wordpress Tested in 1devs server with apache (not nginx)

Useful Htaccess Tricks and Tips for your websites (better performance, speed up, stability and more)

Apache configuration file (.htaccess) .htaccess files are an overhead, this logic should be in your Apache config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html

Techniques in here adapted from all over, including: html5boilerplate: html5boilerplate.com Kroc Camen: camendesign.com/.htaccesss perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/ Useful htaccess tricks & tips: http://www.queness.com/post/5421/17-useful-htaccess-tricks-and-tips

@boogah
boogah / wp_mysql_optimizations.sql
Last active April 20, 2017 20:32
Common database optimizations for WordPress sites.
/* Delete revisions */
DELETE FROM wp_posts WHERE post_type = "revision";
/* Only use this if you no longer care about any of your current revisions! */
/* Delete trashed posts */
DELETE FROM wp_posts WHERE post_type = "trash";
/* Delete Jetpack Feedback Spam */
SELECT * FROM wp_posts WHERE wp_posts.post_type = "feedback" AND wp_posts.post_status= "spam";
@franz-josef-kaiser
franz-josef-kaiser / limit_admin_post_list_fields.php
Created July 3, 2013 13:04
Speed up the post list views in WordPress admin UI screens. Reduce the queried fields to what is needed to display the posts and what "Quick Edit" needs. Saved time increases with a higher limit set for `posts_per_screen` in the screen options drop down.
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) Faster Admin Post Lists
* Description: Reduces the queried fields inside WP_Query for WP_Post_List_Table screens
* Author: Franz Josef Kaiser <wecodemore@gmail.com>
* AuthorURL: http://unserkaiser.com
* License: MIT
*/
@NiklasHogefjord
NiklasHogefjord / gist:6104328
Created July 29, 2013 13:33
WooCommerce - Display cart total weight on the cart page
<?php
/**
* WooCommerce
* --------------
*
* Display cart total weight on the cart page
*
*/
add_action('woocommerce_cart_collaterals', 'myprefix_cart_extra_info');
@agusmu
agusmu / style.css
Created September 2, 2013 01:20
WooCommerce - Fancy Sale Sticker
/* fancy sale sticker */
.woocommerce ul.products li.product .onsale, .woocommerce-page ul.products li.product .onsale, .woocommerce span.onsale, .woocommerce-page span.onsale {
background: transparent url(images/sale.png) no-repeat !important;
width: 125px;
height: 125px;
text-align: left;
text-indent: -99999px;
padding: 0;
margin: 0;
position: absolute;
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active January 8, 2024 13:24
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );