Skip to content

Instantly share code, notes, and snippets.

Drew Jaynes DrewAPicture

Block or report user

Report or block DrewAPicture

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View affwp-edd-fes.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 ) {
View autoload.php
<?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 Dec 24, 2018
Demonstration for how AffiliateWP registers a table to be compatible with the core metadata API.
View class-affiliate-meta-db.php
<?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 Aug 17, 2018
SellBird registration URL live-preview JS.
View sb-signup-url-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' );
} );
View sitelauncher.user.js
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';
View timezone_string-absurdity.php
<?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 Aug 11, 2019
PHPUnit assertion function to check the types of all items in an array
View phpunit-assert-contains-only-type.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() );
* }
*
* @since 2.1
View affiliatewp-woocommerce-product-cat-fix.php
<?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
View affiliatewp-woocommerce-product-cat-fix.php
add_filter( 'rewrite_rules_array', function( $rules ) {
if ( ! function_exists( 'WC' ) || ! function_exists( 'affiliate_wp' ) ) {
return $rules;
}
if ( true === version_compare( WC()->version, '3.0.0', '>=' ) ) {
$permalinks = wc_get_permalink_structure();
} else {
$permalinks = get_option( 'woocommerce_permalinks' );
View forward_static_call.php
<?php
class Beer {
const NAME = 'Beer!';
public static function printed(){
echo 'static Beer:NAME = '. static::NAME . '<br />';
}
}
class Ale extends Beer {
You can’t perform that action at this time.