Skip to content

Instantly share code, notes, and snippets.

James Collins om4james

Block or report user

Report or block om4james

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
@om4james
om4james / wczapier.php
Last active Feb 5, 2018
WooCommerce Zapier send data asynchronously (rather than immediately)
View wczapier.php
<?php
/*
The following code will tell the WooCommerce Zapier extension (v1.7+) to send data to
Zapier asynchronously via WordPress cron, rather than sending the data immediately.
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.
*/
add_filter( 'wc_zapier_send_asynchronously', '__return_true' );
@om4james
om4james / wczapier.php
Created Sep 6, 2017
WooCommerce Zapier send Order data immediately (rather than asynchronously), but send Customer data asynchronously
View wczapier.php
<?php
/*
The following code will tell the WooCommerce Zapier extension 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.
*/
function wc_zapier_send_asynchronously_check( $async, $trigger ) {
@om4james
om4james / wczapier.php
Created Sep 4, 2017
WooCommerce Zapier send data immediately (rather than asynchronously)
View wczapier.php
<?php
/*
The following code will tell the WooCommerce Zapier extension 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.
*/
add_filter( 'wc_zapier_send_asynchronously', '__return_false' );
@om4james
om4james / woocommerce-category-archives.php
Created May 1, 2015
WooCommerce wrap product category/subcategory images in the loop (shop/archive pages)
View woocommerce-category-archives.php
<?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">';
@om4james
om4james / woocommerce-shop-archives.php
Created May 1, 2015
WooCommerce wrap product images in the loop (shop/archive pages)
View woocommerce-shop-archives.php
<?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">';
@om4james
om4james / functions.php
Created Apr 2, 2014
Allow the .4w7 file type to be uploaded to the WordPress media library
View functions.php
<?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';
@om4james
om4james / functions.php
Last active Aug 29, 2015 — forked from simonlk/WooCommerce - Change Sort Code to BSB
WooCommerce - Change Sort Code to BSB
View functions.php
<?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';
@om4james
om4james / functions.php
Last active Sep 3, 2019
Display product description on WooCommerce shop/category pages
View functions.php
<?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;
@om4james
om4james / attachment_url_to_postid-example.php
Last active Dec 17, 2015
attachment_url_to_postid() Simple Example
View attachment_url_to_postid-example.php
<?php
$attachment_id = attachment_url_to_postid( 'http://yourdomain.com/wp-content/uploads/myfile.pdf' );
if ( $attachment_id ) {
// This file was found in the WordPress media library
// In this example we are going to permanently delete this file from the WordPress media library.
// Please be careful if you are copying/pasting this example code!
wp_delete_attachment( $attachment_id, true );
@om4james
om4james / wp_is_mobile_example.php
Last active Dec 17, 2015
wp_is_mobile() example
View wp_is_mobile_example.php
<?php
if ( wp_is_mobile() ) {
// Visitor is on a mobile device
} else {
// Visitor is on a desktop (not mobile) device
}
?>
You can’t perform that action at this time.