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_product_id_as_tracking_id_to_affiliate_link.php
Created July 3, 2020 14:23
Add the WooCommerce product ID as the Tracking ID in the affiliate URL
@EricBusch
EricBusch / get_object_terms_hierarchical.php
Last active June 27, 2023 03:38
Make terms retrieved by wp_get_object_terms() organized hierarchically. [wordpress]
<?php
/**
* Make terms retrieved by wp_get_object_terms() organized hierarchically.
*
* Use this function instead of wp_get_object_terms() to get a hierarchically
* structured array or term data.
*
* This function takes the terms returned by wp_get_object_terms() and organizes
* them into a hierarchical array with the parent's children (and grandchildren)
@EricBusch
EricBusch / deploy.sh
Last active April 15, 2023 13:10
Deploy your plugin to the WordPress.org SVN plugin repository from your GitHub Repository.
#! /bin/bash
#
# Script to deploy from Github to WordPress.org Plugin Repository
# A modification of a number of different sources:
# @link https://github.com/deanc/wordpress-plugin-git-svn
# @link https://github.com/GaryJones/wordpress-plugin-svn-deploy
# @link https://github.com/thenbrent/multisite-user-management/blob/master/deploy.sh
#
# Accompanying Tutorial Here:
# @link https://ericbusch.net/?p=106
@EricBusch
EricBusch / replace-placeholder-with-affiliate-id-in-product-url.php
Created March 30, 2017 14:09
Use this code to replace the "@@@" placeholder in the "url" field with your affiliate network affiliate ID. [datafeedr]
<?php
/**
* Map each affiliate network ID to your affiliate ID for that network.
*
* In this example, Commission Junction's network ID is 3 and my Commission
* Junction affiliate ID is '321321321'.
*/
$affiliate_ids = array(
3 => '321321321', // Commission Junction Affiliate ID.
@EricBusch
EricBusch / add-rel-nofollow-to-woocommerce-product-links.php
Created March 22, 2017 16:23
This code allows you to add a rel="nofollow" to your WooCommerce products that appear in the loop. [datafeedr]
@EricBusch
EricBusch / replace-wordpress-search-results-with-results-from-datafeedr-api.php
Created March 22, 2017 16:03
This code replaces the default functionality of the WordPress search form. If a search is entered into the WordPress search form, this "hijacks" the request and redirects the request to your custom search page. Then it takes the search query and passes it to the Datafeedr API. The results are returned and displayed.
<?php
/**
* THIS IS THE ONLY REQUIRED MODIFICATION!!!
*
* 1. GO HERE WordPress Admin Area > Pages > Add New
* 2. CREATE A NEW PAGE TO BE USED FOR DISPLAYING SEARCH RESULTS.
* 3. REPLACE "123" BELOW WITH THE ID OF YOUR NEW PAGE.
*
* Return the ID of the page to be used to display the search results.
@EricBusch
EricBusch / add-merchant-logo-to-loop.php
Created March 8, 2017 13:57
This code will add the merchant logo (if the logo exists) to the loop between product thumbnail and product name. [datafeedr]
<?php
/**
* Add merchant logo (if it exists) to the Loop between product thumbnail and product name.
*/
add_action( 'woocommerce_before_shop_loop_item_title', 'mycode_add_merchant_logo_to_loop', 20 );
function mycode_add_merchant_logo_to_loop() {
global $product;
if ( dfrpswc_is_dfrpswc_product( $product->id ) ) {
$postmeta = get_post_meta( $product->id, '_dfrps_product', true );
@EricBusch
EricBusch / add-merchant-logo-to-product-details-page.php
Created March 8, 2017 13:55
This code will add the merchant logo (if the logo exists) to the WooCommerce single product page. [datafeedr]
<?php
/**
* Add merchant logo (if it exists) to product details page.
*/
add_action( 'woocommerce_external_add_to_cart', 'mycode_add_merchant_logo_to_single_product_page' );
function mycode_add_merchant_logo_to_single_product_page() {
global $product;
if ( dfrpswc_is_dfrpswc_product( $product->id ) ) {
$postmeta = get_post_meta( $product->id, '_dfrps_product', true );
@EricBusch
EricBusch / import-product-image-during-product-set-update.php
Created March 1, 2017 16:11
Import a product's image during a Product Set import/update instead of after the product is imported. Use with CAUTION. This may cause product imports to be drastically slower or fail. [datafeedr]
<?php
/**
* Import a product's image during a Product Set import/update instead
* of after the product is imported.
*
* Use with CAUTION. This may cause product imports to be drastically slower or fail.
*
* @see do_action_ref_array(), get_post()
*
@EricBusch
EricBusch / move_comparison_set_immediately_below_product_title.php
Created February 22, 2017 14:17
This code removes a Datafeedr Comparison Set from appearing below the product's details on the WooCommerce product page and adds it immediately below the product's title on single product pages.
<?php
/**
* Remove Comparison Sets from WooCommerce Product pages.
*
* @see remove_action(), dfrcs_wc_compset_priority()
*/
add_action( 'wp_head', 'mycode_remove_compset_from_woocommerce_product_pages' );
function mycode_remove_compset_from_woocommerce_product_pages() {
remove_action( 'woocommerce_after_single_product_summary', 'dfrcs_wc_single_product_page_compset', 0 );