Skip to content

Instantly share code, notes, and snippets.

View mcaskill's full-sized avatar
🥃

Chauncey McAskill mcaskill

🥃
View GitHub Profile
@mcaskill
mcaskill / wp-gf-pll-merge_tags.php
Last active August 29, 2015 14:19
WordPress \ Polylang : Adds "current" and "default" language merge tags for Gravity Forms
<?php
if ( ! class_exists('Polylang') ) {
return;
}
/**
* Filter: Replace Polylang merge tags with their respective values
*
* @used-by Filter: GravityForms\'gform_replace_merge_tags'
@mcaskill
mcaskill / wp-gf-wpml-merge_tags.php
Created April 16, 2015 18:37
WordPress \ WPML : Adds "current" and "default" language merge tags for Gravity Forms
<?php
if ( ! class_exists('SitePress') ) {
return;
}
/**
* Filter: Replace WPML merge tags with their respective values
*
* @used-by Filter: GravityForms\'gform_replace_merge_tags'
@mcaskill
mcaskill / wp-wpml-helpers.php
Created April 16, 2015 18:47
WordPress \ WPML : Various utility functions I made but don't remember why or if they work.
<?php
/**
* WPML Utility Functions
*/
if ( ! function_exists('icl_get_object') )
{
/**
* Retrieve an associated translated object from another object's ID.
@mcaskill
mcaskill / wp-acf-location-nowhere.php
Created April 16, 2015 19:07
WordPress \ ACF : Add "Nowhere" as a location to "Page Type" rules.
<?php
/**
* Filter: Add "Nowhere" as a location to "Page Type" rules.
*
* Useful for third-parties seeking to dynamically embed
* the field group in a non-traditional manner.
*
* @used-by Filer: 'acf/location/rule_values/page_type'
* @param array $choices
@mcaskill
mcaskill / Function.Date-Format-Conversion.php
Last active February 6, 2024 11:22
PHP : Translate date/time format between `date()` and `strftime()`
<?php
/**
* Convert date/time format between `date()` and `strftime()`
*
* Timezone conversion is done for Unix. Windows users must exchange %z and %Z.
*
* Unsupported date formats : S, n, t, L, B, G, u, e, I, P, Z, c, r
* Unsupported strftime formats : %U, %W, %C, %g, %r, %R, %T, %X, %c, %D, %F, %x
*
@mcaskill
mcaskill / wp-leadingslash.php
Created April 17, 2015 15:38
WordPress \ Formatting : Prepends a leading slash and removes leading forward slashes and backslashes if they exist.
<?php
/**
* Prepends a leading slash.
*
* Will remove leading forward and backslashes if it exists already before adding
* a leading forward slash. This prevents double slashing a string or path.
*
* The primary use of this is for paths and thus should be used for paths. It is
* not restricted to paths and offers no specific path support.
@mcaskill
mcaskill / wp-get_id_by_path.php
Created April 20, 2015 15:43
WordPress : Retrieve a post ID given its path.
<?php
if ( ! function_exists('get_ID_by_path') ) :
/**
* Retrieves an ID given its path.
*
* @global $wpdb
*
* @param string $page_path Page path
@mcaskill
mcaskill / wp-intart-sort.php
Created May 2, 2015 05:35
WordPress : Sort post titles in alphabetical order, disregarding initial definite and indefinite articles
<?php
/**
* File: Sort posts in alphabetical order, ignoring initial articles.
*
* This condition is achieved using the `post_fields` and `posts_orderby`
* filters. The implementer must provide their own list of definite and
* indefinite articles for the hooks to ignore.
*
* To enable natural language sorting, pass the following Query parameter:
@mcaskill
mcaskill / Function.Array-Group-By.php
Last active January 3, 2024 10:15
PHP : Groups an array by a given key
<?php
if (!function_exists('array_group_by')) {
/**
* Groups an array by a given key.
*
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
*
* Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
* This variant allows $key to be closures.
@mcaskill
mcaskill / git-multi-status.md
Last active December 7, 2015 17:51 — forked from mzabriskie/README.md
View a summary of the status for multiple repositories.

Name

git-multi-status — View a summary of the status for multiple repositories.

Usage

git-multi-status [<options>…​] [--] [<path>…​]