Skip to content

Instantly share code, notes, and snippets.

View mattheu's full-sized avatar

Matthew Haines-Young mattheu

View GitHub Profile
@mattheu
mattheu / attachment-categories.php
Created March 26, 2012 15:36 — forked from willmot/gist:1277790
WordPress attachment category plugin
<?php
/*
Plugin Name: Attachment Categories
Description: Allows attachments to be categorised
Version: 1.0
Author: Human Made Limited
Author URI: http://hmn.md
*/
@mattheu
mattheu / gist:2227062
Created March 28, 2012 15:13
How to use WPThumb to create grayscale images.
<?php
/**
* Use WPThumb to create grayscale images.
*/
// Register a new image size.
// Note: We have could just passed a custom arg to wpthumb.
add_image_size( 'medium:grayscale', 100, 100, true );
@mattheu
mattheu / fiddle.css
Created April 2, 2012 14:25
Matthew's JQuery Tabbed Content
body {
width: 90%;
margin: 1em auto;
font: 0.75em/1.5 sans-serif;
background: #CCC;
}
h1 {
margin: 0 0 0.75em;
font: bold 2em/1 sans-serif;
@mattheu
mattheu / readme.md
Last active December 16, 2015 07:08
New CMB readme

HM Custom Meta Boxes for WordPress

Custom Meta Boxes is a framework for easily adding custom fields to the WordPress post edit page.

It includes several field types including WYSIWYG, media upload and dates (see wiki for a full list). It also supports repeatable and grouped fields.

This project is aimed at developers and is easily extended and customised. It takes a highly modular, Object Orientated approach, with each field as an extension of the CMB_Field abstract class.

The framework also features a basic layout engine for fields, allowing you to align fields to a simple 12 column grid.

// I guess this is a question of best practice and JavaScript design patterns.
// I have an object, and have defined all my functions as properties on this.
// My problem...
// I want to attach a function within the object to a click event.
// As this was getting messy - I wanted to avoid using a closure, instead passing a callback function.
// However within that callback function, this referes to the clicked element.
// How do I access other properties on MyClass?
// What is the BEST way to do this? Am I trying to do something stupid.
@mattheu
mattheu / HM Debugging Functions
Created July 13, 2013 11:46
2 simple functions we use at Human Made for debugging.
/**
* Intelligently replacement for print_r & var_dump.
*
* @param mixed $code
* @param bool $output. (default: true)
* @return $code
*/
function hm( $code, $output = true ) {
@mattheu
mattheu / HM-Debug.php
Last active December 19, 2015 17:19
Human Made debugging functions
<?php
/**
* Intelligently replacement for print_r & var_dump.
*
* @param mixed $code
* @param bool $output. (default: true)
* @return $code
*/
function hm( $code, $output = true ) {
@mattheu
mattheu / gist:6870307
Created October 7, 2013 15:59
Benchmark update_meta_cache SQL query with and without ORDER BY $id_colurmn param
<?php
// Use this to create a load of meta entries to check its still OK when there are loads of meta entries.
// for ( $i = 0; $i < 500; $i++ ) {
// $id = 'test-' . uniqid();
// add_post_meta( 1, $id, rand() );
// }
// die();
@mattheu
mattheu / jquery-ui-mp6-theme
Created October 9, 2013 14:14
MP6 jQuery UI Theme
/*! jQuery UI - v1.10.3 - 2013-10-09
* http://jqueryui.com
* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css, jquery.ui.theme.css
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=%22Open%20Sans%22%2CArial%2Csans-serif&fwDefault=normal&fsDefault=13px&cornerRadius=0&bgColorHeader=%23FFFFFF&bgTextureHeader=flat&bgImgOpacityHeader=100&borderColorHeader=%23dfdfdf&fcHeader=%23555555&iconColorHeader=%23555555&bgColorContent=%23ffffff&bgTextureContent=flat&bgImgOpacityContent=75&borderColorContent=%23dfdfdf&fcContent=%23555555&iconColorContent=%23555555&bgColorDefault=%23222222&bgTextureDefault=flat&bgImgOpacityDefault=100&borderColorDefault=%23222222&fcDefault=%23eee&iconColorDefault=%23eee&bgColorH
<?php
/**
* Plugin Name: PHPMailer SMTP Settings
* Description: Enables SMTP servers, SSL/TSL authentication and SMTP settings.
*/
defined( 'ABSPATH' ) OR exit;
add_action( 'phpmailer_init', 'my_phpmailer_init' );