Skip to content

Instantly share code, notes, and snippets.

View blainerobison's full-sized avatar

Blaine Robison blainerobison

  • Dagrander
  • San Diego
View GitHub Profile
@blainerobison
blainerobison / gist:8151fb2c416cb83f6ee3
Last active December 30, 2015 04:49
js: Delay execution on window resize
var resizeTimer;
// foo
function foo() {
console.log( 'delayed' );
}
// initially run foo
foo();
@blainerobison
blainerobison / gist:8bb58aa33089f729ffdd
Last active December 30, 2015 11:59
wp: Order admin menu items
/**
* Order Admin Menu Items
*/
function custom_menu_order( $menu_ord ) {
if ( ! $menu_ord ) {
return true;
}
return array(
@blainerobison
blainerobison / gist:8164985
Last active January 1, 2016 15:29
Sublime Text user preference settings. Works for both ST 2 & 3.
{
"overlay_scroll_bars": "enabled",
"line_padding_top": 3,
"line_padding_bottom": 3,
"always_show_minimap_viewport": true,
"font_options": [ "gray_antialias" ],
"bold_folder_labels": true,
"caret_extra_width": 2,
"caret_style": "phase",
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker-OceanicNext.tmTheme",
@blainerobison
blainerobison / gist:11272283
Last active December 17, 2017 08:02
wp: Options for WordPress wp-config.php
<?php
/**
* Local / Staging Environment
*
* Used in conjunction with mu-plugins/disable-plugins-dev-environment.php
* Disables plugins specified in plugin file
*
* SET TO FALSE ON PRODUCTION
*/
@blainerobison
blainerobison / gist:f17b4a0d8f4ce1940aac
Last active August 29, 2015 14:02
wp: Display immediate children or siblings as a menu. [WordPress]
<?php
/**
* Get related menu
*
* Displays immediate children or siblings
*
* @param boolean $echo echo or return result
* @return str $r
*/
function prefix_related_menu( $echo = true ) {
@blainerobison
blainerobison / gist:d059063d74ec36b31687
Last active August 29, 2015 14:04
wp: Yoast SEO plugin hooks [WordPress]
<?php
/**
* Change order of Yoast SEO plugin meta box
*
* Plugin: Yoast SEO
*/
function prefix_yoast_meta_order() {
return 'low';
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.1.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
@blainerobison
blainerobison / gist:e802658da007e6e806b1
Last active August 24, 2022 00:42
wp: Custom Upload Directory By File Type [WordPress]
/**
* Set custom upload directory
*
* Images => /img
* PDF => /pdf
* Misc => /misc
*
* Note: Doesn't work with 'browser uploader'
* Note: Use with 'wp_update_attachment_metadata' hook if we want to define our own attachment metadata
* Allowed file types: http://codex.wordpress.org/Uploading_Files#About_Uploading_Files_on_Dashboard
@blainerobison
blainerobison / gist:fecf1bba78527712fd6e
Last active December 17, 2017 07:58
wp: Add Attachment Metadata [WordPress]
/**
* Add attachment metadata
*
* By default, WordPress only adds '_wp_attachment_metadata' metadata to images, audio and video files.
* This hooks into 'wp_update_attachment_metadata' and sets 'file' to the value of '_wp_attached_file'.
*/
function prefix_update_attachment_metadata( $data, $post_id ) {
// only set 'file' if needed
if ( isset( $data['file'] ) ) {
@blainerobison
blainerobison / gist:8f6f81a0ca84bbd82ff9
Created January 9, 2015 13:46
wp: Hide Taxonomy Description [WordPress]
/**
* Hook into Admin_footer on taxonomy edit screens
*
* @return void
*/
function prefix_hide_term_metabox() {
global $current_screen;
$output = false;