Skip to content

Instantly share code, notes, and snippets.

View aubreypwd's full-sized avatar
💻

Aubrey Portwood aubreypwd

💻
View GitHub Profile
@aubreypwd
aubreypwd / po2mo.sh
Last active March 19, 2018 17:37
Programmatically (from the command line) convert a folder of .po files to .mo files.
#!/sh/bin
###
# PO 2 MO files conversion.
#
# @since Monday, March 19, 2018
##
function po2mo {
if ! [ -x "$(command -v msgfmt)" ]; then
@aubreypwd
aubreypwd / wds-migrate-db-pro-no-compat-on-prod.php
Last active November 13, 2017 17:55
This helps protect production sites from leaving compatibility mode in WP Migrate DB Pro on which can cause ill-desired consequences.
<?php
/**
* Plugin Name: WDS WP Migrate DB Pro No Compat on Production
* Plugin URI:
* Description: This helps protect production sites from leaving compatibility mode in WP Migrate DB Pro on which can cause ill-desired consequences.
* Version: 1.0.0
* Author: WebDevStudios
* License: GPL2
*
* @source https://gist.github.com/aubreypwd/20b030952f41b1fe8e41fe5db9fb8aad
@aubreypwd
aubreypwd / jsClass.jQuery.js
Last active December 1, 2016 16:11
How to create a Js application as a jQuery plugin
( function( $ ) {
// Create a jQuery Object.
$.fn.myObject = function() {
var $target = this; // Store the target element in this variable (jQuery stuff).
// Our stuff.
var application = {
/**
@aubreypwd
aubreypwd / firefox.toElement.js
Created November 18, 2015 14:49
Example of how to find the target/toElement localName
var t = false; // Default.
// Get the right target being clicked.
if ( 'target' in event ) {
t = event.target.localName; // Gecko
} else if ( 'toElement' in event && 'undefined' !== event.toElement ) {
t = event.toElement.localName; // Webkit
}
// If the target is an img, a, or li, it's a safe item in the menu.
function ihcrs_wp_insert_post_data( $post_data, $postarr ) {
// Only on events (I have a function to do this...)
if ( ! ihcrs_is_event( $postarr['ID'] ) ){
return $post_data;
}
// Get the current posts's data.
$previous_data = get_post( $postarr['ID'] );
@aubreypwd
aubreypwd / gist:3997ab447f65db49a029
Created December 11, 2014 16:40
Shell Script for turning On/Off Hidden files in Finder
STATUS=`defaults read com.apple.finder AppleShowAllFiles`
if [ $STATUS == TRUE ]; then
defaults write com.apple.finder AppleShowAllFiles FALSE
else
defaults write com.apple.finder AppleShowAllFiles TRUE
fi
killall Finder
@aubreypwd
aubreypwd / wp-config.php
Last active August 29, 2015 14:07
How to create a mobile, hackable, wp-config.php file for local, staging, and production environments (how I do it anyway).
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
@aubreypwd
aubreypwd / .bash_profile
Last active August 15, 2017 15:10
How to colorized your prompt
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color
# Colorful ls
alias ls='ls -GFh'
# I <3 My Prompt
@aubreypwd
aubreypwd / gist:8513348
Last active January 3, 2016 20:09
Example of how to use filters on your returns.
<?php
// Differentiate whether we need to load from
// cache or get live results.
function gdurl_googapi_cache($s){
// First see if we have cached data (15 seconds?)
$gdurl_transient = get_transient( 'gdurl_googapi_cache' );
if( isset($gdurl_transient[$s]) ){
return apply_filters(
@aubreypwd
aubreypwd / gist:7828624
Created December 6, 2013 17:18
Workaround for symlinked plugins when using wp_enqueue_script and __FILE__. See http://core.trac.wordpress.org/ticket/16953 and http://wordpress.org/support/topic/plugins_url-output-erroring?replies=5 for references on this.
<?php
// Fix the __FILE__ problem with symlinks.
// Now just use ___FILE___ instead of __FILE__
$___FILE___ = __FILE__;
if ( isset( $plugin ) ) {
$___FILE___ = $plugin;
}