Skip to content

Instantly share code, notes, and snippets.

Creating ...

Eric Mann ericmann

Creating ...
Block or report user

Report or block ericmann

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
ericmann / gist:2591384
Created May 4, 2012
Non-parent theme psuedoframework
View gist:2591384

#Parent Themes There actually is nothing wrong with the parent/child theme model. I strongly believe that the only kind of theme that should ever be distributed is a parent theme - so clients/devs can create and modify a child theme on top of it.

But I have a problem with developing on top of a parent theme if the child theme is meant for general distribution. Child themes should never be re-sold or distributed.

If I'm planning to build a theme for release, starting with an existing parent theme and building a child theme is a really bad idea.


Working with the popular theme frameworks is just an extension of this problem - i.e. using Genesis or Builder as a generic parent theme and building a custom design as a child theme on top of it.

ericmann / gist:2604547
Created May 5, 2012
Post meta wrapper
View gist:2604547
function get_meta_bool( $post_id, $key ) {
var $string_value = get_post_meta( $post_id, $key, true );
return (bool) $string_value
View gist:2765331
Set up images like this:
<div id="raffle">
<img src="..." data-link="http://link.url" />
<img src="..." data-link="http://link.url" />
Then set up a JS event listener:
jQuery('#raffle').on('click', 'img', function(e) {
View gist:2776232
void this_is_a_subroutine( $args ) {
if ( check )
if ( check )
ericmann / gist:2784237
Created May 24, 2012
Consolidating my Websites
View gist:2784237

When WordPress first rolled in multisite features, I was thrilled. I immediately activated them and merged the two sites I already had - my personal portfolio and my business blog. At the time, I also had to have a "parent network" site ... so it really became three sites:

  • (my primary domain and network parent)
  • (my portfolio)
  • (mapped domain for my business blog)

Over time, my business blog evolved to contain a whole slew of other content - articles on faith, the outdoors, creative writing, etc. I added a couple of new mapped domains to my network and branched the content out to keep things separate:

  • (creative writing)
  • (faith essays)
ericmann / gist:2876388
Created Jun 5, 2012
"Phone app" template from WordCamp Phoenix presentation
View gist:2876388
Template Name: RPC Test
* This template interacts with a new XML-RPC endpoint created specifically to handle `wcphx.change_query`
* Code for the endpoint is available in a ZIP file at:
* Slides from the WordCamp Phoenix presentation are at:
* Video from the presentation is at:
View gist:2937180
// How can I rewrite this to perform multiple checks in a row without repeating if (_allowed.IPs.Contains(userIPAddress)) { authentic = true; goto result; } every time?
public class Authentication {
private List<string> _allowedIPs;
public bool IsAuthentic(string userIPAddress) {
bool authentic = false;
if (_allowedIPs == null)
_allowedIPs = new List<string>();
ericmann / gist:3005609
Created Jun 27, 2012
Authentication System
View gist:3005609

##The Scenario

I have a client-side web application that bounces requests against a server-side API. For the sake of simplicity, every request must pass a username and password. This is similar to old school XML-RPC where the username and password are passed as parameters in every request.

However, as this is a REST service, some of the requests (GET and DELETE) don't have message bodies and must pass the username and password as query variables in the URL:

GET http://application.url/endpoint?username=xxxx&password=xxxx

This is, frankly, a bad idea. Requests are logged on the server, so if I send the password in plaintext, it's now sitting in a log file somewhere on the server. I don't ever want to be sending the password in plaintext over the wire, so I'm stuck with a dilemma.

ericmann / gist:3130115
Created Jul 17, 2012
Sunrise if we architect to use a singleton
View gist:3130115
* Here's the Sunrise class demonstrating how it would be used as a singleton.
* NOTE: Code is for discussion only and has not been tested.
class Sunrise {
static private $instance = null;
static public function get_instance() {
if ( ! isset( self::$instance ) ) {
ericmann / gist:3788867
Created Sep 26, 2012
Auto-generate URLs
View gist:3788867

#The Problem

I need to create custom links based on the current page URL within WordPress. The system needs to work with both pretty and default permalinks. I have a custom rewrite endpoint defined that needs to be added.

So if the URL of the page is http://site.url/?p=25 I need to create http://site.url/?p=25&custom=1

If the URL is http://site.url/2012/post-slug I need to create http://site.url/2012/post-slug/custom

I can't find a built-in function to do this, so I'm thinking I'll need to build my own to do this. Some pseudo-code:

You can’t perform that action at this time.