Skip to content

Instantly share code, notes, and snippets.

View chrispian's full-sized avatar

Chrispian chrispian

View GitHub Profile
@chrispian
chrispian / yummy-ftp-org.php
Last active January 10, 2019 02:49
Organize Yummy FTP Bookmarks
<?php
/**
* Quick script to organize YummyFTP bookmarks into alphabetical sub folders
* Run this in whatever directory you want to organize.
*
* You can set the folders to be upper or lower case and it also does 0-9 for domains that start with numbers
* @package CHB\Tools\YummyFTPOrg
* @author Chrispian Burks <chrispian@gmail.com>
@chrispian
chrispian / gravity-form-tweaks.php
Created January 28, 2019 23:54
Gravity Form Stripe Tweaks
add_filter( 'gform_stripe_customer_id', function ( $customer_id, $feed, $entry, $form ) {
if ( rgars( $feed, 'meta/transactionType' ) == 'product' && rgars( $feed, 'meta/feedName' ) == 'Auto Pay Feed' ) {
$customer_meta = array(
'metadata' => gf_stripe()->get_stripe_meta_data( $feed, $entry, $form ),
);
$customer = gf_stripe()->create_customer( $customer_meta, $feed, $entry, $form );
return $customer->id;
SELECT COUNT(*) as Days, DATE_FORMAT( post_date_gmt, '%M %D, %Y' ) as pub_date FROM `wp_posts` where `post_status` = 'publish' AND post_type = 'post' GROUP BY pub_date;
@chrispian
chrispian / .htaccess
Last active July 25, 2019 18:36
URL Rewrite for local WP Dev using Local by Flywheel
# Basic rules to redirect local uploads to the actual live domain.
# Just edit .htaccess in the app/public folder.
# Credit to Aubrey Portwood for the idea (https://github.com/aubreypwd)
RedirectMatch 301 ^/wp-content/uploads/(.*) https://DOMAIN/wp-content/uploads/$1
RedirectMatch 301 ^/wp-content/themes/THEMENAME/images/(.*) https://DOMAIN/wp-content/themes/THEMENAME/images/$1
@chrispian
chrispian / index.js
Created August 3, 2019 00:31
Gatsby + WordPress TypeError: Cannot read property 'source_url' of null
import React from "react"
import { Link, graphql } from "gatsby"
import Img from "gatsby-image"
import Layout from "../components/layout"
import SEO from "../components/seo"
export default ({ data }) => {
return (
<Layout>
<SEO title="home" />
@chrispian
chrispian / semaphore.php
Created August 6, 2019 20:36
Semaphore example
//Semaphore properties
$key = 1111; // Key can be any unique number
$max = 1; // Max number of connections
$permissions = 0666; // default permissions
$autoRelease = 1; // To keep from a deadlock
// Begin Semaphore locking
$semaphore = sem_get( $key, $max, $permissions, $autoRelease );
if( !$semaphore ) {
// Probably best to log vs. error message. But should exit or return to prevent execution if we can't get the semaphore.
@chrispian
chrispian / yoast-primary-category-permalinks.php
Created September 23, 2019 17:24
Set Yoast PRIMARY category as the peralink
@chrispian
chrispian / woocommerce-filter-related-categories-by-taxonmy-term.php
Last active February 26, 2022 16:01
Only shows related products from the primary category set by Yoast
@chrispian
chrispian / fdns
Created September 27, 2019 19:12
Shell script to flush DNS on mac
#!/bin/sh
`dscacheutil -flushcache`
echo Done. DNS Restarted.
@chrispian
chrispian / filter-search.php
Created November 8, 2019 00:14
Limit WP Search to certain post types
function filter_search($query) {
if ($query->is_search) {
$query->set('post_type', array('post', 'tribe_events', 'page'));
};
return $query;
};
add_filter('pre_get_posts', 'filter_search');