Skip to content

Instantly share code, notes, and snippets.

Avatar

Aubrey Portwood aubreypwd

View GitHub Profile
@aubreypwd
aubreypwd / po2mo.sh
Last active Mar 19, 2018
Programmatically (from the command line) convert a folder of .po files to .mo files.
View po2mo.sh
#!/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 Nov 13, 2017
This helps protect production sites from leaving compatibility mode in WP Migrate DB Pro on which can cause ill-desired consequences.
View wds-migrate-db-pro-no-compat-on-prod.php
<?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 Dec 1, 2016
How to create a Js application as a jQuery plugin
View jsClass.jQuery.js
( 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 Nov 18, 2015
Example of how to find the target/toElement localName
View firefox.toElement.js
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.
View keep-creation-date-on-draft.php
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 Dec 11, 2014
Shell Script for turning On/Off Hidden files in Finder
View gist:3997ab447f65db49a029
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 Aug 29, 2015
How to create a mobile, hackable, wp-config.php file for local, staging, and production environments (how I do it anyway).
View wp-config.php
<?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 Aug 15, 2017
How to colorized your prompt
View .bash_profile
# 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 Jan 3, 2016
Example of how to use filters on your returns.
View gist:8513348
<?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 Dec 6, 2013
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.
View gist:7828624
<?php
// Fix the __FILE__ problem with symlinks.
// Now just use ___FILE___ instead of __FILE__
$___FILE___ = __FILE__;
if ( isset( $plugin ) ) {
$___FILE___ = $plugin;
}