Skip to content

Instantly share code, notes, and snippets.

View nathanielks's full-sized avatar

Nathaniel nathanielks

View GitHub Profile
@nathanielks
nathanielks / Vagrantfile
Created September 26, 2014 21:22
Improved bedrock-ansible Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version '>= 1.5.1'
Vagrant.configure('2') do |config|
config.vm.box = 'roots/bedrock'
# Required for NFS to work, pick any local IP
config.vm.network :private_network, ip: '192.168.50.5'
@nathanielks
nathanielks / webhooks.php
Last active March 14, 2023 23:39
Script used to redirect webhook request from localhost to a local domain
<?php
// Props to goddva: http://stackoverflow.com/questions/1361169/possible-to-add-data-to-the-body-of-a-http-request-using-curl-in-php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://site.dev/webhooks.php?type=stripe");
curl_setopt($ch, CURLOPT_USERAGENT, "My user agent");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
<?php
/*
* Plugin Name: wpMandrill MS
* Plugin URI: trepmal.com
* Description: Network-wide settings for wpMandrill.
* Version: 2013.04.01
* Author: Kailey Lampert
* Author URI: kaileylampert.com
* License: GPLv2 or later
* TextDomain: wpmandrill-ms
@nathanielks
nathanielks / WP_Admin_Notice.php
Last active July 17, 2019 17:33
Simple method to add a notice to the WP Admin
<?php
class WP_Admin_Notice {
public $class = '';
public $message = '';
function __construct( $message, $class = 'updated' ){
$this->class = $class;
$this->message = $message;
add_action( 'admin_notices', array( $this, 'output' ) );
@nathanielks
nathanielks / get_template.php
Last active February 22, 2022 08:49
A set of functions for finding and getting a template and being able to pass parameters to it via an array. Borrowed from https://github.com/woothemes/woocommerce/blob/e3cc5931bad28b24233fb9d14c61c096cbd4b122/includes/wc-core-functions.php#L91
<?php
/**
* Get other templates (e.g. product attributes) passing attributes and including the file.
*
* @access public
* @param mixed $template_name
* @param array $args (default: array())
* @param string $template_path (default: '')
* @param string $default_path (default: '')
* @return void */
@nathanielks
nathanielks / deploy.sh
Created January 23, 2014 18:47
Borrowed from https://github.com/thenbrent/multisite-user-management/blob/master/deploy.sh. Used for shipping to WordPress' plugin repository
#! /bin/bash
# A modification of Dean Clatworthy's deploy script as found here: https://github.com/deanc/wordpress-plugin-git-svn
# The difference is that this script lives in the plugin's git repo & doesn't require an existing SVN repo.
# main config
PLUGINSLUG="multisite-user-management"
CURRENTDIR=`pwd`
MAINFILE="ms-user-management.php" # this should be the name of your main php file in the wordpress plugin
# git config
/* Multisite */
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'somesite.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('MAJ_DEV', true);
// So, I'm debating whether user_role should be defined as primary_user_role,
// and changed from maj_student to something like journal_host|journal_guest?
// that would mess up though what links are displayed in the navigation
// though... but that's inconsequential. there are other ways of determining
// how those would be selected/displayed.
// my journals
// if not a teacher, display this
// family/friends
// get_users and filter by family/friend role
// teachers
// Okie doke. Need to process how to handle reciprocal connections, as well
// as determining when to add a user to blog as a certain type. For
// example, lets talk about students adding family friends as students.
// A student will invite another student as a family friend. It'll check to
// see if that user exists, if so, record their user id and email an
// invitation to that user. The user will then accept the invitation. On
// invitation acceptance, when it goes to add the student to the journal
// hosts journal, it'll check to see if the current user ( journal guest )
// is a student. If so, it'll also add the journal host to the journal
// guests' journal as well.
@nathanielks
nathanielks / class-cur-abstract.php
Created December 30, 2013 23:35
Instead of having to add the get_instance function to every class you want to use, I wanted to be able to extend an abstract class with just that functionality. This is the fruit of my efforts. You can read up more on it here:http://us1.php.net/lsb and here:
<?php
abstract class Cur_Abstract {
public static $instance;
public static function get_instance() {
// Instead of doing is_object( static::$instance ), we check to see if
// static::$instance is an instance of static::$class. Because we're
// extending the class, static::$instance wants to be shared across any
// classes that extend Cur_Abstract, muddling up this check. If it were