Skip to content

Instantly share code, notes, and snippets.

View mattheu's full-sized avatar

Matthew Haines-Young mattheu

View GitHub Profile
@mattheu
mattheu / CMB-field.linklist.js
Last active May 24, 2016 09:04
A custom CMB field type for some flexible content
@mattheu
mattheu / gist:7135691
Last active December 26, 2015 10:19
Salty-WordPress / Nginx conf - for projects where the acual site is in a public directory add this to the Salty WordPress default config
if ( -d /srv/www/$root/public ) {
set $root '${root}/public';
}
@mattheu
mattheu / gist:7127778
Created October 23, 2013 22:18
## Fix login loop. * When WordPress is installed in a subdirectory, wp-admin/ links don't work correctly. We fix this with an nginx rewrite. * But... it appends reauth=1 to the url which forces a reauthentication when submitted... and you have to log in again!
/**
* Fix login loop.
*
* When WordPress is installed in a subdirectory, wp-admin/ links don't work correctly. We fix this with an nginx rewrite.
* But... it appends reauth=1 to the url which forces a reauthentication when submitted... and you have to log in again!
*/
add_filter( 'login_url', function( $url ) {
if ( '/wp-admin/' === add_query_arg( array() ) ) {
@mattheu
mattheu / gist:7117050
Last active December 26, 2015 07:39
WP-CLI command to generate test content. Lorem ipsum post text and random images from the flickr api.
<?php
define( 'MPH_GENERATOR_FLICKR_API_KEY', '' );
if ( ! 'MPH_GENERATOR_FLICKR_API_KEY' )
die( 'You must define the Flickr API key.' );
if ( defined( 'WP_CLI' ) && WP_CLI ) {
/**
<?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' );
@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
@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 / 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 / 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 ) {
// 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.