Skip to content

Instantly share code, notes, and snippets.

View psorensen's full-sized avatar

Peter Sorensen psorensen

  • 10up
  • United States
View GitHub Profile
@psorensen
psorensen / term-created-event.js
Created July 24, 2017 01:53
Wordpress: Fire event when term is created.
$( document ).ajaxComplete( function( event, xhr, settings ) {
try {
var queryStringArray = settings.data.split('&');
} catch(e) {
var queryStringArray = {};
}
// only when
if ( $.inArray( 'action=add-tag', queryStringArray ) !== -1 ) {
const $xml = $( xhr.responseXML );
@psorensen
psorensen / Webpack Error:
Last active April 25, 2017 07:49
Webpack error on yarn run build:production
Hash: 9f3e91dd416ab52900c4 i Version: webpack 2.1.0-beta.26
Time: 6262ms
[13] multi customizer 40 bytes {1} [built]
[14] multi main 52 bytes {0} [built]
+ 13 hidden modules
ERROR in ./styles/main.scss
Module build failed: Error
at /Applications/MAMP/htdocs/openminds/wp-content/themes/hoang/node_modules/webpack/lib/NormalModule.js:143:35
at /Applications/MAMP/htdocs/openminds/wp-content/themes/hoang/node_modules/loader-runner/lib/LoaderRunner.js:359:11
Worker information
hostname: i-0388d96-precise-production-2-worker-org-docker.travisci.net:d28a5fd8-3589-4295-975d-59cd61e40876
version: v2.5.0 https://github.com/travis-ci/worker/tree/da3a43228dffc0fcca5a46569ca786b22991979f
instance: e0656f8:travis:php
startup: 518.8849ms
system_info
Build system information
Build language: php
Build group: stable
Build dist: precise
@psorensen
psorensen / edd_create_subscription.php
Last active January 24, 2017 19:02
create EDD subscription for user email
<?php
private function om_add_nfg_subscription( $args ) {
// check if user already exists
$user = get_user_by('email', $args['email']);
$user_id = $user ? $user->data->ID : null;
// register new user if doesn't exist
if (! $user_id )
@psorensen
psorensen / main.scss
Created January 10, 2017 00:08
Sage main.scss
@import "common/variables";
// Import npm dependencies
@import "~bootstrap/scss/bootstrap";
@import "~slick-carousel/slick/slick";
@import "~slick-carousel/slick/slick-theme";
@import "~font-awesome/scss/font-awesome";
@import "common/global";
@import "components/buttons";
@psorensen
psorensen / wpMandrill-send-function.php
Created August 8, 2016 23:49
wpMandrill example send function
function SendTemplate() {
// Create a template called MyCoolTemplate and use this code:
$template_code = '
Hello *|FNAME|*,
<p>Your personal coupon code is: *|COUPON|*</p>
<p>Event Date: *|DATE|*</p>
<p>Address: *|ADDRESS|*</p>
@psorensen
psorensen / user_exists_by_id.php
Created August 5, 2016 19:20
Wordpress: Find If User exists by ID
/**
* Determine if user exists by ID
* @param int $user_id User ID
* @return bool true if user exists
*/
public function user_id_exists( $user_id ){
global $wpdb;
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->users WHERE ID = %d", $user ) );
@psorensen
psorensen / slimes.php
Created October 2, 2015 18:43
slimes app->request
object(Slim\Http\Request)[39]
protected 'env' =>
object(Slim\Environment)[36]
protected 'properties' =>
array (size=25)
'REQUEST_METHOD' => string 'POST' (length=4)
'REMOTE_ADDR' => string '::1' (length=3)
'SCRIPT_NAME' => string '/slimes' (length=7)
'PATH_INFO' => string '/contact' (length=8)
'QUERY_STRING' => string '' (length=0)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello!</title>
<link rel="stylesheet" href="https://stackedit.io/res-min/themes/base.css" />
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body><div class="container"><h1 id="membership-transition-notes">Membership Transition Notes</h1>
@psorensen
psorensen / convertformdatatoobject.js
Last active September 25, 2015 19:20
Convert form data to object
function get_form_data($form){
var search_form_data = $($form),
search_form_data_object = search_form_data.serializeArray(),
search_form_data_len = search_form_data_object.length;
// loop through object and asign key/value pairs
var returnObj = {};
for (var i = 0; i < search_form_data_len; i++) {
returnObj[search_form_data_object[i].name] = search_form_data_object[i].value;