Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tannerm's full-sized avatar

Tanner Moushey tannerm

View GitHub Profile
<?php
// Edited by Mission Lab on 7/31/2023 to add SubStack posts
$api_url = 'https://substackapi.com/api/feeds/[your-username].substack.com?sort=new&limit=4';
// Set up cURL to fetch data from the Substack API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@tannerm
tannerm / CLI.php
Last active November 15, 2021 15:35
Migrate WP CLI script
/**
*
* ## OPTIONS
*
* <environment>
* : The environment you are going to. 'local' or 'stage'. Defaults to 'local'
*
* <language>
* : The language to import the content to
*
add_action( 'wpmu_new_user', function( $user_id ) {
add_user_to_blog( 19, $user_id, 'participant' ); // add user to forum site as participant
// subscribe user to forum
$forum_id = 0; // update the forum id
switch_to_blog( 19 ); // switch to the correct site
bbp_add_user_forum_subscription( $user_id, $forum_id ); // add user to the forum
restore_current_blog(); // switch back to the original site
} );
<?php
/**
* Filter the subscriptions that can be used in the upgrade path
* original filter: https://docs.google.com/document/d/19-H7iF-6M_xuKQIF_V6VdeuwXyXaGgWAU9zrJnxavOw/edit
*/
function trm_filter_subscriptions( $subscriptions, $user_id ) {
// make sure the user is active and get the subscription ID
$user_subscription = ( rcp_is_recurring( $user_id ) && rcp_is_active( $user_id ) && 'cancelled' !== rcp_get_status() ) ? rcp_get_subscription_id( $user_id ) : '';
$subscriptions = rcp_get_subscription_levels( 'active' );
<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
@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' );
<?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 / 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);
@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);
<?php
Singleton::get_instance();
class Singleton {
/**
* @var
*/
protected static $_instance;