Skip to content

Instantly share code, notes, and snippets.

@lumpysimon
lumpysimon / gist:1989492
Created March 6, 2012 22:37
wordpress page.php
<?php
get_header();
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
@lumpysimon
lumpysimon / gist:1989756
Created March 6, 2012 23:29
wordpress get attached images slideshow
$args = array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image/jpeg',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1
);
$slides = get_posts( $args );
@lumpysimon
lumpysimon / gist:2393401
Created April 15, 2012 15:20
css speech bubbles
/*
CSS Speech Bubbles
Usage: Apply a class of .speech-bubble and .speech-bubble-DIRECTION
<div class="speech-bubble speech-bubble-top">Hi there</div>
From: http://net.tutsplus.com/tutorials/html-css-techniques/css-refreshers-borders/
*/
.speech-bubble {
position: relative;
background-color: #292929;
@lumpysimon
lumpysimon / gist:2630992
Created May 7, 2012 22:24
wordpress set display name based on first name & last name
add_filter( 'pre_user_display_name', 'default_display_name' );
function default_display_name( $name ) {
if ( isset( $_POST['display_name'] ) )
return sanitize_text_field( $_POST['display_name'] );
if ( isset( $_POST['first_name'] ) ) {
$name = sanitize_text_field( $_POST['first_name'] );
@lumpysimon
lumpysimon / Lumpy add_.sublime-snippet
Created March 21, 2013 10:07
Sublime Text snippet: WordPress add_action / add_filter in class PHP
<snippet>
<content><![CDATA[
add_${1:action}( '${2:hook}', $5array( \$this, '${3:function}' )${4:, 10, 2} );]]></content>
<tabTrigger>lwpadd</tabTrigger>
<scope>source.php</scope>
<description>add_action or add_filter (Lumpy WordPress PHP)</description>
</snippet>
@lumpysimon
lumpysimon / Lumpy reg ext post type.sublime-snippet
Created March 21, 2013 10:09
Sublime Text snippet: WordPress register_extended_post_type PHP
<snippet>
<content><![CDATA[
${1: if ( function_exists( 'register_extended_post_type' ) ) \{
}${3: } register_extended_post_type(
${3: } '${4:name}',
${3: } array(
${3: }${16: ${5:'capability_type' => 'post',
${3: } }${6:'hierarchical' => false,
${3: } }${7:'menu_position' => ${8:99},
@lumpysimon
lumpysimon / Lumpy class.sublime-snippet
Last active December 15, 2015 05:49
Sublime Text snippet: PHP class with __construct function
<snippet>
<content><![CDATA[
defined( 'ABSPATH' ) or die();
\$$1 = new $1;
@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" }