Skip to content

Instantly share code, notes, and snippets.

@mattbanks
mattbanks / functions.php
Last active August 29, 2015 13:59
Pre-WordPress 3.9 showing kitchen sink in WYSIWYG editor
<?php
add_filter( 'tiny_mce_before_init', 'mb_unhide_kitchensink' );
function mb_unhide_kitchensink( $args ) {
$args['wordpress_adv_hidden'] = false;
return $args;
}
@mattbanks
mattbanks / index.php
Created August 5, 2014 16:43
Awful loop usage in WordPress theme index.php
<?php global $wp_query;
query_posts(
array_merge(
$wp_query->query,
array(
'orderby' => 'post_date',
'order' => 'desc'
)
)
);
@mattbanks
mattbanks / gist:55c990b1d5b517ccf043
Created June 3, 2015 15:10
TextExpander 5 snippet for a new WP_Query wrapped in a transient
// Get any existing copy of our transient data
if ( false === ( $%filltext:name=Query Name:default=myquery% = get_transient( '%filltext:name=Query Name:default=myquery%' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$%filltext:name=Query Name:default=myquery%_args = array(
'post_type' => '%filltext:name=Post Type:default=post%',
'order' => '%fillpopup:name=Order:default=ASC:DESC%',
'orderby' => '%fillpopup:name=Orderby:default=date:ID:rand:title:author:menu_order%',
'post_status' => 'publish',
'posts_per_page' => %filltext:name=Posts Per Page:default=-1%
@mattbanks
mattbanks / 0_reuse_code.js
Created September 29, 2015 19:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mattbanks
mattbanks / js-detectie
Created May 4, 2012 14:24 — forked from padolsey/gist:527683
JavaScript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@mattbanks
mattbanks / gist:2956247
Created June 19, 2012 20:07
Animate Scroll to Top
// Animate scroll to top
$('.top').on('click', function() {
$('body,html').animate({
scrollTop: 0
}, 600);
return false;
});
@mattbanks
mattbanks / gist:2979288
Created June 23, 2012 18:20
WordPress as git submodule
cd wpstarter
git init
touch README.md
git submodule add git://github.com/WordPress/WordPress.git wp
cd wp
git fetch --tags
git checkout 3.4
cd ..
git add .
git commit -m 'core files, checkout 3.4'
@mattbanks
mattbanks / gist:3004901
Created June 27, 2012 15:39 — forked from jchristopher/gist:2998780
AppleScript: iTerm tail PHP error log
tell application "iTerm"
activate
set t to (make new terminal)
tell t
tell (make new session at the end of sessions)
exec command "tail -f /Applications/MAMP/logs/php_error.log"
end tell
end tell
end tell
@mattbanks
mattbanks / gist:3153899
Created July 20, 2012 23:46
Create new WP_Query with TextExpander (version 4 required)
<?php
// New query
$%filltext:name=Query Name:default=myquery%_args = array(
'post_type' => '%filltext:name=Post Type:default=post%',
'order' => '%fillpopup:name=popup 7:default=ASC:DESC%',
'orderby' => '%fillpopup:name=popup 9:default=date:ID:rand:title:author:menu_order%',
'post_status' => 'publish',
'posts_per_page' => %filltext:name=Posts Per Page:default=-1%
);
$%filltext:name=Query Name:default=myquery% = new WP_Query( $%filltext:name=Query Name:default=myquery%_args );
@mattbanks
mattbanks / gist:3379965
Created August 17, 2012 15:35 — forked from billerickson/gist:3379905
WordPress Security
WordPress is actually one of the most secure pieces of software available. It powers 17%
of the 1,000,000 most visited websites, so it is being constantly tested both internally
and by hackers. When an issue is discovered, an update is released which you can install
with one click in the dashboard.
The vast majority of hacked WordPress websites are running an out-of-date version of
WordPress. Once WordPress is updated, any vulnerabilities that are patched are now publicly
known, so old versions are vulnerable.
The next most likely source of hacking is your host. If your server isn't secure, it doesn't