Skip to content

Instantly share code, notes, and snippets.

💻
Use the Source

Tom McFarlin tommcfarlin

💻
Use the Source
Block or report user

Report or block tommcfarlin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View codegraphics.swift
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@tommcfarlin
tommcfarlin / get-trello-names.js
Last active Aug 26, 2016
[JavaScript] Returns an array of all of the names of a Trello boards members.
View get-trello-names.js
/**
* Retrieves a list of all of the members on a Trello board and stores and
* returns their names in an array. It will not include any duplicates.
*
* Trello names are usually represented as "Elliot Alderson (mrrobot)" but the
* returned array will only return an array with their actual name (that is,
* Ellio Alderson).
*
* This does not require jQuery or any third-party library to run. If you want
* to run this from the console of Chrome, then paste this entire function into
View ajax-reg.js
/**
* This file is enqueued by means of wp_enqueue_script() - variables are passed
* in from PHP by means of wp_localize_script()
*
*/
/* TM: We use an anonymous function to invoke the JavaScript. Also refactored for proper
* WordPress coding standards.
*/
(function( $ ) {
@tommcfarlin
tommcfarlin / complete-mobile-media-query-boilerplate.css
Last active Jul 22, 2018
A media query boilerplate for responsive design that covers iPhones, iPhone 5s, tablets, and iPads for viewing sites and applications in both portrait and landscape mode.
View complete-mobile-media-query-boilerplate.css
/**
* Note that the following media queries are intended to be used for the specified device or screen size
* in both portrait and landscape mode.
*
* Desktop queries are not provided since the default styles for most sites and applications typically focus
* on that for the default sites.
*
* Contributes, comments, and all that fun stuff always welcome :).
*/
@tommcfarlin
tommcfarlin / add-custom-post-type-menu.php
Created Apr 25, 2013
[WordPress] Add a custom post type menu as a child of an existing custom post type menu.
View add-custom-post-type-menu.php
<?php
// Define the 'Portfolio' post type. This is used to represent galleries
// of photos. This will be our top-level custom post type menu
$args = array(
'labels' => array(
'all_items' => 'Gallery',
'menu_name' => 'Portfolio',
'singular_name' => 'Gallery',
'edit_item' => 'Edit Gallery',
@tommcfarlin
tommcfarlin / strip-hidden-ascii-chars.php
Last active Dec 15, 2015
[WordPress] Occasionally, I've been parsing out data provided to me by third-parties and there have been hidden ASCII characters that can muck up programmatically inserting data into the database. Here's a simple regex for stripping out everything *except* alphanumeric characters.
View strip-hidden-ascii-chars.php
<?php
// Replace anything that is not an 'a-z', 'A-Z', or '0-9' from the given $value
$value = preg_replace( "/[^a-zA-Z0-9\s]/", "", $value );
/*
* Read the comments below to see some of the available functions WordPress provides for evaluating the validity of the characters in the input string.
* /
@tommcfarlin
tommcfarlin / jquery-boilerplate.js
Created Mar 7, 2013
[WordPress] Properly loading jQuery within WordPress without having to use the `noConflict` method, or creating your own reference such as `$wp = jQuery`.
View jquery-boilerplate.js
/**
* This gist demonstrates how to properly load jQuery within the context of WordPress-targeted JavaScript so that you don't
* have to worry about using things such as `noConflict` or creating your own reference to the jQuery function.
*
* @version 1.0
*/
(function( $ ) {
"use strict";
$(function() {
@tommcfarlin
tommcfarlin / meta-data-serialization.php
Last active Aug 4, 2017
An example function used to demonstrate how meta data is typically saved in a WordPress theme or plugin. The gist is made public so that developers can contribute to the standard security boilerplate functionality in order to simplify, reduce, and improve our serialization functions.
View meta-data-serialization.php
<?php
/**
* An example function used to demonstrate how to use the `user_can_save` function
* that provides boilerplate security checks when saving custom post meta data.
*
* The ultimate goal is provide a simple helper function to be used in themes and
* plugins without the need to use a set of complex conditionals and constants.
*
* Instead, the aim is to have a simplified function that's easy to read and that uses
* WordPress APIs.
You can’t perform that action at this time.