Skip to content

Instantly share code, notes, and snippets.

View nathanielks's full-sized avatar

Nathaniel nathanielks

View GitHub Profile
// polyfill webpack require.ensure
if (typeof require.ensure !== 'function') require.ensure = (d, c) => c(require)
export default <% if (addStore) { %>(store) => (<% } %>{
path: '<%= camelEntityName %>',
getComponents (location, cb) {
require.ensure([
'views/<%= pascalEntityName %>View/<%= pascalEntityName %>View'
], (require) => {
let view = require('views/<%= pascalEntityName %>View/<%= pascalEntityName %>View').default
@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
@nathanielks
nathanielks / new.php
Created November 21, 2013 18:03
tribe_get_the_day_link bug. Line 16 in old.php was attributing $date_description to 'next day' as opposed to comparing that it was true. It also wasn't feeding date on line 19 a unix timestamp.
<?php
/**
* Get the date for the day navigation link
*
* @param string $date_description
* @return string
* @since 3.1.1
* @throws OverflowException
*/
function tribe_get_the_day_link_date( $date_description ) {
@nathanielks
nathanielks / wp_ultimate_csv_importer.php
Created November 18, 2013 18:23
Updated wp_ultimate_csv_importer.php. Works with WP installs that are in a separate directory now. Updated hard links to wp-content and wp-admin to use admin_url and plugins_url.
<?php
/**
*Plugin Name: WP Ultimate CSV Importer
*Plugin URI: http://www.smackcoders.com/blog/how-to-guide-for-free-wordpress-ultimate-csv-importer-plugin.html
*Description: A plugin that helps to import the data's from a CSV file.
*Version: 3.2.3
*Author: smackcoders.com
*Author URI: http://www.smackcoders.com
*
* Copyright (C) 2013 Smackcoders (www.smackcoders.com)
@nathanielks
nathanielks / add-to-sidebar.php
Created April 26, 2013 18:22
These functions will programmatically add widgets to a specified sidebar. This can be useful when a theme is first installed to fill specific sidebars with widgets you're written for your theme. $add_to_sidebar takes the id of the sidebar you wish to add to. $widgets takes the id's of the widgets you wish to add.
<?php
function cur_add_widget_to_sidebar( $widget_name, $add_to_sidebar, &$sidebar_options ){
$widget = get_option('widget_'.$widget_name);
if(!is_array($widget))$widget = array();
$count = count($widget)+1;
$sidebar_options[$add_to_sidebar][] = $widget_name.'-'.$count;
$widget[$count] = array();
update_option('widget_'.$widget_name,$widget);
@nathanielks
nathanielks / WooCommerce Sale Products up front
Last active December 11, 2015 12:38
This will force WooCommerce sale items to the front of the store listing, prices lowest to highest, then sorted by title A-Z.
/**
* Sale Products Up Front
*/
add_action( 'woocommerce_product_query', 'cur_sale_products_up_front', 10, 2);
add_filter('posts_request', 'cur_modify_products_query', 10, 2);
add_filter('loop_start', 'cur_reorder_sale_items');
//Utility function
function cur_replace_text($startPoint, $endPoint, $newText, $source) {