Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ericmann's full-sized avatar
⚒️
Creating ...

Eric Mann ericmann

⚒️
Creating ...
View GitHub Profile
@ericmann
ericmann / gist:8929492
Created February 11, 2014 04:58
Allow Trash Posts
<?php
class My_Post_Work {
public function __construct() {
add_action( 'init', array( $this, 'custom_rewrites' ) );
add_filter( 'posts_results', array( $this, 'make_trash_public' ), 10, 2 );
add_filter( 'the_posts', array( $this, 'make_trash_private' ), 10, 2 );
}

Ghost is an open source platform for blogging founded by John O'Nolan and Hannah Wolfe. It's a node.js application and therefore works great in conjunction with nginx. This guide will will help you create a high performance nginx virtual host configuration for Ghost.

"Don't use #nodejs for static content" - @trevnorris. If #nginx isn't sitting in front of your node server, you're probably doing it wrong.

— Bryan Hughes (@nebrius) August 30, 2014
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

The node.js application runs on a port on your server. We can configure nginx to proxy to this port and also cache so that we don't need to rely on express, the default n

<?php
$query_timer = 0;
add_filter( 'do_parse_request', function( $parse ) {
global $query_timer;
$query_timer = microtime( true );
return $parse;
@ericmann
ericmann / autoloader.php
Created April 24, 2015 23:23
Simple autoloader for WordPress Must-Use plugins. The loader assumes plugins use the format `{plugin-name}\{plugin-name}`.php for their core file. If not, they're skipped.
<?php
/**
* MU-Plugin Autoloader
*
* @author Eric Mann <eric@eamann.com>
* @license MIT
* @copyright 2015 Eric Mann
*/
if ( ! defined( 'ABSPATH' ) ) {

Keybase proof

I hereby claim:

  • I am ericmann on github.
  • I am eamann (https://keybase.io/eamann) on keybase.
  • I have a public key whose fingerprint is F7CA EACB D776 6264 C62E 0B32 9DC3 CED2 E6A0 7E86

To claim this, I am signing this object:

@ericmann
ericmann / Customfile
Created August 21, 2015 18:23
Hyper-V and Samba Customfile
config.vm.provider :hyperv do |v, override|
override.vm.box = "ericmann/trusty64"
end
config.vm.synced_folders.each do |id, options|
# Make sure we use SMB for file mounts on Windows
if ! options[:type] && Vagrant::Util::Platform.windows?
options[:type] = "smb"
end
end
@ericmann
ericmann / temp-testing-curl.php
Last active August 29, 2015 14:28
Temporary Test Code
/**
* Gets the PURL from the Friendbuy API.
*
* @param string e-mail address
* @returns object API Response
*/
function friendbuy_get_purl( $email ) {
// Verify param is actually an e-mail
if ( ! is_email( $email ) ) {
@ericmann
ericmann / gist:2591384
Created May 4, 2012 02:12
Non-parent theme psuedoframework

#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.

#Frameworks

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
ericmann / gist:2604547
Created May 5, 2012 18:22
Post meta wrapper
function get_meta_bool( $post_id, $key ) {
var $string_value = get_post_meta( $post_id, $key, true );
return (bool) $string_value
}
Set up images like this:
<div id="raffle">
<img src="..." data-link="http://link.url" />
<img src="..." data-link="http://link.url" />
</div>
Then set up a JS event listener:
jQuery('#raffle').on('click', 'img', function(e) {