Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
@DrewAPicture
DrewAPicture / progress-bar.blade.php
Created November 16, 2023 10:41 — forked from gwleuverink/progress-bar.blade.php
Progress bar blade component
@props([
'percentage' => 0,
'failed' => false
])
@php
$done = $failed || $percentage == 100;
@endphp
<div {{ $attributes->merge(['class' => ' space-y-1'])->whereDoesntStartWith('wire:poll') }}
<?php
/**
* Plugin With Checks Bootstrap
*
* @package Plugin With Checks
* @subpackage Core
* @copyright Copyright (c) 2021, Sandhills Development, LLC
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0.0
*/
@DrewAPicture
DrewAPicture / clean_404_emails.php
Last active September 27, 2023 09:03
Original snippet by wp-mix.com at http://wp-mix.com/wordpress-404-email-alerts/ With the improved OOP style, implementation is a lot more straightforward, just add <?php new Clean_404_Email; to the top of your 404.php template.
<?php
// Just require() this class via your theme's functions.php file.
/* Then instantiate this at the top of your 404.php file with:
if ( class_exists( 'Clean_404_Email' ) )
new Clean_404_Email;
*/
class Clean_404_Email {
var $time, $request, $blog, $email, $theme, $theme_data, $site, $referer, $string, $address, $remote, $agent, $message;
@DrewAPicture
DrewAPicture / phpunit-assert-contains-only-type.php
Last active January 6, 2021 14:52
PHPUnit assertion function to check the types of all items in an array
<?php>
/**
* Checks if all first-level items in the array are of the given type.
*
* Example:
*
* function test_get_posts_with_no_fields_arg_should_return_array_of_WP_Post_objects() {
* $this-assertContainsOnlyType( 'WP_Post', get_posts() );
* }
*
<?php
/**
* Attempts to log a referral when a new vendor is registered via an affiliate in FES.
*
* @see The 'edd_post_insert_' . $type hook, where $type is 'vendor'.
*
* @param int. $vendor_id Newly-created vendor ID.
* @param array $data Vendor data.
*/
function affwp_edd_fes_vendor_registration_referral( $vendor_id, $data ) {
#!/bin/sh
# A script that leverages Trac XML-RPC (I know, I know) to upload patches.
#
# This script is written specifically for the Mac, in that it reads from
# your keychain to derive your SVN password. You can change the SVN_PASS
# line below if you wanted to pull from ~/.svn/ or what not.
#
# Basic usage: `trac-attach.sh 12345` uploads a patch to ticket #12345,
# using the name 12345.diff. If there exists a 12345.diff, the patch is
<?php
/**
* Automatically locates and loads files based on their namespaces and their
* file names whenever they are instantiated.
*
* @package WerdsWords
*/
spl_autoload_register(function( $filename ) {
// First, separate the components of the incoming file.
@DrewAPicture
DrewAPicture / class-affiliate-meta-db.php
Last active December 24, 2018 05:53
Demonstration for how AffiliateWP registers a table to be compatible with the core metadata API.
<?php
/**
* Core class used to implement affiliate meta.
*
* @since 1.6
*
* @see Affiliate_WP_DB
*/
class Affiliate_WP_Affiliate_Meta_DB extends Affiliate_WP_DB {
@DrewAPicture
DrewAPicture / sb-signup-url-preview.js
Created August 17, 2018 16:29
SellBird registration URL live-preview JS.
$( '#store-name' ).on( 'keyup', function( event ) {
var toConvert = $( this ).val(),
converted = toConvert.replace( /\s+/g, '-' ).toLowerCase(),
description = $( this ).next( '.form-text' );
description.text( 'e.g. ' + converted + '.sellbird.com' );
} );
@DrewAPicture
DrewAPicture / gist:2998325
Created June 26, 2012 19:39
Show git branch in Terminal (Mac)
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PS1="$GREEN\u@machine$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ "