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:cc8b06dd2a04a5818edd
Created July 2, 2015 23:01
Remove Meta Boxes - WordPress
/**
* Remove meta boxes
*
* @return void
*/
function prefix_remove_meta_boxes() {
/* Publish meta box. */
remove_meta_box( 'submitdiv', 'post', 'normal' );
@blainerobison
blainerobison / gist:552e49abec345d431dd3
Created March 11, 2015 00:32
Custom Upload Directories
/**
* Add custom directory filter
*
* 'ev_custom_upload_directory'
*/
function ev_pre_upload( $file ) {
add_filter( 'upload_dir', 'ev_custom_upload_directory' );
return $file;
}
@blainerobison
blainerobison / SassMeister-input.scss
Created February 9, 2015 18:54
Generated by SassMeister.com.
// ----
// Sass (v3.4.11)
// Compass (v1.0.3)
// ----
// Your Example
#id > .element {
#{selector-unify(&, div)} {
color: blue;
}
@blainerobison
blainerobison / gist:16220392bdd29d8ee634
Created January 30, 2015 14:30
wp: Order get_terms() Numerically [WordPress]
/**
* Order get_terms() by number
*
* @param string $orderby ORDERBY clause of the terms query.
* @param array $args An array of terms query arguments.
* @param string|array $taxonomies A taxonomy or array of taxonomies.
* @return string
*/
function prefix_get_terms_orderby_numeric( $orderby, $args, $taxonomies ) {
@blainerobison
blainerobison / gist:1f1e59c99f5c9a78b93d
Last active December 17, 2015 22:35
wp: Move Category Count Inside Link [WordPress]
/**
* Move Category Post Counts Inside Link
*
* filters wp_list_categories()
*
* @param string $links link html output
* @return string
*/
function prefix_move_category_count( $links ) {
@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;
@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: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
<?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: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';