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
*/
<?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 ) {
<?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' );
} );
var bookmarkLauncherSetup = (function() {
var bookmarks = {}, url;
bookmarks['r'] = 'https://www.reddit.com/r/popular';
bookmarks['f'] = 'https://facebook.com';
bookmarks['a'] = 'https://smile.amazon.com';
bookmarks['h'] = 'https://secure.helpscout.net/members/login/';
bookmarks['i'] = 'http://www.imdb.com/';
bookmarks['m'] = 'http://mutrunk.dev/wp-admin';
bookmarks['t'] = 'http://twitter.com/home';
<?php
/**
* Attempts to retrieve the WP timezone, or if not set, the timezone derived from the gmt_offset.
*
* @access private
* @since 2.2
*
* @return string Timezone string, or if all checks fail, default is 'UTC'.
*/
private function get_core_timezone() {
@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
/**
* Plugin Name: AffiliateWP - WooCommerce Product Categories Fix
* Plugin URI: https://affiliatewp.com
* Description: Fixes product category 404s when used in conjunction with pretty affiliate URLs.
* Author: AffiliateWP, LLC
* Author URI: https://affiliatewp.com
* Version: 1.0
*
* AffiliateWP Debug is distributed under the terms of the GNU General Public License as published by