Skip to content

Instantly share code, notes, and snippets.

@tnorthcutt
tnorthcutt / tls-test.php
Created February 13, 2018 15:32
Testing local TLS version
<?php
function stripe_test()
{
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
\Stripe\Stripe::$apiBase = "https://api-tls12.stripe.com";
try {
\Stripe\Charge::all();
echo "TLS 1.2 supported, no action required.";
} catch (\Stripe\Error\ApiConnection $e) {
Given this collection:
Illuminate\Support\Collection {#1108
all: [
"verb" => [
"have",
"have-not",
],
"type" => [
"1",
@tnorthcutt
tnorthcutt / membermouse.php
Last active December 27, 2017 15:38
Don't show meal plans older than (sign up date + 1 week)
<?php
/**
* Don't show meal plans older than (sign up date + 1 week)
* @since 1.0.0
*
* @author Travis Northcutt
*
*/
function gfmp_show_allowed_meal_plans( $query ) {
// First, make sure we're on the front end and on the right archive view
@tnorthcutt
tnorthcutt / membermouse.php
Last active December 27, 2017 15:38
Protect plans older than sign up date minus one week.
<?php
/**
* Protect plans older than sign up date minus one week.
*
* This is for a site with new content published weekly;
* adjust as necessary for other publishing schedules.
*
* @since 1.0.0
*
* @author Travis Northcutt

UsedByTeams Model Trait For Laravel Spark

Automatically limit your models to the current team

So you're using spark, and you have teams enabled. You start creating models and want to have them be team specific. Instead of writing, Model::where('team_id', auth()->user()->currentTeam->id)->get(); use this trait to add that behind the scenes so that every time you call on your model, it's assumed that you mean for the current team.

This assumes that the model has a team_id, while it adds a scope of where team_id = currentTeam->id.

Note: Implicit Route Model Binding in 5.2, auth session doesn't exist at the point of this trait causing issue. fixed in 5.3

@tnorthcutt
tnorthcutt / drip.html
Created April 4, 2017 16:07
better drip mobile responsive template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style type="text/css">
/* Based on The MailChimp Reset INLINE: Yes. */
/* Client-specific Styles */
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */
body{width:100% !important; margin:0; padding:0;}

CMB2 Canned Issue Response

Unfortunately, we can't support every person's specific or custom implementations for CMB2. Github issues are reserved for confirmed bug reports and occasional feature requests. Please review the CONTRIBUTING.md for support suggestions. Please also review the additional resources listed at the bottom of that document, as the solution you're looking for may already be present.

CMB2 Taxonomy field canned response

The taxonomy fields are not intended to provide an arbitrary list of terms to pick from, but are intended to be a replacement for the default taxonomy metaboxes. I.e. they are meant to set the taxonomy terms on an object. Any other use of these types will be hacky and/or buggy. I suggest looking at building a custom field type for this: https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#a-dropdown-for-taxonomy-terms-which-does-not-set-the-term-on-the-post

CMB2 wrong PR response

Thank you for

Keybase proof

I hereby claim:

  • I am tnorthcutt on github.
  • I am tnorthcutt (https://keybase.io/tnorthcutt) on keybase.
  • I have a public key whose fingerprint is BB70 0712 BEE1 724F 4790 F84F ACFD 9A82 F3EE 95F3

To claim this, I am signing this object:

@tnorthcutt
tnorthcutt / functions.php
Created May 31, 2013 18:56
Allow extra tags in content on archive pages
<?php
add_filter( 'get_the_content_limit_allowedtags', 'ehr_content_limit_allowed_tags' );
function ehr_content_limit_allowed_tags($tags) {
$tags .= '<a>';
return $tags;
}
@tnorthcutt
tnorthcutt / archive-leader.php
Created May 28, 2013 21:11
Subtitles for CPT archive issue
<?php
add_action( 'genesis_after_entry_content', 'genesis_do_post_title', 20 );
add_action( 'genesis_after_entry_content', 'ehr_do_post_subtitle', 21 );
genesis();