Skip to content

Instantly share code, notes, and snippets.

View twoelevenjay's full-sized avatar
🏠
Working from home

Leon Francis Shelhamer twoelevenjay

🏠
Working from home
View GitHub Profile
@twoelevenjay
twoelevenjay / woocommerce-give-subcat-list-items-their-own-ul.php
Last active November 9, 2023 15:30
Move WooCommerce subcategory list items into their own <ul> separate from the product <ul>.
<?php
/**
* Move WooCommerce subcategory list items into
* their own <ul> separate from the product <ul>.
*/
add_action( 'init', 'move_subcat_lis' );
function move_subcat_lis() {
// Remove the subcat <li>s from the old location.
@twoelevenjay
twoelevenjay / watch.rb
Created October 22, 2017 02:40 — forked from JamieMason/watch.rb
Watch a folder for changes to files, then reload Chrome
#!/usr/bin/env ruby
require 'tempfile'
require 'fileutils'
# Signals
trap("SIGINT") { exit }
# Setup
TARGET_FOLDER = ARGV[0]
TARGET_URL = ARGV[1]
@twoelevenjay
twoelevenjay / vvv-custom.yml
Created August 25, 2017 17:30
Custom site file for VVV
sites:
trg:
repo: https://github.com/JPry/vvv-base.git
hosts:
- trg.dev
custom:
admin_user: trg
admin_password: trg
admin_email: trg@localhost.local
title: TRG
@twoelevenjay
twoelevenjay / vvv-provision-08-25-2017
Created August 25, 2017 17:29
vvv-provision-08-25-2017 klog with VVV not resolving custom host correctly.
MacBook-Pro:vagrant-local leon.shelhamer$ vagrant provision
Ignoring ffi-1.9.10 because its extensions are not built. Try: gem pristine ffi --version 1.9.10
Ignoring nokogiri-1.6.3.1 because its extensions are not built. Try: gem pristine nokogiri --version 1.6.3.1
Ignoring unf_ext-0.0.7.1 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.1
__ ___ ___ __ ____
\ \ / \ \ / \ \ / / |___ \
\ \ / / \ \ / / \ \ / / __) |
\ V / \ V / \ V / / __/
@twoelevenjay
twoelevenjay / make_ifttt_clickable.php
Created January 16, 2017 16:33
make_ifttt_clickable.php
<?php
add_filter( 'the_content', 'make_ifttt_clickable', 1 );
function make_ifttt_clickable( $content ) {
$reg_ex = '/http:\/\/ift.tt(\/\S*)?/';
$link = '<a target="_blank" href="http://ift.tt${1}">http://ift.tt${1}</a>';
return preg_replace( $reg_ex, $link, $content );
}
@twoelevenjay
twoelevenjay / pr-schedule-woocommerce.md
Last active July 28, 2016 00:53
Schedule of PRs for the update variations from cart feature of WooCommerce

Schedule of PRs for the update variations from cart feature of WooCommerce

I believe these are the best steps of implementing the changes to WooCommerce needed to add the ability for customers to update the variations of products that have already been added to the cart. These steps represent individual smaller pull requests per @mikejolley.

You can see all of the changes together by comparing here.

PR step 1

  1. Add new files. Don't touch core at all. The cart-update-variation.js file takes the available varitions that are loaded with wp_localize_script() and compares them to the selected values of the attribute select fields. When a match is found the it will update a hidden field with variation id. This field is used when updating the cart. This vsariation id update is
<?php
/*
* Conditionally hide shipping methid, based
* on shipping class found in the cart
*/
function is_shipping_class_in_cart( $shipping_class ) {
$is_shipping_class_in_cart = false;
<!doctype html>
<!-- Bootstrap Under Construction Boilerplate -->
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!-- Consider adding a manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->
<?php
/*
* Sometimes you might find a WooCommerce shop ends up with products that
* have an attribute assigned but no terms selected for that attribute.
* I used this script to bulk delete any empty attribute from 117 products.
* In my case I was able to simply hook it to 'init', however when dealing
* with 500 plus products this may cause a timeout error. In these cases
* I would make this an AJAX function and create a JS script to handle multple
* requests in chunks.
@twoelevenjay
twoelevenjay / admin-create-new-customer-on-frontend-checkout.php
Created December 12, 2015 02:16
Allow admins to manually enter new WooCommerce orders from the frontend checkout field.
<?php
// Allow admins to manually enter new WooCommerce orders from the frontend checkout field.
// Hook the woocommerce_checkout_customer_id filter found in the WC_Checkout class.
add_filter( 'woocommerce_checkout_customer_id', 'change_current_user_id_to_new_user' );
function change_current_user_id_to_new_user( $user_id ) {
//Check if logged in user is admin.
if ( current_user_can( 'manage_options' ) ) {