Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / bocoup-training-more-efficient-event-handlers.js
Created February 12, 2013 21:38
Bocoup training: More Efficient jQuery Event Handlers
// Straightforward + simple.
$("button").on("click", function(event) {
event.preventDefault();
var button = $(this);
var numberElem = button.find(".number");
var number = Number(numberElem.text()) - 1;
numberElem.text(number);
if (number === 0) {
button.prop("disabled", true);
button.off("click");
@wycks
wycks / image_optimize-wordpress.php
Last active December 16, 2020 01:48
Remove WordPress full size images from being inserted into a post + option to and add max size to to prevent users from inserting massive images.
<?php
/**
*
* This removes the ability to add the FULL image size into a post, it does not alter or delete the image
* Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
*
* For now we have to do it this way to make the labels translatable, see trac ref below.
*
* If your theme has $content_width GLOBAL make sure and remove it
@jan-koch
jan-koch / remove-woo-scripts.php
Created February 28, 2020 09:14
Remove WooCommerce related resources except on WooCommerce-based pages (products, cart, checkout, etc). Use on a testing environment before pasting this into your live website!
/**
* This code snippet removes JavaScript and CSS files loaded from WooCommerce if they are not necessary.
*
* Please test this on a staging copy of your website before putting this into the functions.php of your live website.
*/
add_action( 'wp_enqueue_scripts', 'my_remove_woo_assets', 99 );
function my_remove_woo_assets() {
if ( function_exists( 'is_woocommerce' ) ) { // Check if Woo is installed.
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { // Only run on non-Woo pages.
// Remove unnecessary stylesheets.
@ffdead
ffdead / if-resolution.scss
Created December 5, 2012 12:32
SASS resolution media query mixin
/* @author 14islands.com
* SASS mixins for future proof resolution media query
*/
@mixin if-min-resolution($dppx) {
@include if-resolution(min, $dppx) {
@content;
}
}
@einkoro
einkoro / password_bcrypt.php
Last active May 10, 2016 16:52
Must-use plugin for WordPress to swap phpass to PHP 5.5's new password_hash and password_verify using bcrypt
<?php
/**
* Plugin Name: WP PASSWORD_BCRYPT
* Plugin URI: http://bitpiston.com/
* Description: Replaces wp_hash_password and wp_check_password's phpass hasher with PHP 5.5's password_hash and password_verify using bcrypt.
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
* Version: 1.2
* Licence: BSD
*/
@mglaman
mglaman / wp-widget-custom-classes.php
Created June 12, 2013 02:10
Allows the ability to add custom classes to WordPress widgets (just through filter, does not add form.)
<?php
//Hook into dynamic_sidebar_params filter
//found in dynamic_siderbar ( wp-include/widgets.php ) line 886
add_filter( 'dynamic_sidebar_params', 'extend_widgets_sidebar_params', 10);
//I have my classes stored within an array in an option called widget_classes
if((!$widget_classes = get_option('widget_classes')) || !is_array($widget_classes) ) $widget_classes = array();
/* Params callback on setting widget params */
anonymous
anonymous / class-piklist.php
Created February 15, 2014 09:35
includes/class-piklist.php - Solution to getting piklist working on windows (and in my case, on a dropbox hardlinked folder structure)
<?php
if (!defined('ABSPATH'))
{
exit;
}
class PikList
{
public static $version;