Skip to content

Instantly share code, notes, and snippets.

View om4james's full-sized avatar

James Collins om4james

View GitHub Profile
om4james / functions.php
Last active August 29, 2015 13:57 — forked from simonlk/WooCommerce - Change Sort Code to BSB
WooCommerce - Change Sort Code to BSB
* Rename WooCommmerce's "Sort Code" to "BSB". Useful for Australian stores
* Ref:
function woocommerce_sort_code_rename_to_bsb($translation, $text, $domain) {
if ($domain == 'woocommerce') {
switch ($text) {
case 'Sort Code':
$translation = 'BSB';
om4james / functions.php
Created April 2, 2014 02:54
Allow the .4w7 file type to be uploaded to the WordPress media library
* Allow the .4w7 file type to be uploaded to the WordPress media library.
* Ref:
* Put this snippet into a child theme's functions.php file
function rasq_myme_types( $mime_types ){
$mime_types['4w7'] = 'application/octet-stream';
om4james / woocommerce-category-archives.php
Created May 1, 2015 04:45
WooCommerce wrap product category/subcategory images in the loop (shop/archive pages)
* 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 / mini-loops-2-recent-posts.html
Created October 5, 2011 08:44
Mini Loops Example: 2 recent posts displayed on home page
[miniloop number_posts=2]
{image from=thumb width=75 height=75 class=alignleft}{ml_excerpt wlength=35 up_to_more=1 after=More... space_between=1}</li>
om4james / 1_unsafe.php
Created May 5, 2012 00:02
WordPress String Translation Escaping Example
echo '<p>' . __('This is some text that needs to be translatable in my WordPress plugin', 'myplugin') . '</p>';
om4james / custom.css
Created May 30, 2012 05:26
Google Chrome (Mac) - Disable Google search, Google mail ads, Facebook Ads, and Facebook Trending Articles
/* Add the following CSS rules to ~/Library/Application Support/Google/Chrome/Default/User StyleSheets/Custom.css */
/* Hide Google Mail Ads and right hand panel */
td.y3 { display: none; }
om4james / wp_is_mobile_example.php
Last active December 17, 2015 10:58
wp_is_mobile() example
if ( wp_is_mobile() ) {
// Visitor is on a mobile device
} else {
// Visitor is on a desktop (not mobile) device
om4james / attachment_url_to_postid-example.php
Last active December 17, 2015 11:28
attachment_url_to_postid() Simple Example
$attachment_id = attachment_url_to_postid( '' );
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 / increase-timeout.php
Last active September 24, 2020 06:32 Subscriptions Check Timeout Increase
* When WooCommerce core checks for subscriptions on the Dashboard -> WooCommerce -> Extensions -> Subscriptions screen,
* sometimes a "Could not find any subscriptions on your 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.
function( $args, $endpoint ) {
om4james / wczapier.php
Last active April 30, 2021 06:38
WooCommerce Zapier send data asynchronously (rather than immediately)
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.