Skip to content

Instantly share code, notes, and snippets.

View thejamescollins's full-sized avatar

James Collins thejamescollins

View GitHub Profile
@thejamescollins
thejamescollins / wp-engine-swagger.json
Last active May 31, 2022 02:36
WP Engine Swagger Definition Fixes
{
"swagger": "2.0",
"info": {
"description": "The API described in this document is subject to change.\n",
"version": "1.5.7",
"title": "WP Engine API",
"termsOfService": "https://wpengine.com/legal/terms-of-service/"
},
"host": "api.wpengineapi.com",
"basePath": "/v1",
@thejamescollins
thejamescollins / increase-timeout.php
Last active September 24, 2020 06:32
WooCommerce.com Subscriptions Check Timeout Increase
<?php
/**
* When WooCommerce core checks for subscriptions on the Dashboard -> WooCommerce -> Extensions -> WooCommerce.com Subscriptions screen,
* sometimes a "Could not find any subscriptions on your WooCommerce.com account" error occurs.
*
* This code snippet increases the 5 second timeout for the request to a much higher 30 seconds, which should help prevent the error.
*/
add_filter(
'woocommerce_helper_api_request_args',
function( $args, $endpoint ) {
@thejamescollins
thejamescollins / wczapier.php
Last active April 30, 2021 06:38
WooCommerce Zapier send data asynchronously (rather than immediately)
<?php
/*
The following code will tell the WooCommerce Zapier extension (v1.7.x - v1.9.x) to send data to
Zapier asynchronously via WordPress cron, rather than sending the data immediately.
This snippet does not apply for WooCommerce Zapier version 2.0+, which uses WooCommerce core's webhook devliery mechanism instead.
Please note that we only suggest doing this if your WP-Cron facility is working reliably.
Save this file as wczaper.php and place it in your wp-content/mu-plugins/ directory.
@thejamescollins
thejamescollins / wczapier.php
Last active April 30, 2021 06:39
WooCommerce Zapier send Order data immediately (rather than asynchronously), but send Customer data asynchronously
<?php
/*
The following code will tell the WooCommerce Zapier extension (v1.7.x - v1.9.x). to send Order data to
Zapier immediately, rather than sending the data asynchronously via WordPress cron.
Customer data is still sent asynchronously via WordPress cron.
Save this file as wczaper.php and place it in your wp-content/mu-plugins/ directory.
This snippet does not apply for WooCommerce Zapier version 2.0+, which uses WooCommerce core's webhook devliery mechanism instead.
@thejamescollins
thejamescollins / wczapier.php
Last active April 30, 2021 06:40
WooCommerce Zapier send data immediately (rather than asynchronously)
<?php
/*
The following code will tell the WooCommerce Zapier extension (v1.7.x - 1.9.x) to send data to
Zapier immediately, rather than sending the data asynchronously via WordPress cron.
Save this file as wczaper.php and place it in your wp-content/mu-plugins/ directory.
This snippet does not apply for WooCommerce Zapier version 2.0+, which uses WooCommerce core's webhook devliery mechanism instead.
*/
@thejamescollins
thejamescollins / woocommerce-category-archives.php
Created May 1, 2015 04:45
WooCommerce wrap product category/subcategory images in the loop (shop/archive pages)
<?php
/**
* Archives: wrap the category/subcategory image/thumbnail in a div.
*
* The category image itself is hooked in at priority 10 using woocommerce_subcategory_thumbnail(),
* so priority 9 and 11 are used to open and close the div.
*/
add_action( 'woocommerce_before_subcategory_title', function(){
echo '<div class="imagewrapper">';
@thejamescollins
thejamescollins / woocommerce-shop-archives.php
Created May 1, 2015 04:03
WooCommerce wrap product images in the loop (shop/archive pages)
<?php
/**
* Shop/archives: wrap the product image/thumbnail in a div.
*
* The product image itself is hooked in at priority 10 using woocommerce_template_loop_product_thumbnail(),
* so priority 9 and 11 are used to open and close the div.
*/
add_action( 'woocommerce_before_shop_loop_item_title', function(){
echo '<div class="imagewrapper">';
@thejamescollins
thejamescollins / functions.php
Created April 2, 2014 02:54
Allow the .4w7 file type to be uploaded to the WordPress media library
<?php
/**
* Allow the .4w7 file type to be uploaded to the WordPress media library.
*
* Ref: https://gist.github.com/om4james/9927208
*
* Put this snippet into a child theme's functions.php file
*/
function rasq_myme_types( $mime_types ){
$mime_types['4w7'] = 'application/octet-stream';
@thejamescollins
thejamescollins / functions.php
Last active August 29, 2015 13:57 — forked from simonlk/WooCommerce - Change Sort Code to BSB
WooCommerce - Change Sort Code to BSB
<?php
/**
* Rename WooCommmerce's "Sort Code" to "BSB". Useful for Australian stores
* Ref: https://gist.github.com/om4james/9885791
*/
function woocommerce_sort_code_rename_to_bsb($translation, $text, $domain) {
if ($domain == 'woocommerce') {
switch ($text) {
case 'Sort Code':
$translation = 'BSB';
@thejamescollins
thejamescollins / functions.php
Last active April 1, 2024 19:21
Display product description on WooCommerce shop/category pages
<?php
/**
* Add the product's short description (excerpt) to the WooCommerce shop/category pages. The description displays after the product's name, but before the product's price.
*
* Ref: https://gist.github.com/om4james/9883140
*
* Put this snippet into a child theme's functions.php file
*/
function woocommerce_after_shop_loop_item_title_short_description() {
global $product;