Skip to content

Instantly share code, notes, and snippets.

View EricBusch's full-sized avatar

Eric Busch EricBusch

  • Owen Sound, Ontario
View GitHub Profile
@EricBusch
EricBusch / add_size_attribute-01.php
Last active September 28, 2022 16:16 — forked from EricBusch/add_color_attribute-01.php
Automatically add the product's size as a size attribute for this product. [datafeedr][dfrpswc]
<?php
/**
* Add the product's size as a size attribute for this product.
*
* The attribute "Size" with a slug of "size" must already exist here:
* WordPress Admin Area > Products > Attributes.
*
* @param array|string $value The current value of the $attribute for this $post.
* @param string $attribute The slug of the attribute. Examples: pa_size or pa_shoe-size
@EricBusch
EricBusch / add_size_attribute-02.php
Last active September 28, 2022 16:17 — forked from EricBusch/add_color_attribute-02.php
Automatically add the product's size as a size attribute from different product fields for this product. [datafeedr][dfrpswc]
<?php
/**
* Add the product's size as a size attribute for this product.
*
* The attribute "Size" with a slug of "size"
* must already exist here:
* WordPress Admin Area > Products > Attributes.
*
* @param array|string $value The current value of the $attribute for this $post.
@EricBusch
EricBusch / add_color_attribute-03.php
Last active September 28, 2022 16:13 — forked from EricBusch/add_color_attribute-03.php
Automatically add the product's color as a color attribute and normalize the color name. [datafeedr][dfrpswc]
<?php
/**
* Add the product's color as a color attribute for this product.
*
* The attribute "Color" with a slug of "color" must already exist here:
* WordPress Admin Area > Products > Attributes.
*
* @param array|string $value The current value of the $attribute for this $post.
* @param string $attribute The slug of the attribute. Examples: pa_color or pa_shoe-size
@EricBusch
EricBusch / add_color_attribute-04.php
Last active September 28, 2022 16:14 — forked from EricBusch/add_color_attribute-04.php
Automatically add the product's color as a color attribute from multiple fields and normalize the color name. [datafeedr][dfrpswc]
<?php
/**
* Add the product's color as a color attribute for this product.
*
* The attribute "Color" with a slug of "color" must already exist here:
* WordPress Admin Area > Products > Attributes.
*
* @param array|string $value The current value of the $attribute for this $post.
* @param string $attribute The slug of the attribute. Examples: pa_color or pa_shoe-size
@EricBusch
EricBusch / add_color_attribute-05.php
Last active September 28, 2022 16:12 — forked from EricBusch/add_color_attribute-05.php
Automatically add the product's color as a color attribute from multiple fields with defaults and normalize the color name. [datafeedr][dfrpswc]
<?php
/**
* Add the product's color as a color attribute for this product.
*
* The attribute "Color" with a slug of "color" must already exist here:
* WordPress Admin Area > Products > Attributes.
*
* @param array|string $value The current value of the $attribute for this $post.
* @param string $attribute The slug of the attribute. Examples: pa_color or pa_shoe-size
@EricBusch
EricBusch / siteground-ssh-setup.md
Last active July 30, 2024 15:03 — forked from EricBusch/siteground-ssh-setup.md
Here are instructions on setting up SSH access on SiteGround using a Mac.

Open the Terminal app on Mac.

Change directories so that you are in your user's .ssh directory. For example, my user directory is named "Eric" so I would type the following into Terminal:

cd /Users/Eric/.ssh

Now you need to generate your SSH key pairs. Enter the following command into Terminal (source 1, source 2):

ssh-keygen -t rsa -b 4096 -C "[email protected]"

@EricBusch
EricBusch / @plan.md
Last active November 15, 2017 20:09 — forked from dillinghamio/@plan.md
Laravel Spark @plan Blade Directive - Create new Blade Directive (conditional)

@plan Blade Directive For Laravel Spark

Works with user & team billing

Add this to the boot() method of your AppServiceProvider

\Blade::directive('plan', function($plans) {

 $model = auth()-&gt;user();
@EricBusch
EricBusch / prevent-content-override.php
Created January 5, 2018 13:57 — forked from EricBusch/prevent-content-override.php
Prevent the product name, product description and product excerpt from being overwritten during a Product Set update. [datafeedr]
<?php
/**
* Prevent product titles, descriptions & excerpts from being overwritten during Product Set updates.
*
* @param array $post Array containing WordPress Post information.
* @param array $product Array containing Datafeedr Product information.
* @param array $set Array containing Product Set information.
* @param string $action Either "update" or "insert" depending on what the Product Set is doing.
*
<?php
/**
* This modifies the affiliate link and redirects the link back to the site's
* homepage with specific query parameters added.
*/
add_filter( 'dfrapi_after_affiliate_id_insertion', 'mycode_redirect_to_exit_page', 20, 3 );
function mycode_redirect_to_exit_page( $url, $product, $affiliate_id ) {
$args = array(
@EricBusch
EricBusch / sort-by-discount.php
Created April 26, 2018 14:04 — forked from EricBusch/sort-by-discount.php
Add "Sort by discount" to sorting options. Defaults to biggest to smallest discount.
<?php
/**
* Add "Sort by discount" to sorting options. Defaults to biggest to smallest discount.
*/
add_filter( 'woocommerce_get_catalog_ordering_args', 'mycode_woocommerce_add_salediscount_to_catalog_ordering_args' );
function mycode_woocommerce_add_salediscount_to_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'discount' == $orderby_value ) {
$args['orderby'] = 'meta_value_num';