Skip to content

Instantly share code, notes, and snippets.

View tannerm's full-sized avatar

Tanner Moushey tannerm

View GitHub Profile
@tannerm
tannerm / functions.php
Last active August 29, 2015 13:57 — forked from flowdee/functions.php
<?php
/**
* Remove trailing parenthesis from youtube oembed
*
* @param $html
* @param $url
*
* @return mixed
*/
@tannerm
tannerm / functions.php
Last active August 29, 2015 13:58
Password protect content.
<?php
/**
* Redirect password protected content to it's own file
*/
function tm_password_protect_redirect() {
// if password is not required or has been entered, continue with standard behavior
if ( ! post_password_required() ) {
return;
}
@tannerm
tannerm / protected.php
Created April 7, 2014 05:47
Protected content template
<?php
/** template for protected content when password is not found */
get_header(); ?>
<div class="main-content" id="content" role="main">
<h1 class="top-heading"></h1>
<div class="intro"></div>
<?php the_content(); ?>
</div>
@tannerm
tannerm / oo.js
Last active August 29, 2015 13:59
JavaScript Object Oriented
(function($) {
'use strict';
var myTestClass = function() {
var SELF = this;
SELF.init = function() {};
}
<?php
Singleton::get_instance();
class Singleton {
/**
* @var
*/
protected static $_instance;
@tannerm
tannerm / login.js
Last active November 9, 2015 19:12
WordPress Ajax Login
jQuery(document).ready(function($){
'use strict';
var ajaxLogin = function() {
var SELF = this;
SELF.data = {'security': tm.security};
SELF.init = function(id) {
SELF.$loginContainer = $(id);
@tannerm
tannerm / take_this_coupons.js
Last active August 29, 2015 14:14
Call GravityForms custom price function before coupons while maintaining coupon functionality.
/**
* Custom price the Registration form and support other custom price functions
* Yes this is kind of a hack, but we need out function to fire first
*/
var registrationTotal = function() {
var SELF = this;
SELF.init = function() {
// This would be the right way to make this happen if the coupons extension didn't mess it up
// gform.addFilter('gform_product_total', SELF.swapVars);
<?php
/*
* Plugin Name: wpMandrill MS
* Plugin URI: https://gist.github.com/tannerm/b6d06e3d784f7c12bdd5
* Description: Network-wide settings for wpMandrill.
* Version: 2015.07.07
* Author: Kailey Lampert, Tanner Moushey
* Author URI: kaileylampert.com
* License: GPLv2 or later
* TextDomain: wpmandrill-ms
@tannerm
tannerm / remove_prev_role_meta.php
Created August 12, 2015 01:57
Companion function for Conditional Profile Field Groups plugin to remove invalid group meta when a user's role changes.
function remove_prev_role_meta( $user_id = null) {
// Define the user we are working on
if ( ! $user_id ) {
$user_id = get_current_user_id();
}
// Set valid groups
$valid_groups = bp_xprofile_get_groups( array( 'user_id' => $user_id ) );
$valid_group_ids = wp_list_pluck( $valid_groups, 'id' );
<div id="spotxchange"></div>
<script type="text/javascript">
window.isMobile = function () {
var check = false;
(function (a) {
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(2