Skip to content

Instantly share code, notes, and snippets.

@lumpysimon
lumpysimon / Lumpy error log.sublime-snippet
Created March 21, 2013 10:18
Sublime Text snippet: PHP error_log print_r
<snippet>
<content><![CDATA[error_log( "Lumpy: $1 " ${2:. print_r( \$$3 , true )} );]]></content>
<tabTrigger>lel</tabTrigger>
<scope>source.php</scope>
<description>error_log (Lumpy PHP)</description>
</snippet>
@lumpysimon
lumpysimon / Lumpy function.sublime-snippet
Created March 21, 2013 10:19
Sublime Text snippet: PHP function with arg & default
<snippet>
<content><![CDATA[
function ${1:name}(${2: \$${3:arg} ${4:= $5 }}) {
$0
}
@lumpysimon
lumpysimon / gist:5212084
Last active December 15, 2015 05:49 — forked from twosixcode/gist:1988097
Sublime Text key binding: swap paste & paste-and-indent (put in Preferences -> Key Bindings - User)
// swap the keybindings for paste and paste_and_indent
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" }
@lumpysimon
lumpysimon / gist:5583782
Created May 15, 2013 12:51
PHP backtrace
$trace=debug_backtrace();
$caller=array_shift($trace);
error_log( "Lumpy: mail debug function " . print_r( $trace[0]['function'] , true ) );
error_log( "Lumpy: mail debug class " . print_r( $caller['class'] , true ) );
@lumpysimon
lumpysimon / gist:5a68f561fd2381e64efe
Last active March 8, 2016 17:06
Example WordPress custom post type and taxonomy definitions using Extended CPTs and Extended Taxos
register_extended_post_type(
'newsletter',
array(
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 45,
'quick_edit' => false,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'admin_cols' => array(
'newsletter-image' => array(
@lumpysimon
lumpysimon / hyphenate.css
Created September 30, 2015 23:53
Bulletproof hyphenation using CSS
.hyphenate {
overflow-wrap: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@lumpysimon
lumpysimon / wp-stylesheet-loader.php
Last active January 10, 2017 09:52
WordPress cache-busting stylesheet loader
add_action( 'wp_enqueue_scripts', 'abc_styles' );
function abc_styles() {
wp_enqueue_style(
'abc',
get_stylesheet_uri(),
array(),
filemtime( get_template_directory() . '/style.css' )
);
@lumpysimon
lumpysimon / wp-disable-rest.php
Created November 26, 2015 22:44
Completely disable WordPress REST API
add_filter( 'rest_enabled', '_return_false' );
add_filter( 'rest_jsonp_enabled', '_return_false' );
@lumpysimon
lumpysimon / .lando.yml
Created May 16, 2018 13:02
Lando config file for Kirby with Apache, PHP 7.2, SSL and MailHog
name: kirby
proxy:
appserver:
- kirby.lndo.site
mailhog:
- mail.kirby.lndo.site
services:
appserver:
type: php:7.2
via: apache
@lumpysimon
lumpysimon / meta-tags.php
Last active July 10, 2018 14:10
Kirby meta tags config file
<?php
c::set('meta-tags.default', function(Page $page, Site $site) {
if ( $page->isErrorPage() )
return [
'title' => $page->title()
];
$title = ( $page->isHomePage() ? $site->title() : $page->title() . ' - ' . $site->title() );