Skip to content

Instantly share code, notes, and snippets.

Matt Banks mattbanks

Block or report user

Report or block mattbanks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattbanks
mattbanks / functions.php
Last active Aug 29, 2015
Pre-WordPress 3.9 showing kitchen sink in WYSIWYG editor
View functions.php
<?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 Aug 5, 2014
Awful loop usage in WordPress theme index.php
View index.php
<?php global $wp_query;
query_posts(
array_merge(
$wp_query->query,
array(
'orderby' => 'post_date',
'order' => 'desc'
)
)
);
@mattbanks
mattbanks / gist:55c990b1d5b517ccf043
Created Jun 3, 2015
TextExpander 5 snippet for a new WP_Query wrapped in a transient
View gist:55c990b1d5b517ccf043
// 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 Sep 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 — forked from padolsey/gist:527683
JavaScript: Detect IE
View js-detectie
// ----------------------------------------------------------
// 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 Jun 19, 2012
Animate Scroll to Top
View gist:2956247
// Animate scroll to top
$('.top').on('click', function() {
$('body,html').animate({
scrollTop: 0
}, 600);
return false;
});
@mattbanks
mattbanks / gist:2979288
Created Jun 23, 2012
WordPress as git submodule
View gist:2979288
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 Jun 27, 2012 — forked from jchristopher/gist:2998780
AppleScript: iTerm tail PHP error log
View gist:3004901
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 Jul 20, 2012
Create new WP_Query with TextExpander (version 4 required)
View gist:3153899
<?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 Aug 17, 2012 — forked from billerickson/gist:3379905
WordPress Security
View gist:3379965
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
You can’t perform that action at this time.